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
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