Showing posts with label nagios. Show all posts
Showing posts with label nagios. Show all posts

Friday, 7 March 2014

Using Nagios and SNMP to monitor network devices

Usage:
check_snmp 
-H <ip_address>
-o <OID>
[-w warn_range]
[-c crit_range]
[-C community]
[-s string]
[-r regex]
[-R regexi]
[-t timeout]
[-e retries]
[-l label]
[-u units]
[-p port-number]
[-d delimiter]
[-D output-delimiter]
[-m miblist]
[-P snmp version]
[-L seclevel]
[-U secname]
[-a authproto]
[-A authpasswd]
[-x privproto]
[-X privpasswd]

Note:

the -c and -w (critical and warning ranges respectively) reflect ranges differently depending on if you want a critical to be low (under 10 for example) or high (over 90). In the former case, say the Signal Level of a microwave device you are monitoring is critical when under 10% and warning under 20% then the format of the -w and -c would be:

            -w 25: -c 10:

If on the other hand you are looking at Signal to Noise ratio where warning is 50 dB and critical is 75 dB then the command would be:

            -w :50 -c :75

If you have say a table where numbers translate to other things, again using a Microwave example:

wvSubDataRate  OBJECT-TYPE
               SYNTAX      INTEGER {
                              rf-bw-1p5-Mbps(1),
                                                          rf-bw-2p25-Mbps(2),
                                                          rf-bw-3-Mbps(3),
                                                          rf-bw-4p5-Mbps(4),
                                      rf-bw-6-Mbps(5),
                                      rf-bw-9-Mbps(6),
                                      rf-bw-12-Mbps(7),
                                                          rf-bw-13p5-Mbps(8),
                                      rf-bw-18-Mbps(9),
                                      rf-bw-24-Mbps(10),
                                                          rf-bw-27-Mbps(11),
                                      rf-bw-36-Mbps(12),
                                      rf-bw-48-Mbps(13),
                                      rf-bw-54-Mbps(14),
                                      rf-bw-72-Mbps(15),
                                      rf-bw-96-Mbps(16),
                                      rf-bw-108-Mbps(17)
                           }
               MAX-ACCESS  read-only
               STATUS      current
               DESCRIPTION
                    "The data rate of the station."
               ::= { wvSubStatusEntry 4 }            
and you'd like to have the actual data rate instead of the number then you need to tell it what MIB to use by putting the -m switch at the end e.g.

-m MWAVE-MIB and it will translate the output (typically just a number like "15 = rf-bw-72-Mbps) - giving you meaningful output.

That's it for now but more to follow as I keep working with this type of hardware.


How to fix Nagios3 external commands error

After installing nagios3 and trying to send it a command to reschedule a check or do some other external activity you may get the following error:

Error: Could not stat() command file '/var/lib/nagios3/rw/nagios.cmd'!
The external command file may be missing, Nagios may not be running, and/or Nagios may not be checking external commands.
An error occurred while attempting to commit your command for processing.
In order to fix it, do the following actions:

Check that /etc/nagios3/nagios.cfg has:

check_external_commands=1

Also check that

command_check_interval=15s is uncommented and
command_check_interval=-1 is commented like this:
command_check_interval=15s
#command_check_interval=-1
Check the path for command_file is OK. It usually looks like this:
command_file=/var/lib/nagios3/rw/nagios.cmd
Make sure that the user www-data is part of the nagios group - this is located in /etc/group

Check permissions on the command file that we looked at above:
# ls -l /var/lib/nagios3/rw/nagios.cmd
prw-rw---- 1 nagios nagios 0 Mar  7 11:56 /var/lib/nagios3/rw/nagios.cmd
If it looks like this, we're good.

The next thing to check is that the directory that nagios.cmd resides in has executable rights for the nagios group:
# ls -l /var/lib/nagios3/
total 180
-rw------- 1 nagios www-data 176049 Mar  7 11:58 retention.dat
drwx------ 2 nagios www-data   4096 Mar  7 11:56 rw
drwxr-x--- 3 nagios nagios     4096 Jun 14  2013 spool
Uh oh - rw has no group rights! Fix it with this command:

# chmod g+x /var/lib/nagios3/rw
and then
# service nagios3 restart
And the crowd goes wild!

Adventures with Immich

With the implementation of my Proxmox server it's now time to play with some new applications - and we'll start with Immich, a repla...