iperf service with systemd

Issues related to applications and software problems
Post Reply
yugher
Posts: 18
Joined: 2017/02/13 19:24:40

iperf service with systemd

Post by yugher » 2019/05/08 20:07:07

Hi,
I am trying to create a very simple systemd unit service, in attemp to manage "iperf" (bandwidth measurement tool).

I installed iperf with yum and created this file:
# cat /etc/systemd/system/iperf.service
[Unit]
Description=iperf
After=network.target

[Service]
ExecStart=/usr/bin/iperf -s -D
ExecStop=/usr/bin/killall -9 iperf
Type=forking
PIDFile=/var/run/iperf.pid

[Install]
WantedBy=default.target
If I run systemctl start iperf, it hangs and I never return to bash. Anyway, service is started:
# systemctl status iperf
● iperf.service - iperf
Loaded: loaded (/etc/systemd/system/iperf.service; disabled; vendor preset: disabled)
Active: activating (start) since Wed 2019-05-08 21:52:46 CEST; 4s ago
Process: 18776 ExecStart=/usr/bin/iperf -s -D (code=exited, status=0/SUCCESS)
CGroup: /system.slice/iperf.service
└─18777 /usr/bin/iperf -s -D

May 08 21:52:46 jus systemd[1]: Starting iperf...
May 08 21:52:46 jus iperf[18776]: Running iperf
May 08 21:52:46 jus systemd[1]: PID file /var/run/iperf.pid not readable (yet?) after start.
# ps aux |grep iperf
root 18770 0.0 0.0 134820 1292 pts/2 S+ 21:52 0:00 systemctl start iperf
root 18777 0.0 0.0 98952 412 ? Ssl 21:52 0:00 /usr/bin/iperf -s -D
root 18783 0.0 0.0 112708 944 pts/0 S+ 21:53 0:00 grep --color=auto iperf
I also tried with Type=simple, this way service seems to start, but I get:

systemctl status iperf
● iperf.service - Iperf Bandwidth Test Service
Loaded: loaded (/etc/systemd/system/iperf.service; disabled; vendor preset: disabled)
Active: inactive (dead)
May 08 21:54:16 jus systemd[1]: iperf.service start operation timed out. Terminating.
May 08 21:54:16 jus systemd[1]: Failed to start iperf.
May 08 21:54:16 jus systemd[1]: Unit iperf.service entered failed state.
May 08 21:54:16 jus systemd[1]: iperf.service failed.
May 08 21:54:33 jus systemd[1]: Started iperf.
May 08 21:54:33 jus iperf[18815]: Running Iperf Server as a daemon
May 08 21:54:49 jus systemd[1]: Started iperf.
May 08 21:54:49 jus iperf[18834]: Running Iperf Server as a daemon
May 08 21:55:18 jus systemd[1]: Started iperf.
May 08 21:55:18 jus iperf[18870]: Running Iperf Server as a daemon


What is my error?
Thank you!

yugher
Posts: 18
Joined: 2017/02/13 19:24:40

Re: iperf service with systemd

Post by yugher » 2019/05/08 21:39:27

I just found this:

https://gist.github.com/mmasaki/3147f23fca698da9ff79

and works fine.

It seems "-D" (daemonize) option is not a good thing in my previous systemd unit file, which doesn't make sense for me.
Can anyone explain me this?
Thank you!

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: iperf service with systemd

Post by aks » 2019/05/09 17:21:51

I guess the -D code actually does the things that systemd does now (i.e.: make it a TSR - only to show how old I am). :D

Post Reply