System Configuration
This sections describes how the operating system has to be configured in order to run the DMPACK programs:
-
Message Queues – Enable message passing on Linux and FreeBSD (required).
-
Time Zone – Set the correct time zone of the sensor node.
-
Time Synchronisation – Enable synchronisation with an NTP server.
-
Power Saving – Disable USB power saving on Linux.
-
Cron – Add cron jobs to run programs periodically.
Message Queues
The sensor node must have POSIX message queues enabled.
Linux
The POSIX message queue file system should already be mounted at /dev/mqueue
by default. Otherwise, run:
# mkdir -p /dev/mqueue # mount -t mqueue none /dev/mqueue
Set the maximum number of messages and the maximum message size to some reasonable values, for example:
# sysctl fs.mqueue.msg_max=32 # sysctl fs.mqueue.msgsize_max=16384
The maximum message size has to be at least 16384 bytes. Add the settings to
/etc/sysctl.conf
to make them permanent:
fs.mqueue.msg_max=32
fs.mqueue.msgsize_max=16384
FreeBSD
On FreeBSD, make sure the kernel module mqueuefs
is loaded, and the message
queue file system is mounted:
# kldstat -m mqueuefs Id Refs Name 522 1 mqueuefs
Otherwise, we can simply load and mount the file system:
# kldload mqueuefs # mkdir -p /mnt/mqueue # mount -t mqueuefs null /mnt/mqueue
To load messages queues at system start, add the module mqueuefs
to
/etc/rc.conf
, and the file system to /etc/fstab
:
# sysrc kld_list+="mqueuefs" # echo "null /mnt/mqueue mqueuefs rw 0 0" >> /etc/fstab
Additionally, we may increase the system limits of POSIX message queues with
sysctl(8), or in /etc/sysctl.conf
. The defaults are:
# sysctl kern.mqueue.maxmsg kern.mqueue.maxmsg: 32 # sysctl kern.mqueue.maxmsgsize kern.mqueue.maxmsgsize: 16384
The maximum message size has to be at least 16384 bytes.
Time Zone
The local time zone of the sensor client should be set to a zone without summer
daylight-saving. For instance, time zone Europe/Berlin
implies Central
European Summer Time (CEST), which is usually not desired for long-term
observations, as it leads to time jumps. Instead, use time zone GMT+1
or UTC
in this case.
Linux
On Linux, list all time zones and set the preferred one with timedatectl(1):
# timedatectl list-timezones # timedatectl set-timezone Etc/GMT+1
FreeBSD
On FreeBSD, configure the time zone using:
# tzsetup
Time Synchronisation
The system time should be updated periodically by synchronising it with network time servers. A Network Time Protocol (NTP) client has to be installed and configured to enable the synchronisation.
Linux
On Debian Linux, install the NTP package:
# apt-get install ntp
Query the NTP servers to synchronise with:
# ntpq -p
The system time should be updated now:
# date -R
On error, try to reconfigure the NTP service:
# dpkg-reconfigure ntp
FreeBSD
Set the current date and time intially by passing the IP or FQDN of the NTP server to ntpdate(1):
# ntpdate -b ptbtime1.ptb.de
The NTP daemon ntpd(8) is configured through file /etc/ntp.conf
. If
favoured, we can replace the existing NTP server pool 0.freebsd.pool.ntp.org
with a single server, for example:
server ptbtime1.ptb.de iburst
Add the following entries to /etc/rc.conf
:
ntpd_enable="YES"
ntpd_sync_on_start="YES"
ntpd_flags="-g"
Start the ntpd(8) service:
# service ntpd start
Power Saving
On Linux, power saving for USB devices may be enabled by default. This can cause
issues if sensors are attached through an USB adapter. USB power saving is
enabled if the kernel boot parameter usbcore.autosuspend
is not -1
:
# cat /sys/module/usbcore/parameters/autosuspend 2
We can update the boot loader to turn auto-suspend off. Edit /etc/default/grub
and change GRUB_CMDLINE_LINUX_DEFAULT
to:
GRUB_CMDLINE_LINUX_DEFAULT="quiet usbcore.autosuspend=-1"
Then, update the boot loader:
# update-grub
The system has to be rebooted for the changes to take effect.
Cron
On Unix-like operating system, cron is
usually used to run jobs periodically. For instance, in order to update an XML
feed or to generate HTML reports at regular intervals, add a schedule of the
task to perform to the crontab(5) file of a local user. For example, to edit
the cron jobs of user www
with crontab(1) run:
# crontab -u www -e
The following crontab(5) entry adds a job to generate reports every hour,
using utility script mkreport.sh
:
SHELL=/bin/sh
MAILTO=/dev/null
# Create reports every hour, suppress logging.
@hourly -q /usr/local/share/dmpack/dmreport/mkreport.sh
Alter script mkreport.sh
to your set-up. Status mails and logging are
disabled. The shell script mkreport.sh
must have the execution bits set.
Modify the script according to your set-up. The parameter -q
disables syslog
messages. Additionally, we may update an Atom XML feed of logs by running
dmfeed every five minutes:
*/5 * * * * -q /usr/local/bin/dmfeed --config /usr/local/etc/dmpack/dmfeed.conf
The feed is updated only if new logs have arrived in the meantime, unless option
--force
is passed as an additional argument.