Zoneminder
Contents
functions.php
Clear Events
cd /var/cache/zoneminder/events/ rm -rf *
Debian Squeeze
- Enable Backports
nano /etc/apt/sources.list
add:
deb http://backports.debian.org/debian-backports squeeze-backports main contrib non-free
Install other stuff:
apt-get install libfaac-dev apt-get install libmp3lame-dev apt-get install libogg-dev apt-get install libjpeg-dev apt-get install libtheora-dev apt-get install libvorbis-dev apt-get install libx264-dev apt-get -t squeeze-backports install libxvidcore-dev
Install Zoneminder:
apt-get install zoneminder
ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf /etc/init.d/apache2 restart
- zmwatch[22830]: ERR [Can't get shared memory id '7a6d0002', 2: No such file or directory]
Make shared memory key work:
Test it:
echo 167772160 >/proc/sys/kernel/shmall echo 167772160 >/proc/sys/kernel/shmmax
Restart Zoneminder
/etc/init.d/zoneminder stop
Make it perm
nano /etc/sysctl.conf # Increase the maximum shared memory kernel.shmall = 167772160 kernel.shmmax = 167772160
/etc/init.d/zoneminder start
libjpeg turbo
You can use libjpeg-turbo to speed things up. This is worth it. I had a system at like 6.0 load and now it is at .10 Plus they just released a new version of libjpeg turbo.
root@hslmonitor:~# locate libjpeg /usr/lib/libjpeg.a /usr/lib/libjpeg.la /usr/lib/libjpeg.so /usr/lib/libjpeg.so.62 /usr/lib/libjpeg.so.62.0.0 /usr/share/doc/libjpeg62 /usr/share/doc/libjpeg62-dev /usr/share/doc/libjpeg62-dev/changelog.Debian.gz /usr/share/doc/libjpeg62-dev/changelog.gz /usr/share/doc/libjpeg62-dev/coderules.doc.gz /usr/share/doc/libjpeg62-dev/copyright /usr/share/doc/libjpeg62-dev/examples /usr/share/doc/libjpeg62-dev/examples/example.c.gz /usr/share/doc/libjpeg62-dev/libjpeg.doc.gz /usr/share/doc/libjpeg62-dev/README.Debian /usr/share/doc/libjpeg62-dev/structure.doc.gz /usr/share/doc/libjpeg62/changelog.Debian.gz /usr/share/doc/libjpeg62/changelog.gz /usr/share/doc/libjpeg62/copyright /usr/share/doc/libjpeg62/README.gz /var/cache/apt/archives/libjpeg62-dev_6b1-1_amd64.deb /var/cache/apt/archives/libjpeg62_6b1-1_amd64.deb
replace libjpeg with libjpeg-turbo (64bit)
dpkg --remove --force-depends libjpeg62 dpkg --remove --force-depends libjpeg62-dev wget libjpeg-turbo 64bit deb file mv (downloaded name) to libjpeg-turbo-official_1.3.0_amd64.deb or whatever dpkg -i libjpeg-turbo-official_1.3.0_amd64.deb
ln -s /opt/libjpeg-turbo/lib/libjpeg.a /usr/lib/libjpeg.a && \ ln -s /opt/libjpeg-turbo/include/jconfig.h /usr/include/jconfig.h && \ ln -s /opt/libjpeg-turbo/include/jerror.h /usr/include/jerror.h && \ ln -s /opt/libjpeg-turbo/include/jmorecfg.h /usr/include/jmorecfg.h && \ ln -s /opt/libjpeg-turbo/include/jpeglib.h /usr/include/jpeglib.h
- I used (64bit):
ln -s /opt/libjpeg-turbo/lib64/libjpeg.a /usr/lib/libjpeg.a && \ ln -s /opt/libjpeg-turbo/include/jconfig.h /usr/include/jconfig.h && \ ln -s /opt/libjpeg-turbo/include/jerror.h /usr/include/jerror.h && \ ln -s /opt/libjpeg-turbo/include/jmorecfg.h /usr/include/jmorecfg.h && \ ln -s /opt/libjpeg-turbo/include/jpeglib.h /usr/include/jpeglib.h
- Taken from same link:
echo "/opt/libjpeg-turbo/lib" > /etc/ld.so.conf.d/libjpeg-turbo.conf && \ echo "/usr/local/lib" > /etc/ld.so.conf.d/ffmpeg.conf && \ echo "LD_LIBRARY_PATH=/usr/local/lib:/opt/libjpeg-turbo/lib:$LD_LIBRARY_PATH" >> /etc/bash.bashrc && \ echo "export LD_LIBRARY_PATH" >> /etc/bash.bashrc
- I used (just for turbo)
echo "/opt/libjpeg-turbo/lib64" > /etc/ld.so.conf.d/libjpeg-turbo.conf && \ echo "LD_LIBRARY_PATH=/opt/libjpeg-turbo/lib64:$LD_LIBRARY_PATH" >> /etc/bash.bashrc && \ echo "export LD_LIBRARY_PATH" >> /etc/bash.bashrc
ldconfig
Disable Corrupt JPEG Data
zmc_m3[12280]: WAR [Corrupt JPEG data: 1 extraneous bytes before marker 0xd9]
Another way is just disable writing these messages to log files. If you are using rsyslog (default in debian):
#cat /etc/rsyslog.d/00-zm-foscam.conf :msg, contains, "WAR [Corrupt JPEG data: 1 extraneous bytes before marker 0xd9]" ~ :msg, contains, "WAR [Corrupt JPEG data: 2 extraneous bytes before marker 0xd9]" ~ #service rsyslog restart
If you are use syslog-ng:
destination df_null { }; filter f_libjpeg { message(“WAR \\[Corrupt JPEG data: .+ extraneous bytes before marker”); }; log { source(s_src); filter(f_libjpeg); destination(df_null); flags(final); };
- http://www-personal.umd.umich.edu/~dennismv/corruptjpeg.html
- http://foscam.us/forum/fi8918wcorruptjpegdata-1extraneous-bytes-before-marker-0xd9-t1067.html
Controlling CPU Usage
The lib turbo jpeg is reccomended but if you are using modetect it is best to lower the framrate. From the Zoneminder FAQ's:
- Capture frame rates. Unless there's a compelling reason in your case there is often little benefit in running cameras at 25fps when 5-10fps would often get you results just as good. Try changing your monitor settings to limit your cameras to lower frame rates. You can still configure ZM to ignore these limits and capture as fast as possible when motion is detected.
I had a VM cpu at 100 percent with 3 cams. I lowered to 5fps and cpu is at 30 percent.
Notes
- http://www.zoneminder.com/wiki/index.php/Foscam
- http://kotisivu.dnainternet.net/vuorris/zoneminder/zm_manual/index.html
- http://www.zoneminder.com/wiki/index.php/Documentation#Introduction
- http://www.zoneminder.com/wiki/index.php/FAQ
CentOS 7 w/ Repo Install
Install
Install CentOS Min
wget http://zmrepo.zoneminder.com/el/7/x86_64/zmrepo-7-4.el7.centos.noarch.rpm sudo yum install --nogpgcheck zmrepo-7-4.el7.centos.noarch.rpm sudo yum install zoneminder less /usr/share/doc/zoneminder-*/README.Centos7
systemctl enable mariadb systemctl start mariadb mysql_secure_installation
mysql -u root -p < /usr/share/zoneminder/db/zm_create.sql mysql -u root -p grant select,insert,update,delete,lock tables,alter on zm.* to 'zmuser'@localhost identified by 'zmpass'; exit;
mysqladmin -u root -p reload
firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --reload
On Upgrade
1. The Apache ScriptAlias has been changed from "/cgi-bin/zm/zms" to
"/cgi-bin-zm/zms". This has been to done to avoid this bug: https://bugzilla.redhat.com/show_bug.cgi?id=973067
IMPORTANT: ZoneMinder will not update this value during an upgrade. You must manually update ZM_PATH_ZMS yourself under Options. This does not affect new installs.
2. Verify /etc/zm/zm.conf.
If zm.conf was manually edited before running the upgrade, the installation may not overwrite it. In this case, it will create the file /etc/zm/zm.conf.rpmnew.
For example, this will happen if you are using database account credentials other than zmuser/zmpass.
Compare /etc/zm/zm.conf to /etc/zm/zm.conf.rpmnew. Verify that zm.conf contains any new config settings that may be in zm.conf.rpmnew.
3. Verify permissions of the zmuser account.
Overtime, the database account permissions required for normal operation have changed. Verify the zmuser database account has been granted select, insert, update, delete, lock tables, and alter permission to the ZoneMinder database:
mysql -u root -p mysql> show grants for zmuser@localhost; mysql> exit;
4. Verify the database was upgraded automatically.
From the web console, ZoneMinder should show a status of "Running", and the version number should have incremented.
If it is not running, then try to start it. The web console will indicate if there is a database version conflict. If this is the case, then you may need to manually update the database from the command line:
sudo zmupdate.pl
Modern versions of ZoneMinder don't require any parameters added to the zmupdate command. However, if ZoneMinder complains, you may need to call zmupdate in the following manner:
sudo zmupdate.pl --user=root --pass=<mysql_root_pwd> --version=<from version>
Configuration
nano /etc/zm/zm.conf
Notes
You can disable SELINUX if you want.
sudo setenforce 0
To permanently disable SELinux, edit /etc/selinux/conf and change the SELINUX line from "enforcing" to "disabled". This change will take effect after a reboot.