2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/other/snmp__fn
2012-01-14 22:17:24 +01:00

128 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
#set -x
### Constants ------------------------------------------------------------------
SNMPCLIENT=`basename $0 | sed 's/^snmp_//g' | cut -d "_" -f1`
SNMPGET="/usr/bin/snmpget -c $community -v 2c $SNMPCLIENT"
### Variables ------------------------------------------------------------------
fnSysVersion="1.3.6.1.4.1.12356.1.3.0"
FGTcpu="1.3.6.1.4.1.12356.1.8.0"
fnSysVersion="1.3.6.1.4.1.12356.1.3.0"
fnSysMemUsage="1.3.6.1.4.1.12356.1.9.0"
fnSysSesCount="1.3.6.1.4.1.12356.1.10.0"
fnVPNSslStatsLoginUsers="1.3.6.1.4.1.12356.9.5.1.3.1"
fnVPNSslStatsActiveWebSessions="1.3.6.1.4.1.12356.9.5.1.5.1"
fnVPNSslStatsActiveTunnels="1.3.6.1.4.1.12356.9.5.1.7.1"
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`
WEBS=`$SNMPGET $fnVPNSslStatsActiveWebSessions | cut -d ":" -f4 | cut -d " " -f2`
ATUN=`$SNMPGET $fnVPNSslStatsActiveTunnels | cut -d ":" -f4 | cut -d " " -f2`
### Functions ------------------------------------------------------------------
autoconf()
{
if [ $SCPU ]; then
echo yes, OID $FGTcpu can be readed.
else
echo no, one or multiple OID can not be readed.
exit 1
fi
if [ $SMEM ]; then
echo yes, OID $fnSysMemUsage can be readed.
else
echo no, one or multiple OID can not be readed.
exit 1
fi
if [ $SCNT ]; then
echo yes, OID $fnSysSesCount can be read.
else
echo no, one or multiple OID can not be read.
exit 1
fi
exit 0
}
config()
{
echo "multigraph fn_cpu"
echo "host_name $SNMPCLIENT"
echo "graph_title $UNIT - CPU usage"
echo 'graph_category system'
echo 'graph_vlabel %'
echo 'graph_info This graph shows current CPU usage.'
echo 'graph_args --base 1000 -r --lower-limit 0 --upper-limit 100'
echo 'forticpu.label CPU'
echo 'forticpu.info CPU usage'
echo 'forticpu.draw AREA'
echo ''
echo "multigraph fn_memory"
echo "host_name $SNMPCLIENT"
echo "graph_title $UNIT - Memory usage"
echo 'graph_category system'
echo 'graph_vlabel %'
echo 'graph_info This graph shows current memory usage.'
echo 'graph_args --base 1000 -r --lower-limit 0 --upper-limit 100'
echo 'fortimemory.label Memory'
echo 'fortimemory.info Memory usage'
echo 'fortimemory.draw AREA'
echo ''
echo "multigraph fn_sessions"
echo "host_name $SNMPCLIENT"
echo "graph_title $UNIT - Sessions"
echo 'graph_category Other'
echo 'graph_vlabel Active Sessions'
echo 'graph_info Active session count on the Fortigate firewall'
echo 'fortisessions.label Sessions'
echo 'fortisessions.info Active session count'
echo 'fortisessions.draw AREA'
echo ''
echo "multigraph fn_vpnsessions"
echo "host_name $SNMPCLIENT"
echo "graph_title $UNIT - SSLvpn Sessions"
echo 'graph_category Other'
echo 'graph_vlabel Sessions/Users'
echo 'graph_info Loged in users with SSLvpn (WebSession or Tunnel-Mode)'
echo 'fortiuser.label Users'
echo 'fortiuser.info Loged in SSLvpn users'
echo 'fortiwebs.label WebSessions'
echo 'fortiwebs.info Active SSLvpn WebSessions'
echo 'fortiatun.label ActiveTunnels'
echo 'fortiatun.info Active SSLvpn Tunnels'
exit 0
}
values()
{
echo "multigraph fn_cpu"
echo "forticpu.value $SCPU"
echo ""
echo "multigraph fn_memory"
echo "fortimemory.value $SMEM"
echo ""
echo "multigraph fn_sessions"
echo "fortisessions.value $SCNT"
echo ""
echo "multigraph fn_vpnsessions"
echo "fortiuser.value $USER"
echo "fortiwebs.value $WEBS"
echo "fortiatun.value $ATUN"
}
### Main -----------------------------------------------------------------------
if [ "$1" = "autoconf" ]; then autoconf
fi
if [ "$1" = "config" ]; then config
fi
values