Description

Le listener-rest est une source qui expose une API REST permettant d'ajouter de nouveaux hôtes via des requêtes HTTP contenant un objet décrivant un hôte au format JSON.

Voici un exemple de requête avec cURL :

curl -u USER:PASSWORD \
     -H "Content-Type: application/json" \
     -d '{"host-name":"my_host", "use":"linux", "address":"192.168.1.254"}' \
     -X PUT 'http://SYNCHRONIZER-IP-INTERFACE:7761/shinken/listener-rest/v1/hosts/'


Configuration

Voici le fichier CFG de configuration présent dans : /etc/shinken/listeners/listener-rest.cfg

Exemple de fichier de configuration



#===============================================================================
# listener-rest
#===============================================================================
# Daemons that can load this listener:
# - synchronizer
#===============================================================================


define listener {

    # ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ #
    # │ ──────────────────────────────────────    MODULE IDENTITY    ────────────────────────────────────── │ #
    # └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ #

    # ─── Listener name [ Must be unique ]                                                    [ MANDATORY ] ───
    listener_name                                       listener-rest

    # ─── Module type [ Do not edit ]                                                         [ MANDATORY ] ───
    listener_name                                       listener-rest

    # ─── Display a description on the interface for this source                                            ───
    description                                         The listener-rest allow listening by HTTP(s)/REST hosts

    # ─── In minutes, what is the schedule import interval for this source.                                 ───
    # ─── 0 = don't schedule this source, will run only if an administrator launch it from the interface    ───
    import_interval                                     0

    # ─── Imply if a source is before another source when merging data                                   ───
    order                                               5

    # ─── Enabled this source or not                                                                        ───
    enabled                                             0

    # ┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐ #
    # │ ─────────────────────────────────────    LISTENER OPTIONS    ────────────────────────────────────── │ #
    # └─────────────────────────────────────────────────────────────────────────────────────────────────────┘ #

    # ─── The IPv4 address to listen to                                                                     ───
    # >>> Default : 0.0.0.0                                                                                 ───
    # ─── NOTE: The address 0.0.0.0 means all interfaces                                                    ───
    # host                                              0.0.0.0

    # ─── The port to listen to                                                                             ───
    # >>> Default : 7761                                                                                    ───
    # post                                              7761

}



#===============================================================================
# listener-rest
#===============================================================================
# Daemons that can load this listener:
# - synchronizer
#===============================================================================
 
 
define listener {
    listener_name           listener-rest

	#======== Module identity ========= 
	# Listener type (to load module code). Do not edit. 
	module_type 			listener-rest

	order                   5
    import_interval         0
 
    # enabled: is this listener enabled or not
    enabled                 0
 
    # description: display a description on the interface for this source
    description             The listener-rest allow listening by HTTP(s)/REST hosts
  
    #======== Listening address =========
    # host: IP address to listen to.
    # note: 0.0.0.0 = all interfaces.
    host                    0.0.0.0
 
    # port to listen
    port                    7761

 }