Page 1 of 1

Disk Space used per camera?

Posted: Wed Feb 03, 2010 10:34 pm
by troyy0206
Is there an easy way to tell how much disk space each camera is using?

Posted: Wed Feb 03, 2010 10:58 pm
by Paranoid
If you cd into the events directory (usually (webroot)/htdocs/zm/events) you will see a directory for each camera. The directories are numbers and have a softlink to them from a link that matches the monitor name.

You can then do "du -sh <directory>" to find out how much space each camera is using.

Posted: Thu Feb 04, 2010 5:05 am
by troyy0206
Paranoid wrote:If you cd into the events directory (usually (webroot)/htdocs/zm/events) you will see a directory for each camera. The directories are numbers and have a softlink to them from a link that matches the monitor name.

You can then do "du -sh <directory>" to find out how much space each camera is using.
Sure would be nice if someone were to add this as a feature to display as an HTML table...maybe run the job and update the stats each hour or once a day or something ;)

Posted: Thu Feb 04, 2010 3:44 pm
by coke
There ya go. Pop that in your favorite job scheduler, and bookmark the file in your browser. That's assuming, of course, that /var/www is where your webserver's looking, if it's not, change appropriately.

Code: Select all

#!/bin/sh
du -sh /var/www/events/* > /var/www/spaceused.txt

slightly improved

Posted: Wed Feb 10, 2010 3:03 pm
by dcbour
Since the question was asked...and I wanted an html report to do it...
Might even link this into my console report some how or link off it...

Code: Select all

#!/bin/bash
cd /var/cache/zoneminder/events
for d in `ls -latr|grep \>|awk '{print $8}'`;do du -sDm $d;done >/tmp/events.tmp

df|grep -v none|grep -v udev >/tmp/disksize.tmp


# Now build html report from data files retrieved...first table is all monitors and data size...

echo "<html><head><title>Disk Utilization by Monitor Report</title></head><body><center>" >/tmp/diskusage.html
echo "<h1>Monitor Usage Report</h1><table>" >>/tmp/diskusage.html
cat /tmp/events.tmp |awk '{print "<tr><td>" $2 "</td><td>" $1 " MB</td></tr>"}' >>/tmp/diskusage.html
echo "</table>" >>/tmp/diskusage.html
echo "<h1>Disk Usage Report</h1><table>" >>/tmp/diskusage.html
echo "<table>" >>/tmp/diskusage.html
cat /tmp/disksize.tmp |awk '{print "<tr><td>" $1 "</td><td>" $2 "</td><td>" $3 "</td><td>" $4 "</td><td>" $5 "</td><td>" $6 "</td></tr>"}' >>/tmp/diskusage.html
echo "</table></html>" >>/tmp/diskusage.html


mv /tmp/diskusage.html /var/www/
This dumps the number based path...and only shows the monitor labels, as well as the overall disk usage report (in case you have two disks or more...can view it all at once.)

Note the path changes are slightly different from the example above to fit my ubuntu installation.

Once again, a cron to run daily and this is good to go or simply add to the daily cron

Posted: Tue Mar 02, 2010 5:35 am
by webtron
Thanks for this its handy for me but I get an error when I try to run this script from cron schedules in webmin.

du: cannot access `10:34': No such file or directory
du: cannot access `14:22': No such file or directory
du: cannot access `14:23': No such file or directory
du: cannot access `14:24': No such file or directory

I can execute the script normally and it all works just not in cron and I'm running it as root. Any ideas?

Posted: Tue Mar 02, 2010 6:33 am
by webtron
After much digging around on Google I found an answer. Noyes lines 2 and 3

Code: Select all

#!/bin/bash
export LANG=en_US.UTF-8
LANG=en_US.UTF-8
cd /var/cache/zoneminder/events
for d in `ls -latr|grep \>|awk '{print $8}'`;do du -sDm $d;done >/tmp/events.tmp

df|grep -v none|grep -v udev >/tmp/disksize.tmp


# Now build html report from data files retrieved...first table is all monitors and data size...

echo "<html><head><title>Disk Utilization by Monitor Report</title></head><body><center>" >/tmp/diskusage.html
echo "<h1>Monitor Usage Report</h1><table>" >>/tmp/diskusage.html
cat /tmp/events.tmp |awk '{print "<tr><td>" $2 "</td><td>" $1 " MB</td></tr>"}' >>/tmp/diskusage.html
echo "</table>" >>/tmp/diskusage.html
echo "<h1>Disk Usage Report</h1><table>" >>/tmp/diskusage.html
echo "<table>" >>/tmp/diskusage.html
cat /tmp/disksize.tmp |awk '{print "<tr><td>" $1 "</td><td>" $2 "</td><td>" $3 "</td><td>" $4 "</td><td>" $5 "</td><td>" $6 "</td></tr>"}' >>/tmp/diskusage.html
echo "</table></html>" >>/tmp/diskusage.html


mv /tmp/diskusage.html /usr/share/zoneminder/