Спасибо за ответ, я взял пример с вашего ответа. Я также создал функции для получения данных с монитора. Затем я создам файл json для отображения данных с помощью Datables, например:
#!/usr/bin/python
import bigsuds
import re
import datetime
import json
# Fonction pour recuperer les strings d'un moniteur
def get_moniteur_type(obj, monitor):
try:
return obj.LocalLB.Monitor.get_template_type([monitor])[0]
except Exception, e:
print e
# Fonction pour recuperer les strings d'un moniteur
def get_stype_string(obj, monitor, stype):
try:
return obj.LocalLB.Monitor.get_template_string_property([monitor],[stype])[0]['value']
except Exception, e:
print e
# Fonction reverse sur la reponse attendue a un test applicatif, si true, on ne doit pas avoir la reponse indiquee dans la receive string
def get_reverse_mode(obj, monitor):
try:
return obj.LocalLB.Monitor.get_template_reverse_mode([monitor])[0]
except Exception, e:
print e
# Fonction pour recuperer l'intervalle et le timeout d'un moniteur
def get_itype_string(obj, monitor, itype):
try:
return obj.LocalLB.Monitor.get_template_integer_property([monitor],[itype])[0]['value']
except Exception, e:
print e
# Fonction pour recuperer le port utilise par le moniteur
def get_moniteur_port(obj, monitor):
try:
return obj.LocalLB.Monitor.get_template_destination([monitor])[0]['ipport']['port']
except Exception, e:
print e
# Information de connexion au F5
try:
b = bigsuds.BIGIP(
hostname = "server-f5.domaine",
username = "user",
password = "password",
)
except Exception, e:
print e
#On recupere tous les moniteurs present dans la partition Common, qui est l'emplacement des moniteurs crees par le reseau
b.Management.Partition.set_active_partition(active_partition='Common')
noms_long = b.LocalLB.Monitor.get_template_list()
#On boucle sur les noms des moniteurs en filtrant ceux crees pour dune
for nom in noms_long:
#On supprime \Common\ dans le nom long pour avoir le nom du moniteur
moniteur = format(nom['template_name'])[8:]
#On ne va recuperer que les moniteurs qui commencent par"startname"
if re.match(r'^startname', moniteur):
print "{ \"moniteur\": \"",moniteur,"\", \"type\": \"",get_moniteur_type(b, moniteur),"\", \"requette_http\": \"",get_stype_string(b, moniteur, "STYPE_SEND"),"\", \"reponse_attendue\": \"",get_stype_string(b, moniteur, "STYPE_RECEIVE"),"\", \"mode_reverse\": \"",get_reverse_mode(b, moniteur),"\", \"timeout\": \"",get_itype_string(b, moniteur, "ITYPE_TIMEOUT"),"\", \"intervale\": \"",get_itype_string(b, moniteur, "ITYPE_INTERVAL"),"\", \"port\": \"",get_moniteur_port(b, moniteur),"\", \"type\": \"",get_moniteur_type(b, moniteur),"\"},"
В этом примере меня интересует восстановление после теста приложения, отправленного запроса и ожидаемого ответа или нет, но в целом у меня могут быть тесты для определенного порта или тесты UDP. Это все о наличии основных данных.