snmptranslate
$ snmptranslate -On NET-SNMP-EXTEND-MIB::nsExtendOutput1Table
.1.3.6.1.4.1.8072.1.3.2.3
snmpwalk
$ snmpwalk -v2c -c somesecgrp my.hostname.net .1.3.6.1.4.1.8072.1.3.2.3
iso.3.6.1.4.1.8072.1.3.2.3.1.1.8.117.112.103.114.97.100.101.115 = STRING: "2"
iso.3.6.1.4.1.8072.1.3.2.3.1.2.8.117.112.103.114.97.100.101.115 = STRING: "2"
iso.3.6.1.4.1.8072.1.3.2.3.1.3.8.117.112.103.114.97.100.101.115 = INTEGER: 1
iso.3.6.1.4.1.8072.1.3.2.3.1.4.8.117.112.103.114.97.100.101.115 = INTEGER: 2
Usage (Nagios)
services.cfg
define service {
use generic-service ; Name of service template to use
host_name mymonitoredhost
service_description waiting upgrades ; upgrades waiting
contact_groups linux-admins
notification_options u,c,r
check_command check_snmp!iso.3.6.1.4.1.8072.1.3.2.3.1.1.8.117. 112.103.114.97.100.101.115!0!2!somesecgrp
}
Note: There is newline (\n) character in snmp OID string - between 117.112 (in check_snmp command), please remove it before use if you will copy&paste this
BASH script
to determine number of upgrades waiting on APT based systems /usr/local/bin/check-apt-upgrades.bash
#! /bin/bash
# returns and prints 0 if there are no upgrades available
# returns and prints 1 if some fail occurs
# returns and prints 2 if there are upgrades available
# returns and prints 3 if there are SECURITY upgrades available
upgrade_status="$(apt-get -q -s upgrade)"
if (echo "$upgrade_status" | grep -i "security" > "/dev/null"); then
echo "3"
exit 3
fi
upgrades_line=$(echo "$upgrade_status" | grep '[0-9]* upgraded, [0-9]* newly installed, [0-9]* to remove and [0-9]* not upgraded')
if [ $? -gt 0 ]; then
echo "1"
exit 1
fi
upgrades_number=$(echo "$upgrades_line" | awk '/ upgraded/ {print $1}')
if [ $? -gt 0 ]; then
echo "1"
exit 1
fi
if [ "$upgrades_number" -gt 0 ]; then
echo "2"
exit 2
fi
echo "0"
exit 0
BASH script
to determine number of upgrades waiting on YUM based systems /usr/local/bin/check-yum-upgrades.bash
#! /bin/bash
# returns and prints 0 if there are no upgrades available
# returns and prints 1 if some fail occurs
# returns and prints 3 if there are upgrades available
sudo yum check-update > "/dev/null"
es=$?
if [ $es -ne 0 ]; then
if [ $es -eq 100 ]; then
echo "3"
exit 3
fi
echo "1"
exit 1
fi
echo "0"
exit 0
SNMP daemon configuration
snmpd.conf
extend upgrades /usr/local/bin/check-apt-upgrades.bash
|