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
6e7b34be
Commit
6e7b34be
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
parameter for custom script; detect debian
parent
8635b0bb
No related branches found
No related tags found
1 merge request
!184
parameter for custom script; detect debian
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_snmp_printer
+42
-5
42 additions, 5 deletions
check_snmp_printer
with
42 additions
and
5 deletions
check_snmp_printer
+
42
−
5
View file @
6e7b34be
...
@@ -3,21 +3,52 @@
...
@@ -3,21 +3,52 @@
#
#
# Wrapper for check_snmp_printer plugin
# Wrapper for check_snmp_printer plugin
#
#
# The reason behind this wrapper is detecting the snmp auth
# parameters by check_dnmp_includes which needs a snmp target
# to find its custom config.
#
# All given params will be sent to
# /usr/lib64/nagios/plugins/check_snmp_printer_v2.0.1
# except "-c <script>"
#
# TODO: IML like help
#
# USAGE
# check_snmp_printer -H <host|ip> --<what>
# check_snmp_printer -H <host|ip> -c <script> --<what>
#
# <host>|<ip> target to connect
# <what> what information will be shown
# --consum
# --messages
# --pagecount
# --trays
# <script> script to execute with full path
#
# ------------------------------------------------------------
# ------------------------------------------------------------
# 2021-03-22 <axel.hahn@iml.unibe.ch> v0.1
# 2021-03-22 <axel.hahn@iml.unibe.ch> v0.1
# 2023-09-18 <axel.hahn@iml.unibe.ch> v0.2 snmpv3 support
# 2023-09-18 <axel.hahn@iml.unibe.ch> v0.2 snmpv3 support
# 2023-10-12 <axel.hahn@iml.unibe.ch> v0.3 parameter for custom script; detect debian
# ============================================================
# ============================================================
# ------------------------------------------------------------
# ------------------------------------------------------------
# CONFIG
# CONFIG
# ------------------------------------------------------------
# ------------------------------------------------------------
.
$(
dirname
$0
)
/check_snmp_includes
.
$(
dirname
$0
)
/inc_pluginfunctions
.
$(
dirname
$0
)
/check_snmp_includes
debug
=
0
# check='/usr/lib64/nagios/plugins/check_snmp_printer'
# check='/usr/lib64/nagios/plugins/check_snmp_printer'
# updated script is taken from https://github.com/Tylan/check_snmp_printer/tree/master
# updated script is taken from https://github.com/Tylan/check_snmp_printer/tree/master
check
=
'/usr/lib64/nagios/plugins/check_snmp_printer_v2.0.1'
nagiosDir
=
'/usr/lib64/nagios/plugins'
debug
=
0
myscript
=
"check_snmp_printer_v2.0.1"
case
"
$(
ph.getOS
)
"
in
debian
)
nagiosDir
=
'/usr/lib/nagios/plugins'
;;
esac
# ------------------------------------------------------------
# ------------------------------------------------------------
# MAIN
# MAIN
...
@@ -25,10 +56,14 @@ debug=0
...
@@ -25,10 +56,14 @@ debug=0
sParams
=
"
$*
"
sParams
=
"
$*
"
# find host behind param -H
# find host behind param -H
SNMPTARGET
=
$(
echo
$sParams
|
sed
-Ee
's#.*\-H\ ([0-9a-z\.\-]*).*#\1#'
)
SNMPTARGET
=
$(
echo
$sParams
|
sed
-Ee
's#.*\-H\ ([0-9a-z\.\-]*).*#\1#'
)
# detect -c <script>
check
=
$(
echo
$sParams
|
sed
-Ee
's#.*\-c\ ([0-9a-z\.\-_/]*).*#\1#'
)
test
"
$check
"
=
"
$sParams
"
&&
check
=
"
${
nagiosDir
}
/
${
myscript
}
"
test
"
$check
"
=
"
$sParams
"
||
sParams
=
$(
echo
$sParams
|
sed
-Ee
's#\-c\ ([0-9a-z\.\-_/]*)##'
)
# find SNMPTARGET in config
# find SNMPTARGET in config
test
-z
"
$SNMPAUTH
"
&&
read_config
test
-z
"
$SNMPAUTH
"
&&
read_config
sParams+
=
"
$SNMPAUTH
"
sParams+
=
"
$SNMPAUTH
"
...
@@ -52,4 +87,6 @@ case "$what" in
...
@@ -52,4 +87,6 @@ case "$what" in
esac
esac
test
"
$debug
"
=
"1"
&&
(
echo
"
$what
:"
;
echo
calling
$check
$sParams
;
echo
)
test
"
$debug
"
=
"1"
&&
(
echo
"
$what
:"
;
echo
calling
$check
$sParams
;
echo
)
$check
$sParams
$check
$sParams
-t
$SNMPTIMEOUT
# ------------------------------------------------------------
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