Page 1 of 1

Way to create monitors from the command line/ansible?

Posted: Tue Sep 22, 2020 5:06 pm
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?

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

Posted: Wed Sep 23, 2020 2:27 pm
by bkjaya1952
Please refer this link to use curl commands to ceate monitors

https://zoneminder.readthedocs.io/en/1.32.3/api.html

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

Posted: Thu Sep 24, 2020 5:55 pm
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.