Forum Discussion
Using the Python SDK for monitors
I'm starting to use the python SDK and I can't figure out how to access the monitor objects on the BIGIP.
Here's my code for displaying the nodes
from f5.bigip import ManagementRoot
mgmt = ManagementRoot('IP Address', 'user', 'password)
nodes = mgmt.tm.ltm.nodes
for node in nodes.get_colletion():
print(node.name)
Here's my code for displaying the monitors
from f5.bigip import ManagementRoot
mgmt = ManagementRoot('ip address', 'user', 'password')
monitors = mgmt.tm.ltm.monitors
for monitor in monitors.get_collection()
print(monitor.name)
I read the documentation located http://f5-sdk.readthedocs.io/en/latest/index.html
The difference between monitors and node in the documentation is the (star) * is separated by colon in the node portion. Don't know if that makes a difference. REST Kind -> tm:ltm:monitors* REST Kind -> tm:ltm:node:*
Any thoughts would help
4 Replies
- Ed_Summers
Nimbostratus
(YMMV depending on version. I'm using version 12.1.2.)
'monitor' is another collection with the various monitor types underneath it. If you just get the collection from 'monitor' you'll have a list of reference links to the sub-collections underneath it. One way of getting an actual list of monitors is to get the collection of the specific monitor type:
>>> https_monitors = mgmt.tm.ltm.monitor.https_s.get_collection() >>> for mon in https_monitors: ... print(mon.name) ...
Reminder that since the monitor objects are collections, they'll end in 's', or '_s' if the resource already ends in 's'. Example: to get https monitors, use 'https_s'. To get http monitors, use 'https'.
Apologies if I've butchered SDK terminology on collections/sub-collections. I'm still getting used to the environment myself.
- Daniel_Tremmel
Altostratus
Hi guys,
how can I create a new monitor using the Python SDK?
Unfortunately
monitor = mgmt.tm.ltm.monitors.monitor.create(partition='Common', name='MyMonitor01')
is not working.
AttributeError: '' object has no attribute 'monitors'
regards
Daniel
- Rob_74473
Cirrus
I'm trying to get a list of all available monitors. Is there a way to loop through the monitor types to then do a get_collection():
for monitor in mgmt.tm.ltm.monitor.get_collection(): for item in monitor.get_collection(): pprint(item)
This clearly doesn't work
- Rob_74473
Cirrus
It seems I'm not allowed to edit an answer...
What I'm trying to achieve is a select field in a web page that mirrors the behavior of the Health Monitors section of a pool properties page in the BigIP gui, so that I can add/remove monitors from a pool through the rest api.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com