Can I trigger/create my own notifications?
-
Trying to find info if I can trigger a notification by myself/by my config.
I've set up Pushover and it works. But I would like to configure my own, fine grained notifications. (Can't find this in docs or here in the forum - at least not succeeded finding this)Two examples:
- I would like notifications sent when a named Alias is updated
- I would also like notifications sent when X happens... (perhaps by filtering some string in a log)
Thanks in advance for feedback :-)
-
Did you saw this https://forum.netgate.com/topic/137707/auto-update-check-checks-for-updates-to-base-system-packages-and-sends-email-alerts/16?_=1640877410356
Get the script, edit it.
Like this - remove a lot of lines :<?php require_once("pkg-utils.inc"); require_once("notices.inc"); require_once("util.inc"); if (!empty($msg)) { log_error("Updates were found - sending email"); notify_via_pushover($msg); } ?>
add one line :
$msg = "Hello there !"
Like this :
<?php
require_once("pkg-utils.inc");
require_once("notices.inc");
require_once("util.inc");$msg = "Hello there !"
if (!empty($msg)) {
log_error("Updates were found - sending email");
notify_via_pushover($msg);
}?>
Save the with a filename and 'php' extension.
Now go for it :
php - q yourfilename.php
You should receive something over pushover (dono what that is actually - so I could test myself).
Remember : PHP is what Basic was at the end of the last century : you can do what you want.
-
@gertjan Nope - missed that one. But great tip, thanks for the details as well
-
Worked :-) Two small typos (?) but excellent tip - thank you very much!
<?php require_once("pkg-utils.inc"); require_once("notices.inc"); require_once("util.inc"); # Added ';' to the end of line $msg = "Great tip from Gertjan!"; if (!empty($msg)) { notify_via_pushover($msg); } # When executed, removed space -> '-q': # php -q /root/pushover_test.php ?>