In some situations you may want a very simple service based on a plugin that just writes random perfdata so that you can test out all following components, such as RRD files, graphs in the GUI, the NPCD service, third party integrations like Nagflux, or something else. This is an easy way to do it:
Create a python script that outputs random data
In this example, we are mimicking the output of check_snmpif_errors, but this can easily be changed in the code. We are generating four random float numbers in a two decimal precision and inserting them into the perfdata string, then printing it.
#!/usr/bin/env python3 import random x = random.random() rand = [] for _ in range (4): rand.append(round(random.uniform(0.00,5.00),2)) str = f"foo | discard_in={rand[-1]};6;8;; discard_out={rand[-2]};6;8;; error_in={rand[-3]};6;8;; error_out={rand[-4]};6;8;;" print(str)
Create a new check command that uses the script and use it
Create a new command named something like check_snmpif_fake that refers to where you saved the file, for example $USER1$/custom/check_snmpif_fake.py
where $USER1$
is the standard shorthand for /opt/plugins
.
Then create a new service that uses this check command, and use "Test this check" to verify that the output is as you expect.
You may want to edit the check_interval for this service to run every minute, rather than the default five.
Optionally use a custom graph template
If you want to try out a specific graph template rather than the default one, you need to map that template to the name of the check command you selected. For example, in templates.dist
you could create a symlink as:
ln -s check_snmpif_errors.php check_snmpif_fake.php
Since check_snmpif_fake.php
now exists, albeit as a symlink to another file, that template will be used for graph generation.
Comments
0 comments
Please sign in to leave a comment.