@tacolover101
you'll need to address the variable replacing as you please. it would be easy enough to substitute $1 / $2 though.
To help others, I will describe what I had to do to get your script working like it was a default plugin:
Changed your script adding the variables:
#!/bin/bash
data=$(snmpget -v2c -c
$1 -mALL
$2 1.3.6.1.2.1.1.3.0 | sed -e 's/.*(\(.*\))/\1/')
human=$(echo $data | cut -d ' ' -f 2,3,4)
perf=$(echo $data | cut -d ' ' -f 1)
echo "$human | uptime=$perf"
$1: SNMP communit name
$2: hostname
Saved the script on
/usr/local/nagios/libexec naming it as
uptime_snmp.sh
On commands.cfg I created a command to call the script:
Code: Select all
define command{
command_name uptime_snmp
command_line $USER1$/uptime_snmp.sh $ARG1$ $ARG2$
}
Finally, the service on the host file is written as:
define service{
use generic-service
host_name SWITCH-CORE
service_description UPTIME
check_command uptime_snmp!community!$HOSTADDRESS$
}
Thanks for everyone. That was really a quick reply!