CLAPI et REST sous Centreon 2.8
Comment automatiser la supervision avec Puppet et Centreon ?
Centreon 2.8 – Monitorez votre infrastructure
Centreon 2.8 - Export vers Graphite / Graphana et InfluxDB
Centreon 2.8 – Monitorez votre infrastructure
Centreon 2.8 - Nouveau module de graph C3JS
Centreon 2.8 – Monitorez votre infrastructure
Centreon 2.8 – module de graph C3JS
Centreon 2.8 – Monitorez votre infrastructure
Cartes interactives avec le module Map4
Centreon 2.8 – Monitorez votre infrastructure
Monitoring applicatif avec le module BAM
Centreon 2.8 – Monitorez votre infrastructure
Vue business avec le module BI
Centreon CLAPI - Management et configuration via CLI
L’intérêt ?
• Ajouter/Supprimer/Mettre à jour des objets comme :
• Les hôtes, les services, les templates, les groupes, les catégories et
les contacts
• Générer des fichiers de configuration
• Assigner les configurations aux pollers
• Gérer les pollers
• Importer / Exporter des configurations
Tout cela via CLI sur le serveur central.
https://documentation-fr.centreon.com/docs/centreon/en/2.8.x/api/clapi/index.html
Centreon CLAPI - Création d’un hôte
/usr/share/centreon/bin centreon
[root@centreon ~]# ./centreon -u admin -p XXXPASSWORDXXX -o HOST -a ADD -v «OpenIT-Web-Server;Serveur-WEB ;192.168.4.34;generic-
host;central;Linux »
Ordre Description
1 Host name
2 Host alias
3 Host IP address
4 Host templates; for multiple definitions, use delimiter |
5 Instance name (poller)
6 Hostgroup; for multiple definitions, use delimiter |
Centreon CLAPI - Rajout du paramètre timezone à cet hôte
/usr/share/centreon/bin centreon
[root@centreon ~]# ./centreon -u admin -p XXXPASSWORDXXX -o HOST -a setparam -v "OpenIT-Web-Server;timezone;Europe/Berlin"
Ordre Description
1 Host name
2 Param name
3 Param value
Centreon CLAPI - Désactiver un contact
/usr/share/centreon/bin centreon
[root@centreon core]# ./centreon -u admin -p XXXPASSWORDXXX -o contact -a disable -v «pierrick»
Ordre Description
1 User name
Centreon CLAPI - Les objets
…
Centreon est en grande partie manageable via CLAPI et
les objets associés :
https://documentation-fr.centreon.com/docs/centreon/en/2.8.x/api/clapi/index.html
Centreon CLAPI - QUID d’une intégration de 4000 hôtes ?
HOST;ADD;OpenIT-Web-Server;;SVRDEVGED1;;Central;
HOST;setparam;OpenIT-Web-Server;check_period;24x7
HOST;setparam;OpenIT-Web-Server;host_active_checks_enabled;2
HOST;setparam;OpenIT-Web-Server;host_passive_checks_enabled;2
HOST;setparam;OpenIT-Web-Server;host_checks_enabled;2
HOST;setparam;OpenIT-Web-Server;host_obsess_over_host;2
HOST;setparam;OpenIT-Web-Server;host_check_freshness;2
HOST;setparam;OpenIT-Web-Server;host_event_handler_enabled;2
HOST;setparam;OpenIT-Web-Server;host_flap_detection_enabled;2
HOST;setparam;OpenIT-Web-Server;host_process_perf_data;2
HOST;setparam;OpenIT-Web-Server;host_retain_status_information;2
HOST;setparam;OpenIT-Web-Server;host_retain_nonstatus_information;2
HOST;setparam;OpenIT-Web-Server;host_notifications_enabled;2
HOST;setparam;OpenIT-Web-Server;contact_additive_inheritance;0
HOST;setparam;OpenIT-Web-Server;cg_additive_inheritance;0
HOST;setparam;OpenIT-Web-Server;host_snmp_community;Openit-public
HOST;setparam;OpenIT-Web-Server;host_snmp_version;2c
HOST;setparam;OpenIT-Web-Server;host_locked;0
HOST;setparam;OpenIT-Web-Server;host_register;1
HOST;setparam;OpenIT-Web-Server;host_activate;1
HOST;addtemplate;OpenIT-Web-Server;generic-host
HOST;addtemplate;OpenIT-Web-Server;OS-Linux-SNMP
HOST;applytpl;OpenIT-Web-Server
HG;addmember;Linux-Servers;OpenIT-Web-Server
HG;addmember;Web-Servers;OpenIT-Web-Server
… (x le nombre d’hôtes)
Perl/Python/VBscript….
Centreon CLAPI
[root@SVCTRP01 bin]# ./centreon -u admin -p XXXPASSWORDXXX -i /tmp/hosts_import.txt
DEMO – Imports de plusieurs hôtes via Centreon CLAPI
Centreon API REST - API HTTP au format JSON
95% des actions réalisables via CLAPI sont disponibles via l’API REST (source Wiki Centreon)
1. Autoriser un utilisateur Centreon à utiliser l’API
2. Créer un jeton d’authentification
curl -s --data 'username=REST&password=centreon‘ 'http://meetup-
centreon.hidora.com/centreon/api/index.php?action=authenticate'
curl -s 'http://meetup-centreon.hidora.com/centreon/api/index.php?action=action&object=centreon_clapi' -H 'Content-Type:
application/json' -H 'centreon_auth_token: NTg5MzNhZWM0NzQyODAuOTk2MzU0NjM=' --data 'action=show&object=HOST'
3. Interroger Centreon via l’API
Centreon API REST - API HTTP au format JSON
DEMO - JSON contenant la liste des hosts dans Centreon
Firefox RESTClient
Retrouvez-nous sur :
http://www.slideshare.net/open-it-services #genevemonitoring
#monitoringlove
@OpenIT_Services

CLAPI et API REST sous Centreon 2.8

  • 1.
    CLAPI et RESTsous Centreon 2.8 Comment automatiser la supervision avec Puppet et Centreon ?
  • 2.
    Centreon 2.8 –Monitorez votre infrastructure Centreon 2.8 - Export vers Graphite / Graphana et InfluxDB
  • 3.
    Centreon 2.8 –Monitorez votre infrastructure Centreon 2.8 - Nouveau module de graph C3JS
  • 4.
    Centreon 2.8 –Monitorez votre infrastructure Centreon 2.8 – module de graph C3JS
  • 5.
    Centreon 2.8 –Monitorez votre infrastructure Cartes interactives avec le module Map4
  • 6.
    Centreon 2.8 –Monitorez votre infrastructure Monitoring applicatif avec le module BAM
  • 7.
    Centreon 2.8 –Monitorez votre infrastructure Vue business avec le module BI
  • 8.
    Centreon CLAPI -Management et configuration via CLI L’intérêt ? • Ajouter/Supprimer/Mettre à jour des objets comme : • Les hôtes, les services, les templates, les groupes, les catégories et les contacts • Générer des fichiers de configuration • Assigner les configurations aux pollers • Gérer les pollers • Importer / Exporter des configurations Tout cela via CLI sur le serveur central. https://documentation-fr.centreon.com/docs/centreon/en/2.8.x/api/clapi/index.html
  • 9.
    Centreon CLAPI -Création d’un hôte /usr/share/centreon/bin centreon [root@centreon ~]# ./centreon -u admin -p XXXPASSWORDXXX -o HOST -a ADD -v «OpenIT-Web-Server;Serveur-WEB ;192.168.4.34;generic- host;central;Linux » Ordre Description 1 Host name 2 Host alias 3 Host IP address 4 Host templates; for multiple definitions, use delimiter | 5 Instance name (poller) 6 Hostgroup; for multiple definitions, use delimiter |
  • 10.
    Centreon CLAPI -Rajout du paramètre timezone à cet hôte /usr/share/centreon/bin centreon [root@centreon ~]# ./centreon -u admin -p XXXPASSWORDXXX -o HOST -a setparam -v "OpenIT-Web-Server;timezone;Europe/Berlin" Ordre Description 1 Host name 2 Param name 3 Param value
  • 11.
    Centreon CLAPI -Désactiver un contact /usr/share/centreon/bin centreon [root@centreon core]# ./centreon -u admin -p XXXPASSWORDXXX -o contact -a disable -v «pierrick» Ordre Description 1 User name
  • 12.
    Centreon CLAPI -Les objets … Centreon est en grande partie manageable via CLAPI et les objets associés : https://documentation-fr.centreon.com/docs/centreon/en/2.8.x/api/clapi/index.html
  • 13.
    Centreon CLAPI -QUID d’une intégration de 4000 hôtes ? HOST;ADD;OpenIT-Web-Server;;SVRDEVGED1;;Central; HOST;setparam;OpenIT-Web-Server;check_period;24x7 HOST;setparam;OpenIT-Web-Server;host_active_checks_enabled;2 HOST;setparam;OpenIT-Web-Server;host_passive_checks_enabled;2 HOST;setparam;OpenIT-Web-Server;host_checks_enabled;2 HOST;setparam;OpenIT-Web-Server;host_obsess_over_host;2 HOST;setparam;OpenIT-Web-Server;host_check_freshness;2 HOST;setparam;OpenIT-Web-Server;host_event_handler_enabled;2 HOST;setparam;OpenIT-Web-Server;host_flap_detection_enabled;2 HOST;setparam;OpenIT-Web-Server;host_process_perf_data;2 HOST;setparam;OpenIT-Web-Server;host_retain_status_information;2 HOST;setparam;OpenIT-Web-Server;host_retain_nonstatus_information;2 HOST;setparam;OpenIT-Web-Server;host_notifications_enabled;2 HOST;setparam;OpenIT-Web-Server;contact_additive_inheritance;0 HOST;setparam;OpenIT-Web-Server;cg_additive_inheritance;0 HOST;setparam;OpenIT-Web-Server;host_snmp_community;Openit-public HOST;setparam;OpenIT-Web-Server;host_snmp_version;2c HOST;setparam;OpenIT-Web-Server;host_locked;0 HOST;setparam;OpenIT-Web-Server;host_register;1 HOST;setparam;OpenIT-Web-Server;host_activate;1 HOST;addtemplate;OpenIT-Web-Server;generic-host HOST;addtemplate;OpenIT-Web-Server;OS-Linux-SNMP HOST;applytpl;OpenIT-Web-Server HG;addmember;Linux-Servers;OpenIT-Web-Server HG;addmember;Web-Servers;OpenIT-Web-Server … (x le nombre d’hôtes) Perl/Python/VBscript…. Centreon CLAPI [root@SVCTRP01 bin]# ./centreon -u admin -p XXXPASSWORDXXX -i /tmp/hosts_import.txt DEMO – Imports de plusieurs hôtes via Centreon CLAPI
  • 14.
    Centreon API REST- API HTTP au format JSON 95% des actions réalisables via CLAPI sont disponibles via l’API REST (source Wiki Centreon) 1. Autoriser un utilisateur Centreon à utiliser l’API 2. Créer un jeton d’authentification curl -s --data 'username=REST&password=centreon‘ 'http://meetup- centreon.hidora.com/centreon/api/index.php?action=authenticate' curl -s 'http://meetup-centreon.hidora.com/centreon/api/index.php?action=action&object=centreon_clapi' -H 'Content-Type: application/json' -H 'centreon_auth_token: NTg5MzNhZWM0NzQyODAuOTk2MzU0NjM=' --data 'action=show&object=HOST' 3. Interroger Centreon via l’API
  • 15.
    Centreon API REST- API HTTP au format JSON DEMO - JSON contenant la liste des hosts dans Centreon Firefox RESTClient
  • 16.
    Retrouvez-nous sur : http://www.slideshare.net/open-it-services#genevemonitoring #monitoringlove @OpenIT_Services