Skip to content
Snippets Groups Projects
Commit 7f05c501 authored by Andrea Gottsponer's avatar Andrea Gottsponer
Browse files

- add disc check to snmp-synology

parent 6adeaf0f
Branches
No related tags found
1 merge request!48- add disc check to snmp-synology
......@@ -14,7 +14,7 @@
#
# SYNTAX:
# label --> DATA:[method]:label:[text]
# n x data --> DATA:[method]:data:[perf-label]:[oid]:[optional unit]
# n x data --> DATA:[method]:data:[perf-label]:[oid]:[optional unit]:[loop oid]
#
# DATA:cpu:label:CPU usage
# DATA:cpu:data:cpu-user:1.3.6.1.4.1.2021.11.9.0:%
......@@ -33,6 +33,10 @@
# DATA:synotemp:label:Synology NAS temperature
# DATA:synotemp:data:temp:1.3.6.1.4.1.6574.1.2.0:°C
#
# DATA:disc:label:Disc usage
# DATA:disc:data:disc-free:1.3.6.1.4.1.6574.3.1.1.2::1.3.6.1.4.1.6574.3.1.1.4
# DATA:disc:data:disc-space:1.3.6.1.4.1.6574.3.1.1.2::1.3.6.1.4.1.6574.3.1.1.5
#
# ----------------------------------------------------------------------
# 2020-08-11 <axel.hahn@iml.unibe.ch> initial version
# 2020-08-13 <axel.hahn@iml.unibe.ch> add host in label for counter data
......@@ -45,6 +49,7 @@
ABOUT="SNMP performance data v0.4"
SNMPCOMMUNITY="public"
SNMPVERSION="2c"
SNMPWALK=$(which snmpwalk)
SNMPGET=$(which snmpget)
HOSTNAME="127.0.0.1"
......@@ -201,9 +206,30 @@ fi
prflist=( $(_cfg_dataitem 4) )
oidlist=( $(_cfg_dataitem 5) )
unitlist=( $(_cfg_dataitem 6) )
looplist=( $(_cfg_dataitem 7) )
# --- check for looplist
if [ -n "$looplist" ]; then
nb=`$SNMPWALK -OQne -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME ${oidlist[*]} 2> /dev/null | wc -l`
declare -a tmpPrflist=()
declare -a tmpOidlist=()
declare -a tmpUnitlist=()
for i in `seq 1 $nb`;
do
for j in `seq 1 ${#looplist[@]}`
do
tmpPrflist+=("${prflist[$(($j-1))]}.$(($i-1))")
tmpOidlist+=("${looplist[$(($j-1))]}.$(($i-1))")
tmpUnitlist+=("${unitlist[$(($j-1))]}")
done
done
prflist=( "${tmpPrflist[@]}" )
oidlist=( "${tmpOidlist[@]}" )
unitlist=( "${tmpUnitlist[@]}" )
fi
# --- SNPGET to all wanted oids
# --- SNMPGET to all wanted oids
SYNO=`$SNMPGET -One -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME ${oidlist[*]} 2> /dev/null`
if [ $? -ne 0 ] ; then
......@@ -219,13 +245,18 @@ do
value=$(_get ${oidlist[$index]})
unit="${unitlist[$index]}"
# handle counter data
if [ "$(_iscounter ${oidlist[$index]})" = "true" ]; then
value2=`ph.perfdeltaspeed "snmp-data-${HOSTNAME}-${method}-${label}" $value`
_wd "$( printf '%-14s total: %-14s delta: %6s %s per sec' $label $value $value2 $unit )"
value=$value2
# handle loop data
if [ -n "$looplist" ]; then
_wd "$( printf '%-14s %s %s' $label $value $unit )"
else
_wd "$( printf '%-14s %s %s' $label $value $unit )"
# handle counter data
if [ "$(_iscounter ${oidlist[$index]})" = "true" ]; then
value2=`ph.perfdeltaspeed "snmp-data-${HOSTNAME}-${method}-${label}" $value`
_wd "$( printf '%-14s total: %-14s delta: %6s %s per sec' $label $value $value2 $unit )"
value=$value2
else
_wd "$( printf '%-14s %s %s' $label $value $unit )"
fi
fi
ph.perfadd "${label}" "${value}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment