Monitoring solution for openHAB et al

To provide a bit more details about how I got the Zabbix to see my Synology DSM7 (I’m not running server or web on Synology so this is monitoring only.

  1. On Synology under Control Panel → Terminal & SNMP → SNMP

  2. I never could get it to work with SNMP 3 so I ended up configuring it to use v2. I’ll probably go back and try again someday.

  1. On Zabbix go to Configuration → Hosts → Create Host. Fill out the relevant info for the host.

  2. Add an SNMP interface and populate as follows (using your hostnames/IP addresses.

  1. Now click on “Macros” and add the SNMP_COMMUNITY variable we used above, making it match the community name you configured on the Synology in step 2.

I can’t remember if I had to wait awhile before the data started to flow.

1 Like

To add to the conversation…

I never looked into much details about how you can generate graphs with openHAB, but since I already had a Zabbix instance before using openHAB, I thought I could link the two together.

If you guys are interested I have a script that reads values from MQTT and transfer them back to Zabbix. So I can use all the cool graph stuff from Zabbix.

Although I suspect OH 3 is better at that now, I didn’t find a quick way to generate nice graph with OH 2.4 back in the days :stuck_out_tongue:

Edit: oh I just noticed MQTT is now supported natively since 6.0 LTS. That’s my script being useless I guess :laughing:

within OH3, you can do this either “on the fly” with just a click in the “items”-Section or you simply click some charts on a “page” - just like in zabbix.
e.g. here within the “items”:

1 Like

I have described my monitoring setup here:

1 Like

Please post the instructions. I would like to see how you did it.

Thanks

I just updated these instructions for OH3 and have not tested it yet but it should be good. I’m heading out of town for a week and I didn’t want to wait until I was back to post. Note that if you change the blockly script the email command inside of it goes away so you need to reinsert it. It’s this part:

        var Actions = Java.type("org.openhab.core.model.script.actions.Things");

        var mailActions = Actions.getActions("mail","mail:smtp:SMTP_Server");

        mailActions.sendHtmlMail("email@youremail.com", "Alert – openHAB System Offline", "An openHAB system has gone offline. Please check Tailscale to identify offline system.");

Also, you’ll need to change the name “SMTP_Server” to whatever the ID of your SMTP server is. The rule:


Alert – OH System Down

This rule will send an email if an openHAB system is offline for more than 3 hours.

Required: Tailscale installed on system to be monitored, another OH system to monitor IP addresses with Network Binding and Mail Binding installed, and a group (Item) for the OH systems you want to monitor with the aggregation function set to “All ON then ON else OFF”.

Settings > Things > + > Network Binding > Pingable Network Device > ID = Ping_Customername# > Label = Ping – Customername# > Hostname or IP = ip from Tailscale (without :8080) > Refresh Interval = 300000 > Retry = 6 > Create Thing

Settings > Things > Thing just created > Channels > Online (switch) > Add Link To Item > Create a new Item > Name = Ping_Customername# > Label = Ping – Customername# > Parent Group = OH Systems > Close > Link > Save

Rules > New Rule > ID = Alert_System_Offline > Name = Alert – System Offline

Code > Replace existing code with code below:


configuration: {}
triggers:
  - id: "1"
    configuration:
      groupName: OH_Systems
    type: core.GroupStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
        type="oh_log" id="3ntY/cqP4OEGlO7ekWty" x="-2016" y="20"><field
        name="severity">info</field><value name="message"><shadow type="text"
        id="@OcaG9FOaYg;%cr@X4`X"><field name="TEXT">OH System Offline Rule
        Started</field></shadow></value><next><block type="controls_if"
        id="4@U|GA#I9vjU{n3s.~8R"><mutation elseif="1"></mutation><value
        name="IF0"><block type="logic_compare" id="R{MRikkH@)iW/;AFZj[;"><field
        name="OP">EQ</field><value name="A"><block type="oh_getitem_state"
        id="G)zY2,`/ZYvEBN]~{%rM"><value name="itemName"><shadow type="oh_item"
        id="GaA70K1x29}AXBTTI{-{"><field
        name="itemName">OH_Systems</field></shadow></value></block></value><value
        name="B"><block type="text" id="H=Fzh6lL;=|~mCoqAwBd"><field
        name="TEXT">OFF</field></block></value></block></value><statement
        name="DO0"><block type="oh_timer" id="NdTJ2fW$1~t6gvsjW|mp"><field
        name="delayUnits">plusHours</field><value name="delay"><shadow
        type="math_number" id="otI%iP,VT#I=+[%M8=$v"><field
        name="NUM">3</field></shadow></value><value name="timerName"><shadow
        type="text" id="hry6.e7COO#4Yrlw%PNr"><field name="TEXT">OH System
        Offline Timer</field></shadow></value><statement name="timerCode"><block
        type="oh_log" id="{k@Er3wG8e6$n.*+A_g["><field
        name="severity">info</field><value name="message"><shadow type="text"
        id="C`ZX6$9jB.8rJ+#GpmIk"><field name="TEXT">Email Sent - OH System
        Offline</field></shadow></value></block></statement></block></statement><value
        name="IF1"><block type="logic_compare" id="`0xmVOp9Yi!jHAVTY~nr"><field
        name="OP">EQ</field><value name="A"><block type="oh_getitem_state"
        id="gn_P~zcF0r4[%lu*XxNO"><value name="itemName"><shadow type="oh_item"
        id="rB6;`FJ6$r67tZ2u0Y|0"><field
        name="itemName">OH_Systems</field></shadow></value></block></value><value
        name="B"><block type="text" id="Vv,,Sxe#prf8)FVHzium"><field
        name="TEXT">ON</field></block></value></block></value><statement
        name="DO1"><block type="oh_timer_cancel"
        id="o(tjF3t^a{zsOe8!gwom"><value name="timerName"><shadow type="text"
        id="N?I[ze3evs@))+@xy@h{"><field name="TEXT">OH System Offline
        Timer</field></shadow></value></block></statement></block></next></block></xml>
      type: application/javascript
      script: >
        var logger =
        Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' +
        ctx.ruleUID);


        var scriptExecution = Java.type('org.openhab.core.model.script.actions.ScriptExecution');


        var zdt = Java.type('java.time.ZonedDateTime');


        if (typeof this.timers === 'undefined') {
          this.timers = [];
        }



        logger.info('OH System Offline Rule Started');

        var Actions = Java.type("org.openhab.core.model.script.actions.Things");

        var mailActions = Actions.getActions("mail","mail:smtp:SMTP_Server");

        mailActions.sendHtmlMail("email@youremail.com", "Alert – openHAB System Offline", "An openHAB system has gone offline. Please check Tailscale to identify offline system.");

        if (itemRegistry.getItem('OH_Systems').getState() == 'OFF') {
          if (typeof this.timers['OH System Offline Timer'] === 'undefined' || this.timers['OH System Offline Timer'].hasTerminated()) {
            this.timers['OH System Offline Timer'] = scriptExecution.createTimer(zdt.now().plusHours(3), function () {
              logger.info('Email Sent - OH System Offline');
              })
          }
        } else if (itemRegistry.getItem('OH_Systems').getState() == 'ON') {
          if (typeof this.timers['OH System Offline Timer'] !== 'undefined') {
            this.timers['OH System Offline Timer'].cancel();
            this.timers['OH System Offline Timer'] = undefined;
          }
        }
    type: script.ScriptAction

Save > Save