[systemd-devel] Back trace systemd service unit by pid
aleivag
aleivag at gmail.com
Thu Dec 21 07:21:39 UTC 2017
the simplest way is to use busctl as
aleivag at algx:~$ busctl call org.freedesktop.systemd1
/org/freedesktop/systemd1 org.freedesktop.systemd1.Manager GetUnitByPID u
28729
o "/org/freedesktop/systemd1/unit/nginx_2eservice"
from that you are a awk away of what you want. if you want to get clever
you can always do:
aleivag at algx:~$ busctl call org.freedesktop.systemd1
/org/freedesktop/systemd1 org.freedesktop.systemd1.Manager GetUnitByPID u
28729 | awk '{print $2}' | xargs -i busctl get-property
org.freedesktop.systemd1 {} org.freedesktop.systemd1.Unit Id
s "nginx.service"
But depending on what you want, if you are not bound to use a shell, you
can try using sd-bus.h in you code.
Alvaro Leiva
On Wed, Dec 20, 2017 at 9:48 PM, Kevin Hsu <hsukvn at gmail.com> wrote:
> Hi folks,
>
> I am looking for a good way to backtrace systemd service by a process id.
> The "systemctl status <pid>" command is available to do the magic. It will
> show a full status of the service that creates the
> pid. But this command gives too many details. The only thing I need is the
> service unit name. Is there any simple way instead of parsing results from
> "systemctl status" ?
>
> For example like
>
> > systemctl service-get 5566
> > nginx.service
>
>
> Thanks,
> Kevin Hsu
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20171220/1090ae48/attachment.html>
More information about the systemd-devel
mailing list