Skip to content
Snippets Groups Projects
Commit e3d311df authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch 'fix-netstat' into 'master'

Fix SNMP netio

See merge request !51
parents 39bcac34 b182ebf5
No related branches found
No related tags found
1 merge request!51Fix SNMP netio
......@@ -3,3 +3,4 @@ check_smart.pl
paramtest
check_snmp_syno.sh
check-cpu.sh
static/*
\ No newline at end of file
......@@ -38,15 +38,19 @@
# 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
# 2022-10-21 v0.4 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# 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
# 2022-10-21 v0.4 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# 2022-10-21 v0.5 <andrea.gottsponer@unibe.ch> remove grep: warning: stray \ before white space
# 2022-10-25 v0.6 <axel.hahn@unibe.ch> fix empty value in performance data; shell fixes
# ======================================================================
. `dirname $0`/inc_pluginfunctions
. $(dirname $0)/inc_pluginfunctions
# --- basic vars
ABOUT="SNMP performance data v0.4"
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
self_APPVERSION=0.6
SNMPCOMMUNITY="public"
SNMPVERSION="2c"
SNMPWALK=$(which snmpwalk)
......@@ -125,14 +129,18 @@ _iscounter(){
#---------------------------------------------------
# --- show usage
usage()
{
cat <<EOH
function showHelp(){
cat <<EOH
______________________________________________________________________
$self_APPNAME
v$self_APPVERSION
$ABOUT
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
University of Bern * Institute of Medical Education
GNU GPL 3.0
SNMP performance data of Synology storages.
USAGE:
./check_snmp_data -h hostname [-C communitystring] -m method
......@@ -146,11 +154,11 @@ PARAMETERS:
EOH
# --- dynamic: add current methods
_cfg_getMethods | while read line
_cfg_getMethods | while read -r line
do
METHOD=`echo $line | cut -f 1 -d ":"`
METHOD=$(echo "$line" | cut -f 1 -d ":")
descr=$(_cfg_getlabel)
printf " %-10s %-50s\n" $METHOD "$descr"
printf " %-10s %-50s\n" "$METHOD" "$descr"
done
# --- finish usage
......@@ -199,8 +207,8 @@ fi
# --- read metadata of the selected METHOD
info=$(_cfg_getlabel)
if [ -z "$info" ]; then
echo ERROR: unknown METHOD [$METHOD]
usage
echo "ERROR: unknown METHOD [$METHOD]"
showHelp
fi
prflist=( $(_cfg_dataitem 4) )
......@@ -210,14 +218,14 @@ 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`
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`;
for i in $(seq 1 $nb);
do
for j in `seq 1 ${#looplist[@]}`
for j in $(seq 1 ${#looplist[@]})
do
tmpPrflist+=("${prflist[$(($j-1))]}.$(($i-1))")
tmpOidlist+=("${looplist[$(($j-1))]}.$(($i-1))")
......@@ -230,7 +238,7 @@ if [ -n "$looplist" ]; then
fi
# --- SNMPGET to all wanted oids
SYNO=`$SNMPGET -One -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME ${oidlist[*]} 2> /dev/null`
SYNO=$($SNMPGET -One -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME ${oidlist[*]} 2> /dev/null)
if [ $? -ne 0 ] ; then
$SNMPGET -One -t 10 -v $SNMPVERSION -c $SNMPCOMMUNITY $HOSTNAME ${oidlist[*]}
......@@ -239,6 +247,8 @@ fi
# --- performance data
typeset -i value
for index in ${!oidlist[*]}
do
label="${prflist[$index]}"
......@@ -251,7 +261,7 @@ do
else
# handle counter data
if [ "$(_iscounter ${oidlist[$index]})" = "true" ]; then
value2=`ph.perfdeltaspeed "snmp-data-${HOSTNAME}-${method}-${label}" $value`
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
......
......@@ -4,22 +4,23 @@
**check_snmp_data** is a plugin for fetching performance data with a set of given OIDs.
It can handle current values (i.e. load or cpu usage) and counter values (i.e. network io).
It can handle current values (i.e. load / cpu usage / disc usage) and counter values (i.e. network io).
## Syntax
``$ check_snmp_data -h HOSTNAME [-C COOMMUNITYSTRING] -v -m METHOD``
### Parameters
Starting the script without parameters shows a help.
Start the script without parameter to get the help.
```txt
______________________________________________________________________
CHECK_SNMP_DATA
v0.6
SNMP performance data v1.0
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
University of Bern * Institute of Medical Education
GNU GPL 3.0
SNMP performance data of Synology storages.
USAGE:
./check_snmp_data -h hostname [-C communitystring] -m method
......@@ -34,6 +35,7 @@ PARAMETERS:
load System load
netio Network IO (experimental)
synotemp Synology NAS temperature
disc Disc usage
EXAMPLE:
./check_snmp_data -h 192.168.100.12 -v -m cpu
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment