I'm completely new to scripting, but willing to learn!
I want to know how should I approach the following:
- read out values from monit xml or json output so I can see status of monit monitored applications/processes.
- monit runs on a remoet/sperate Rpi n the same network
- domoticz runs on my Synology NAS, with dashticz to get some nice overviews.
I mainly want to have a visual of the status of the remote Rpi.
Maybe someone allready build a plugin like this, I searched for that but could not find it, the one thing found was a discontinued plugin (PiMonitor), anda plugin which I cannot get to work (Pi RemoteMonitor) as I cannot get 'python3-lxml' working on my NAS.
Or someone can point me to some examples doing the same for other json/xml information collecting.
Is python the correct language to get this working, or should I better foccus on a lua script or dventz?
It looks like the json output
Example of output in json and xml below:
json:
Code: Select all
Monit 5.25.2 uptime: 2d 8h 18m
[1;36mRemote Host 'pihole-FTL'[0m
status [0;92mOK[0m
monitoring status Monitored
monitoring mode active
on reboot start
port response time [0;39m0.882 ms to 127.0.0.1:4711 type TCP/IP protocol DEFAULT[0m
data collected [0;39mSun, 24 Jan 2021 21:15:47[0m
[1;36mRemote Host 'dnsmasq'[0m
status [0;92mOK[0m
monitoring status Monitored
monitoring mode active
on reboot start
port response time [0;39m1.202 s to 127.0.0.1:53 type UDP/IP protocol DEFAULT[0m
data collected [0;39mSun, 24 Jan 2021 21:15:49[0m
[1;36mRemote Host 'lighttpd'[0m
status [0;92mOK[0m
monitoring status Monitored
monitoring mode active
on reboot start
port response time [0;39m0.456 ms to 127.0.0.1:80 type TCP/IP protocol DEFAULT[0m
data collected [0;39mSun, 24 Jan 2021 21:15:49[0m
[1;36mSystem 'raspberrypi'[0m
status [0;92mOK[0m
monitoring status Monitored
monitoring mode active
on reboot start
load average [0;39m[0.00] [0.00] [0.00][0m
cpu [0;39m0.1%us 0.1%sy 0.1%wa[0m
memory usage [0;39m79.7 MB [8.6%][0m
swap usage [0;39m0 B [0.0%][0m
uptime [0;39m2d 9h 41m[0m
boot time [0;39mFri, 22 Jan 2021 11:35:24[0m
data collected [0;39mSun, 24 Jan 2021 21:15:49[0m
Code: Select all
<monit>
<server>
<id>4d3b3997da6a796e039e2916323e5b78</id>
<incarnation>1611315337</incarnation>
<version>5.25.2</version>
<uptime>238280</uptime>
<poll>300</poll>
<startdelay>300</startdelay>
<localhostname>raspberrypi</localhostname>
<controlfile>/etc/monit/monitrc</controlfile>
<httpd>
<address>192.168.1.50</address>
<port>2812</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.19.75-v7+</release>
<version>#1270 SMP Tue Sep 24 18:45:11 BST 2019</version>
<machine>armv7l</machine>
<cpu>4</cpu>
<memory>948304</memory>
<swap>102396</swap>
</platform>
<service type="4">
<name>pihole-FTL</name>
<collected_sec>1611558493</collected_sec>
<collected_usec>754043</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<onreboot>0</onreboot>
<pendingaction>0</pendingaction>
<port>
<hostname>127.0.0.1</hostname>
<portnumber>4711</portnumber>
<request></request>
<protocol>DEFAULT</protocol>
<type>TCP</type>
<responsetime>0.000800</responsetime>
</port>
</service>
<service type="4">
<name>dnsmasq</name>
<collected_sec>1611558494</collected_sec>
<collected_usec>955541</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<onreboot>0</onreboot>
<pendingaction>0</pendingaction>
<port>
<hostname>127.0.0.1</hostname>
<portnumber>53</portnumber>
<request></request>
<protocol>DEFAULT</protocol>
<type>UDP</type>
<responsetime>1.201442</responsetime>
</port>
</service>
<service type="4">
<name>lighttpd</name>
<collected_sec>1611558494</collected_sec>
<collected_usec>956003</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<onreboot>0</onreboot>
<pendingaction>0</pendingaction>
<port>
<hostname>127.0.0.1</hostname>
<portnumber>80</portnumber>
<request></request>
<protocol>DEFAULT</protocol>
<type>TCP</type>
<responsetime>0.000415</responsetime>
</port>
</service>
<service type="5">
<name>raspberrypi</name>
<collected_sec>1611558494</collected_sec>
<collected_usec>956006</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<onreboot>0</onreboot>
<pendingaction>0</pendingaction>
<system>
<load>
<avg01>0.00</avg01>
<avg05>0.00</avg05>
<avg15>0.00</avg15>
</load>
<cpu>
<user>0.1</user>
<system>0.1</system>
<wait>0.1</wait>
</cpu>
<memory>
<percent>8.7</percent>
<kilobyte>82664</kilobyte>
</memory>
<swap>
<percent>0.0</percent>
<kilobyte>0</kilobyte>
</swap>
</system>
</service>
</monit>