Raspberry Pi 2 vnstat.service

This forum is for topics dealing with problems with software specifically in the ARMv7h repo.

Raspberry Pi 2 vnstat.service

Postby chub » Fri May 06, 2016 7:18 am

Hello, this is my first post on any Arch forum. I jumped straight to Arch for arm, because I have a little bit of Gentoo background. (compiling on the Raspberry Pi 2 didn't seem feasible at the time).

So here is my problem: I've been trying to adjust the vnstat.service file to run like the vnstatd manual says. What I'm trying to do is to correct the missing pidfile. I need this pidfile for scripts that I need to signal the main instance/daemon. Currently the way it starts up, doesn't seem to create a pidfile.

$this->bbcode_second_pass_code('', '# cat /lib/systemd/system/vnstat.service
[Unit]
Description=vnStat network traffic monitor
Documentation=man:vnstatd(1) man:vnstat(1) man:vnstat.conf(5)
After=network.target

[Service]
ExecStart=/usr/sbin/vnstatd -n
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
')
Now my knowledge on systemd is limited, but it seems it is currently set as Type=simple (or implied) and that the application will not fork into the background and that systemd will on it's behalf. However, if the application is called in this way, then it will not create the pidfile.

$this->bbcode_second_pass_code('', '# vnstatd -n')
Followed by running in another terminal:
$this->bbcode_second_pass_code('', '# ls -la /var/run/vnstat/vnstat.pid
ls: cannot access '/var/run/vnstat/vnstat.pid': No such file or directory')
If I change the command to the following:
$this->bbcode_second_pass_code('', '# vnstatd --daemon')
Checking for the pidfile:
$this->bbcode_second_pass_code('', '# ls -la /var/run/vnstat/vnstat.pid
-rw-r--r-- 1 root root 6 May 6 09:07 /var/run/vnstat/vnstat.pid')
And there the pidfile is. I thought, I would now create a custom service file to reflect that. I called mine vnstatd.service and placed it in /etc/systemd/system.

$this->bbcode_second_pass_code('', '# cat /etc/systemd/system/vnstatd.service
[Unit]
Description=vnStat network traffic monitor
Documentation=man:vnstatd(1) man:vnstat(1) man:vnstat.conf(5)
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/vnstatd --daemon
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -TERM $MAINPID

[Install]
WantedBy=multi-user.target')
However, it seems that vnstatd fails to fork into the background, when calling it like this.

So what am I doing wrong? Any help would be appreciated. Thanks!
chub
 
Posts: 7
Joined: Fri May 06, 2016 6:42 am

Re: Raspberry Pi 2 vnstat.service

Postby pepedog » Fri May 06, 2016 8:00 am

Snippets would have been best to do what you did
https://wiki.archlinux.org/index.php/Sy ... n_snippets

But probably a tmpfile is what you need to do
https://wiki.archlinux.org/index.php/Sy ... rary_files
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK


Return to ARMv7h

Who is online

Users browsing this forum: No registered users and 7 guests