Way to create monitors from the command line/ansible?

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
ddev
Posts: 4
Joined: Mon Sep 21, 2020 8:20 pm

Way to create monitors from the command line/ansible?

Post by ddev »

I have a ansible script that set up zoneminder in a new virtual machine, and then I manually added some monitors and changed some settings. I'm about to start screwing with mysql settings, meaning that afterwards I'll likely need to scrap the virtual machine and rebuild it. (It's be better to create the monitors from ansible anyway). Is there easy way to create the monitors from ansible (or from bash)? i see zmu, but I dont see a way to create the monitors from "zmu ---help".

The easiest option I see is that since the configs are in the mysql database, i should be able to do:
echo "insert into Monitors (Name, ServerId, Path, ...) values ('camera 1', 0, 'rtsp://{camera address}', ...);" | mysql
to create the monitors. and
echo "update Configs set Value = -2 where Name = 'ZM_LOG_LEVEL_DATABASE';" | mysql
to change settings.

Given that I already know bash and sql, is there any easier options for me that I'm missing?
User avatar
bkjaya1952
Posts: 282
Joined: Sat Aug 25, 2018 3:24 pm
Location: Sri Lanka

Re: Way to create monitors from the command line/ansible?

Post by bkjaya1952 »

Please refer this link to use curl commands to ceate monitors

https://zoneminder.readthedocs.io/en/1.32.3/api.html
ddev
Posts: 4
Joined: Mon Sep 21, 2020 8:20 pm

Re: Way to create monitors from the command line/ansible?

Post by ddev »

Thanks. Using curl with that seems to be a better way to go for creating the monitor.

Of interest:
* the defaults when creating by hand, and the default when creating through the API appear to be differnt. (for example the default for how many frames get buffered)
* Also, creating a monitor by API does not automatically create a zone for it like the UI does. This probably makes sense as someone who calls the API probably knows that he'll need a zone, where as the UI user could be using it for the first time and not realize a zone needs to be created. Just pointing this out to make sure it's intended behavior.
Post Reply