SNMP Cisco Problem

Wengrzik, Andreas Wengrzik at ewr.de
Tue Nov 9 13:09:52 CET 2004


Hi!

I tried to make my own check_plugin...
but it always give me the same output ?


heres the script

PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1.4.2.2 $' | sed -e 's/[^0-9.]//g'`

. $PROGPATH/utils.sh

HOST2CHK=$1
COMMUNITY=$2
WARNING=$3
CRITICAL=$4
OPTERROR=33

if [ $# -eq 0 ]
# Exit and complain if no argument(s) given.
then
  echo "-H Switch IP Adress"
  echo "-C Community"
  echo "-P Switchport"
fi


while getopts ":H:C:P:w:c:" Option
do
  case $Option in
    H     ) HOST2CHK=$OPTARG;;
    C     ) COMMUNITY=$OPTARG;;
    P	   ) PORT=$OPTARG;;
    *     ) echo "Unimplemented option chosen.";;
  esac
done

if [ -z $HOST2CHK ]
then
   echo "HOST -H nicht gesetzt"
   exit $OPTERROR
fi

if [ -z $COMMUNITY ]
then
   echo "Community -C nicht gesetzt"
   exit $OPTERROR
fi

if [ -z $PORT ]
then
   echo "Port -P nicht gesetzt"
   exit $OPTERROR
fi

STATUS=`snmpget -v1 -Ovqn -t9 -c $COMMUNITY $HOST2CHK .1.3.6.1.2.1.2.2.1.8.$PORT`
echo $STATUS

if [ $STATUS='up' ]
then
   echo "Status ist OK!"
exit $STATE_OK

else

if [ $STATUS = up ]
then

   echo "Status ist kritisch!"
exit $STATE_CRITICAL

fi
fi


and heres the output:

[root at server libexec]# ./check_cisco -H 172.16.0.23 -C nagios  -P 3
down
Status ist OK!
[root at server libexec]# ./check_cisco -H 172.16.0.23 -C nagios  -P 4
up			
Status ist OK!

I have put an echo command to be sure $STATUS has the right value.

Anyone can help me?? Thanks!!

> -----Original Message-----
> From: Wengrzik, Andreas 
> Sent: Tuesday, November 09, 2004 10:04 AM
> To: nagios-users at lists.sourceforge.net
> Subject: RE: [Nagios-users] SNMP Cisco Problem
> 
> 
> I stuck at this problem...
> 
> The output is always this string:
> 
> snmpwalk -v 1 -c nagios 172.16.0.23 .1.3.6.1.2.1.2.2.1.8.4
> 
> IF-MIB::ifOperStatus.4 = INTEGER: up(1)
> 
> And if i need check_snmp it fails.
> 
> So i need to write a script which cuts onyl the    1    or    
>  2 out of the ( ).
> I search antoher script and the do it with this syntax:
> 
> FREE=`snmpwalk $HOST2CHK $COMMUNITY 
> .1.3.6.1.4.1.9.9.48.1.1.1.6.1 | cut -d ":" -f 2`
> 
> 
> but, i can´t use this i think... Becaus cut needs a 
> delimiter, and here i have two brackets around my value.
> Does anyone know better to play with scripting??
> 
> Thanks a lot!!!
> 
> Bye
> 
> 
> 
> > -----Original Message-----
> > From: Robert Nelson [mailto:rnelson at windchannel.com]
> > Sent: Monday, November 08, 2004 10:34 PM
> > To: Wengrzik, Andreas; nagios-users at lists.sourceforge.net
> > Subject: RE: [Nagios-users] SNMP Cisco Problem
> > 
> > 
> > Try using the check_snmp plugin on the command line. I believe it
> > responds with a number, i.e. "1" , "2", or "3". So your check 
> > should be
> > "check_snmp!interfaces.ifTable.ifEntry.ifAdminStatus.34!1!2!2"
> > 
> > Rob Nelson
> > Network Engineer
> > Windchannel Communications
> > 919-538-6326 
> > 
> > > -----Original Message-----
> > > From: Wengrzik, Andreas [mailto:Wengrzik at ewr.de] 
> > > Sent: Monday, November 08, 2004 8:51 AM
> > > To: nagios-users at lists.sourceforge.net
> > > Subject: [Nagios-users] SNMP Cisco Problem
> > > 
> > > 
> > > Hi!
> > > 
> > > I currently try to check a Cisco Catalyst 3550.
> > > So i got this result with snmpget
> > > 
> > > #snmpwalk -v 1 -c nagios 172.16.0.23 
> > > interfaces.ifTable.ifEntry.ifAdminStatus.1
> > > IF-MIB::ifAdminStatus.1 = INTEGER: up(1)
> > > 
> > > and this is my service descr for nagios
> > > 
> > > define service {
> > > 	host_name		SW_NOT_UG
> > > 	service_description	SNMP_TEST
> > > 	check_command		
> > > check_snmp!interfaces.ifTable.ifEntry.ifAdminStatus.34!"INTEGE
> > > R: up(1)"!"INTEGER: down(2)"!"INTEGER: down(2)"
> > > 	max_check_attempts	3
> > > 	normal_check_interval	1
> > > 	retry_check_interval	3
> > > 	check_period    	24x7
> > >         notification_interval   20
> > >         notification_period     24x7
> > >         notification_options    w,c,u,r
> > >         contact_groups          SMS
> > > 	}
> > > 
> > > 
> > > With this description i got only this message in Nagios:
> > > 	Invalid warning threshold: INTEGER: up(1)  
> > > 
> > > I also tried to change " to '  - no result.
> > > So, what can i do else to get informations in a correct way?
> > > 
> > > Sorry for this question its the first time i use snmp.
> > > 
> > > Thanks for your help!
> > > 
> > > Bye
> > > 
> > > 
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by:
> > > Sybase ASE Linux Express Edition - download now for FREE
> > > LinuxWorld Reader's Choice Award Winner for best database 
> on Linux.
> > > http://ads.osdn.com/?ad_idU88&alloc_id065&op=ick
> > > _______________________________________________
> > > Nagios-users mailing list
> > > Nagios-users at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/nagios-users
> > > ::: Please include Nagios version, plugin version (-v) and OS 
> > > when reporting any issue. 
> > > ::: Messages without supporting info will risk being sent 
> > to /dev/null
> > > 
> > 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Sybase ASE Linux Express Edition - download now for FREE
> LinuxWorld Reader's Choice Award Winner for best database on Linux.
> http://ads.osdn.com/?ad_idU88&alloc_id065&op=ick
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS 
> when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null
> 


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_idU88&alloc_id065&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list