My check_snmp command doesn´t work for switch monitoring

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Jessuzz94
Posts: 162
Joined: Thu Jun 04, 2015 12:08 pm

Re: My check_snmp command doesn´t work for switch monitoring

Post by Jessuzz94 »

when i put the command " snmpget -v 2c public 192.168.1.20 .1.3.6.1.2.1.1.3.0" it shows this :

Code: Select all

No community name specified.
USAGE: snmpget [OPTIONS] AGENT OID [OID]...

  Version:  5.7.2
  Web:      http://www.net-snmp.org/
  Email:    [email protected]

OPTIONS:
  -h, --help            display this help message
  -H                    display configuration file directives understood
  -v 1|2c|3             specifies SNMP version to use
  -V, --version         display package version number
SNMP Version 1 or 2c specific
  -c COMMUNITY          set the community string
SNMP Version 3 specific
  -a PROTOCOL           set authentication protocol (MD5|SHA)
  -A PASSPHRASE         set authentication protocol pass phrase
  -e ENGINE-ID          set security engine ID (e.g. 800000020109840301)
  -E ENGINE-ID          set context engine ID (e.g. 800000020109840301)
  -l LEVEL              set security level (noAuthNoPriv|authNoPriv|authPriv)
  -n CONTEXT            set context name (e.g. bridge1)
  -u USER-NAME          set security name (e.g. bert)
  -x PROTOCOL           set privacy protocol (DES|AES)
  -X PASSPHRASE         set privacy protocol pass phrase
  -Z BOOTS,TIME         set destination engine boots/time
General communication options
  -r RETRIES            set the number of retries
  -t TIMEOUT            set the request timeout (in seconds)
Debugging
  -d                    dump input/output packets in hexadecimal
  -D[TOKEN[,...]]       turn on debugging output for the specified TOKENs
                           (ALL gives extremely verbose debugging output)
General options
  -m MIB[:...]          load given list of MIBs (ALL loads everything)
  -M DIR[:...]          look in given list of directories for MIBs
    (default: /home/c4sonora/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mib                                                                                        s/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/                                                                                        share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp)
  -P MIBOPTS            Toggle various defaults controlling MIB parsing:
                          u:  allow the use of underlines in MIB symbols
                          c:  disallow the use of "--" to terminate comments
                          d:  save the DESCRIPTIONs of the MIB objects
                          e:  disable errors when MIB symbols conflict
                          w:  enable warnings when MIB symbols conflict
                          W:  enable detailed warnings when MIB symbols conflict
                          R:  replace MIB symbols from latest module
  -O OUTOPTS            Toggle various defaults controlling output display:
                          0:  print leading 0 for single-digit hex characters
                          a:  print all strings in ascii format
                          b:  do not break OID indexes down
                          e:  print enums numerically
                          E:  escape quotes in string indices
                          f:  print full OIDs on output
                          n:  print OIDs numerically
                          q:  quick print for easier parsing
                          Q:  quick print with equal-signs
                          s:  print only last symbolic element of OID
                          S:  print MIB module-id plus last element
                          t:  print timeticks unparsed as numeric integers
                          T:  print human-readable text along with hex strings
                          u:  print OIDs using UCD-style prefix suppression
                          U:  don't print units
                          v:  print values only (not OID = value)
                          x:  print all strings in hex format
                          X:  extended index format
  -I INOPTS             Toggle various defaults controlling input parsing:
                          b:  do best/regex matching to find a MIB node
                          h:  don't apply DISPLAY-HINTs
                          r:  do not check values for range/type legality
                          R:  do random access to OID labels
                          u:  top-level OIDs must have '.' prefix (UCD-style)
                          s SUFFIX:  Append all textual OIDs with SUFFIX before                                                                                         parsing
                          S PREFIX:  Prepend all textual OIDs with PREFIX before                                                                                         parsing
  -L LOGOPTS            Toggle various defaults controlling logging:
                          e:           log to standard error
                          o:           log to standard output
                          n:           don't log at all
                          f file:      log to the specified file
                          s facility:  log to syslog (via the specified facility     
...

...
...
...                                                                                   )



when i put the command "ll /usr/share/snmp/mibs" it shows this :

Code: Select all

total 296
drwxr-xr-x 2 root     root      4096 Jun  5 09:23 ./
drwxr-xr-x 5 root     root      4096 Jun  4 11:10 ../
-rw-rw-r-- 1 c4sonora c4sonora 68104 May 26  2011 DISMAN-EVENT-MIB.txt
-rw-r--r-- 1 root     root      1913 Apr  8  2014 GNOME-SMI.txt
-rw-r--r-- 1 root     root      5931 Oct  9  2012 LM-SENSORS-MIB.txt
-rw-r--r-- 1 root     root     15901 Oct  9  2012 NET-SNMP-AGENT-MIB.txt
-rw-r--r-- 1 root     root      9160 Oct  9  2012 NET-SNMP-EXAMPLES-MIB.txt
-rw-r--r-- 1 root     root      9326 Oct  9  2012 NET-SNMP-EXTEND-MIB.txt
-rw-r--r-- 1 root     root      2036 Oct  9  2012 NET-SNMP-MIB.txt
-rw-r--r-- 1 root     root      1215 Oct  9  2012 NET-SNMP-MONITOR-MIB.txt
-rw-r--r-- 1 root     root      3350 Oct  9  2012 NET-SNMP-PASS-MIB.txt
-rw-r--r-- 1 root     root      2504 Oct  9  2012 NET-SNMP-PERIODIC-NOTIFY-MIB.t                                                                                        xt
-rw-r--r-- 1 root     root      1226 Oct  9  2012 NET-SNMP-SYSTEM-MIB.txt
-rw-r--r-- 1 root     root      4814 Oct  9  2012 NET-SNMP-TC.txt
-rw-r--r-- 1 root     root      5039 Oct  9  2012 NET-SNMP-VACM-MIB.txt
-rw-rw-r-- 1 c4sonora c4sonora 14565 Jun  4 12:37 SNMPv2-MIB-V1SMI.my
-rw-r--r-- 1 root     root     14565 Jun  4 13:02 SNMPv2-MIB-V1SMI.txt
-rw-r--r-- 1 root     root      2163 Oct  9  2012 UCD-DEMO-MIB.txt
-rw-r--r-- 1 root     root      4613 Oct  9  2012 UCD-DISKIO-MIB.txt
-rw-r--r-- 1 root     root      3087 Oct  9  2012 UCD-DLMOD-MIB.txt
-rw-r--r-- 1 root     root      6476 Oct  9  2012 UCD-IPFILTER-MIB.txt
-rw-r--r-- 1 root     root      8118 Oct  9  2012 UCD-IPFWACC-MIB.txt
-rw-r--r-- 1 root     root     18274 Oct  9  2012 UCD-SNMP-MIB-OLD.txt
-rw-r--r-- 1 root     root     48890 Oct  9  2012 UCD-SNMP-MIB.txt
Jessuzz94
Posts: 162
Joined: Thu Jun 04, 2015 12:08 pm

Re: My check_snmp command doesn´t work for switch monitoring

Post by Jessuzz94 »

Now this appears in my nagios web interface

what means the mesagge "External command error: Unknown flag passed to -C: s "?

Port 5 Status
UNKNOWN 06-05-2015 11:48:37 2d 0h 46m 48s 1/1 External command error: Unknown flag passed to -C: i

Uptime
UNKNOWN 06-05-2015 11:50:26 0d 0h 4m 16s 1/1 External command error: Unknown flag passed to -C: s
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: My check_snmp command doesn´t work for switch monitoring

Post by jdalrymple »

If fixing the MIB problem isn't of interest to you, you can just change your original service to read:

Code: Select all

define service{
     use generic-service
     host_name switchcisco
     service_description Uptime
     check_command check_snmp!-C public -o .1.3.6.1.2.1.1.3.0
}
Jessuzz94
Posts: 162
Joined: Thu Jun 04, 2015 12:08 pm

Re: My check_snmp command doesn´t work for switch monitoring

Post by Jessuzz94 »

these numbers is the direct calling of the mibs or the service in specific?, i have this in my switch.cfg

define service{
check_command check_snmp!.1.3.6.1.2.1.1.4.0
}

and it works and says Uptime OK: testcontact, i dont know what means with the "testcontact" but works

but yes i interesting to resolve the problems of the MIBS, because other monitoring services like the ports tatus have include MIBS in the check_command
Jessuzz94
Posts: 162
Joined: Thu Jun 04, 2015 12:08 pm

Re: My check_snmp command doesn´t work for switch monitoring

Post by Jessuzz94 »

now i commented the "mibs: " line in /etc/snmp/snmp.conf" and downloaded the snmp-mibs-downloader. and the command

"snmpget -v 2c <CiscoIP> -c public sysUpTimeInstance" works, but still have problems with mibs to monitor uptime or portstatus
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: My check_snmp command doesn´t work for switch monitoring

Post by jdalrymple »

Jessuzz94 wrote:define service{
check_command check_snmp!.1.3.6.1.2.1.1.4.0
}

and it works and says Uptime OK: testcontact, i dont know what means with the "testcontact" but works
.1.3.6.1.2.1.1.4.0 isn't uptime, it's system contact


Jessuzz94 wrote:but still have problems with mibs to monitor uptime or portstatus
Can you be more specific?
Jessuzz94
Posts: 162
Joined: Thu Jun 04, 2015 12:08 pm

Re: My check_snmp command doesn´t work for switch monitoring

Post by Jessuzz94 »

In the nagios web interface, in the switch monitoring i have 3 services, PING, Port 1 Status and Uptime, the port status and uptime i have UNKNOWN, and the descriptions says :

Port 1 Status | UNKNOWN | External command error: Unknown flag passed to -C: i
Uptime | UNKNOWN | External command error: Unknown flag passed to -C: s

what is the problem?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: My check_snmp command doesn´t work for switch monitoring

Post by jdalrymple »

If your service definition hasn't changed, then your command definition must have. Something is wrong.

Show us the command definition for check_snmp.
Jessuzz94
Posts: 162
Joined: Thu Jun 04, 2015 12:08 pm

Re: My check_snmp command doesn´t work for switch monitoring

Post by Jessuzz94 »

in commands.cfg my check_snmp command is:

command_name: check_snmp
command_line: $USER1$/check_snmp -H $HOSTADDRESS$ -C public -o $ARG1$ $ARG2$ $ARG3$

in mi switch.cfg:

define service{
use generic-service
host_name switchcisco
service_decription Uptime
check_command check_snmp!-C public -o sysUpTime.0
}

define service{
use generic-service
host_name switchcisco
service_description Port 1 Status
check_command check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB
}
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: My check_snmp command doesn´t work for switch monitoring

Post by jdalrymple »

Jessuzz94 wrote:command_name: check_snmp
command_line: $USER1$/check_snmp -H $HOSTADDRESS$ -C public -o $ARG1$ $ARG2$ $ARG3$
So then services should be:

Code: Select all

define service{
 use generic-service
 host_name switchcisco
 service_decription Uptime
 check_command check_snmp!sysUpTime.0
 }

define service{
 use generic-service
 host_name switchcisco
 service_description Port 1 Status
 check_command check_snmp!ifOperStatus.1
 }
Locked