Aller au contenu principal

HTTP Server

Contenu du pack​

Modèles​

Le connecteur de supervision HTTP Server apporte un modèle d'hôte :

  • App-Protocol-HTTP-custom

Le connecteur apporte les modèles de service suivants (classés selon le modèle d'hôte auquel ils sont rattachés) :

AliasModèle de serviceDescription
HTTP-Response-TimeApp-Protocol-HTTP-Response-Time-customContrôle le temps de réponse d'une page web

Les services listés ci-dessus sont créés automatiquement lorsque le modèle d'hôte App-Protocol-HTTP-custom est utilisé.

Métriques & statuts collectés​

Voici le tableau des services pour ce connecteur, détaillant les métriques rattachées à chaque service.

MétriqueUnité
contentN/A
http.content.size.bytesB
http.response.time.secondss
http.extracted.value.countcount

Pour obtenir ce nouveau format de métrique, incluez la valeur --use-new-perfdata dans la macro de service EXTRAOPTIONS.

Prérequis​

La page ou application web interrogée doit être accessible via le protocole HTTP ou HTTPS depuis le collecteur. Il est possible d'utiliser un proxy lorsque cela est nécessaire.

Installer le connecteur de supervision​

Pack​

  1. Si la plateforme est configurée avec une licence online, l'installation d'un paquet n'est pas requise pour voir apparaître le connecteur dans le menu Configuration > Gestionnaire de connecteurs de supervision. Au contraire, si la plateforme utilise une licence offline, installez le paquet sur le serveur central via la commande correspondant au gestionnaire de paquets associé à sa distribution :
dnf install centreon-pack-applications-protocol-http
  1. Quel que soit le type de la licence (online ou offline), installez le connecteur HTTP Server depuis l'interface web et le menu Configuration > Gestionnaire de connecteurs de supervision.

Plugin​

À partir de Centreon 22.04, il est possible de demander le déploiement automatique du plugin lors de l'utilisation d'un connecteur. Si cette fonctionnalité est activée, et que vous ne souhaitez pas découvrir des éléments pour la première fois, alors cette étape n'est pas requise.

Plus d'informations dans la section Installer le plugin.

Utilisez les commandes ci-dessous en fonction du gestionnaire de paquets de votre système d'exploitation :

dnf install centreon-plugin-Applications-Protocol-Http

Utiliser le connecteur de supervision​

Utiliser un modèle d'hôte issu du connecteur​

  1. Ajoutez un hôte à Centreon depuis la page Configuration > Hôtes.
  2. Complétez les champs Nom, Alias & IP Address/DNS correspondant à votre ressource.
  3. Appliquez le modèle d'hôte App-Protocol-HTTP-custom. Une liste de macros apparaît. Les macros vous permettent de définir comment le connecteur se connectera à la ressource, ainsi que de personnaliser le comportement du connecteur.
  4. Renseignez les macros désirées. Attention, certaines macros sont obligatoires.
MacroDescriptionValeur par défautObligatoire
PROTOCOLSpecify https if needed (Default: 'http')http
PORTPort used by web server80X
EXTRAOPTIONSAny extra option you may want to add to every command (E.g. a --verbose flag). Toutes les options sont listées ici
  1. Déployez la configuration. L'hôte apparaît dans la liste des hôtes supervisés, et dans la page Statut des ressources. La commande envoyée par le connecteur est indiquée dans le panneau de détails de l'hôte : celle-ci montre les valeurs des macros.

Utiliser un modèle de service issu du connecteur​

  1. Si vous avez utilisé un modèle d'hôte et coché la case Créer aussi les services liés aux modèles, les services associés au modèle ont été créés automatiquement, avec les modèles de services correspondants. Sinon, créez les services désirés manuellement et appliquez-leur un modèle de service.
  2. Renseignez les macros désirées (par exemple, ajustez les seuils d'alerte). Les macros indiquées ci-dessous comme requises (Obligatoire) doivent être renseignées.
MacroDescriptionValeur par défautObligatoire
EXPECTEDCONTENT--expected-string='mypattern' is a shortcut for --critical-content='%{content} !~ /mypattern/mi'. It is recommended to use directly --critical-content
URLPATHSet path to get web page (Default: '/')/
EXTRAOPTIONSAny extra option you may want to add to the command (E.g. a --verbose flag). Toutes les options sont listées ici
  1. Déployez la configuration. Le service apparaît dans la liste des services supervisés, et dans la page Statut des ressources. La commande envoyée par le connecteur est indiquée dans le panneau de détails du service : celle-ci montre les valeurs des macros.

Comment puis-je tester le plugin et que signifient les options des commandes ?​

Une fois le plugin installé, vous pouvez tester celui-ci directement en ligne de commande depuis votre collecteur Centreon en vous connectant avec l'utilisateur centreon-engine (su - centreon-engine). Vous pouvez tester que le connecteur arrive bien à superviser une ressource en utilisant une commande telle que celle-ci (remplacez les valeurs d'exemple par les vôtres) :

/usr/lib/centreon/plugins/centreon_protocol_http.pl \
--plugin=apps::protocols::http::plugin \
--mode=response \
--hostname=10.0.0.1 \
--proto='http' \
--port='80' \
--urlpath='/' \
--warning='' \
--critical=''

La commande devrait retourner un message de sortie similaire à :

OK: response time 0.078s | 'http.response.time.seconds'=0.078s;;;0; 'http.response.size.count'=49602B;;;0; 'http.response.resolve.time.milliseconds'=4.176ms;;;0; 'http.response.connect.time.milliseconds'=4.176ms;;;0; 'http.response.processing.time.milliseconds'=44.163ms;;;0; 'http.response.transfer.time.milliseconds'=4.176ms;;;0;

Diagnostic des erreurs communes​

Rendez-vous sur la documentation dédiée pour le diagnostic des erreurs communes des plugins Centreon.

Modes disponibles​

Dans la plupart des cas, un mode correspond à un modèle de service. Le mode est renseigné dans la commande d'exécution du connecteur. Dans l'interface de Centreon, il n'est pas nécessaire de les spécifier explicitement, leur utilisation est implicite dès lors que vous utilisez un modèle de service. En revanche, vous devrez spécifier le mode correspondant à ce modèle si vous voulez tester la commande d'exécution du connecteur dans votre terminal.

Tous les modes disponibles peuvent être affichés en ajoutant le paramètre --list-mode à la commande :

/usr/lib/centreon/plugins/centreon_protocol_http.pl \
--plugin=apps::protocols::http::plugin \
--list-mode

Le plugin apporte les modes suivants :

ModeModèle de service associé
collection [code]Not used in this Monitoring Connector
expected-content [code]App-Protocol-HTTP-Expected-Content-custom
json-content [code]App-Protocol-HTTP-Json-Content-custom
response [code]App-Protocol-HTTP-Response-Time-custom
soap-content [code]App-Protocol-HTTP-Soap-Content-custom

Options disponibles​

Options génériques​

Les options génériques sont listées ci-dessous :

OptionDescription
--modeDefine the mode in which you want the plugin to be executed (see--list-mode).
--dyn-modeSpecify a mode with the module's path (advanced).
--list-modeList all available modes.
--mode-versionCheck minimal version of mode. If not, unknown error.
--versionReturn the version of the plugin.
--pass-managerDefine the password manager you want to use. Supported managers are: environment, file, keepass, hashicorpvault and teampass.
--verboseDisplay extended status information (long output).
--debugDisplay debug messages.
--filter-perfdataFilter perfdata that match the regexp. Eg: adding --filter-perfdata='avg' will remove all metrics that do not contain 'avg' from performance data.
--filter-perfdata-advFilter perfdata based on a "if" condition using the following variables: label, value, unit, warning, critical, min, max. Variables must be written either %{variable} or %(variable). Eg: adding --filter-perfdata-adv='not (%(value) == 0 and %(max) eq "")' will remove all metrics whose value equals 0 and that don't have a maximum value.
--explode-perfdata-maxCreate a new metric for each metric that comes with a maximum limit. The new metric will be named identically with a '_max' suffix). Eg: it will split 'used_prct'=26.93%;0:80;0:90;0;100 into 'used_prct'=26.93%;0:80;0:90;0;100 'used_prct_max'=100%;;;;
--change-perfdata --extend-perfdataChange or extend perfdata. Syntax: --extend-perfdata=searchlabel,newlabel,target[,[newuom],[min],[m ax]] Common examples: Convert storage free perfdata into used: --change-perfdata=free,used,invert() Convert storage free perfdata into used: --change-perfdata=used,free,invert() Scale traffic values automatically: --change-perfdata=traffic,,scale(auto) Scale traffic values in Mbps: --change-perfdata=traffic_in,,scale(Mbps),mbps Change traffic values in percent: --change-perfdata=traffic_in,,percent()
--extend-perfdata-groupAdd new aggregated metrics (min, max, average or sum) for groups of metrics defined by a regex match on the metrics' names. Syntax: --extend-perfdata-group=regex,namesofnewmetrics,calculation[,[ne wuom],[min],[max]] regex: regular expression namesofnewmetrics: how the new metrics' names are composed (can use $1, $2... for groups defined by () in regex). calculation: how the values of the new metrics should be calculated newuom (optional): unit of measure for the new metrics min (optional): lowest value the metrics can reach max (optional): highest value the metrics can reach Common examples: Sum wrong packets from all interfaces (with interface need --units-errors=absolute): --extend-perfdata-group=',packets_wrong,sum(packets_(discard |error)_(in|out))' Sum traffic by interface: --extend-perfdata-group='traffic_in_(.*),traffic_$1,sum(traf fic_(in|out)_$1)'
--change-short-output --change-long-outputModify the short/long output that is returned by the plugin. Syntax: --change-short-output=pattern~replacement~modifier Most commonly used modifiers are i (case insensitive) and g (replace all occurrences). Eg: adding --change-short-output='OK~Up~gi' will replace all occurrences of 'OK', 'ok', 'Ok' or 'oK' with 'Up'
--change-exitReplace an exit code with one of your choice. Eg: adding --change-exit=unknown=critical will result in a CRITICAL state instead of an UNKNOWN state.
--range-perfdataRewrite the ranges displayed in the perfdata. Accepted values: 0: nothing is changed. 1: if the lower value of the range is equal to 0, it is removed. 2: remove the thresholds from the perfdata.
--filter-uomMask the units when they don't match the given regular expression.
--opt-exitReplace the exit code in case of an execution error (i.e. wrong option provided, SSH connection refused, timeout, etc). Default: unknown.
--output-ignore-perfdataRemove all the metrics from the service. The service will still have a status and an output.
--output-ignore-labelRemove the status label ("OK:", "WARNING:", "UNKNOWN:", CRITICAL:") from the beginning of the output. Eg: 'OK: Ram Total:...' will become 'Ram Total:...'
--output-xmlReturn the output in XML format (to send to an XML API).
--output-jsonReturn the output in JSON format (to send to a JSON API).
--output-openmetricsReturn the output in OpenMetrics format (to send to a tool expecting this format).
--output-fileWrite output in file (can be combined with json, xml and openmetrics options). E.g.: --output-file=/tmp/output.txt will write the output in /tmp/output.txt.
--disco-formatApplies only to modes beginning with 'list-'. Returns the list of available macros to configure a service discovery rule (formatted in XML).
--disco-showApplies only to modes beginning with 'list-'. Returns the list of discovered objects (formatted in XML) for service discovery.
--float-precisionDefine the float precision for thresholds (default: 8).
--source-encodingDefine the character encoding of the response sent by the monitored resource Default: 'UTF-8'.
--http-peer-addrSet the address you want to connect to. Useful if hostname is only a vhost, to avoid IP resolution.
--proxyurlProxy URL. Eg: http://my.proxy:3128
--proxypacProxy pac file (can be a URL or a local file).
--insecureAccept insecure SSL connections.
--http-backendPerl library to use for HTTP transactions. Possible values are: lwp (default) and curl.
--ssl-optSet SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE").
--curl-optSet CURL Options (--curl-opt="CURLOPT_SSL_VERIFYPEER => 0" --curl-opt="CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_1" ).

Options des modes​

Les options disponibles pour chaque modèle de services sont listées ci-dessous :

OptionDescription
--hostnameIP Address/FQDN of the web server's host
--portPort used by web server
--methodSpecify http method used (Default: 'GET')
--protoSpecify https if needed (Default: 'http')
--urlpathSet path to get web page (default: '/')
--credentialsSpecify this option if you access the web page with authentication
--usernameSpecify username for authentication (mandatory if --credentials is specified)
--passwordSpecify password for authentication (mandatory if --credentials is specified)
--basicSpecify this option if you access webpage over basicauthentication and don't want a '401 UNAUTHORIZED' error to be logged on your webserver. Specify this option if you access web page over hidden basic authentication or you'll get a '404 NOT FOUND' error. (Use with --credentials)
--ntlmv2Specify this option if you access web page over ntlmv2 authentication (Use with --credentials and --port options)
--timeoutThreshold for HTTP timeout (default: 5)
--no-followDo not follow http redirect
--cert-fileSpecify certificate to send to the web server
--key-fileSpecify key to send to the web server
--cacert-fileSpecify root certificate to send to the web server
--cert-pwdSpecify certificate's password
--cert-pkcs12Specify type of certificate (PKCS12)
--dataSet POST data request. (For JSON data, add the following option:--header='Content-Type: application/json')
--headerSet HTTP headers (multiple option)
--get-paramSet GET params (multiple option. Example: --get-param='key=value')
--post-paramSet POST params (multiple option. Example: --post-param='key=value')
--cookies-fileSave cookies in a file (Example: '/tmp/lwp_cookies.dat')
--extracted-patternSet pattern to extract a number (use --warning-extracted and --critical-extracted option).
--expected-string--expected-string='toto' is a shortcut for --critical-content='%{content} !~ /toto/mi'. It is recommended to use directly --critical-content.
--unknown-statusWarning threshold for http response code (default: '%{http_code} \< 200 or %{http_code} >= 300')
--warning-statusWarning threshold for http response code
--critical-statusCritical threshold for http response code
--warning-timeWarning threshold in seconds (web page response time)
--critical-timeCritical threshold in seconds (web page response time)
--warning-sizeWarning threshold for content size
--critical-sizeCritical threshold for content size
--warning-extractedWarning threshold for extracted value
--critical-extractedCritical threshold for extracted value
--unknown-contentSet warning threshold for content page (default: ''). You can use the following variables: %{content}, %{header}, %{first_header}, %{code}
--warning-contentDefine the conditions to match for the status to be WARNING (Default: ''). You can use the following variables: %{content}, %{header}, %{first_header}, %{code}
--critical-contentSet critical threshold for content page (Default: ''). You can use the following variables: %{content}, %{header}, %{first_header}, %{code}

Pour un mode, la liste de toutes les options disponibles et leur signification peut être affichée en ajoutant le paramètre --help à la commande :

/usr/lib/centreon/plugins/centreon_protocol_http.pl \
--plugin=apps::protocols::http::plugin \
--mode=response \
--help