The idea of the monitoring-common-shell-library is to have reoccurring code like threshold-evaluation, unit tests, etc. to be shared between plugins.
This reduces the code-lines of a plugin a lot and allows to quick develop a new monitoring-plugin.
Basically, monitoring-common-shell-library relies heavily on Bash 4. Only a few external dependencies are used (see Requirements) which usually are already present on a typical Linux installation.
Some plugins that use the monitoring-common-shell-library:
- https://netshadow.org/monitoring-plugins/check_lm_sensors2
- https://netshadow.org/monitoring-plugins/check_kerberos
- https://netshadow.org/monitoring-plugins/check_icinga2
- https://netshadow.org/monitoring-plugins/check_doveadm_replication
- Bash 4
- getopt (from util-linux)
- mktemp (from GNU core utilities)
- GNU bc
On Debian and its derivatives, you can quickly fulfilling these requirements by:
sudo apt-get install bash util-unix coreutils bc
monitoring-common-shell-library is also available as Debian package (.deb).
Checkout https://apt.netshadow.net to locate the package and download it.
Basically, functions.sh is ready for use, the shipped Makefile in the libraries root-directory is used for developers only.
The easiest way, to include the libraries functionality into your monitoring plugin, is to source functions.sh from your plugin. This can be done by
source functions.sh
or even in a short form
. functions.sh
If you have installed monitoring-common-shell-library as a software package (eg. .deb), functions.sh is usually located in: /usr/share/monitoring-common-shell-library/functions.sh.
To include from there, write:
source /usr/share/monitoring-common-shell-library/functions.sh
Another way to integrate the library into your plugin, is to concatenate the
contents of functions.sh
to your monitoring plugin.
But note: it might be harder to maintain your plugin if you want to update the functions provided by this library. Your plugin will probably remain more slim, portable and efficient if you choose the way "Including it".
See the automatically generated function-reference in ./FUNCREF.md,
that is automatically generated from functions.sh
.
If you want to extend the monitoring-common-shell-library and contribute your changes to this project, please obey ./CODING.md.
The monitoring-common-shell-library has been written along with a test-suite, that tries to lead the provided functions up the garden path.
It might not be that perfect, but at least ensures some code quality level to be retained.
See ./README.md in the tests directory for more information.
All files are licensed by GNU Affero General Public License v3.
See ./LICENSE file for more information.
(c) 2017-2019 Andreas Unterkircher unki@netshadow.net