Still no sound, but a workaround

Forum for questions and support relating to the 1.24.x releases only.
Locked
koos
Posts: 6
Joined: Mon Jan 31, 2011 9:10 am

Still no sound, but a workaround

Post by koos »

Trying all the suggestions from this forum, I still have no sound in the browser (Latest FF on openSUSE 11.3). Downloading the monitor window to a flat HTML and then reloading it, does produce sound. I do need to change the <iframe> (for the video) to an <object> though. Apparently there is some blocking going on when viewing the live feed. Don't know how, what or why.

The simplest effective workaround I could come up with is tailing the syslog and playing a sound when grepping the string 'Gone into alert state'
And it works pretty well. At least enough for my basic needs.

For those who want to persue this road, here is what I've done:

1. Add a NOPASSWD: userid to the sudoers file for tailing syslog.

Code: Select all

User_Alias LOG = logadmin
Cmnd_Alias LOG_MAINT = /usr/bin/tail -f /var/log/messages
LOG ALL = NOPASSWD: LOG_MAINT
2. The script to run as user logadmin (ex: /usr/local/bin/zm_alarm.sh)

Code: Select all

sudo /usr/bin/tail -f /var/log/messages |
    while true; do 
        if grep -q 'Gone into alarm state'
            then aplay foo.wav
        fi
    done
3. zm_alarm.sh can be run from the init/startup script:

Code: Select all

sudo -u logadmin /usr/local/bin/zm_alarm.sh
I didn't want the script to run as root. Hence the sudo indirection.

HTH.
Koos
Alan87i
Posts: 116
Joined: Sun Jul 27, 2008 9:58 am

Post by Alan87i »

Could you help me understand how to tail the log and have the ZM box play a sound locally when 1 monitor goes into alarm , Using Ubuntu .
I have it working now using the ZM filter , That's fine but it runs on a time delay , I set the filter to run every 20 seconds , Any faster than that seems to drive the system load up .

Thanks
Allan
koos
Posts: 6
Joined: Mon Jan 31, 2011 9:10 am

Post by koos »

Everything you need is posted I think. Tailing and playining a sound on the server is done by the file zm_alarm.sh
In my setup (openSUSE 11.2) ZM is installed by rpm. It has a startup file in /etc/init.d/zm
I added line (3) just after starting the ZM server, somewhere in the start) section.

Can you explain what it is exactly what you don't understand?

Koos
Alan87i
Posts: 116
Joined: Sun Jul 27, 2008 9:58 am

Post by Alan87i »

I'm 1 step above a linux newbie. Until I have a broader understanding of the basic steps that need to be done to apply scripts such as the one you posted I need the steps handed to me. ( on a plate with Fries) LOL

IE step 1 adding this code to the sudoers file.
Were do I find that .
One thing I have learned and has cost me dearly is modifying files and doing it wrong can cause total havoc and usually starting over.

I'll look for this file in Ubuntu later today . And start there
Thanks for the help.
Alan87i
Posts: 116
Joined: Sun Jul 27, 2008 9:58 am

Post by Alan87i »

I added the code to the sodoers file .
I created the zm_alarm.sh file I modified it to play my wave file that is in the root directory. I also added a monitor name in the what to tail part of the script as I would only want this sound played out the system speaker when this 1 camera goes into alarm. Checked the box so it is executable. The Owner and group is set too Root. ( not sure what to change it too)

I then added the 3 part in the int.d script for zm .
Restarted and ZM works as normal but that's it. If I try to run the script in terminal it asks for my user pass word.
koos
Posts: 6
Joined: Mon Jan 31, 2011 9:10 am

Post by koos »

Alan87i wrote:I added the code to the sodoers file.
Good.
I created the zm_alarm.sh file I modified it to play my wave file that is in the root directory. I also added a monitor name in the what to tail part of the script as I would only want this sound played out the system speaker when this 1 camera goes into alarm. Checked the box so it is executable.
Good
The Owner and group is set too Root. ( not sure what to change it too)
That doesn't really matter. root is ok.
I then added the 3 part in the int.d script for zm .
Restarted and ZM works as normal but that's it. If I try to run the script in terminal it asks for my user pass word.
Then you call it backwards or your sudoers file is awray. What happens when you type (as root):

Code: Select all

sudo -u logadmin /usr/local/bin/zm_alarm.sh
Alan87i
Posts: 116
Joined: Sun Jul 27, 2008 9:58 am

Post by Alan87i »

allan@Zoneminder:~$ sudo -u logadmin /usr/local/bin/zm_alarm.sh
sudo: no passwd entry for logadmin!
allan@Zoneminder:~$




is what I get.
Thanks
koos
Posts: 6
Joined: Mon Jan 31, 2011 9:10 am

Post by koos »

Alan87i wrote:allan@Zoneminder:
You need to be root in order to run a command as someone else. Login as root first (su - root).
sudo: no passwd entry for logadmin!
You forgot to create the user logadmin. Type

Code: Select all

useradd --system logadmin
Once

Code: Select all

sudo -u logadmin /usr/local/bin/zm_alarm.sh
works, you can startup ZM as root, and fire up zm_alarm.sh in the process.
Koos
Alan87i
Posts: 116
Joined: Sun Jul 27, 2008 9:58 am

Post by Alan87i »

I did what you you mentioned in the last post.
The script will run when called but the sound does not play when I trigger the camera.

What I did was add the name of the camera in the script with a space , before the part you had in it.

Code: Select all

sudo /usr/bin/tail -f /var/log/messages |
    while true; do
        if grep -q 'bwshop Gone into alarm state'
            then aplay ping.wav
        fi
    done 
As I want this to run only for this camera .
Locked