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

Merge branch 'simple-task/7546-icinga-check-für-ablaufende-gitlab-tokens' into 'master'

Simple task/7546 icinga check für ablaufende gitlab tokens

See merge request !296
parents e7819641 0fecb6de
No related branches found
No related tags found
1 merge request!296Simple task/7546 icinga check für ablaufende gitlab tokens
......@@ -70,6 +70,7 @@
# 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
# 2025-02-12 v1.0 <axel.hahn@unibe.ch> add IML header in help
# ======================================================================
. $(dirname $0)/inc_pluginfunctions
......@@ -77,7 +78,7 @@
# --- basic vars
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
self_APPVERSION=0.8
self_APPVERSION=1.0
METHOD=""
......@@ -160,18 +161,11 @@ function showHelp(){
do
METHOD=$(echo "$line" | cut -f 2 -d ":")
descr=$(_cfg_getlabel)
printf " %-10s %-50s\n" "$METHOD" "$descr"
printf " %-10s %-50s\n" "$METHOD" "$descr"
done
)
cat <<EOH
______________________________________________________________________
$self_APPNAME
v$self_APPVERSION
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
$( ph.showImlHelpHeader )
SNMP performance data of Synology storages.
......@@ -187,10 +181,10 @@ PARAMETERS:
-f FILE
read authentication from config file
default: "/etc/icinga2/snmp.cfg"
-m method what to show
method is one of ...
-m METHOD
what to show; METHOD is one of ...
$_methods
-v verbose output
-v verbose output
CONFIG FILE:
The config file can be multiline and has the syntax
......
#!/bin/sh
# ======================================================================
#
# Include file for SNMP related checks
# Used by
# - check_snmp_data
# - check_snmp_printer
# - check_snmp_synology
#
# ======================================================================
# ----------------------------------------------------------------------
# Variables
......
......@@ -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
# ------------------------------------------------------------
......@@ -5,6 +5,7 @@
# 03.05.2023 v1.2 Axel Hahn: support Snmpv3 connections
# 09.05.2023 v1.3 Axel Hahn: allow complete check or single check(s)
# 12.05.2023 v1.4 Axel Hahn: no raid size check (DSM 5.x)
# 12.02.2025 v1.5 Axel Hahn: update header in help with link to online help
# ----------------------------------------------------------------------
# this plugin check the health of your Synology NAS
# - System status (Power, Fans)
......@@ -24,7 +25,7 @@
# --- basic vars
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
self_APPVERSION=1.4
self_APPVERSION=1.5
SNMPOUTPUT=
option_found=0
......@@ -72,19 +73,10 @@ FLAG_UPDATE=1
FLAG_TEMPERATURE=1
_self=$( basename $0 )
USAGE="
______________________________________________________________________
$self_APPNAME
v$self_APPVERSION
Based on script of Nicolas Ordonez.
Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
USAGE="$( ph.showImlHelpHeader )
Check health of a Synology drive using SNMP.
Based on script of Nicolas Ordonez.
SYNTAX:
$_self [options] -h TARGET
......
......@@ -8,16 +8,18 @@
* [check_ceph_status](check_ceph_status.md)
* [check_clientbackup](check_clientbackup.md)
* [check_couchdb](check_couchdb.md)
* check_couchdb-lb
* [check_conn](check_conn.md)
* [check_cpu](check_cpu.md)
* [check_cronstatus](check_cronstatus.md)
* [check_disk-io](check_disk-io.md)
* [check_dns_responsetime](check_dns_responsetime.md)
* [check_docker_info](check_docker_info.md)
* [check_docker_io](check_docker_io.md)
* [check_docker_stats](check_docker_stats.md)
* [check_dockercontainer_top](check_dockercontainer_top.md)
* [check_eol](check_eol.md)
* [check_fs_errors](check_fs_errors.md)
* [check_file_age](check_file_age.md)
* [check_fs_writable](check_fs_writable.md)
* [check_gitlab_tokens](check_gitlab_tokens.md)
* [check_haproxy_health](check_haproxy_health.md)
......@@ -43,8 +45,7 @@
* [check_requirements](check_requirements.md)
* [check_smartstatus](check_smartstatus.md)
* [check_snmp_data](check_snmp_data.md)
* check_snmp_printer
* check_snmp_switch
* [check_snmp_printer](check_snmp_printer.md)
* [check_snmp_synology](check_snmp_synology.md)
* check_ssl
* [check_ssl_certs](check_ssl_certs.md)
......
......@@ -25,11 +25,13 @@ Start the script without parameter to get the help.
```txt
______________________________________________________________________
CHECK_SNMP_DATA
v0.8
CHECK_SNMP_DATA
v1.0
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_snmp_data.html
______________________________________________________________________
SNMP performance data of Synology storages.
......@@ -46,17 +48,17 @@ PARAMETERS:
-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
mem Memory status
netio Network IO
synodisc Synology Disc usage
synotemp Synology NAS temperature
synoio Synology Space IO
-v verbose output
-m METHOD
what to show; METHOD is one of ...
about About... general device infos
cpu CPU usage
load System load
mem Memory status
netio Network IO
synodisc Synology Disc usage
synotemp Synology NAS temperature
synoio Synology Space IO
-v verbose output
CONFIG FILE:
The config file can be multiline and has the syntax
......@@ -69,7 +71,6 @@ CONFIG FILE:
EXAMPLE:
check_snmp_data -h 192.168.100.12 -v -m cpu
```
## Examples
......
## Check SNMP printer
Script: `check_snmp_printer`
**check_snmp_printer** is a wrapper for Nagios plugin check_snmp_printer. Its main task is to fetch SNMP authentication parameters from a config file and then call the Nagios check.
## Requirements
* snmpget
* snmpwalk
* check_snmp_printer or an update of it eg. <https://github.com/Tylan/check_snmp_printer/tree/master>
## Standalone installation
From this repository ypu need next to this script:
* `inc_pluginfunctions` shared function for all IML checks written in bash
* `check_snmp_includes` with a shared snmp config reader
## Syntax
Start the script without parameter to get the help.
```txt
______________________________________________________________________
CHECK_SNMP_PRINTER
v1.0
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_snmp_printer.html
______________________________________________________________________
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:
check_snmp_printer [-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: /usr/lib64/nagios/plugins/check_snmp_printer_v2.0.1
-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:
check_snmp_printer -H 192.168.100.12 --consum
```
## Examples
### Messages of the printer
`./check_snmp_data -H 192.168.100.12 --messages`
### Consumables
`./check_snmp_data -H 192.168.100.12 --consum`
### Number of pages printed
`./check_snmp_data -H 192.168.100.12 --pagecount`
### Status of trays for paper
`./check_snmp_data -H 192.168.100.12 --trays`
Remark: when using --trays the param `--nofeeder` will be inserted too.
......@@ -23,16 +23,17 @@ Start the script without parameter to get the help.
```txt
______________________________________________________________________
CHECK_SNMP_SYNOLOGY
v1.4
CHECK_SNMP_SYNOLOGY
v1.5
Based on script of Nicolas Ordonez.
Institute for Medical Education - University of Bern
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_snmp_synology.html
______________________________________________________________________
Check health of a Synology drive using SNMP.
Based on script of Nicolas Ordonez.
SYNTAX:
check_snmp_synology [options] -h TARGET
......
#!/bin/bash
tmpfile=/tmp/tmp_myfile_$USER__$$
cd "$( dirname "$0" )"
for f in *.md; do
if head "$f" | grep -q "^# "; then
echo
echo ">>>>> FIX $f"
echo
cp -p "$f" "$tmpfile"
if grep -q "^## Introduction" "$f"; then
echo "Replace '## Introduction'"
sed -i -e "s/^## Introduction.*//" "$tmpfile"
head -1 "$f" | tail -1 | grep "." && sed -i -e '2,3d' "$tmpfile"
# make 1st h1 smaller
sed -i -e "0,/^# /{s/^# /## /}" "$tmpfile"
else
echo "Move Headers"
if grep "^###### " "$f"; then
echo "ABORT: H6 was found that cannot moved to smaller level."
exit 1
fi
for header in "#####" "####" "###" "##" "#"
do
sed -i -e "s/^$header /#$header /g" "$tmpfile"
done
fi
diff -u --color "$f" "$tmpfile"
echo
read -p "Apply changes on '$f' [Y/n]? > " apply
if [ "$apply" = "" ] || [ "$apply" = "y" ]|| [ "$apply" = "Y" ]; then
echo "Applying ..."
mv "$tmpfile" "$f"
else
echo "Keeping current version."
rm "$tmpfile"
fi
sleep 1
echo
echo
echo
echo
echo
echo
echo ----------------------------------------------------------------------
else
echo "OK $f"
fi
done
\ No newline at end of file
#!/bin/bash
tmpfile=/tmp/tmp_myfile_$USER__$$
cd "$( dirname "$0" )"
for f in check*.md; do
if ! head "$f" | grep -q "^Script: \`"; then
myscript="${f//.md/}"
echo
echo ">>>>> FIX $f"
echo
sed -n "1,2p" "$f" > "$tmpfile"
echo "Script: \`${myscript}\`" >> "$tmpfile"
echo >> "$tmpfile"
sed -n "3,\$p" "$f" >> "$tmpfile"
if ! diff -u --color "$f" "$tmpfile"; then
echo
read -p "Apply changes on '$f' [Y/n]? > " apply
if [ "$apply" = "" ] || [ "$apply" = "y" ]|| [ "$apply" = "Y" ]; then
echo "Applying ..."
mv "$tmpfile" "$f"
else
echo "Keeping current version."
rm "$tmpfile"
fi
sleep 1
echo
echo
echo
echo
echo
echo
echo ----------------------------------------------------------------------
fi
else
echo "OK $f"
fi
done
\ No newline at end of file
#!/bin/bash
cd "$( dirname "$0" )" || exit
typeset -i iTotal
typeset -i iErr
typeset -i iWarn
# ----------------------------------------------------------------------
# FUNCTIONS
# ----------------------------------------------------------------------
function getChecks(){
grep "inc_pluginfunctions" * 2>/dev/null | cut -f 1 -d ":" | grep -vE "^(zz_|inc)"
}
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
iTotal=$( getChecks | wc -l )
echo
echo "CHECK IML CHECKS - $( date )"
echo
for check in $( getChecks )
do
if ./$check -h 2>/dev/null| grep -q "https://os-docs.iml.unibe.ch"; then
# echo "✅ OK $check"
url=$( ./$check -h | grep "https://os-docs.iml.unibe.ch" )
if curl -sI $url | grep -q "200 OK"; then
echo "✅ OK : $check"
else
echo "⚠️ WARN : $check - $url"
iWarn+=1
fi
else
echo "❌ ERROR: $check"
iErr+=1
# ./$check -h
fi
done
echo
echo "---- Total : $iTotal"
echo " Errors : $iErr checks with wrong help"
echo " Warnings : $iWarn checks with wrong url"
echo
# ----------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment