Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Make by tools (01.00.01) - action=clean_macro_parameter
Scroll Ignore
scroll-viewporttrue
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-htmlfalse
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtruescroll-htmlfalse
Panel
titleSommaire

Table of Contents
stylenone

Objectifs

/api/v2/inventory est une Méthode POST de type READ qui permet de récupérer des données de supervision, comme sur l'Interface de Visualisation,

  • Filtrées ( optionnel )
  • Triées
  • Rangées :
    • En arbres ( hôtes/clusters => checks )
    • Tous au même niveau

Le BUT de cette route étant d'obtenir un annuaire synthétique des éléments supervisés.

  • Il n'est pas possible de choisir les propriétés affichées en sortie.

Les Paramètres

Cet appel utilise seulement les 3 paramètres suivants :

  • filterX
  • sort
  • output_format


Voir ( voir la page pageV2 - Les paramètres des API du broker-module-livedata - Les paramètres ), pour leur description complète.

Réponse

Codes de retour

Codes de retourExplications
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é.

Retour du code 200

Les propriétés retournées sont :

  • nb_element
  • type (si le paramètre output_format vaut elements_on_same_level )
  • father_uuid
  • father_name
  • par check :
    • check_uuid
    • check_name


Voir ( voir la page pageV2 - Les propriétés présentes dans le retour 200 des API du broker-module-livedata - les propriétés présentes dans le retour 200, pour leur description complète )


Le retour aura une forme différente en fonction du paramètre output_format :

checks_attached_to_father:


  • request_statistics
    • ...
  • elements_found :
    • clusters :
      • cluster1:
        • father_uuid : text
        • father_nametext
        • checks :
          • check_uuid: textcheck_nametext
          • check_uuid: text, check_nametext
          • ...
      • ...
    • hosts : 
      • host1:
        • father_uuidtext
        • father_name : text
        • checks :
          • check_uuid: text, check_nametext
          • check_uuid: textcheck_nametext
          • ...
      • ...

elements_on_same_level :


  • request_statistics
    • ...
  • elements_found :
    • elem1:
      • type: cluster
      • father_name: text
      • father_uuid : text
    • elem2:
      • type: host
      • father_name: text
      • father_uuid : text
    • elem3:
      • type: check_cluster
      • check_uuidtext
      • check_name: text
      • father_name : text
      • father_uuid : text
    • elem4:
      • type: check_host
      • check_uuid : text
      • check_name: text
      • father_name : text
      • father_uuid : text
    • ...
Code Block
languagebashtext
themeEmacs
curl -s -S -H 'x-api-token: XYZ' \
-d "output_format=checks_attached_to_father" \
http://broker-module-livedata:50100/api/v2/inventory
Code Block
languagetext
themeEmacs
curl -s -S -H 'x-api-token: XYZ' \
-d "output_format=elements_on_same_level" \
http://broker-module-livedata:50100/api/v2/inventory

Exemple de de sortie attendue :

Code Block
languagebash
themeRDark
titlehttp://localhost:50100/api/v2/inventory
{
  "request_statistics": {
titlehttp://localhost:50100/api/v2/inventory
{
  "request_statistics": {
    "nb_elements_total": 9,
    "nb_hosts_total": 4,
    "nb_elements_total": 9,
    "nb_hosts_total": 4,
    "nb_clusters_total": 1,
    "nb_checks_total": 4,
    "nb_elements_filtered": 9,
    "nb_hosts_filtered": 4,
    "nb_clusters_filtered": 1,
    "nb_checks_filtered": 4
  },
  "elements_found": {
    "clusters": [
      {
        "father_uuid": "d6921ee8ba1511eba36c0800277faebe",
        "father_name": "datacenter bdx",
        "checks": [
          {
            "check_name": "System Uptime",
            "check_uuid": "d6921ee8ba1511eba36c0800277faebe-e6daad4cba1511eb95980800277faebe"
          }
        ]
      }
    ],
    "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": []
      }
    ]
  }
}

Exemple de de sortie attendue :

code
Code Block
languagebash
themeEmacs
curl -s -S -H 'x-api-token: XYZ' \
-d "output_format=elements_on_same_level" \
http://broker-module-livedata:50100/api/v2/inventory
themeRDark
titlehttp://localhost:50100/api/v2/inventory
{
  "request_statistics": {
    "nb_elements_total": 9,
    "nb_hosts_total": 4,
    "nb_clusters_total": 1,
    "nb_checks_total": 4,
    "nb_elements_filtered": 9,
    "nb_hosts_filtered": 4,
    "nb_clusters_filtered": 1,
    "nb_checks_filtered": 4
  },
  "elements_found": [
    {
      "father_uuid": "2c6dcf1aba1611ebaa7d0800277faebe",
      "father_name": "Bordeaux",
      "type": "host"
    },
    {
      "check_name": "CPU Stats",
      "type": "check_host",
      "father_uuid": "2c6dcf1aba1611ebaa7d0800277faebe",
      "father_name": "Bordeaux",
      "check_uuid": "2c6dcf1aba1611ebaa7d0800277faebe-c296d75e5ad911e58cc5080027f08538"
    },
    {
      "check_name": "Disks Stats",
      "type": "check_host",
      "father_uuid": "2c6dcf1aba1611ebaa7d0800277faebe",
      "father_name": "Bordeaux",
      "check_uuid": "2c6dcf1aba1611ebaa7d0800277faebe-c29735965ad911e58cc5080027f08538"
    },
    {
      "father_uuid": "d6921ee8ba1511eba36c0800277faebe",
      "father_name": "datacenter bdx",
      "type": "cluster"
    },
    {
      "check_name": "System Uptime",
      "type": "check_cluster",
      "father_uuid": "d6921ee8ba1511eba36c0800277faebe",
      "father_name": "datacenter bdx",
      "check_uuid": "d6921ee8ba1511eba36c0800277faebe-e6daad4cba1511eb95980800277faebe"
    },
    {
      "father_uuid": "8db8b5f0ba1611eba60d0800277faebe",
      "father_name": "Lyon",
      "type": "host"
    },
    {
      "father_uuid": "76f45d80ba1e11eba2670800277faebe",
      "father_name": "Nantes",
      "type": "host"
    },
    {
      "check_name": "CPU Stats",
      "type": "check_host",
      "father_uuid": "76f45d80ba1e11eba2670800277faebe",
      "father_name": "Nantes",
      "check_uuid": "76f45d80ba1e11eba2670800277faebe-c296d75e5ad911e58cc5080027f08538"
    },
    {
      "father_uuid": "e5460dc2ba1611eb81580800277faebe",
      "father_name": "Rennes",
      "type": "host"
    }
  ]
} 

Retour du code 400

Paramètres POST incorrects

Paramètre inconnu
Code Block
languagebashtext
themeEmacs
$ curl -s -S -H "x-api-token: XYZ" \
-d "parametre_inconnu=is_status_:true" \
http://broker-module-livedata:50100/api/v2/inventory
ERROR 400: POST parameter [ parametre_inconnu ] is unknown
Panel
borderColor#dfe1e5
borderWidth1
borderStylesolid

ERROR 400: POST parameter [ parametre_inconnu ] is unknown

Paramètre désactivé sur cette route
Code Block
languagebashtext
themeEmacs
$ curl -s -S -H "x-api-token: XYZ" \
-d "output_field=perf_data" \
http://broker-module-livedata:50100/api/v2/inventory:50100/api/v2/inventory
ERROR 400: POST parameter [ output_field ] is not available for this route
Panel
borderColor#dfe1e5
borderWidth1
borderStylesolid

ERROR 400: POST parameter [ output_field ] is not available for this route

Messages d'erreurs des filtres ( filterX )

Filtre inexistant
Code Block
languagebashtext
themeEmacs
$ curl -s -S -H "x-api-token: XYZ" \
-d "filter0=is_status_:true" \
http://broker-module-livedata:50100/api/v2/inventory/v2/inventory
ERROR 400: filtering[0]: invalid field name [ is_status_ ]



Panel
borderColor#dfe1e5
borderWidth1
borderStylesolid

ERROR 400: filtering[0]: invalid field name [ is_status_ ]

Filtre incomplet
Code Block
languagebashtext
themeEmacs
$ curl -s -S -H "x-api-token: XYZ" \
-d "filter0=-d "filter0=next_check" \
http://broker-module-livedata:50100/api/v2/inventory
ERROR 400: filtering[0]: missing value for field [ next_check" \
http://broker-module-livedata:50100/api/v2/inventory ]
Panel
borderColor#dfe1e5
borderWidth1
borderStylesolid

ERROR 400: filtering[0]: missing value for field [ next_check ]

Filtre incorrect
Valeur incorrecte pour ce type de filtre
Code Block
languagebashtext
themeEmacs
$ curl -s -S -H "x-api-token: XYZ" \
-d "filter0=status:9" \
http://broker-module-livedata:50100/api/v2/inventory-livedata:50100/api/v2/inventory
ERROR 400: filtering[0]: field [ status ] => wrong value ['9']
Panel
borderColor#dfe1e5
borderWidth1
borderStylesolid

ERROR 400: filtering[0]: field [ status ] => wrong value [u'9']

Opérateur incorrect
Code Block
languagebashtext
themeEmacs
$ curl -s -S -H "x-api-token: XYZ" \
-d "filter0=next_check:avant" \
http://broker-module-livedata:50100/api/v2/inventory
ERROR 400: filtering[0]: field [ next_check ] unknown date constraint [ avant ]
Panel
borderColor#dfe1e5
borderWidth1
borderStylesolid

ERROR 400: filtering[0]: field [ next_check ] unknown date constraint [ avant ]

Argument incorrect
Code Block
languagebashtext
themeEmacs
$ curl -s -S -H "x-api-token: XYZ" \
-d "filter0=next_check:in-less-than|hier" \
http://broker-module-livedata:50100/api/v2/inventory-module-livedata:50100/api/v2/inventory
ERROR 400: filtering[0]: field [ next_check ] => [ in-less-than ] => invalid literal for int() with base 10: 'hier'
Panel
borderColor#dfe1e5
borderWidth1
borderStylesolid

ERROR 400: filtering[0]: field [ next_check ] => [ in-less-than ] => invalid literal for int() with base 10: 'hier'

Messages d'erreurs liés aux paramètres de tri ( sort )

Propriété inconnu
Code Block
languagebashtext
themeEmacs
$ curl -s -S -H "x-api-token: XYZ" \
-d "sort=host" \
http://broker-module-livedata:50100/api/v2/inventory/v2/inventory
ERROR 400: sort: invalid field name [ host ]
Panel
borderColor#dfe1e5
borderWidth1
borderStylesolid

ERROR 400: sort: invalid field name [ host ]

Ordre de tri incorrect
Code Block
languagebashtext
themeEmacs
$ curl -s -S -H "x-api-token: XYZ" \
-d "sort=father_name:big" \
http://broker-module-livedata:50100/api/v2/inventory
ERROR 400: sort: invalid sort direction [ big ] for field [ host_name ]
Panel
borderColor#dfe1e5
borderWidth1
borderStylesolid

ERROR 400: sort: invalid sort direction [ big ] for field [ host_name ]

Messages d'erreurs liés au paramètre de format du résultat ( output_formatformat )

Valeur incorrecte
Code Block
languagebashtext
themeEmacs
$ curl -s -S -H "x-api-token: XYZ" \
-d "output_format=vrai" \
http://broker-module-livedata:50100/api/v2/inventory
ERROR 400: output_format: invalid value [ vrai ]
Panel
borderColor#dfe1e5
borderWidth1
borderStylesolid

ERROR 400: output_format: invalid value [ vrai ]

Excerpt Include
V2 - Les erreurs communes lors de l'envoi de la requête
V2 - Les erreurs communes lors de l'envoi de la requête
nopaneltrue