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
28d87af8
Commit
28d87af8
authored
4 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
snmp_printer: add help and debug param
parent
94103557
Branches
Branches containing commit
No related tags found
1 merge request
!296
Simple task/7546 icinga check für ablaufende gitlab tokens
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_snmp_printer
+92
-33
92 additions, 33 deletions
check_snmp_printer
with
92 additions
and
33 deletions
check_snmp_printer
+
92
−
33
View file @
28d87af8
...
...
@@ -11,24 +11,11 @@
# /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
# 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
# 2025-02-12 <axel.hahn@unibe.ch> v1.0 add help and debug param
# ============================================================
# ------------------------------------------------------------
...
...
@@ -38,6 +25,9 @@
.
$(
dirname
$0
)
/inc_pluginfunctions
.
$(
dirname
$0
)
/check_snmp_includes
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPVERSION
=
1.0
debug
=
0
# check='/usr/lib64/nagios/plugins/check_snmp_printer'
...
...
@@ -45,15 +35,80 @@ debug=0
nagiosDir
=
'/usr/lib64/nagios/plugins'
myscript
=
"check_snmp_printer_v2.0.1"
case
"
$(
ph.getOS
)
"
in
debian
)
nagiosDir
=
'/usr/lib/nagios/plugins'
;;
debian
)
nagiosDir
=
'/usr/lib/nagios/plugins'
;;
esac
#---------------------------------------------------
# --- show usage
function
showHelp
(){
_self
=
$(
basename
$0
)
cat
<<
EOH
$(
ph.showImlHelpHeader
)
This is a wrapper for the check_snmp_printer plugin.
Maybe you want to upgrade it from
<https://github.com/Tylan/check_snmp_printer/tree/master>
The wrapper does
- scan for snmp auth parameters of given host by check_snmp_includes
- adds snmp timeout
- executes check_snmp_printer with given other params
USAGE:
$_self
[-d] [-c SCRIPT] -H SNMPTARGET [other params]
PARAMETERS:
-d, --debug (as 1st param)
Debug mode: shows all generated params.
"-d" or "--debug" will be removed from params for
check_snmp_printer script
-c SCRIPT
Set script to execute with full path
default:
$nagiosDir
/
$myscript
-H HOSTNAME
required: as fqdn or ip address; default: localhost
All other params for check_snmp_printer, eg.
--consum
--messages
--pagecount
--trays
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:
$_self
-H 192.168.100.12 --consum
EOH
}
# ------------------------------------------------------------
# MAIN
# ------------------------------------------------------------
# show help
if
[
"$#"
-eq
0
]
;
then
showHelp
exit
0
fi
if
[
"
$1
"
=
"--debug"
]
||
[
"
$1
"
=
"-d"
]
;
then
debug
=
1
shift
fi
sParams
=
"
$*
"
# find host behind param -H
...
...
@@ -64,29 +119,33 @@ 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
to add snmp auth parameters
test
-z
"
$SNMPAUTH
"
&&
read_config
sParams+
=
"
$SNMPAUTH
"
# find what to show ... it is more for debug message
what
=
$(
echo
$sParams
|
sed
-Ee
's#.*\-\-([a-z]*).*#\1#'
)
case
"
$what
"
in
consum
)
what
=
"Consumables"
;;
messages
)
what
=
"Messages of the printer"
;;
pagecount
)
what
=
"Number of printed pages"
;;
trays
)
what
=
"Status of trays for paper"
sParams
=
"
$sParams
--nofeeder"
;;
consum
)
what
=
"Consumables"
;;
messages
)
what
=
"Messages of the printer"
;;
pagecount
)
what
=
"Number of printed pages"
;;
trays
)
what
=
"Status of trays for paper"
sParams
=
"
$sParams
--nofeeder"
;;
esac
# add our global snmp timeout
sParams+
=
" -t
$SNMPTIMEOUT
"
test
"
$debug
"
=
"1"
&&
(
echo
"
$what
:"
;
echo
calling
$check
$sParams
;
echo
)
$check
$sParams
-t
$SNMPTIMEOUT
$check
$sParams
# ------------------------------------------------------------
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