OP5 Monitor notifications by RSS

If you are using OP5 Monitor free version for personal/non-production/lab use you will find that notifications by e-mail or SMS is a bit overkill and annoying.
So I created this simple RSS function that consists of a notification script that is called from a check commmand that writes the notification to a text file on the op5-monitor server, and a custom PHP-script that reads the same text file and presents it in RSS format.
This way I can add https://op5monitor.mydomain.com/rss.php?channel=contactname in a RSS browser and receive alerts that way instead.

NOTE: In OP5 Monitor 7+ it looks like you should use: /opt/monitor/op5/notify/custom instead of /opt/plugins/custom , I had trouble with this after upgrading.

# Comma is csv seperator so replace it with dot if found in output
OUTPUT=$(echo $5 | sed 's/,/./g')
UUID=$(cat /proc/sys/kernel/random/uuid)

Change the check command host-notify to the below (or create a new one)


Change the check command service-notify to the below (or create a new one)


Create the file /var/www/html/rss.php with the below content (note that “channel” is the same as contact)
Modify text, domain, etc as needed. Add your contacts/channels at the end.

$channel = $_GET['channel'];
if ($channel != "") {
          $monitoringfile = "/opt/monitor/var/notifications-$channel.csv";
          header("Content-Type: application/xml; charset=ISO-8859-1");
          $item = $_GET['item'];
          echo "
<rss version=\"2.0\">
    <title>OP5 Monitor - $channel alerts</title>
    <description>A list of monitoring alerts</description>
         $file = file($monitoringfile);
         $file = array_reverse($file);
         foreach($file as $line){
            $displayItem = false;
            if (strlen($line) > 5) {
              if (strlen($item) > 0) {
                if(strpos($line, $item) !== false) {
                  $displayItem = true;
              } else {
                $displayItem = true;
              if ($displayItem) {
                $datetime=date('D, d M Y H:i:s +0000', $columns[1]);
                if (strpos($columns[3], "|") > 0) {
                  $desc=split("\|", $columns[3]);
                } else {
                echo "
      <guid isPermaLink=\"false\">$columns[0]</guid>
      <author>OP5 Monitor</author>
           if ($counter > 100) break;
          echo "
} else {
       echo "
<TITLE>op5monitor.mydomain.com RSS Alerts</TITLE>
<h1>Choose channel</h1>
  <li><a href=\"rss.php?channel=monitor\">All alerts</a></li>
  <li><a href=\"rss.php?channel=lab\">Lab alerts</a></li>

And add this if you feel its needed.

echo >/opt/monitor/var/notifications-lab.csv
echo >/opt/monitor/var/notifications-monitor.csv

Leave a Reply

Your email address will not be published. Required fields are marked *