Outils pour utilisateurs

Outils du site


brouillon_snmp

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
brouillon_snmp [2008/08/28 12:02] thierrybrouillon_snmp [2008/08/28 13:18] (Version actuelle) thierry
Ligne 254: Ligne 254:
 Oh! un arbre! Oh! un arbre!
  
 +
 +
 +==== v1 ou v2c ====
 +Il faudra choisir un protocole "-v1" , "-v 1" , "-v2c" ou "-v 2c".
 +
 +Les réponses n'ont pas toujours le même format.
 +
 +Nous, on choisira "-v 2c" ... mouai.
  
 ==== snmpget ==== ==== snmpget ====
Ligne 284: Ligne 292:
  
 Comme vous pouvez l'imaginer, on peut "marcher" en parcourant l'arbre... Comme vous pouvez l'imaginer, on peut "marcher" en parcourant l'arbre...
 +
 +
 +
  
  
Ligne 300: Ligne 311:
   SNMPv2-MIB::sysORID.9 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance   SNMPv2-MIB::sysORID.9 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
  
-Retourner toutes les informations de la branche ".1" ( Huge !)+Retourner toutes les informations de la branche ".1"
   $ snmpwalk -v 2c -c code_secret1 localhost .1   $ snmpwalk -v 2c -c code_secret1 localhost .1
- + ou 
 +  $ snmpwalk -v 2c -c code_secret1 localhost .iso 
 +(huge output !) 
 + 
 +Un poil plus interessant: 
 +  $ snmpwalk -v 2c -c code_secret1 localhost .1.3.6.1.4.1.2021.8.1 
 +  UCD-SNMP-MIB::extIndex.1 = INTEGER: 1 
 +  UCD-SNMP-MIB::extNames.1 = STRING: raidmon 
 +  UCD-SNMP-MIB::extCommand.1 = STRING: /usr/bin/sudo /root/prod/snmpd/raidmon 
 +  UCD-SNMP-MIB::extResult.1 = INTEGER: 0 
 +  UCD-SNMP-MIB::extOutput.1 = STRING: RAID OK (2/2) 
 +  UCD-SNMP-MIB::extErrFix.1 = INTEGER: 0 
 +  UCD-SNMP-MIB::extErrFixCmd.1 = STRING: 
 + 
 + 
 +==== snmptable ==== 
 +Sortir des tables... 
 + 
 +  $ snmptable -v 2c -c code_secret1 localhost sysORTable 
 +  SNMP table: SNMPv2-MIB::sysORTable 
 +   
 +                                          sysORID                                                                     sysORDescr  sysORUpTime 
 +                                    IF-MIB::ifMIB    The MIB module to describe generic objects for network interface sub-layers 0:0:00:00.00 
 +                              SNMPv2-MIB::snmpMIB                                             The MIB module for SNMPv2 entities 0:0:00:00.00 
 +                                  TCP-MIB::tcpMIB                                The MIB module for managing TCP implementations 0:0:00:00.00 
 +                                       IP-MIB::ip                        The MIB module for managing IP and ICMP implementations 0:0:00:00.00 
 +                                  UDP-MIB::udpMIB                                The MIB module for managing UDP implementations 0:0:00:00.00 
 +          SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup                                      View-based Access Control Model for SNMP. 0:0:00:00.00 
 +   SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance                                          The SNMP Management Architecture MIB. 0:0:00:00.00 
 +                  SNMP-MPD-MIB::snmpMPDCompliance                                The MIB for Message Processing and Dispatching. 0:0:00:00.00 
 +         SNMP-USER-BASED-SM-MIB::usmMIBCompliance The management information definitions for the SNMP User-based Security Model. 0:0:00:00.00 
 + 
 +==== snmpset ==== 
 +Fixer une valeur:\\ 
 +"The SET request is used to modify information on the target agent - updating the configuration of that agent, or controlling the behaviour of the remote system." 
 +[[http://www.net-snmp.org/wiki/index.php/TUT:snmpset|Suite]] 
 + 
 + 
 +==== snmptrap ==== 
 +FIXME 
 + 
 +====== tips ====== 
 +===== snmp et commande externe ===== 
 + 
 +On va prendre exemple d'un monitoring de RAID ! 
 + 
 + 
 +==== commande ==== 
 +On a composé un script de monitoring RAID trés simple: 
 +  $ cat /root/prod/snmpd/raidmon 
 +  #!/bin/sh 
 +   
 +  # pour snmpd 
 +  # Il n'accepte que la 1er ligne en reponse 
 +   
 +  MDADM=/sbin/mdadm 
 +  EGREP=/bin/egrep 
 +   
 +  [ -x "$MDADM" ] || exit 0 
 +   
 +  COUNT=0 
 +  RAIDOK=0 
 +  CRITICAL=0 
 +   
 +  for RAIDDEV in /dev/md* 
 +  do 
 +    if [ -b "$RAIDDEV"
 +    then 
 +      COUNT=$(( COUNT + 1 )) 
 +   
 +      if [ -z "$( $MDADM --detail $RAIDDEV | $EGREP '^ *State *: *(clean|active) *$' )" ] 
 +      then 
 +        CRITICAL=$(( CRITICAL + 1 )) 
 +      else 
 +        RAIDOK=$(( RAIDOK + 1 )) 
 +      fi 
 +    fi 
 +  done 
 +   
 +  if [ "$CRITICAL" = "0"
 +  then 
 +    echo "RAID OK ($RAIDOK/$COUNT)" 
 +  else 
 +    echo "RAID CRITICAL ($CRITICAL/$COUNT)" 
 +  fi 
 +   
 +  exit 0 
 +   
 +  ### vim: set shiftwidth=2 softtabstop=2 : ### 
 + 
 +En root, quand on fait : **''/root/prod/snmpd/raidmon''** on a : 
 +  # /root/prod/snmpd/raidmon 
 +  RAID OK (2/2) 
 + 
 +On attend qu'une simple ligne en retour, avec "OK" ou "CRITICAL" (c'est pour **''nagios''**, voir plus loin) 
 + 
 +Mais en simple **''user''** on aura: 
 +  $ /root/prod/snmpd/raidmon 
 +  mdadm: cannot open /dev/md0: Permission denied 
 +  mdadm: cannot open /dev/md1: Permission denied 
 +  RAID CRITICAL (2/2) 
 + 
 +Donc, il faudra l'executer en **"root"**, mais le daemon **''snmpd''** ne tourne (idéalement) qu'en simple user **''snmp''**. On peut changer en **''root''**, __mais on ne le fera pas__ ! 
 + 
 +On va utiliser [[brouillon_sudo|sudo]] 
 + 
 +Donc, aprés avoir configuré "sudo" pour autoriser le **''user''** **''snmp''**, on fera: 
 +  $ sudo /root/prod/snmpd/raidmon 
 +  RAID OK (2/2) 
 + 
 +Bien ! 
 + 
 +==== snmpd.conf ==== 
 + 
 +Insérer la commande dans le fichier de conf (exemple): 
 +  # TJ ---------- 
 +  exec raidmon /usr/bin/sudo /root/prod/snmpd/raidmon 
 +  # ------------- 
 + 
 +Puis on redemarre: 
 +  # /etc/init.d/snmpd restart 
 + 
 + 
 + 
 + 
 +==== snmpget RAID ==== 
 + 
 +  $ snmpget -v 2c -c code_secret1 localhost .1.3.6.1.4.1.2021.8.1.101.1 
 +  UCD-SNMP-MIB::extOutput.1 = STRING: RAID OK (2/2) 
 +Ou encore: 
 +  $ snmpget -v 2c -c code_secret1 localhost UCD-SNMP-MIB::extOutput.1 
 +  UCD-SNMP-MIB::extOutput.1 = STRING: RAID OK (2/2) 
 + 
 +Un peu plus d'info: 
 +  $ snmpwalk -v 2c -On -c code_secret1 localhost .1.3.6.1.4.1.2021.8.1 
 +  .1.3.6.1.4.1.2021.8.1.1.1 = INTEGER: 1 
 +  .1.3.6.1.4.1.2021.8.1.2.1 = STRING: raidmon 
 +  .1.3.6.1.4.1.2021.8.1.3.1 = STRING: /usr/bin/sudo /root/prod/snmpd/raidmon 
 +  .1.3.6.1.4.1.2021.8.1.100.1 = INTEGER: 0 
 +  .1.3.6.1.4.1.2021.8.1.101.1 = STRING: RAID OK (2/2) 
 +  .1.3.6.1.4.1.2021.8.1.102.1 = INTEGER: 0 
 +  .1.3.6.1.4.1.2021.8.1.103.1 = STRING: 
 + 
 +Si j'ai bien compris, chaque script ajouté dans la conf de "snmpd" ajouter "+1" a l'OID de l'objet, dans l'ordre de leur déclaration. 
 + 
 +Donc: 
 +  .1.3.6.1.4.1.2021.8.1.1.1 
 +  .1.3.6.1.4.1.2021.8.1.1.2 
 +  .1.3.6.1.4.1.2021.8.1.1.3 
 +  etc... 
 +  .1.3.6.1.4.1.2021.8.1.101.1 
 +  .1.3.6.1.4.1.2021.8.1.101.2 
 +  .1.3.6.1.4.1.2021.8.1.101.3 
 +  etc... etc... 
 + 
 +==== snmp et autres ==== 
 +=== disk === 
 +Documenté dans le fichier de conf, on ajouter: 
 +  # TJ --------- 
 +  disk / 10000000 
 +  # ------------ 
 +Pour voir la place dispo sur le disk (avec un minimum facultatif): 
 +  $ snmpwalk -v 2c -c code_secret1 localhost .1.3.6.1.4.1.2021.9 
 +  UCD-SNMP-MIB::dskIndex.1 = INTEGER: 1 
 +  UCD-SNMP-MIB::dskPath.1 = STRING: / 
 +  UCD-SNMP-MIB::dskDevice.1 = STRING: /dev/md0 
 +  UCD-SNMP-MIB::dskMinimum.1 = INTEGER: 10000000 
 +  UCD-SNMP-MIB::dskMinPercent.1 = INTEGER: -1 
 +  UCD-SNMP-MIB::dskTotal.1 = INTEGER: 74975192 
 +  UCD-SNMP-MIB::dskAvail.1 = INTEGER: 68444916 
 +  UCD-SNMP-MIB::dskUsed.1 = INTEGER: 2721672 
 +  UCD-SNMP-MIB::dskPercent.1 = INTEGER: 4 
 +  UCD-SNMP-MIB::dskPercentNode.1 = INTEGER: 1 
 +  UCD-SNMP-MIB::dskErrorFlag.1 = INTEGER: 0 
 +  UCD-SNMP-MIB::dskErrorMsg.1 = STRING: 
 +=== charge cpu === 
 +  $ snmpwalk -v 2c -c code_secret1 localhost .1.3.6.1.4.1.2021.10 
 + 
 + 
brouillon_snmp.1219924942.txt.gz · Dernière modification : 2008/08/28 12:02 de thierry