Hi Community!
Once logged in as root in command prompt, is there a way to restart a specific monitor´s capture daemon from prompt?
What command would that be?
Sometimes I have black screens on IP cameras and although there is some kind of check built into ZM nevertheless, sometimes I have to go into the http console, click on the Source of the monitor, change anything, Save it which in default restarts such monitor. Im looking for a restart from command prompt to that monitor rather than doing all the above steps through the console.
Regards!
How to restart specific monitor capture daemon from prompt?
Yes,
Use:
#/usr/bin/perl -wT /usr/lib/zm/bin/zmdc.pl restart zmc -m X
where X it´s the monitor that you need restart.
I was made a script (ugly pre-beta) to do it automatically:
Of corse thar I use a infinite loop ("for (( ; ; )) do") with a time of 5 seconds interval ("sleep 5") os executions... you may increase you decrease it.
This script acess zm index web page [http://127.0.0.1/zm/index.php] that have monitor list the look first for "errorText" [/bin/gawk -F "=" '/errorText/ { print }'], the red highlight for down monitors;
Then look for print just the Modect and monitor [/bin/gawk -F "=" '/Modect|monitor/ { print $5 }'] because on index.php we have two lines for same monitor, if you use another function like "Mocord" you will need replace in script;
Now look just for monitor number and print the command [/bin/gawk -F "\"" '{ printf("/usr/bin/perl -wT /usr/lib/zm/bin/zmdc.pl restart zmc -m " $1 ";")]:
#/usr/bin/perl -wT /usr/lib/zm/bin/zmdc.pl restart zmc -m X ;
where the X it´s for monitor number and ";" for sequential comands if he have more than one monitor down.
Don´t forget to make sure that your zmdc.pl it´s in "/usr/lib/zm/bin/zmdc.pl" or locate your and change patch in te script.
Remember to chmod 755 the script :c)
Now just put the script in /etc/rc.local and after reboot will run and just type: #/path/your_script.sh &
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 7181 0.0 0.0 4452 1376 ? S May17 0:40 /bin/bash /tmp/checar.sh
And at every 5 seconds:
root 25501 0.0 0.0 5340 1300 ? S 11:40 0:00 /usr/bin/wget http://127.0.0.1/zm/index.php -O /tmp/index.php
You will not worry about script load :c)
I was tried to use "tail -n 1 /var/log/zm/zmdc.log" without sucess because a have a lot, really lot of disconnects in eight remote cameras and was loosing some with "tail -n 1".
I wish a better gawk code to use less commands, but at this moment I haven´t time to do it... it´s working nicely and good to me.
Neppon
Use:
#/usr/bin/perl -wT /usr/lib/zm/bin/zmdc.pl restart zmc -m X
where X it´s the monitor that you need restart.
I was made a script (ugly pre-beta) to do it automatically:
Code: Select all
#!/bin/bash
for (( ; ; ))
do
/bin/rm -rf /tmp/index.php && /usr/bin/wget http://127.0.0.1/zm/index.php -O /tmp/index.php && cat /tmp/index.php |/bin/gawk -F "=" '/errorText/ { print }' |/bin/gawk -F "=" '/Modect|monitor/ { print $5 }'|/bin/gawk -F "\"" '{ printf("/usr/bin/perl -wT /usr/lib/zm/bin/zmdc.pl restart zmc -m " $1 ";")| "/bin/sh" }'
sleep 5
done
This script acess zm index web page [http://127.0.0.1/zm/index.php] that have monitor list the look first for "errorText" [/bin/gawk -F "=" '/errorText/ { print }'], the red highlight for down monitors;
Then look for print just the Modect and monitor [/bin/gawk -F "=" '/Modect|monitor/ { print $5 }'] because on index.php we have two lines for same monitor, if you use another function like "Mocord" you will need replace in script;
Now look just for monitor number and print the command [/bin/gawk -F "\"" '{ printf("/usr/bin/perl -wT /usr/lib/zm/bin/zmdc.pl restart zmc -m " $1 ";")]:
#/usr/bin/perl -wT /usr/lib/zm/bin/zmdc.pl restart zmc -m X ;
where the X it´s for monitor number and ";" for sequential comands if he have more than one monitor down.
Don´t forget to make sure that your zmdc.pl it´s in "/usr/lib/zm/bin/zmdc.pl" or locate your and change patch in te script.
Remember to chmod 755 the script :c)
Now just put the script in /etc/rc.local and after reboot will run and just type: #/path/your_script.sh &
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 7181 0.0 0.0 4452 1376 ? S May17 0:40 /bin/bash /tmp/checar.sh
And at every 5 seconds:
root 25501 0.0 0.0 5340 1300 ? S 11:40 0:00 /usr/bin/wget http://127.0.0.1/zm/index.php -O /tmp/index.php
You will not worry about script load :c)
I was tried to use "tail -n 1 /var/log/zm/zmdc.log" without sucess because a have a lot, really lot of disconnects in eight remote cameras and was loosing some with "tail -n 1".
I wish a better gawk code to use less commands, but at this moment I haven´t time to do it... it´s working nicely and good to me.
Neppon
Hi Neppon!
Thanks for your tips I am actually trying to make some kind of blue screen, black screen, image freeze detection that when true sends a restart on the capture daemon. One other question, does:
#/usr/bin/perl -wT /usr/lib/zm/bin/zmdc.pl restart zmc -m X
Work for both 1.23 and 1.24.2 versions?
What version are you using?
Regards!
Thanks for your tips I am actually trying to make some kind of blue screen, black screen, image freeze detection that when true sends a restart on the capture daemon. One other question, does:
#/usr/bin/perl -wT /usr/lib/zm/bin/zmdc.pl restart zmc -m X
Work for both 1.23 and 1.24.2 versions?
What version are you using?
Regards!
If the wheel really works, we don´t need do it...kingofkya wrote:Dont reinvent the wheel ppl
ZM alredy does this.
WATCH_CHECK_INTERVAL How often to check the capture daemons have not locked up (?)
On thing works in theory differs from wath really happens...
Before use this script, I really was tried the check_interval and many other options and distros (actually using archlinux), but without sucess.. you see command to restart zmdc in log, but it not really restart the d4mmit (sorry) service... can´t understand why develop team don´t like to do improvements in networked cameras, but it´s the life... if you have floor, make a bread!
Sometimes "reload" can´t bring to life zmdc monitor and need a "restart".
By the way, I´m using a check to apache too, make a "httpd reload" when it freeze, and it freeze a lot of times at every 60 seconds... oops "httpd -k" it´s the wheel that shound do it, but just don´t.
Neppon
Unfortunelly I have not you lucky.
For now I installed "stock" archlinux (make minimal add like put my monitors that was remote ubuntu 10 with 2 local cams each one) to see if was someting that I do, but still happens. Using http simple conect method because rtsp don´t worked, regardless port config and nat config.
I need check for down monitor and send zmcd restart comand, look for /zm/index.php and if no response make a "http restart".
Plus, if I not make a "http reload" after every time zms got signal 15 will lock the stream in montage view using CAN_STREAM no and STREAM_METHOD jpg (to force use cambozola in firefox).
And still need to add:
<meta http-equiv="refresh" content="30">
To my montage.php for a page refresh every 30 seconds or java client freeze in few minuts of view.
It´s not a beautiful or best solution, but at this moment it´s working and now I can backup my brother shop cam´s imagens and serve live video for both 4 cam´s.
ps.: sorry for bad english write, I´m from brazil and self learned anything, include english :c)
Neppon
For now I installed "stock" archlinux (make minimal add like put my monitors that was remote ubuntu 10 with 2 local cams each one) to see if was someting that I do, but still happens. Using http simple conect method because rtsp don´t worked, regardless port config and nat config.
I need check for down monitor and send zmcd restart comand, look for /zm/index.php and if no response make a "http restart".
Plus, if I not make a "http reload" after every time zms got signal 15 will lock the stream in montage view using CAN_STREAM no and STREAM_METHOD jpg (to force use cambozola in firefox).
And still need to add:
<meta http-equiv="refresh" content="30">
To my montage.php for a page refresh every 30 seconds or java client freeze in few minuts of view.
It´s not a beautiful or best solution, but at this moment it´s working and now I can backup my brother shop cam´s imagens and serve live video for both 4 cam´s.
ps.: sorry for bad english write, I´m from brazil and self learned anything, include english :c)
Neppon
Hi
Well, yes I am aware of WATCH_CHECK_INTERVAL, but too, have gone into the console many times to find that a simple restart in the Source hence zm capture restart gets things going. I have yet o find what is the trouble first, a loss of signal that freezes capture or if its the capture itself which freezes first. I tend to think that something happens to the IP cam itself which then triggers de zm capture freeze. I do know that I am yet to see a capture freeze using analog camaras, so tend to think the culprit would go to the IP cam itself o perhaps some weird stuff going on with the lan itself, which is pretty big in my case. Unfortunately I have not yet been succesful on recreating the freeze, just find it like that when randomly logging into the console.
Neppon.. do you use that command on version 1.23 or 1.24.2 ? Or does that work on both?
Regards!
Well, yes I am aware of WATCH_CHECK_INTERVAL, but too, have gone into the console many times to find that a simple restart in the Source hence zm capture restart gets things going. I have yet o find what is the trouble first, a loss of signal that freezes capture or if its the capture itself which freezes first. I tend to think that something happens to the IP cam itself which then triggers de zm capture freeze. I do know that I am yet to see a capture freeze using analog camaras, so tend to think the culprit would go to the IP cam itself o perhaps some weird stuff going on with the lan itself, which is pretty big in my case. Unfortunately I have not yet been succesful on recreating the freeze, just find it like that when randomly logging into the console.
Neppon.. do you use that command on version 1.23 or 1.24.2 ? Or does that work on both?
Regards!
I was tested with 1.23 and 1.24.1 and 1.24.2 with same result.Eklectick wrote: Neppon.. do you use that command on version 1.23 or 1.24.2 ? Or does that work on both?
Looks lime poor conection with remote servers (2 cam´s each).
If the "signal loos" feature that look for static images in monitors may be used in networked cam´s, perhaps we have a better fail detect and restart.
My complete script atually looks like:
Code: Select all
#!/bin/sh
for (( ; ; ))
do
/bin/rm -rf /tmp/index.php && /usr/bin/wget http://127.0.0.1:82/zm/index.php?view=console2 -O /tmp/index.php 2> /dev/null && cat /tmp/index.php |/bin/gawk -F "=" '/errorText/ { print }' |/bin/gawk -F "=" '/Modect|monitor/ { print $5 }'|/bin/gawk -F """ '{ printf("/usr/bin/perl -wT /usr/lib/zm/bin/zmdc.pl restart zmc -m "$1)| "/bin/sh" }'
sleep 2
T=`tail -n 1 /var/log/messages.log |grep "Got signal 15"`
if [ "${T}" != "" ]; then
sh /etc/rc.d/httpd reload 2> /dev/null
echo "ZMS Sinal 15: `date`">>/var/log/httpd/restart_log
fi
Z=`tail /var/log/httpd/access_log |grep "GET /zm/index.php HTTP/1.1" 200 0"|tail -n 1`
if [ "${Z}" != "" ]; then
sh /etc/rc.d/httpd reload 2> /dev/null
echo "PHP: `date`">>/var/log/httpd/restart_log
fi
Y=`tail -n 1 /var/log/httpd/error_log |grep "Timeout waiting for output from CGI script /var/www/cgi-bin/nph-zms"`
if [ "${Y}" != "" ]; then
sh /etc/rc.d/httpd reload 2> /dev/null
echo "CGI: `date`">>/var/log/httpd/restart_log
fi
sleep 2
done