0x00 Overview

There is already a ICMP Ping plugin for Domoticz that you can find in their Forum.
But that has it's own issues. ICMP Ping requiers RAW Sockets and they requiere root access.
Domoticz does not need to run as root by default, and I prefer having it run with a limited user.
But then, the ICMP Ping plugins fails.
The most simple workaround? Ping from external script and push the values to Domoticz!

Ping Graph

0x01 Setup

As expected we need to start with creating a dummy devices for all target we want to ping.
I decided to setup 3 targets:

But you probably will switch (at lesat the third one).

0x02 The script

When I said the script we will need will be simple, this is what I ment:



while true; do
    val=`ping -c 3 -q | tail --lines 1 | tr "/" " " | awk '{print $8}'`
    curl "${domo_url}/json.htm?type=command&param=udevice&idx=37&nvalue=0&svalue=${val}"

    val=`ping -c 3 -q | tail --lines 1 | tr "/" " " | awk '{print $8}'`
    curl "${domo_url}/json.htm?type=command&param=udevice&idx=38&nvalue=0&svalue=${val}"

    val=`ping -c 3 -q cooolbox.bg | tail --lines 1 | tr "/" " " | awk '{print $8}'`
    curl "${domo_url}/json.htm?type=command&param=udevice&idx=39&nvalue=0&svalue=${val}"

    sleep 300

As I already explain in Domoticz APC#Run Script.
But the short story it - I run this from the init by adding this line
q2:3:respawn:/opt/domoticz/scripts/ping_check.sh in /etc/inittab.

0x03 End result

Ping Small

Ping Graph