[PATCH] tbot_contrib/utils.py: collect some usefull linux utils

Wolfgang Denk wd at denx.de
Mon Apr 20 21:15:18 CEST 2020


Dear Harald,

In message <d77523ba0ac9577cb1dfcb75da1c7b756f11a9a9.camel at denx.de> you wrote:
>
> > +        ret = lnx.exec("systemctl", "status", s, "--no-pager")
> > +        if ret[0] != 0:
>
> I think it is more robust to use `systemctl is-active` for this check.
> Also, you can use `lnx.test()` which makes this a bit more concise:

Actually it is not.  For example, consider "tftp.service".
On deman, systemd will start /usr/sbin/in.tftpd, and intis state
systemctl will indeed report "is-active".  After the inactivity
timeout, in.tftpd will terminate itself, to be restarted only upon a
new tftp request.  In _this_ situation systemctl will report that
tftp is NOT active:

-> systemctl status tftp
tftp.service - Tftp Server
   Loaded: loaded (/usr/lib/systemd/system/tftp.service; indirect; vendor preset: disabled)
   Active: inactive (dead) since Sun 2020-04-19 20:42:20 CEST; 17h ago
     Docs: man:in.tftpd
  Process: 2639904 ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot (code=exited, status=0/SUCCESS)
 Main PID: 2639904 (code=exited, status=0/SUCCESS)
      CPU: 510ms

Apr 19 20:23:44 pollux.denx.de systemd[1]: Started Tftp Server.
...
Apr 19 20:42:20 pollux.denx.de systemd[1]: tftp.service: Succeeded.

-> systemctl is-active tftp
inactive
-> tftp localhost
tftp> get ...
tftp> quit
-> systemctl is-active tftp
active

>From the tftpd man page:

       --timeout timeout, -t timeout
              When run from inetd this specifies how long, in
              seconds, to wait for a second connection before
              terminating the server. inetd will then respawn the
              server when another request comes in. The default is
              900 (15 minutes.)

I agree this is pretty unexpected behaviour, and I even tend to call
it a bug, but then - who am I to criticise systemd and related
tools...

So Heiko's approach indeed makes sense.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Never worry about theory as long as  the  machinery  does  what  it's
supposed to do.                                      - R. A. Heinlein


More information about the tbot mailing list