Page 1 of 1

Notify on camera loss, possible? UPDATED / RESOLVED (sort of

Posted: Mon Sep 21, 2009 6:15 pm
by sniz
Hello all,
I am trying to administer a system remotely and I am having a problem with zm losing connection with cameras. I am tracking down possible problems with shared memory settings, but is there a way for zm to notify if/when it loses a camera? It would make troubleshooting alot easier and would be a useful feature during normal operation as well.

Any help or suggestions you might offer is greatly appreciated.

-- Sniz

Posted: Tue Sep 22, 2009 9:27 am
by cordel
You can setup the logwatch facility to do this.

UPDATED / RESOLVED (sort of...)

Posted: Tue Sep 22, 2009 11:46 am
by sniz
Thanks for the fast response, cordel. I hadn't seen logwatch, but I think I managed to find workable (meaning "Quick and Dirty") solution with swatch.

From what I can tell, main difference between them is that logwatch will parse the log files for desired info as a cron job, and output the results in the desired manner, while swatch will actually monitor the log files as they are being written, looking for matches to text patterns in the form of regular expressions, and send an email or execute a command when it finds one.

(LinuxJournal published an article about installing, configuring, and using swatch back in Aug. '01. You can read it here )

What I did was set swatch to monitor syslog for /Select timed out/, and execute a command that will send an empty email (just headers) with a subject like "Oh_@#$%_ a_camera_is_out" when a matching new entry is written. I don't get any camera-specific info, but I do get notified immediately instead of waiting for the next scheduled cron job.

What do you think?

pinging

Posted: Tue Sep 22, 2009 3:25 pm
by johnnytolengo
Hi all, may be is enought just to do a simply file like this (it is just a mini-example):

Code: Select all

#!/bin/bash

# Programa que pide una direccion IP al usuario y reliza un 3 pings con interva$
ipa=myotherserver.com
ipb=google.com
#ipc=yahoo.com

if $(ping -c3 -i 2 $ipa > /dev/null) ;then
#echo "La maquina $ip esta arriba (up)" | mail -s resultado  email@email.com
A1=1
else
#echo "La maquina $ip esta abajo (down)" | mail -s resultado email@email.com
A1=0
fi


if $(ping -c3 -i 2 $ipb > /dev/null) ;then
B1=1 
else
B1=0
fi

CERO=0
RESULT=$A1+$B1
if [$RESULT -gt $CERO ]; then
echo "La maquina $ip esta arriba (up)" | mail -s resultado  email@email.com

else

echo "La maquina $ip esta abajo (down)" | mail -s resultado email@email.com
fi 

Re: pinging

Posted: Tue Sep 22, 2009 8:30 pm
by sniz
johnnytolengo wrote:Hi all, may be is enought just to do a simply file like this (it is just a mini-example): ...
I'm sorry, I should have been more clear. See, my cameras are fine. It's zm that suddenly can't connect to a camera. The camera is up and running but zm requires a restart to restore the connection.

So I what I need is to be notified if/when zm turns the camera text "red", so I can then find out why.

Posted: Wed Sep 23, 2009 5:57 am
by johnnytolengo
You can make a script which will be read the file /var/log/syslog

first try to find with " tail -f /var/log/syslog " the log zm returns when the camera falied.

With this you just create a script "daemon" that will be inform you or restart zm.

It is just an idea.


JT.