Disk Space used per camera?

Forum for questions and support relating to the 1.24.x releases only.
Locked
troyy0206
Posts: 45
Joined: Fri Oct 30, 2009 1:54 am

Disk Space used per camera?

Post by troyy0206 »

Is there an easy way to tell how much disk space each camera is using?
Paranoid
Posts: 129
Joined: Thu Feb 05, 2009 10:40 pm

Post 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.
troyy0206
Posts: 45
Joined: Fri Oct 30, 2009 1:54 am

Post 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 ;)
coke
Posts: 518
Joined: Wed Jan 30, 2008 5:53 pm
Location: St. Louis, MO, USA

Post 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
dcbour
Posts: 12
Joined: Wed Oct 07, 2009 1:30 am

slightly improved

Post 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
Dave
webtron
Posts: 2
Joined: Tue Mar 02, 2010 5:30 am

Post 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?
webtron
Posts: 2
Joined: Tue Mar 02, 2010 5:30 am

Post 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/ 
Locked