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

Merge branch '6361-fix-ceph-io' into 'master'

getOS from /etc/os-release first

See merge request !84
parents 78bda255 ee5a25ba
No related branches found
No related tags found
1 merge request!84getOS from /etc/os-release first
......@@ -2,7 +2,6 @@
# ======================================================================
#
# NAGIOS / ICINGA CHECK :: check_snmp_data
# this plugin checks snmp performance data
#
# DOCS:
# - Synology - see docs:
......@@ -16,40 +15,52 @@
# label --> DATA:[method]:label:[text]
# n x data --> DATA:[method]:data:[perf-label]:[oid]:[optional unit]:[loop oid]
#
# ---------- General infos for all devices:
#
# DATA:about:label:About... general device infos
# DATA:about:out:text:sysDescr:1.3.6.1.2.1.1.1.0:
# DATA:about:out:text:sysObjectID:1.3.6.1.2.1.1.2.0:
# DATA:about:out:text:sysUpTime:1.3.6.1.2.1.1.3.0:
# DATA:about:out:text:sysContact:1.3.6.1.2.1.1.4.0:
# DATA:about:out:text:sysName:1.3.6.1.2.1.1.5.0:
# DATA:about:out:text:sysLocation:1.3.6.1.2.1.1.6.0:
#
# DATA:cpu:label:CPU usage
# DATA:cpu:data:cpu-user:1.3.6.1.4.1.2021.11.9.0:%
# DATA:cpu:data:cpu-system:1.3.6.1.4.1.2021.11.10.0:%
# DATA:cpu:data:cpu-idle:1.3.6.1.4.1.2021.11.11.0:%
# DATA:cpu:out:data:cpu-user:1.3.6.1.4.1.2021.11.9.0:%
# DATA:cpu:out:data:cpu-system:1.3.6.1.4.1.2021.11.10.0:%
# DATA:cpu:out:data:cpu-idle:1.3.6.1.4.1.2021.11.11.0:%
#
# DATA:load:label:System load
# DATA:load:data:load1:1.3.6.1.4.1.2021.10.1.5.1:
# DATA:load:data:load5:1.3.6.1.4.1.2021.10.1.5.2:
# DATA:load:data:load15:1.3.6.1.4.1.2021.10.1.5.3:
# DATA:load:out:data:load1:1.3.6.1.4.1.2021.10.1.5.1:
# DATA:load:out:data:load5:1.3.6.1.4.1.2021.10.1.5.2:
# DATA:load:out:data:load15:1.3.6.1.4.1.2021.10.1.5.3:
#
# DATA:mem:label:Memory status
# DATA:mem:data:memTotalSwap:1.3.6.1.4.1.2021.4.3.0:
# DATA:mem:data:memAvailSwap:1.3.6.1.4.1.2021.4.4.0:
# DATA:mem:data:memTotalReal:1.3.6.1.4.1.2021.4.5.0:
# DATA:mem:data:memAvailReal:1.3.6.1.4.1.2021.4.6.0:
# DATA:mem:data:memTotalFree:1.3.6.1.4.1.2021.4.11.0:
# DATA:mem:data:memShared:1.3.6.1.4.1.2021.4.13.0:
# DATA:mem:data:memBuffer:1.3.6.1.4.1.2021.4.14.0:
# DATA:mem:data:memCached:1.3.6.1.4.1.2021.4.15.0:
# DATA:mem:out:data:memTotalSwap:1.3.6.1.4.1.2021.4.3.0:
# DATA:mem:out:data:memAvailSwap:1.3.6.1.4.1.2021.4.4.0:
# DATA:mem:out:data:memTotalReal:1.3.6.1.4.1.2021.4.5.0:
# DATA:mem:out:data:memAvailReal:1.3.6.1.4.1.2021.4.6.0:
# DATA:mem:out:data:memTotalFree:1.3.6.1.4.1.2021.4.11.0:
# DATA:mem:out:data:memShared:1.3.6.1.4.1.2021.4.13.0:
# DATA:mem:out:data:memBuffer:1.3.6.1.4.1.2021.4.14.0:
# DATA:mem:out:data:memCached:1.3.6.1.4.1.2021.4.15.0:
#
# DATA:netio:label:Network IO
# DATA:netio:data:in:1.3.6.1.2.1.4.3.0:
# DATA:netio:data:out:1.3.6.1.2.1.4.10.0:
# DATA:netio:out:data:in:1.3.6.1.2.1.4.3.0:
# DATA:netio:out:data:out:1.3.6.1.2.1.4.10.0:
#
# ---------- SYNOLOGY specific:
#
# DATA:disc:label:Synology 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
# DATA:synodisc:label:Synology Disc usage
# DATA:synodisc:out: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:synodisc:out: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
#
# DATA:synotemp:label:Synology NAS temperature
# DATA:synotemp:data:temp:1.3.6.1.4.1.6574.1.2.0:°C
# DATA:synotemp:out:data:temp:1.3.6.1.4.1.6574.1.2.0:°C
#
# DATA:synoio:label:Synology Space IO
# DATA:synoio:data:syno-io-read:1.3.6.1.4.1.6574.102.1.1.12.1
# DATA:synoio:data:syno-io-write:1.3.6.1.4.1.6574.102.1.1.13.1
# DATA:synoio:out:data:syno-io-read:1.3.6.1.4.1.6574.102.1.1.12.1
# DATA:synoio:out:data:syno-io-write:1.3.6.1.4.1.6574.102.1.1.13.1
#
# ----------------------------------------------------------------------
# 2020-08-11 <axel.hahn@iml.unibe.ch> initial version
......@@ -58,6 +69,7 @@
# 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
# 2023-05-05 v0.7 <axel.hahn@unibe.ch> source shared func, support snmpv3; add synoio
# 2023-05-16 v0.8 <axel.hahn@unibe.ch> add about for general infos and without perf data
# ======================================================================
. $(dirname $0)/inc_pluginfunctions
......@@ -65,14 +77,10 @@
# --- basic vars
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
self_APPVERSION=0.7
self_APPVERSION=0.8
METHOD=""
# --- OID declarations
# OID_syno="1.3.6.1.4.1.6574"
# OID_ucdavis="1.3.6.1.4.1.2021" # University of California, Davis - private UCD SNMP MIB extensions
# --- output variables
SYNO=""
out=""
......@@ -95,13 +103,13 @@ _wd()
# get line(s) for config
# param string one of label|data
_cfg_reader(){
grep "^# DATA:$METHOD:$1:" $0
grep "^# DATA:${METHOD}${1}" $0
}
_cfg_getlabel(){
_cfg_reader "label" | cut -f 4- -d ":"
_cfg_reader ":label:" | cut -f 4- -d ":"
}
_cfg_dataitem(){
_cfg_reader "data" | cut -f $1 -d ":" | while read item
_cfg_reader ":out:" | cut -f $1 -d ":" | while read item
do
echo -n "$item "
done
......@@ -150,7 +158,7 @@ function showHelp(){
local _methods=$(
_cfg_getMethods | while read -r line
do
METHOD=$(echo "$line" | cut -f 1 -d ":")
METHOD=$(echo "$line" | cut -f 2 -d ":")
descr=$(_cfg_getlabel)
printf " %-10s %-50s\n" "$METHOD" "$descr"
done
......@@ -247,10 +255,10 @@ if [ -z "$info" ]; then
showHelp
fi
prflist=( $(_cfg_dataitem 4) )
oidlist=( $(_cfg_dataitem 5) )
unitlist=( $(_cfg_dataitem 6) )
looplist=( $(_cfg_dataitem 7) )
prflist=( $(_cfg_dataitem 5) )
oidlist=( $(_cfg_dataitem 6) )
unitlist=( $(_cfg_dataitem 7) )
looplist=( $(_cfg_dataitem 8) )
# --- check for looplist
if [ -n "$looplist" ]; then
......@@ -291,25 +299,38 @@ do
value=$(_get ${oidlist[$index]})
unit="${unitlist[$index]}"
# handle loop data
if [ -n "$looplist" ]; then
_wd "$( printf '%-14s %s %s' $label $value $unit )"
else
# handle counter data
if [ "$(_iscounter ${oidlist[$index]})" = "true" ]; then
isperf=1
outtype='text'
test "$(_iscounter ${oidlist[$index]})" = 'true' && outtype='counter'
test "$(_isinteger ${oidlist[$index]})" = 'true' && outtype='integer'
test -n "$looplist" && outtype='looplist'
# _wd ""; _wd "outtype = $outtype:"
case $outtype in
counter)
value2=$(ph.perfdeltaspeed "snmp-data-${SNMPTARGET}-${method}-${label}" $value)
_wd "$( printf '%-14s total: %-14s delta: %6s %s per sec' $label $value $value2 $unit )"
value=$value2
elif [ "$(_isinteger ${oidlist[$index]})" = "true" ]; then
;;
integer)
_wd "$( printf '%-14s %s %s' $label $value $unit )"
value2=$( echo "${value}" | sed -E "s#([0-9]*) (.).*#\1\2#g")
value=${value2}
else
_wd "$( printf '%-14s %s %s' $label $value $unit )"
fi
fi
;;
looplist)
_wd "$( printf '%-14s %s %s' $label "$value" $unit )"
;;
text)
_wd "$( printf '%-14s %s %s' $label "$value" $unit )"
isperf=0
;;
*)
echo "TODO: handle output of type $outtype"
;;
esac
ph.perfadd "${label}" "${value}"
test $isperf -eq 1 && ph.perfadd "${label}" "${value}"
done
......
......@@ -14,7 +14,7 @@ Start the script without parameter to get the help.
______________________________________________________________________
CHECK_SNMP_DATA
v0.6
v0.8
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
......@@ -23,22 +23,40 @@ ______________________________________________________________________
SNMP performance data of Synology storages.
USAGE:
./check_snmp_data -h hostname [-C communitystring] -m method
check_snmp_data [options] -h SNMPTARGET
PARAMETERS:
-h hostname as fqdn or ip address
-C communitystr optional: community string for snmp; default is public
-v verbose output
-a STRING
authentication params for snmpwalk/ snmpget to connect to target;
default: \"-v2c -c public\" (Snmpv2 with community string \"public\")
-h SNMPTARGET
as fqdn or ip address; default: localhost
-f FILE
read authentication from config file
default: "/etc/icinga2/snmp.cfg"
-m method what to show
method is one of ...
about About... general device infos
cpu CPU usage
load System load
netio Network IO (experimental)
mem Memory status
netio Network IO
synodisc Synology Disc usage
synotemp Synology NAS temperature
disc Disc usage
synoio Synology Space IO
-v verbose output
CONFIG FILE:
The config file can be multiline and has the syntax
[SNMPTARGET[,target2]]:[auth parameters]
The auth parameters set the version and all needed values to connect.
Snmp v2 uses a community string.
Snmp v3 is highly recommended (you should disable Snmp v2) and needs
a user and password.
EXAMPLE:
./check_snmp_data -h 192.168.100.12 -v -m cpu
check_snmp_data -h 192.168.100.12 -v -m cpu
```
......
......@@ -35,6 +35,7 @@
# 2023-02-16 v1.7 <axel.hahn@unibe.ch> adding a generic min and max value did not really help
# 2023-04-24 v1.8 <axel.hahn@unibe.ch> fix unit conversion
# 2023-05-05 v1.9 <axel.hahn@unibe.ch> user specific counter directory
# 2023-05-17 v1.10 <axel.hahn@unibe.ch> ph.getOS searches in os-release first
# ======================================================================
......@@ -87,6 +88,10 @@ function ph.getOS(){
if [ -z $distro ]; then
# centos7, debian, manjaro, ubuntu
distro=$( grep "^ID=" /etc/os-release | cut -f 2 -d "=" )
fi
if [ -z $distro ]; then
distro=$( grep "^ID=" /etc/*-release | cut -f 2 -d "=" )
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment