Nagios check_snmp / Uptime
Nagios check_snmp / Uptime
Hi,
i trying to check uptime of a cameraIP and switchDLINK, and Localhost. i find to make it for winserver with nsclient++ and the check is green in nagios but for other impossible....
with "check_snmp" result critical (plugin timed out), with uptime_by_snmp critical too(code of 13 bound...), but in terminal with snmpget ...... its worked fine and i get the good result.
i trying to check uptime of a cameraIP and switchDLINK, and Localhost. i find to make it for winserver with nsclient++ and the check is green in nagios but for other impossible....
with "check_snmp" result critical (plugin timed out), with uptime_by_snmp critical too(code of 13 bound...), but in terminal with snmpget ...... its worked fine and i get the good result.
-
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Nagios check_snmp / Uptime
Looks like one of your problems is that not all the necessary MIBs are loaded properly.
I think to start it would be very good if you could post the relevant parts of your service configuration files and commands.cfg
Can you share these please? If you need to you can mask out the community string.
I think to start it would be very good if you could post the relevant parts of your service configuration files and commands.cfg
Can you share these please? If you need to you can mask out the community string.
Re: Nagios check_snmp / Uptime
where is my reply?? i reply with code, commands and service of my camera, switch ????
Re: Nagios check_snmp / Uptime
service
commands
Code: Select all
# Monitor uptime via SNMP
define service{
use generic-service ; Inherit values from a template
host_name cameratest196
service_description Uptime
check_command check_snmp! -c public -o sysUpTime.0
}
# Monitor uptime_by_snmp
define service {
host_name cameratest196
service_description Uptime_by_SNMP
check_command uptime_by_snmp!public
use generic-service
normal_check_interval 1
}
Code: Select all
# 'check_uptime' command definition for linux hosts
define command{
command_name check_time
command_line $USER1$/check_time -H $HOSTADDRESS$
}
# 'uptime_by_snmp' command definition
define command {
command_name uptime_by_snmp
command_line /usr/local/nagios/libexec/uptime_by_snmp $HOSTADDRESS$ $ARG1$
}
-
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Nagios check_snmp / Uptime
Can we see the check_snmp command definition in commands.cfg to troubleshoot this one? It looks pretty good.Expertise wrote:service
# Monitor uptime via SNMPCode: Select all
define service{ use generic-service ; Inherit values from a template host_name cameratest196 service_description Uptime check_command check_snmp! -c public -o sysUpTime.0 }
You may also want to run the following from the command line just to be sure there isn't a communication problem:
Code: Select all
snmpget -v 2c -c public <cameratest196 IP Addr> sysUpTime.0
This looks OK... but...Expertise wrote: # Monitor uptime_by_snmpCode: Select all
define service { host_name cameratest196 service_description Uptime_by_SNMP check_command uptime_by_snmp!public use generic-service normal_check_interval 1 }
Does the binary /usr/local/nagios/libexec/uptime_by_snmp really exist?Expertise wrote:Code: Select all
# 'uptime_by_snmp' command definition define command { command_name uptime_by_snmp command_line /usr/local/nagios/libexec/uptime_by_snmp $HOSTADDRESS$ $ARG1$ }
Check time uses the rdate protocol just to see if the time between the 2 servers matches. Is that really what you want to do? Most people would be best serviced using check_ntp_time.Expertise wrote: commandsCode: Select all
# 'check_uptime' command definition for linux hosts define command{ command_name check_time command_line $USER1$/check_time -H $HOSTADDRESS$ }
Re: Nagios check_snmp / Uptime
i'm NOOB in all linux and nagios and i try to configure nagios for supervision serveur, cameraIP, switch ect... and i'm learning alone then i try for begenning to display "uptime" (life line i think in english) of my camera, just like uptime of my win computer (its work directly with check_nt and nsclient++) i thinking its simple but i cant make just it LOL
edit: i change command check_time to check_uptime and service too in localhost and now i have this message
"Usage:
check_uptime [-u uom] [-w threshold] [-c threshold] [-t] [-h] [-vvv] [-V]"
# 'check_snmp' command definition
define command{
command_name check_snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}
"command generic i cant touch it"
1-snmpget:
snmpget -v1 -c public 192.168.52.196 1.3.6.1.2.1.1.3.0 --> this mine GOOD
iso.3.6.1.2.1.1.3.0 = Timeticks: (25857410) 2 days, 23:49:34.10 --> return "uptime"
snmpget -v 2c -c public 192.168.52.196 sysUpTime.0
sysUpTime.0: Unknown Object Identifier (Sub-id not found: (top) -> sysUpTime) -->your ERROR
2-uptime_by_snmp
Yes it's doesnt exist and i find the script, i creat file uptime_by_snmp.pl and i deposit it in folder libexec but not work too
edit: i change command check_time to check_uptime and service too in localhost and now i have this message
"Usage:
check_uptime [-u uom] [-w threshold] [-c threshold] [-t] [-h] [-vvv] [-V]"
# 'check_snmp' command definition
define command{
command_name check_snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}
"command generic i cant touch it"
1-snmpget:
snmpget -v1 -c public 192.168.52.196 1.3.6.1.2.1.1.3.0 --> this mine GOOD
iso.3.6.1.2.1.1.3.0 = Timeticks: (25857410) 2 days, 23:49:34.10 --> return "uptime"
snmpget -v 2c -c public 192.168.52.196 sysUpTime.0
sysUpTime.0: Unknown Object Identifier (Sub-id not found: (top) -> sysUpTime) -->your ERROR
2-uptime_by_snmp
Yes it's doesnt exist and i find the script, i creat file uptime_by_snmp.pl and i deposit it in folder libexec but not work too
Code: Select all
#!/bin/sh
#
# 2003-01-11, Fredrik Wanglund
#
# This plugin gets the uptime from a host via snmp.
#
# To use the plugn, do the following:
#
# First, create a checkcommand (typically in etc/checkcommands.cfg):
#
# define command {
# command_name uptime_by_snmp
# command_line /usr/local/nagios/libexec/uptime_by_snmp $HOSTADDRESS$ $ARG1$
# }
#
# If your Nagios-plugin is not located in /usr/local/nagios/libexec/,
# You have to change the path in the command-definition AND the
# variable NAGIOSPLUGSDIR below.
#
# Second, Add a service-definition (typically in etc/services.cfg):
#
# define service {
# host_name server
# service_description Uptime
# check_command uptime_by_snmp!public
# use generic-service
# normal_check_interval 10
# }
#
# Replace the 'use' statement with whatever template you would like to use,
# or fill up the definition with required parameters if you dont want to
# use any template.
#
# The arguments to the 'check_command' is:
# 1) The command-name, disk_by_snmp
# 2) The SNMP community-string
#
# READY.
#
#
#
# Change this if you have installed NAgios in a non-default place:
NAGIOSPLUGSDIR=/usr/local/nagios/libexec
UPTIMESDIR=/usr/local/nagios/uptimes
UPT=`$NAGIOSPLUGSDIR/check_snmp -H $1 -o .1.3.6.1.2.1.1.3.0 -C $2`
RES=$?
if [ $RES = 0 ]; then
TICKS=`echo $UPT|cut -d "(" -f 2|cut -d ")" -f 1`
if [ -f $UPTIMESDIR/$1 ]; then
if [ -s $UPTIMESDIR/$1 ]; then
MAXTICKS=`cat $UPTIMESDIR/$1|cut -d ":" -f 2`
else
MAXTICKS=0
fi
if [ $TICKS -gt $MAXTICKS ]; then
DATE=`date "+%s"`
echo "$DATE, $1, $MAXTICKS, $TICKS" >> /tmp/ticks
echo "$DATE:$TICKS" > $UPTIMESDIR/$1
fi
else
echo "$1: $TICKS" >> /tmp/ticks
fi
RET=`echo $UPT|cut -d ")" -f 2`
else
RET=$UPT
RES=1
fi
RET="Uptime: $RET"
echo $RET
exit $RES
-
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Nagios check_snmp / Uptime
I'm wondering if you didn't accidentally change it in your command definition instead of in your service definition. You cannot change it in your command definition - the command check_uptime will not accept a -H argumentExpertise wrote:edit: i change command check_time to check_uptime and service too in localhost and now i have this messageCode: Select all
# 'check_uptime' command definition for linux hosts define command{ command_name check_time command_line $USER1$/check_time -H $HOSTADDRESS$ }
Code: Select all
Usage: check_uptime [-u uom] [-w threshold] [-c threshold] [-t] [-h] [-vvv] [-V]" # 'check_snmp' command definition define command{ command_name check_snmp command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$ }
This indicates that you don't have your MIBs loaded. Either fix SNMP so it's loading your MIBs or change this:Expertise wrote:1-snmpget:
snmpget -v1 -c public 192.168.52.196 1.3.6.1.2.1.1.3.0 --> this mine GOOD
iso.3.6.1.2.1.1.3.0 = Timeticks: (25857410) 2 days, 23:49:34.10 --> return "uptime"
snmpget -v 2c -c public 192.168.52.196 sysUpTime.0
sysUpTime.0: Unknown Object Identifier (Sub-id not found: (top) -> sysUpTime) -->your ERROR
Code: Select all
define service{
use generic-service ; Inherit values from a template
host_name cameratest196
service_description Uptime
check_command check_snmp! -c public -o sysUpTime.0
}
Code: Select all
define service{
use generic-service ; Inherit values from a template
host_name cameratest196
service_description Uptime
check_command check_snmp! -c public -o .1.3.6.1.2.1.1.3.0
}
You'll need to change this:Expertise wrote:2-uptime_by_snmp
Yes it's doesnt exist and i find the script, i creat file uptime_by_snmp.pl and i deposit it in folder libexec but not work too
Code: Select all
#!/bin/sh # # 2003-01-11, Fredrik Wanglund # # This plugin gets the uptime from a host via snmp. # # To use the plugn, do the following: # # First, create a checkcommand (typically in etc/checkcommands.cfg): # # define command { # command_name uptime_by_snmp # command_line /usr/local/nagios/libexec/uptime_by_snmp $HOSTADDRESS$ $ARG1$ # } # # If your Nagios-plugin is not located in /usr/local/nagios/libexec/, # You have to change the path in the command-definition AND the # variable NAGIOSPLUGSDIR below. # # Second, Add a service-definition (typically in etc/services.cfg): # # define service { # host_name server # service_description Uptime # check_command uptime_by_snmp!public # use generic-service # normal_check_interval 10 # } # # Replace the 'use' statement with whatever template you would like to use, # or fill up the definition with required parameters if you dont want to # use any template. # # The arguments to the 'check_command' is: # 1) The command-name, disk_by_snmp # 2) The SNMP community-string # # READY. # # # # Change this if you have installed NAgios in a non-default place: NAGIOSPLUGSDIR=/usr/local/nagios/libexec UPTIMESDIR=/usr/local/nagios/uptimes UPT=`$NAGIOSPLUGSDIR/check_snmp -H $1 -o .1.3.6.1.2.1.1.3.0 -C $2` RES=$? if [ $RES = 0 ]; then TICKS=`echo $UPT|cut -d "(" -f 2|cut -d ")" -f 1` if [ -f $UPTIMESDIR/$1 ]; then if [ -s $UPTIMESDIR/$1 ]; then MAXTICKS=`cat $UPTIMESDIR/$1|cut -d ":" -f 2` else MAXTICKS=0 fi if [ $TICKS -gt $MAXTICKS ]; then DATE=`date "+%s"` echo "$DATE, $1, $MAXTICKS, $TICKS" >> /tmp/ticks echo "$DATE:$TICKS" > $UPTIMESDIR/$1 fi else echo "$1: $TICKS" >> /tmp/ticks fi RET=`echo $UPT|cut -d ")" -f 2` else RET=$UPT RES=1 fi RET="Uptime: $RET" echo $RET exit $RES
Code: Select all
# 'uptime_by_snmp' command definition
define command {
command_name uptime_by_snmp
command_line /usr/local/nagios/libexec/uptime_by_snmp $HOSTADDRESS$ $ARG1$
}
Code: Select all
# 'uptime_by_snmp' command definition
define command {
command_name uptime_by_snmp
command_line /usr/local/nagios/libexec/uptime_by_snmp.pl $HOSTADDRESS$ $ARG1$
}
Re: Nagios check_snmp / Uptime
1-snmpget :
i change sysUpTime.0 to .1.3.6....... and now it's works THXXXXXXX.
then how to use MIB, if i dont have mib i do using "numbers" for request .1.3.6... and if i have mib i can use it's "name" sysUpTime.0 ?? now how to load MIB .
i DL the mib of my switch but where i place it ?
(http://tsd.dlink.com.tw/downloads2008detail.asp)
"MIB:DGS-1210-08P/24P D1 MIB of FW v4.10.023 (for DEU) "
mine is DGS-1210-08P i take this but its can't worked too (i dont know use it hihi).
2-uptime_by_snmp :
i change command and i add " .pl " but not working too
"(Return code of 13 is out of bounds) "
my script his in the good folder.
i change sysUpTime.0 to .1.3.6....... and now it's works THXXXXXXX.
then how to use MIB, if i dont have mib i do using "numbers" for request .1.3.6... and if i have mib i can use it's "name" sysUpTime.0 ?? now how to load MIB .
i DL the mib of my switch but where i place it ?
(http://tsd.dlink.com.tw/downloads2008detail.asp)
"MIB:DGS-1210-08P/24P D1 MIB of FW v4.10.023 (for DEU) "
mine is DGS-1210-08P i take this but its can't worked too (i dont know use it hihi).
2-uptime_by_snmp :
i change command and i add " .pl " but not working too
"(Return code of 13 is out of bounds) "
my script his in the good folder.
-
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Nagios check_snmp / Uptime
Read SNMP documentation here: http://www.net-snmp.org/wiki/index.php/ ... ading_MIBSExpertise wrote:now how to load MIB .
i DL the mib of my switch but where i place it ?
Also you don't need to have any device specific MIBs for sysUpTime.0 - all SNMP enabled devices should answer that query, and yours clearly does.
Expertise wrote:i change command and i add " .pl " but not working too
"(Return code of 13 is out of bounds) "
my script his in the good folder.
It might be good to just try and run your command as user Nagios:
Code: Select all
sudo su nagios -c "/usr/local/nagios/libexec/uptime_by_snmp.pl <IP of HOST>"
Re: Nagios check_snmp / Uptime
HI, very thank you for your help, now I understand little more hihi
1-snmpget --> OK
"i just place all my MIB of archive.zip in the folder MIB and its works"
I learn with you in command if i dont have MIB i search uptime with number 1.3.XXXXX work without MIB, and if i have MIB i use this call name sysUpTime.0.
2-script.pl --> Forbiden
with all MIB in right folder its works good and my SWITCH are OK "uptime", "port 1 linked status"
but its never finish .......
3-MRTG
I install mrtg but i block with a little think, I can't make auto start of refresh all log for mrtg
http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html
this code to launch mrtg and I read the tuto but i dont understand how to make symbolique link ect...
1-snmpget --> OK
"i just place all my MIB of archive.zip in the folder MIB and its works"
I learn with you in command if i dont have MIB i search uptime with number 1.3.XXXXX work without MIB, and if i have MIB i use this call name sysUpTime.0.
2-script.pl --> Forbiden
with all MIB in right folder its works good and my SWITCH are OK "uptime", "port 1 linked status"
but its never finish .......
3-MRTG
I install mrtg but i block with a little think, I can't make auto start of refresh all log for mrtg
http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html
this code to launch mrtg and I read the tuto but i dont understand how to make symbolique link ect...
Code: Select all
/usr/local/mrtg-2/bin/mrtg /home/mrtg/cfg/mrtg.cfg
Code: Select all
You can also run mrtg as a daemon process by adding the line
RunAsDaemon: Yes
to your mrtg configuration file and then creating a startup script in your system startup sequence. Unfortunately, adding startup scripts differs widely amongst different unix systems. The modern ones normally have a directory called /etc/init.d or /etc/rc.d/init.d where you put scripts which starts the process you want to run when the system boots. Further you must create a symbolic link in /etc/rc3.d or /etc/rc.d/rc?.d called S65mrtg (this is just a sample name ... it is just important that it starts with S followed by a two digit number). If you are not sure about this, make sure you consult the documentation of your system to make sure you get this right.
A minimal script to put into init.d might look like this:
#! /bin/sh
cd /usr/local/mrtg-2.17.4/bin && ./mrtg --user=mrtg-user \
/home/httpd/mrtg/mrtg.cfg --logging /var/log/mrtg.log