Jul 022015
 

Time has come, I need to start switching my mentality from SysV to modern init systems. Turns out, that systemd thingy is not so bad! Actually, it’s pretty cool.

There is an interesting video from RedHat Summit 2015 (at the bottom of this page) which I wholeheartedly recommend, especially it doesn’t solely apply to Red Hat – Debian Jessie uses systemd too.

My notes for impatient:

 

  • Slice (each gets CPUShares=1024)
    user.slice
    system.slice # services
    machine.slice #vms, containers, etc
  • Scope
  • Service

 

systemctl list-unit-files --no-pager|grep lvm
systemctl -t service list-unit-files
systemctl -t service
systemctl -t socket
systemctl -t socket list-unit-files
systemctl get-default
systemctl set-default multi-user  # runlevel 3, no GUI
systemctl set-default graphical.target # aka runlevel 5, graphical.target
systemctl list-timers # can be used to periodically run fstrim for example?
systemd-delta # what changed on system comparing to originally shipped by distributor
systemctl rescue
systemctl emergency
systemd-cgtop # this is cool!
systemd-cgls
journalctl # logging. Trusted and untrusted fields in logs, untrusted are generated by logging app
journalctl -xn
journalctl -k -b -1
journalctl /dev/sda
journalctl /usr/bin/python-thinlinc
journalctl _SYSTEMD_UNIT=avahi-daemon.service

Checkout systemd based containers! Didn’t expect that

man systemd-nspawn
mkdir /var/lib/container/debian-tree
debootstrap --arch=amd64 unstable /var/lib/container/debian-tree/
systemd-nspawn -D /var/lib/container/debian-tree/

or assuming you have a bridge

systemd-nspawn --network-bridge=br-eth0 -D /var/lib/container/ka-lite

This installs a minimal Debian unstable distribution into the directory /var/lib/container/debian-tree/ and then spawns a shell in a namespace container in it. Wow. I know you can use like Linux Containers but this systemd-nspawn is already there waiting to be used.

Have fun.


 

Jun 162015
 

Intro

Sadly, Zoneminder is not available in Debian 8. Here you can find my recipe for building debian package and installing Zoneminder, currently version 1.28.1 from git. Based on slightly amended instructions for Debian 8 Jessie from README.md

insta-16

Prerequisite

aptitude install -y apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg8 apache2-mpm-prefork libapache2-mod-php5 php5-cli libphp-serialization-perl libavcodec-dev libavformat-dev libswscale-dev libavutil-dev libv4l-dev libtool ffmpeg libnetpbm10-dev libavdevice-dev libmime-lite-perl dh-autoreconf dpatch

Build

cd /usr/src
git clone https://github.com/ZoneMinder/ZoneMinder.git zoneminder;
cd zoneminder
ln -s distros/debian8 debian
dpkg-checkbuilddeps # and apt install if anything is missing

vim zoneminder/debian/changelog # add new version on top with email address matching your GPG key and then

dpkg-buildpackage

 

Installation

One level above should hopefully find a deb package matching the architecture of the build host:

ls -l /usr/src/zoneminder*.deb
cd /usr/src
for i in `ls *.deb`;do echo "------------- $i";dpkg -i $i;done
apt-get install -f
dpkg-reconfigure zoneminder

 

Lets see:

systemctl status zoneminder

 zoneminder.service - ZoneMinder CCTV recording and security system
 Loaded: loaded (/lib/systemd/system/zoneminder.service; enabled)
 Active: active (running) since Tue 2015-06-16 13:28:12 BST; 3min 21s ago
 Main PID: 5602 (zmdc.pl)
 CGroup: /system.slice/zoneminder.service
 /usr/bin/perl -wT /usr/bin/zmdc.pl startup
 /usr/bin/perl -wT /usr/bin/zmfilter.pl
 /usr/bin/perl -wT /usr/bin/zmaudit.pl -c
 /usr/bin/perl -wT /usr/bin/zmwatch.pl
 /usr/bin/perl -w /usr/bin/zmupdate.pl -c
 Jun 16 13:28:11 sambor.home zmdc[5632]: INF ['zmaudit.pl -c' started at 15/06/16 13:28:11]
 Jun 16 13:28:11 sambor.home zmfilter[5626]: INF [Scanning for events]
 Jun 16 13:28:11 sambor.home zmdc[5638]: INF ['zmwatch.pl' started at 15/06/16 13:28:11]
 Jun 16 13:28:11 sambor.home zmdc[5602]: INF ['zmwatch.pl' starting at 15/06/16 13:28:11, pid = 5638]
 Jun 16 13:28:12 sambor.home zmwatch[5638]: INF [Watchdog starting]
 Jun 16 13:28:12 sambor.home zmwatch[5638]: INF [Watchdog pausing for 30 seconds]
 Jun 16 13:28:12 sambor.home zmdc[5602]: INF ['zmupdate.pl -c' starting at 15/06/16 13:28:12, pid = 5645]
 Jun 16 13:28:12 sambor.home zmdc[5645]: INF ['zmupdate.pl -c' started at 15/06/16 13:28:12]
 Jun 16 13:28:12 sambor.home zmupdate[5645]: INF [Checking for updates]
 Jun 16 13:28:12 sambor.home zmupdate[5645]: INF [Got version: '1.28.1']

Well, well, well. Look who’s up and running!

Configuration

Alright, we can now connect to server IP address and start adding monitors

http://10.10.0.231/zm/index.php

Start with checking your cameras:

zmu -d /dev/video0 -q -v

It took me a while to experiment with settings and find the most optimal configuration. My camera is connected via BT878 video card and it worked with

Capture Method v4l2
 Device Channel 1
 Device Format NTSC
 Capture Pallet Auto
 Target Colorspace 32bit
 Capture Width 768
 Capture Height 480
 # although Crop Capabilities in debug advertised it as 924 x 576
 

I use it in Mocord mode.

Last hint, make sure you have plenty of space to store data produced by Zoneminder.
I have changed symlinks /usr/share/zoneminder/{events,images,temp} and pointed them to dedicated zfs filesystem with ample of space:

for i in events images temp;do mkdir /tank/zoneminder/$i;ln -s /tank/zoneminder/$i /usr/share/zoneminder/$i:done
 chown www-data. /tank/zoneminder/*

Logging

Is default Zoneminder inclination to log bloody EVERYTHING to blooming EVERYWHERE driving you mad? Well, welcome to the club!

vim /etc/rsyslog.conf

and replace line 62 adding local1.!*

# *.*;auth,authpriv.none -/var/log/syslog
# As per http://www.zoneminder.com/wiki/index.php/Documentation#Logging
*.*;local1.!*;auth,authpriv.none -/var/log/syslog

And restart rsyslog

systemctl restart rsyslog