Monitoring ZM state

Forum for questions and support relating to the 1.30.x releases only.
Post Reply
stevewrightnz1
Posts: 48
Joined: Mon Jun 08, 2015 9:57 am
Location: New Zealand
Contact:

Monitoring ZM state

Post by stevewrightnz1 » Tue Nov 01, 2016 10:03 pm

Hi guy's

I want to be able to monitor the status of ZM to ensure that it up as much as possible.

My thoughts are along the lines of a python of perl script triggered by cron say every 15-30 minutes that sends an email if I get a "Stopped" status.

Is there a map somewhere of where variables are stored in the sql database of choice?

I'm think I'm possibly looking to test the "Running" part of this "ZoneMinder Console - Running - default v1.30.0" on the ZM console page which I assume is pulled from somewhere in the MySQL database when the page is generated?

Any Ideas??

Steve

gert
Posts: 14
Joined: Fri Jul 01, 2016 12:43 am

Re: Monitoring ZM state

Post by gert » Tue Nov 01, 2016 10:50 pm

If you're running on the machine with zoneminder, you can just use `sudo service zoneminder status`. I'm looking into this myself, and would also monitor mysql, as in my case, that has been the source of my downtime. Having not messed with cron jobs, I tend to default to creating upstart jobs.

Relevant notes:
Return code of `sudo service XXXX status`:
mysql stopped: 0
mysql running: 0
zoneminder stopped: 1
zoneminder running: 0

Output of `sudo service XXXX status`:
mysql stopped: mysql stop/waiting
mysql running: mysql start/running, process #####
zoneminder stopped: ZoneMinder is stopped
zoneminder running: ZoneMinder is running

User avatar
knight-of-ni
Posts: 2327
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Monitoring ZM state

Post by knight-of-ni » Tue Nov 01, 2016 11:40 pm

Why roll your own solution when you can use a health monitoring solution, like Zabbix? It can get send emails and can log just about anything for you.

If you are running a recent distro (i.e. have systemd) and simply want to restart zoneminder if it stops (and you don't want to figure out why it stopped in the first place), then just put "Restart=Always" into your zoneminder service file, then issue a daemon-reload.

Also note that, if you have a "Requires" statement in your service file, systemd will stop zoneminder if mysql or http stop for any reason.... so the cause of zoneminder stopping might be due one of those other services.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/

Tantamount
Posts: 71
Joined: Wed Feb 03, 2016 7:51 am

Re: Monitoring ZM state

Post by Tantamount » Wed Nov 02, 2016 12:02 am

Some quick ways to check the health:

look at "ps" output and check to see if zmc processes exist. No zmc == no working monitors.

Query the "Logs" table for recent entries. It's fairly noisy and contains timestamps, so should have recent timestamps. Can't query table? mysql trouble. Timestamps too old? trouble. Lots of recent entries with "ERR" code? Could be trouble.
2 LaView LV-PB932F4
4 ReoLink RLC-411
CentOS 7.4 - 8 Core Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz, 16 Gigs ram (Running under XenServer as a VM)
ZoneMinder Version : 1.31.1 Release : 1.320.20180206gitga177d8e9.el7.centos

stevewrightnz1
Posts: 48
Joined: Mon Jun 08, 2015 9:57 am
Location: New Zealand
Contact:

Re: Monitoring ZM state

Post by stevewrightnz1 » Sat Nov 05, 2016 3:08 am

Looks like monitoring the Logs table might work for what I want. Judging by the entries it looks like a ton of stuff gets written to the MySQL table so I'm guessing that if nothing is written for say 5 minutes (300 seconds) then something is probably awry? Really just looking for an email telling me to have a look.

Will write a small perl script and run a cron job every 30 minutes to see what happens.

Steve

c128
Posts: 63
Joined: Sat Sep 14, 2013 3:36 pm

Re: Monitoring ZM state

Post by c128 » Sat Nov 05, 2016 11:16 pm

You *could* roll something yourself, or you could just make use of the free offering from Datadog: https://www.datadoghq.com/pricing/

The no cost option with them will cover 5 hosts, and if you install the Datadog agent on your Zoneminder box you can trigger email alerts based on whatever you want (as well as see past metrics history for memory usage, CPU usage etc. on your box).

I use Datadog at work for monitoring AWS services, but it works great (for free) for monitoring a handful of home servers - been using it recently to understand some Zoneminder-related CPU issues, and have an email monitor setup based on a CPU metric from the agent. Uptime can be dealt with in a similar way:

http://docs.datadoghq.com/integrations/process/
https://www.datadoghq.com/blog/introduc ... onitoring/

Most of the other (mostly cloud) monitoring services have a similar free offering (New Relic, etc.) - unless you're running on ARM, then their agents install quickly and easily and with very little overhead.

Incidentally, Datadog also has integrations for MySQL, Apache etc. So, if you want, you can get specific metrics on those too.

Attached is an example of some of my Zoneminder host's stats from the last month, just to see the sort of "extras" you get (for nothing).
datadog_zoneminder.png
datadog_zoneminder.png (168.78 KiB) Viewed 3214 times

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests