Dans ce tutoriel, nous décrirons comment Centreon peut superviser vos ressources déployées dans la plateforme cloud Amazon Web Services.

Example of AWS Architecture – Copyright AWS Inc.

La solution Centreon inclut de multiples plugins permettant de superviser AWS, et même un plugin par service AWS. Au moment où nous écrivons cet article, les services AWS suivants sont inclus dans la librairie de Plugins Centreon :

  • Billing
  • Cloudfront
  • Cloudwatch
  • EBS
  • Elasticache
  • ELB
  • Lambda
  • RDS
  • S3

Les Centreon Plugin Pack, qui facilitent la configuration de ces plugins en fournissant des modèles d’hôtes et de services prêts à l’emploi, sont inclus dans les solutions Centreon IMP et Centreon EMS. Référez-vous à notre documentation ou la page intégration de notre site internet pour connaître nos derniers Plugin Packs.

Dans ce tutoriel, nous étudierons l’exemple suivant : comment superviser une machine virtuelle AWS EC2 ?

Dans un premier temps, nous expliquerons comment Centreon se connecte au service Amazon CloudWatch pour collecter les métriques. Puis, nous installerons le Plugin AWS EC2 et le testerons depuis la Command Line Interface afin de comprendre comment cela fonctionne. Enfin, nous verrons comment utiliser le Plugin Pack et débuter la supervision facilement.

** La suite de cet article et le tutoriel sont rédigés en anglais **

 

1. AWS API credentials and Amazon CloudWatch service

AWS provides a Rest API for all its cloud services. There is one API access per Amazon Region.

For the Centreon plugins to connect and authenticate with this API, an Access Key, consisting of an access key ID and a secret access key is needed. This AWS IAM documentation gives information about how to use the Identity and Access Management service to create the required credentials such as:

  • Amazon Region name (eg ‘us-east-2’)
  • Secret Key
  • Access Key

 

AWS includes its own monitoring service: CloudWatch. CloudWatch is a free service (at least for basic use) that collects performance metrics for all your AWS resources. CloudWatch comes with its own API that Centreon plugins will query every five minutes. The free package allows up to 1 million requests per month, which should be plenty enough.

Please refer to the Amazon CloudWatch documentation for further information.

 

2. Installing and testing the AWS EC2 Centreon Plugin

Prerequisites

The Centreon AWS monitoring plugins requires either the Perl paws library or the awscli command line to connect to the AWS Rest API. In this tutorial, we will use the awscli tool which we will install alongside the plugin.

Plugin Installation

The Centreon AWS plugins are open source. The Git repository can be found under the project centreon-plugins. To install the EC2 plugin, let’s use the packages provided by Centreon on a CentOS/RedHat 7.x operating system. This should be done on the poller that accesses the AWS API.

# yum install centreon-plugin-Cloud-Aws-Ec2-Api.noarch awscli

 

Testing the Plugin

It’s always a good practice to test the plugin from the CLI, at the minimum to verify our credentials grant access to the API. Let’s perform various tests to validate the proper operation of this plugin and to know more about its functionalities.

Please note that by default the plugin collects the average usage of your resources. But it’s also possible to get the minimum and maximum usage of your resources by using the –statistic option. For example, to get both the average and minimum usage metrics, you must add the following option in your command line:

--statistic=average --statistic=minimum

 

Test 1 – Get the EC2 instance list
$ /usr/lib/centreon/plugins/centreon_aws_ec2_api.pl --plugin=cloud::aws::ec2::plugin --custommode=awscli --region=eu-west-1 --aws-secret-key='cgDbAaBKpGSYphr8+RiWcvXAf3Y7QpT' --aws-access-key='AKIAIAHAQ7FJ7C3Q' --mode=list-instances 
List instances: 
[Name = i-f15afe17][AvailabilityZone = us-east-2b][InstanceType = t2.small][State = running][Tags = centreon-support]
[Name = i-06717f4d0eee337af][AvailabilityZone = us-east-2b][InstanceType = t2.micro][State = stopped][Tags = centreon-poc-ha-poller]
 

 

Test 2 – Check EC2 instance status

For this check, we need to give the name of the EC2 instance with –name option.

$ /usr/lib/centreon/plugins/centreon_aws_ec2_api.pl --plugin=cloud::aws::ec2::plugin --custommode=awscli --region=eu-west-1 --aws-secret-key='cgDbAaBKpGSYphr8+RiWcvXAf3Y7QpT' --aws-access-key='AKIAIAHAQ7FJ7C3Q' --mode=status --type=instance --name=i-f15afe17 --critical-status='%{status} =~ /failed/i'
OK: Instance 'i-f15afe17' StatusCheckFailed_Instance: passed, StatusCheckFailed_System: passed 

 

Test 3 – Check all CPU metrics of EC2 instance

Specify the name of the EC2 instance with –name option.

$ /usr/lib/centreon/plugins/centreon_aws_ec2_api.pl --plugin=cloud::aws::ec2::plugin --custommode=awscli --region=eu-west-1 --aws-secret-key='cgDbAaBKpGSYphr8+RiWcvXAf3Y7QpT' --aws-access-key='AKIAIAHAQ7FJ7C3Q' --mode=cpu --type=instance --name=i-f15afe17 
OK: Instance 'i-f15afe17' average CPUCreditBalance: 288.00, CPUCreditUsage: 0.02, CPUSurplusCreditBalance: 0.00, CPUSurplusCreditsCharged: 0.00, CPUUtilization: 0.37 % | 'cpucreditbalance_average'=288.00;;;; 'cpucreditusage_average'=0.02;;;; 'cpusurpluscreditbalance_average'=0.00;;;; 'cpusurpluscreditscharged_average'=0.00;;;; 'cpuutilization_average'=0.37%;;;;

Here a short description of each metric (More details in this AWS documentation):

Metric Description
cpucreditbalance The number of earned CPU credits that an instance has accrued since it was launched or started.
cpucreditusage The number of CPU credits spent by the instance for CPU utilization.
cpusurpluscreditbalance The number of surplus credits that have been spent by an unlimited instance when its CPUCreditBalance value is zero.
cpusurpluscreditscharged The number of spent surplus credits that are not paid down by earned CPU credits, and which, then incur an additional charge.
cpuutilization The percentage of allocated EC2 compute units that are currently in use on the instance.

 

Test 4  – Check AWS EC2 network metrics

Specify the name of the EC2 instance with –name option.

$ /usr/lib/centreon/plugins/centreon_aws_ec2_api.pl --plugin=cloud::aws::ec2::plugin --custommode=awscli --region=eu-west-1 --aws-secret-key='cgDbAaBKpGSYphr8+RiWcvXAf3Y7QpT' --aws-access-key='AKIAIAHAQ7FJ7C3Q' --mode=network --type=instance --name=i-f15afe17 
OK: Instance 'i-f15afe17' average NetworkIn: 39.90KB, NetworkOut: 40.59KB, NetworkPacketsIn: 123.00 packets, NetworkPacketsOut: 117.40 packets | 'networkin_average'=40858.40B;;;; 'networkout_average'=41559.40B;;;; 'networkpacketsin_average'=123.00packets;;;; 'networkpacketsout_average'=117.40packets;;;;

Here is a short description of each metric (more details in this AWS documentation)

Metric Description
networkin The number of bytes received on all network interfaces by the instance.
networkout The number of bytes sent out on all network interfaces by the instance.
networkpacketsin The number of packets received on all network interfaces by the instance.
networkpacketsout The number of packets sent out on all network interfaces by the instance.

 

Test 5 – Check AWS EC2 disk metrics

Specify the name of the EC2 instance with –name option.

$ /usr/lib/centreon/plugins/centreon_aws_ec2_api.pl --plugin=cloud::aws::ec2::plugin --custommode=awscli --region=eu-west-1 --aws-secret-key='cgDbAaBKpGSYphr8+RiWcvXAf3Y7QpT' --aws-access-key='AKIAIAHAQ7FJ7C3Q' --mode=diskio --type=instance --name=i-f15afe17
OK: Instance 'i-f15afe17' average DiskReadBytes: 0.00B, DiskWriteBytes: 0.00B, DiskReadOps: 0.00 ops, DiskWriteOps: 0.00 ops | 'diskreadbytes_average'=0.00B;;;; 'diskwritebytes_average'=0.00B;;;; 'diskreadops_average'=0.00ops;;;; 'diskwriteops_average'=0.00ops;;;;

Here a short description of each metrics (More detail this AWS documentation):

Metric Description
diskreadbytes Bytes read from all instance store volumes available to the instance.
diskwritebytes Bytes written to all instance store volumes available to the instance.
diskreadops Completed read operations from all instance store volumes available to the instance in a specified period of time.
diskwriteops Completed write operations to all instance store volumes available to the instance in a specified period of time.

 

3. Installing and using the AWS EC2 Centreon Plugin Pack

Plugin Packs Manager is the name of the Centreon user interface by which you can list, download and update from 300+ Centreon Plugin Packs.

From the Configuration > Plugin Packs > Manager user interface, search for aws:

Centreon Plugin Pack Manager user interface

  • Install the  AWS EC2 pack by clicking on the ‘+’ button
  • As usual, the ‘?’ button will automatically redirects to the relevant Monitoring Procedure, including how to install the relevant Plugin

If the installation has been completed properly, you should find the host template Cloud-Aws-Ec2-Instance-Custom in the Configuration > Hosts > Templates menu.

To monitor our AWS EC2 instance, we need to create a new host in Centreon with the following parameters:

  • IP Address / DNS: localhost
  • Host Template: Cloud-Aws-EC2-Instance-custom;
  • Macros AWSSECRETKEY, AWSACCESSKEY and AWSREGION: your AWS API credentials
  • Macro AWSINSTANCENAME: your instance name (eg i-f15afe17)

 

  • Make sure you check the option to Create Services linked to the Template too: this will automatically create and configure the 5 Services defined by the Service Templates included in the Plugin Pack:
    • Cloud-Aws-Ec2-Cpu-Credit-Api for CPU credits usage metrics
    • Cloud-Aws-Ec2-Cpu-Usage-Api for CPU usage metrics
    • Cloud-Aws-Ec2-Diskio-Api for disks I/O utilization metrics
    • Cloud-Aws-Ec2-Network-Api for network usage metrics
    • Cloud-Aws-Ec2-Status-Api for internal checks status metrics

You are now ready to generate the configuration, export it and send it to the Poller:

You are now able to verify Centreon is collecting metrics for your EC2 instance in the Monitoring > Status Details > Hosts user interface:

Done! Your Centreon platform is now monitoring your AWS EC2 virtual machine.

Tip: the Configuration > Hosts > Templates user interface lets you modify the Cloud-Aws-Ec2-Instance-Custom template to save the credentials in the relevant macro. You are also able to create one such template per AWS Region.

 

4. What’s next?

From there on, you can start using all the Centreon AWS Plugin Packs and plugins to monitor your complete AWS infrastructure. You will then be able to build views to see and share the performance and availability of your cloud infrastructure and applications using Centreon dedicated tools: Custom View for tactical dashboards, MAP for graphical dashboards and MBI for weekly and monthly analytics reports.

 

Real-time AWS infrastructure monitoring with Centreon MAP

 

Visit our Plugin Packs Library! 300+ industry standard IT domains already addressed: networks, servers, applications, storage, database, devices, equipment, etc. – physical, virtual and hybrid infrastructures.

More tutorials:

 

Tags : ---