How to get service reload timestamp
Andy Pieters
systemd at andypieters.me.uk
Mon Jan 8 17:10:52 UTC 2024
On Mon, 8 Jan 2024 at 11:49, port19 <port19 at port19.xyz> wrote:
> Hi all,
>
> we currently have a monitoring check that alerts us of a service-specific
> config file having changed more recently than the services last restart.
> We retrieve the restart time via `systemctl show <service>
> --property=ActiveEnterTimestamp`.
> Is there a comparably elegant way to retreive the reload timestamp?
> To avoid confusion, by reload I do not mean `systemctl daemon-reload`, I
> mean `systemctl reload <service>`.
>
> Alternatively, is there a way to let systemd handle the reloading of
> services on change of related config files?
>
You didn't say what systemd version you use (mine is 255)
systemctl show httpd | fgrep -i rel
ReloadResult=success
ReloadSignal=1
ExecReload={ path=/usr/bin/httpd ; argv[]=/usr/bin/httpd -k graceful ;
ignore_errors=no ; start_time=[Mon 2024-01-08 17:08:45 GMT] ;
stop_time=[Mon 2024-01-08 17:08:45 GMT] ; pid=1476187 ; code=exited ;
status=0 }
ExecReloadEx={ path=/usr/bin/httpd ; argv[]=/usr/bin/httpd -k graceful ;
flags= ; start_time=[Mon 2024-01-08 17:08:45 GMT] ; stop_time=[Mon
2024-01-08 17:08:45 GMT] ; pid=1476187 ; code=exited ; status=0 }
ManagedOOMMemoryPressureLimit=0
CanReload=yes
So with a bit of awk you can get at it this way
failing that, every reload is actually done via an ExecReload command in
the service file, so you could intercept this with your own command instead
NeedDaemonReload=no
>
> Best,
> port19
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20240108/7c1aae20/attachment-0001.htm>
More information about the systemd-devel
mailing list