From 6db166599184da8c7b7f500118067fb1d6a34514 Mon Sep 17 00:00:00 2001 From: Thomas Diener Date: Wed, 25 Jan 2012 16:59:33 +0100 Subject: [PATCH] MIB file availability check added --- plugins/other/snmp__fn | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/other/snmp__fn b/plugins/other/snmp__fn index 5b3b9dd3..b481995a 100755 --- a/plugins/other/snmp__fn +++ b/plugins/other/snmp__fn @@ -12,6 +12,7 @@ # # Version: v1.00 30.10.2011 First draft of the fortigate plugin # v1.01 19.01.2012 OID to MIB changed, plugins gets faster +# v1.02 25.01.2012 MIB file availability check added # # Parameters: config (required) # autoconf (optional) @@ -28,7 +29,7 @@ # Fortigate Activate snmp on your Fortigate firewall. Fortigate documentation # at https://support.fortinet.com # -# MIB Download and copy the Fortigate MIB defintion file to +# MIB Download and copy the original Fortigate MIB defintion file to # /usr/share/snmp/mibs/FORTINET-300-MIB.txt (Filename depends on # used Version) # @@ -45,8 +46,12 @@ SNMPCLIENT=`basename $0 | sed 's/^snmp_//g' | cut -d "_" -f1` MIBFILE="/usr/share/snmp/mibs/FORTINET-300-MIB.20080414.txt" FNTYPE=`echo $MIBFILE | cut -d "." -f1 | cut -d "/" -f6` -SNMPGET="/usr/bin/snmpget -m $MIBFILE -c $community -v 2c $SNMPCLIENT" - +if [ -r $MIBFILE ]; then + SNMPGET="/usr/bin/snmpget -m $MIBFILE -c $community -v 2c $SNMPCLIENT" +else + echo no, MIB definition file not available or readable. + exit 1 +fi ### Variables ------------------------------------------------------------------ fnSysVersion="1.3.6.1.4.1.12356.1.3.0" @@ -57,10 +62,9 @@ fnSysSesCount="$FNTYPE::fnSysSesCount.0" fnVPNSslStatsLoginUsers="$FNTYPE::fnVpnSslStatsLoginUsers.1" fnVPNSslStatsActiveWebSessions="$FNTYPE::fnVpnSslStatsActiveWebSessions.1" fnVPNSslStatsActiveTunnels="$FNTYPE::fnVpnSslStatsActiveTunnels.1" -mibfile="/usr/share/snmp/mibs/FORTINET-300-MIB.20080414.txt" -UNIT=`$SNMPGET $fnSysVersion | cut -d ":" -f4 | cut -d " " -f2 | cut -d "\"" -f2` -SCPU=`$SNMPGET $FGTcpu | cut -d ":" -f4 | cut -d " " -f2` +UNIT=`$SNMPGET $fnSysVersion | cut -d ":" -f4 | cut -d " " -f2 | cut -d "\"" -f2` +SCPU=`$SNMPGET $FGTcpu | cut -d ":" -f4 | cut -d " " -f2` SMEM=`$SNMPGET $fnSysMemUsage | cut -d ":" -f4 | cut -d " " -f2` SCNT=`$SNMPGET $fnSysSesCount | cut -d ":" -f4 | cut -d " " -f2` USER=`$SNMPGET $fnVPNSslStatsLoginUsers | cut -d ":" -f4 | cut -d " " -f2` @@ -86,7 +90,7 @@ autoconf() exit 1 fi if [ $SCNT ]; then - echo yes, OID $fnSysSesCount can be read. + echo yes, OID $fnSysSesCount can be readed. else echo no, one or multiple OID can not be read. exit 1 @@ -107,7 +111,6 @@ config() echo 'forticpu.info CPU usage' echo 'forticpu.draw AREA' echo '' - echo "multigraph fn_memory" echo "host_name $SNMPCLIENT" echo "graph_title $UNIT - Memory usage"