Monitoring sound over time for long periods to see trends using a microphone
Tags icinga, monitoring, munin
Recently a post was made requesting a solution to detecting sound in a studio to see if it is populated with lots of noise (lots of noise=people/bands playing) this way the person monitoring it wouldn't have to go through the trouble of hulking all their stuff to the studio.
I posted an interesting solution so I'm sharing it here and a little more on this blog. See post #9 of this thread.
I'm going to expand upon that munin plugin and make it a little more robust and informative. I'll rewrite the munin plugin a bit to include more information on the same graph and be a little better.
Of course, that plugin can be further improved by writing an awk script which parses out all of the values and displays all three values at once that way the sox command is only run once and it uses less CPU. Though power savings will be almost negligible by doing that. I kept it this way for readability mostly.
The new munin plugin improves upon the last one by providing more information which is a little more useful than just knowing the maximum amplitude of the 1 second sample recorded at the time of running the plugin. At any rate I thought that was a cool little project I got myself into so I documented it here.
SAM
I posted an interesting solution so I'm sharing it here and a little more on this blog. See post #9 of this thread.
I'm going to expand upon that munin plugin and make it a little more robust and informative. I'll rewrite the munin plugin a bit to include more information on the same graph and be a little better.
Code:
#!/bin/sh case $1 in config) cat <<EOM graph_title Sound Amplitude graph_args -l -1 --upper-limit 1 graph_vlabel Amplitude graph_info Shows the sound amplitude values during the 1 second interval recorded discretely every minute. mxamp.label max_ampl mxamp.info Maximum amplitude mnamp.label min_ampl mnamp.info Minimum amplitude mdamp.label mid_ampl mdamp.info Midline amplitude EOM exit 0;; esac arecord -d 1 -f cd -t wav /tmp/foo.wav &> /dev/null echo -n "mxamp.value " sox /tmp/foo.wav -n stat 2>&1 | grep 'Maximum amplitude' | awk '{print $3}' echo -n "mnamp.value " sox /tmp/foo.wav -n stat 2>&1 | grep 'Minimum amplitude' | awk '{print $3}' echo -n "mdamp.value " sox /tmp/foo.wav -n stat 2>&1 | grep 'Midline amplitude' | awk '{print $3}' rm -f /tmp/foo.wav
The new munin plugin improves upon the last one by providing more information which is a little more useful than just knowing the maximum amplitude of the 1 second sample recorded at the time of running the plugin. At any rate I thought that was a cool little project I got myself into so I documented it here.
SAM
Total Comments 1
Comments
-
Thanks unSpawn for an emailed patch which creates more secure temporary files. Here's his code after applying the patch.
Code:#!/bin/sh case $1 in config) cat <<EOM graph_title Sound Amplitude graph_args -l -1 --upper-limit 1 graph_vlabel Amplitude graph_info Shows the sound amplitude values during the 1 second interval recorded discretely every minute. mxamp.label max_ampl mxamp.info Maximum amplitude mnamp.label min_ampl mnamp.info Minimum amplitude mdamp.label mid_ampl mdamp.info Midline amplitude EOM exit 0;; esac LANG=C; LC_ALL=C; export LANG LC_ALL; MYTMPDIR=`mktemp -p /tmp -d ampl.XXXXXXXXXX` && { arecord -d 1 -f cd -t wav "${MYTMPDIR}/foo.wav" &> /dev/null echo -n "mxamp.value " sox "${MYTMPDIR}/foo.wav" -n stat 2>&1 | awk '/Maximum amplitude/ {print $3}' echo -n "mnamp.value " sox "${MYTMPDIR}/foo.wav" -n stat 2>&1 | awk '/Minimum amplitude/ {print $3}' echo -n "mdamp.value " sox "${MYTMPDIR}/foo.wav" -n stat 2>&1 | awk '/Midline amplitude/ {print $3}' rm -rf "${MYTMPDIR}" } exit 0
SAMPosted 06-12-2012 at 09:52 AM by sag47
Updated 06-12-2012 at 11:09 AM by sag47