#!/bin/bash # checks Fujitsu-Siemens Serverview Agents per snmp, output the affected subsystem(s) # Comments, Questions etc. mailto : kk@mkk.de Kevin Kuntz ####### ServerView MIBS ######## #Main-Tree Serverview srv_view_oid=1.3.6.1.4.1.231.2.10.2.11 #System-Status srv_view_sysstat_oid=$srv_view_oid.2.1.0 #System-Status-Return-Message #Should return an error Message, but dont work here, so its not used srv_view_sysstat_return_string_oid=$srv_view_oid.2.2.0 #Number of avaible Subsystems srv_view_subsys_count_oid=$srv_view_oid.3.2.0 #Subsystem-Tree OID srv_view_subsys_oid=$srv_view_oid.3.1.1 ######## ServerView MIBS ######## #Output for incomplete,wrong or missing parameters syntax () { echo "Usage: check_serverview -H <-C community String> <-v snmp-version>" echo exit 3 } #Function to check all subsystems, output every subsystem which is not "ok" check_sub () { subsys_count=$($get -c $community_string -v $snmp_version $Host -O v $srv_view_subsys_count_oid | cut -b10) for i in $(seq 1 $subsys_count) ; do snmp_status=$($get -c $community_string -v $snmp_version $Host -O v $srv_view_subsys_oid.3.$i | cut -b10) if [ $snmp_status != 1 ]; then ( $get -c $community_string -v $snmp_version $Host -O v $srv_view_subsys_oid.2.$i | cut -b9- ) fi done } #Dont know, how to use "dynamic", unordered command line parameters # Help Output if [ $1 = "-h" ] ; then echo checks Fujitsu-Siemens Serverview Agents per snmp, output the affected subsystem*s* echo Uses snmpget from the net-snmp-package echo echo -H echo host to check echo -C echo snmp community string, default is "public" echo -v echo snmp version, default is "1" echo echo Comments, questions, sexual offers etc. mailto : kk@mkk.de Kevin Kuntz echo syntax fi # Setting Hostname if [ x$1 = "x-H" -a x != x$2 ] ; then Host=$2 else syntax exit 3 fi # Setting Community String if [ x$3 = "x-C" -a x != x$4 ] ; then community_string=$4 else community_string=public fi # Setting snmp version if [ x$3 = "x-v" -a x != x$4 ] ; then snmp_version=$4 else snmp_version=1 fi #Path to snmpget get=$(which snmpget) if [ -z $get ]; then echo "Error snmpget not installed or wrong path" exit 3 fi snmp_sysstat=$($get -c $community_string -v $snmp_version $Host -O v $srv_view_sysstat_oid | cut -b10) case $snmp_sysstat in 1) echo "Serverview Agent Status OK" exit 0 ;; 2) echo -n "Serverview Agent Warning : " check_sub exit 1 ;; 3|4) echo -n "Serverview Agent Critical : " check_sub exit 2 ;; *) echo "Serverview Agent Status unknown" exit 3 ;; esac