I have been looking at this for a few days and no luck in finding the issue. Grrr
I have had a working alert template to let me know when printer toner goes below 2% that worked fine when referencing against the “toner” table but now that it has changed to “printer_supplies” I can’t seem to get it to work. Specifically {{ $value['printer_supplies.supply_descr'] }} does not pull the value into the template for the e-mail. I have it surrounded by a @foreach…
For clarity here are the lines where it is not working:
Pretty sure I have the names right… maybe a typo I am not seeing? Or maybe they weren’t exposed to the faults loop? Here is the table I am checking against:
MariaDB [librenms]> select devices.hostname, printer_supplies.supply_descr, printer_supplies.supply_current, printer_supplies.supply_type from devices, printer_supplies WHERE (devices.device_id = printer_supplies.device_id ) AND printer_supplies.supply_type = "tonerCartridge" ;
+----------------+--------------------------------+----------------+----------------+
| hostname | supply_descr | supply_current | supply_type |
+----------------+--------------------------------+----------------+----------------+
...
| 192.168.2.178 | Black Cartridge 81X HP CF281X. | 2 | tonerCartridge |
...
+----------------+--------------------------------+----------------+----------------+
16 rows in set (0.001 sec)
Let me know if you see something I missed - thank you!!
Hi @Tadpole
DB data is not automatically exposed in alerts. To find out what is available, you can use the test scripts for alerts and templates :
librenms@monitoring1:~$ ./scripts/test-alert.php
Info:
Use this to send an actual alert via transports that is currently active.
Usage:
-r Is the Rule ID.
-h Is the device ID or hostname
-d Debug
Example:
./scripts/test-alert.php -r 4 -d -h localhost
and for templates :
librenms@monitoring1:~$ ./scripts/test-template.php
Usage:
-t Is the template ID.
-h Is the device ID or hostname
-r Is the rule ID
-p Is the transport name (optional)
-s Is the alert state <0|1|2|3|4> (optional - defaults to current state.)
0 = ok, 1 = alert, 2 = acknowledged, 3 = got worse, 4 = got better
-d Debug
Example:
./scripts/test-template.php -t 10 -d -h localhost -r 2 -p mail
Thanks @PipoCanaja - I was able to get this working turns out I was putting too much so rather than printer_supplies.supply_descr just supply_desc will suffice. In case anyone is looking for an alert template for reporting printer supplies, here is the entire template. (Caveat: I haven’t been able to get the “Alerts sent to” section to work yet… will post that question later)