Méthode POST de type READ qui permet de récupérer des données d'hôtes et éventuellement de ses checks, comme sur l'interface de visualisation :
Cet appel utilise les 4 paramètres suivants :
Voir la page V2 - Les paramètres des API du broker-module-livedata , pour leur description complète.
| Codes de retour | Explications |
|---|---|
| 200 | OK |
| 400 | Paramètre invalide |
| 401 | Accès nécessite une authentification ou un Token valide. |
| 403 | Authentification de l'utilisateur OK, mais droits non suffisant. |
| 500 | L'appel est valide, mais un problème d'exécution est rencontré. |
Les propriétés retournées doivent être choisies avec l'option output_field.
Mais les propriétés suivantes seront au minimum automatiquement retournées :
Voir la page V2 - Les propriétés présentes dans le retour 200 des API du broker-module-livedata , pour la description complète de toutes les propriétés pouvant être renvoyée.
Suivant le paramètre output_format ( checks_attached_to_father / elements_on_same_level )
checks_attached_to_father:
elements_on_same_level:
curl -s -S -H 'x-api-token: XYZ' \ -d "output_format=checks_attached_to_father" \ http://broker-module-livedata:50100/api/v2/hosts |
curl -s -S -H 'x-api-token: XYZ' \ -d "output_format=elements_on_same_level" \ http://broker-module-livedata:50100/api/v2/hosts |
{
"request_statistics": {
"nb_elements_total": 9,
"nb_hosts_total": 4,
"nb_checks_total": 4,
"nb_elements_filtered": 7,
"nb_hosts_filtered": 4,
"nb_checks_filtered": 3
},
"elements_found": {
"clusters": [],
"hosts": [
{
"father_uuid": "2c6dcf1aba1611ebaa7d0800277faebe",
"father_name": "Bordeaux",
"checks": [
{
"check_name": "CPU Stats",
"check_uuid": "2c6dcf1aba1611ebaa7d0800277faebe-c296d75e5ad911e58cc5080027f08538"
},
{
"check_name": "Disks Stats",
"check_uuid": "2c6dcf1aba1611ebaa7d0800277faebe-c29735965ad911e58cc5080027f08538"
}
]
},
{
"father_uuid": "8db8b5f0ba1611eba60d0800277faebe",
"father_name": "Lyon",
"checks": []
},
{
"father_uuid": "76f45d80ba1e11eba2670800277faebe",
"father_name": "Nantes",
"checks": [
{
"check_name": "CPU Stats",
"check_uuid": "76f45d80ba1e11eba2670800277faebe-c296d75e5ad911e58cc5080027f08538"
}
]
},
{
"father_uuid": "e5460dc2ba1611eb81580800277faebe",
"father_name": "Rennes",
"checks": []
}
]
}
} |
{
"request_statistics": {
"nb_elements_total": 9,
"nb_hosts_total": 4,
"nb_checks_total": 4,
"nb_elements_filtered": 7,
"nb_hosts_filtered": 4,
"nb_checks_filtered": 3
},
"elements_found": [
{
"father_uuid": "2c6dcf1aba1611ebaa7d0800277faebe",
"father_name": "Bordeaux",
"type": "host"
},
{
"check_name": "CPU Stats",
"check_uuid": "2c6dcf1aba1611ebaa7d0800277faebe-c296d75e5ad911e58cc5080027f08538",
"father_uuid": "2c6dcf1aba1611ebaa7d0800277faebe",
"father_name": "Bordeaux",
"type": "check_host"
},
{
"check_name": "Disks Stats",
"check_uuid": "2c6dcf1aba1611ebaa7d0800277faebe-c29735965ad911e58cc5080027f08538",
"father_uuid": "2c6dcf1aba1611ebaa7d0800277faebe",
"father_name": "Bordeaux",
"type": "check_host"
},
{
"father_uuid": "8db8b5f0ba1611eba60d0800277faebe",
"father_name": "Lyon",
"type": "host"
},
{
"father_uuid": "76f45d80ba1e11eba2670800277faebe",
"father_name": "Nantes",
"type": "host"
},
{
"check_name": "CPU Stats",
"check_uuid": "76f45d80ba1e11eba2670800277faebe-c296d75e5ad911e58cc5080027f08538",
"father_uuid": "76f45d80ba1e11eba2670800277faebe",
"father_name": "Nantes",
"type": "check_host"
},
{
"father_uuid": "e5460dc2ba1611eb81580800277faebe",
"father_name": "Rennes",
"type": "host"
}
]
} |
curl -s -S -H "x-api-token: XYZ" \ -d "parametre_inconnu=is_status_:true" \ http://broker-module-livedata:50100/api/v2/hosts |
ERROR 400: POST parameter [ parametre_inconnu ] is unknown |
( voir la page V2 - Les paramètres des API du broker-module-livedata#filterX )
curl -s -S -H "x-api-token: XYZ" \ -d "filter01=is_status_:true" \ http://broker-module-livedata:50100/api/v2/hosts |
ERROR 400: filtering[0]: invalid field name [ is_status_ ] |
curl -s -S -H "x-api-token: XYZ" \ -d "filter0=next_check" \ http://broker-module-livedata:50100/api/v2/hosts |
ERROR 400: filtering[0]: missing value for field [ next_check ] |
curl -s -S -H "x-api-token: XYZ" \ -d "filter0=status:9" \ http://broker-module-livedata:50100/api/v2/hosts |
ERROR 400: filtering[0]: field [ status ] => wrong value [u'9'] |
curl -s -S -H "x-api-token: XYZ" \ -d "filter0=next_check:avant" \ http://broker-module-livedata:50100/api/v2/hosts |
ERROR 400: filtering[0]: field [ next_check ] unknown date constraint [ avant ] |
curl -s -S -H "x-api-token: XYZ" \ -d "filter0=next_check:in-less-than|hier" \ http://broker-module-livedata:50100/api/v2/hosts |
ERROR 400: filtering[0]: field [ next_check ] => [ in-less-than ] => invalid literal for int() with base 10: 'hier' |
( voir la page V2 - Les paramètres des API du broker-module-livedata )
curl -s -S -H "x-api-token: XYZ" \ -d "sort=host" \ http://broker-module-livedata:50100/api/v2/hosts |
ERROR 400: sort: invalid field name [ host ] |
curl -s -S -H "x-api-token: XYZ" \ -d "sort=father_name:big" \ http://broker-module-livedata:50100/api/v2/hosts |
ERROR 400: sort: invalid sort direction [ big ] for field [ father_name ] |
( voir la page V2 - Les paramètres des API du broker-module-livedata )
curl -s -S -H "x-api-token: XYZ" \ -d "output_format=vrai" \ http://broker-module-livedata:50100/api/v2/hosts |
ERROR 400: output_format: invalid value [ vrai ] |
( voir la page V2 - Les paramètres des API du broker-module-livedata )
curl -s -S -H "x-api-token: XYZ" \ -d "output_field=is_status_" \ http://broker-module-livedata:50100/api/v2/hosts |
ERROR 400: output_field: invalid field name [ is_status_ ] |