f5-common-python
f5-common-python copied to clipboard
How to get the status of ntp daemon or other daemons
By typing the command "tmsh show sys service" or "tmsh show sys service ntpd", we can see the status of ntpd daemon. What functions should I used in this SDK to get the status of ntpd daemon? How to get the status of ntp daemon or other daemons?
Doesn't look like we have a native sdk support for that functionality. I was looking at the source and some design decisions around top level objects for named and unnamed resources would take quite a bit of refactoring to support that and we're in maintenance mode on this library now that F5 is now primarily focusing on the declarative models presented with DO/AS3/TS.
As a workaround, you can use the sdk bash utility to do so. This isn't that problematic for this instance in particular, as even the json data returned by the /tm/sys/service/ntpd/stats endpoint is just a long text string in the apiAnonymous attribute similar to what you'll receive from bash query.
>>> ntpd_status = b.tm.util.bash.exec_cmd('run', utilCmdArgs='-c "tmsh show sys service ntpd"')
>>> from pprint import pprint as pp
>>> pp(ntpd_status.commandResult)
('* ntpd.service - LSB: start and stop ntpd\n'
' Loaded: loaded (/etc/rc.d/init.d/ntpd; bad; vendor preset: disabled)\n'
' Active: active (running) since Tue 2019-09-10 18:04:16 CDT; 3 weeks 5 '
'days ago\n'
' Docs: man:systemd-sysv-generator(8)\n'
' Process: 4955 ExecStart=/etc/rc.d/init.d/ntpd start (code=exited, '
'status=0/SUCCESS)\n'
' CGroup: /system.slice/ntpd.service\n'
' `-4973 ntpd -g\n'
'\n'
'Oct 07 14:23:04 ltm3.test.local ntpd[4973]: Listen normally on 28 lo:1 '
'127.2.0.2 UDP 123\n'
'Oct 07 14:23:04 ltm3.test.local ntpd[4973]: Listen normally on 29 lo ::1 UDP '
'123\n'
'Oct 07 14:23:04 ltm3.test.local ntpd[4973]: Listen normally on 30 mgmt '
'fe80::20c:29ff:fe21:ad39 UDP 123\n'
'Oct 07 14:23:04 ltm3.test.local ntpd[4973]: Listen normally on 31 eth0 '
'fe80::20c:29ff:fe21:ad39 UDP 123\n'
'Oct 07 14:23:04 ltm3.test.local ntpd[4973]: new interface(s) found: waking '
'up resolver\n'
'Oct 07 14:23:05 ltm3.test.local ntpd[4973]: 0.0.0.0 0528 08 no_sys_peer\n'
'Oct 07 14:23:08 ltm3.test.local ntpd[4973]: Listen normally on 32 mgmt '
'10.0.2.15 UDP 123\n'
'Oct 07 14:23:08 ltm3.test.local ntpd[4973]: new interface(s) found: waking '
'up resolver\n'
'Oct 07 14:24:04 ltm3.test.local ntpd[4973]: Listen normally on 33 eth3 '
'fe80::20c:29ff:fe21:ad57 UDP 123\n'
'Oct 07 14:24:04 ltm3.test.local ntpd[4973]: new interface(s) found: waking '
'up resolver\n')