Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
f165f5cd
Commit
f165f5cd
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
add about for general infos and without perf data
parent
ef3c90cc
No related branches found
No related tags found
1 merge request
!84
getOS from /etc/os-release first
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
check_snmp_data
+77
-56
77 additions, 56 deletions
check_snmp_data
docs/20_Checks/check_snmp_data.md
+26
-8
26 additions, 8 deletions
docs/20_Checks/check_snmp_data.md
with
103 additions
and
64 deletions
check_snmp_data
+
77
−
56
View file @
f165f5cd
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
# ======================================================================
# ======================================================================
#
#
# NAGIOS / ICINGA CHECK :: check_snmp_data
# NAGIOS / ICINGA CHECK :: check_snmp_data
# this plugin checks snmp performance data
#
#
# DOCS:
# DOCS:
# - Synology - see docs:
# - Synology - see docs:
...
@@ -16,41 +15,53 @@
...
@@ -16,41 +15,53 @@
# label --> DATA:[method]:label:[text]
# label --> DATA:[method]:label:[text]
# n x data --> DATA:[method]:data:[perf-label]:[oid]:[optional unit]:[loop oid]
# 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:label:CPU usage
# DATA:cpu:data:cpu-user:1.3.6.1.4.1.2021.11.9.0:%
# DATA:cpu:
out:
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:
out:
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-idle:1.3.6.1.4.1.2021.11.11.0:%
#
#
# DATA:load:label:System load
# DATA:load:label:System load
# DATA:load:data:load1:1.3.6.1.4.1.2021.10.1.5.1:
# DATA:load:
out:
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:
out:
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:load15:1.3.6.1.4.1.2021.10.1.5.3:
#
#
# DATA:mem:label:Memory status
# DATA:mem:label:Memory status
# DATA:mem:data:memTotalSwap:1.3.6.1.4.1.2021.4.3.0:
# DATA:mem:
out:
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:
out:
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:
out:
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:
out:
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:
out:
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:
out:
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:
out:
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:memCached:1.3.6.1.4.1.2021.4.15.0:
#
#
# DATA:netio:label:Network IO
# DATA:netio:label:Network IO
# DATA:netio:data:in:1.3.6.1.2.1.4.3.0:
# DATA:netio:out: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:out:1.3.6.1.2.1.4.10.0:
#
#
# DATA:disc:label:Synology Disc usage
# ---------- SYNOLOGY specific:
# 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: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:label:Synology Space IO
# DATA:synoio:data:syno-io-read:1.3.6.1.4.1.6574.102.1.1.12.1
# DATA:synoio:
out:
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-write:1.3.6.1.4.1.6574.102.1.1.13.1
#
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# 2020-08-11 <axel.hahn@iml.unibe.ch> initial version
# 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
# 2020-08-13 <axel.hahn@iml.unibe.ch> add host in label for counter data
...
@@ -58,6 +69,7 @@
...
@@ -58,6 +69,7 @@
# 2022-10-21 v0.5 <andrea.gottsponer@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
# 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-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
.
$(
dirname
$0
)
/inc_pluginfunctions
...
@@ -65,14 +77,10 @@
...
@@ -65,14 +77,10 @@
# --- basic vars
# --- basic vars
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPVERSION
=
0.
7
self_APPVERSION
=
0.
8
METHOD
=
""
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
# --- output variables
SYNO
=
""
SYNO
=
""
out
=
""
out
=
""
...
@@ -95,13 +103,13 @@ _wd()
...
@@ -95,13 +103,13 @@ _wd()
# get line(s) for config
# get line(s) for config
# param string one of label|data
# param string one of label|data
_cfg_reader
(){
_cfg_reader
(){
grep
"^# DATA:
$METHOD
:
$1
:
"
$0
grep
"^# DATA:
$
{
METHOD
}${
1
}
"
$0
}
}
_cfg_getlabel
(){
_cfg_getlabel
(){
_cfg_reader
"label"
|
cut
-f
4-
-d
":"
_cfg_reader
"
:
label
:
"
|
cut
-f
4-
-d
":"
}
}
_cfg_dataitem
(){
_cfg_dataitem
(){
_cfg_reader
"
data
"
|
cut
-f
$1
-d
":"
|
while
read
item
_cfg_reader
"
:out:
"
|
cut
-f
$1
-d
":"
|
while
read
item
do
do
echo
-n
"
$item
"
echo
-n
"
$item
"
done
done
...
@@ -150,7 +158,7 @@ function showHelp(){
...
@@ -150,7 +158,7 @@ function showHelp(){
local
_methods
=
$(
local
_methods
=
$(
_cfg_getMethods |
while
read
-r
line
_cfg_getMethods |
while
read
-r
line
do
do
METHOD
=
$(
echo
"
$line
"
|
cut
-f
1
-d
":"
)
METHOD
=
$(
echo
"
$line
"
|
cut
-f
2
-d
":"
)
descr
=
$(
_cfg_getlabel
)
descr
=
$(
_cfg_getlabel
)
printf
" %-10s %-50s
\n
"
"
$METHOD
"
"
$descr
"
printf
" %-10s %-50s
\n
"
"
$METHOD
"
"
$descr
"
done
done
...
@@ -247,10 +255,10 @@ if [ -z "$info" ]; then
...
@@ -247,10 +255,10 @@ if [ -z "$info" ]; then
showHelp
showHelp
fi
fi
prflist
=(
$(
_cfg_dataitem
4
)
)
prflist
=(
$(
_cfg_dataitem
5
)
)
oidlist
=(
$(
_cfg_dataitem
5
)
)
oidlist
=(
$(
_cfg_dataitem
6
)
)
unitlist
=(
$(
_cfg_dataitem
6
)
)
unitlist
=(
$(
_cfg_dataitem
7
)
)
looplist
=(
$(
_cfg_dataitem
7
)
)
looplist
=(
$(
_cfg_dataitem
8
)
)
# --- check for looplist
# --- check for looplist
if
[
-n
"
$looplist
"
]
;
then
if
[
-n
"
$looplist
"
]
;
then
...
@@ -291,25 +299,38 @@ do
...
@@ -291,25 +299,38 @@ do
value
=
$(
_get
${
oidlist
[
$index
]
}
)
value
=
$(
_get
${
oidlist
[
$index
]
}
)
unit
=
"
${
unitlist
[
$index
]
}
"
unit
=
"
${
unitlist
[
$index
]
}
"
# handle loop data
isperf
=
1
if
[
-n
"
$looplist
"
]
;
then
_wd
"
$(
printf
'%-14s %s %s'
$label
$value
$unit
)
"
outtype
=
'text'
else
test
"
$(
_iscounter
${
oidlist
[
$index
]
}
)
"
=
'true'
&&
outtype
=
'counter'
# handle counter data
test
"
$(
_isinteger
${
oidlist
[
$index
]
}
)
"
=
'true'
&&
outtype
=
'integer'
if
[
"
$(
_iscounter
${
oidlist
[
$index
]
}
)
"
=
"true"
]
;
then
test
-n
"
$looplist
"
&&
outtype
=
'looplist'
value2
=
$(
ph.perfdeltaspeed
"snmp-data-
${
SNMPTARGET
}
-
${
method
}
-
${
label
}
"
$value
)
_wd
"
$(
printf
'%-14s total: %-14s delta: %6s %s per sec'
$label
$value
$value2
$unit
)
"
# _wd ""; _wd "outtype = $outtype:"
value
=
$value2
case
$outtype
in
elif
[
"
$(
_isinteger
${
oidlist
[
$index
]
}
)
"
=
"true"
]
;
then
counter
)
_wd
"
$(
printf
'%-14s %s %s'
$label
$value
$unit
)
"
value2
=
$(
ph.perfdeltaspeed
"snmp-data-
${
SNMPTARGET
}
-
${
method
}
-
${
label
}
"
$value
)
value2
=
$(
echo
"
${
value
}
"
|
sed
-E
"s#([0-9]*) (.).*#
\1\2
#g"
)
_wd
"
$(
printf
'%-14s total: %-14s delta: %6s %s per sec'
$label
$value
$value2
$unit
)
"
value
=
${
value2
}
value
=
$value2
else
;;
_wd
"
$(
printf
'%-14s %s %s'
$label
$value
$unit
)
"
integer
)
fi
_wd
"
$(
printf
'%-14s %s %s'
$label
$value
$unit
)
"
fi
value2
=
$(
echo
"
${
value
}
"
|
sed
-E
"s#([0-9]*) (.).*#
\1\2
#g"
)
value
=
${
value2
}
;;
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
done
...
...
This diff is collapsed.
Click to expand it.
docs/20_Checks/check_snmp_data.md
+
26
−
8
View file @
f165f5cd
...
@@ -14,7 +14,7 @@ Start the script without parameter to get the help.
...
@@ -14,7 +14,7 @@ Start the script without parameter to get the help.
______________________________________________________________________
______________________________________________________________________
CHECK_SNMP_DATA
CHECK_SNMP_DATA
v0.
6
v0.
8
(c) Institute for Medical Education - University of Bern
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
Licence: GNU GPL 3
...
@@ -23,22 +23,40 @@ ______________________________________________________________________
...
@@ -23,22 +23,40 @@ ______________________________________________________________________
SNMP performance data of Synology storages.
SNMP performance data of Synology storages.
USAGE:
USAGE:
./
check_snmp_data
-h hostname [-C communitystring] -m method
check_snmp_data
[options] -h SNMPTARGET
PARAMETERS:
PARAMETERS:
-h hostname as fqdn or ip address
-a STRING
-C communitystr optional: community string for snmp; default is public
authentication params for snmpwalk/ snmpget to connect to target;
-v verbose output
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
-m method what to show
method is one of ...
method is one of ...
about About... general device infos
cpu CPU usage
cpu CPU usage
load System load
load System load
netio Network IO (experimental)
mem Memory status
netio Network IO
synodisc Synology Disc usage
synotemp Synology NAS temperature
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:
EXAMPLE:
./check_snmp_data -h 192.168.100.12 -v -m cpu
check_snmp_data -h 192.168.100.12 -v -m cpu
```
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment