Skip to content

Latest commit

 

History

History
1244 lines (1031 loc) · 107 KB

guide.rst

File metadata and controls

1244 lines (1031 loc) · 107 KB

Description

"centreon-plugins" is a free and open source project to monitor systems. The project can be used with Centreon, Icinga and all monitoring softwares compatible Nagios plugins.

The lastest version is available on following git repository: https://github.com/centreon/centreon-plugins.git

Installation

Debian Wheezy

Get the last version of "centreon-plugins" from the repository:

# aptitude install git
# git clone https://github.com/centreon/centreon-plugins.git

To monitor SNMP systems, you need to install the following packages:

# aptitude install perl libsnmp-perl

You can install other packages to use more plugins:

# aptitude install libxml-libxml-perl libjson-perl libwww-perl libxml-xpath-perl libnet-telnet-perl libnet-ntp-perl libnet-dns-perl libdbi-perl libdbd-mysql-perl libdbd-pg-perl

To use 'memcached' functionality, you need to install the following CPAN module (no debian package): http://search.cpan.org/~wolfsage/Memcached-libmemcached-1.001702/libmemcached.pm

Centos/Rhel 6

Get the last version of "centreon-plugins" from the repository:

# yum install git
# git clone https://github.com/centreon/centreon-plugins.git

To monitor SNMP systems, you need to install the following packages:

# yum install perl net-snmp-perl

You can install other packages to use more plugins:

# yum install perl-XML-LibXML perl-JSON perl-libwww-perl perl-XML-XPath perl-Net-Telnet perl-Net-DNS perl-DBI perl-DBD-MySQL perl-DBD-Pg

To use 'memcached' functionality, you need to install the following CPAN module (package available in 'rpmforge'): http://search.cpan.org/~wolfsage/Memcached-libmemcached-1.001702/libmemcached.pm

Basic Usage

We'll use a basic example to show you how to monitor a system. I have finished the install section and I want to monitor a Linux in SNMP. First, I need to find the plugin to use in the list:

$ perl centreon_plugins.pl --list-plugin | grep -i linux | grep 'PLUGIN'
PLUGIN: os::linux::local::plugin
PLUGIN: os::linux::snmp::plugin

It seems that 'os::linux::snmp::plugin' is the good one. So I verify with the option --help to be sure:

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --help
...
Plugin Description:
  Check Linux operating systems in SNMP.

It's exactly what I need. Now I'll the option --list-mode to know what can I do with it:

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --list-mode
...
Modes Available:
 cpu
 cpu-detailed
 disk-usage
 diskio
 inodes
 interfaces
 list-diskspath
 list-interfaces
 list-storages
 load
 memory
 processcount
 storage
 swap
 tcpcon
 time
 uptime

I would like to test the 'load' mode:

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=load
UNKNOWN: Missing parameter --hostname.

It's not working because some options are missing. I can have a description of the mode and options with the option --help:

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=load --help

Eventually, I have to configure some SNMP options:

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=load --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public
OK: Load average: 0.00, 0.00, 0.00 | 'load1'=0.00;;;0; 'load5'=0.00;;;0; 'load15'=0.00;;;0;

I can set threshold with options --warning and --critical:

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=load --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --warning=1,2,3 --critical=2,3,4
OK: Load average: 0.00, 0.00, 0.00 | 'load1'=0.00;0:1;0:2;0; 'load5'=0.00;0:2;0:3;0; 'load15'=0.00;0:3;0:4;0;

FAQ

What can I monitor ?

The option --list-plugin can be used to get the list of plugins and a short description.

Headers of the table mean:

  • Transport: The check has internal options for the transport.
  • Protocol: what is used to get the monitoring datas.
  • Experimental: The check is still in development.
Category Check Transport Protocol Experimental Comment Perl dependencies
SSH TELNET WSMAN SNMP HTTP WMI JMX custom
Application Active Directory              
  Use 'dcdiag' command. Must be installed on Windows. Win32::Job
Apache        
        Need Apache 'mod_status' module. LWP::UserAgent, URI, HTTP::Cookies
Apc        
          LWP::UserAgent, URI, HTTP::Cookies
Apcupsd
           
  Use 'apcupsd' commands.  
Bluemind        
        Use 'influxdb' API. JSON, LWP::UserAgent, URI, HTTP::Cookies
Checkmyws        
          JSON, LWP::UserAgent, URI, HTTP::Cookies
Elasticsearch        
          JSON, LWP::UserAgent, URI, HTTP::Cookies
Exchange              
  Use powershell script. Must be installed on Windows. Win32::Job
Github        
        Use 'github' API. JSON, LWP::UserAgent, URI, HTTP::Cookies, DateTime
Hddtemp              
  Open a TCP custom communication  
IIS          
      Must be installed on Windows. Win32::OLE
   
   
   
  openwsman, MIME::Base64
Jenkins        
          JSON, LWP::UserAgent, URI, HTTP::Cookies
Kayako        
        Use 'kayako' API. XML::XPath, Digest::SHA, LWP::UserAgent, URI, HTTP::Cookies
Lmsensors      
             
Msmq              
Must be installed on Windows. Not developed yet.  
Nginx        
        Need 'HttpStubStatusModule' module. LWP::UserAgent, URI, HTTP::Cookies
Pacemaker
           
  Use 'crm_mon' command.  
Pfsense      
             
Selenium              
  Connect to a selenium server to play a scenario. XML::XPath, WWW::Selenium
Tomcat        
        Need tomcat webmanager. XML::XPath, LWP::UserAgent, URI, HTTP::Cookies
Varnish
           
  Use varnish commands.  
VMWare              
  Need 'centreon-vmware' connector from Centreon.  
Pfsense      
             
Protocols Bgp      
             
Dhcp              
    Net::DHCP::Packet, Net::Subnet
Dns              
    Net::DNS
Ftp              
    Net::FTP, Net::FTPSSL
Http        
          LWP::UserAgent, URI, HTTP::Cookies, JSON, JSON::Path, XML::XPath
Ftp              
    Net::FTP, Net::FTPSSL
Imap              
    Net::IMAP::Simple
Jmx            
      JSON::Path, JMX::Jmx4Perl
Ldap              
    Net::LDAP
Ntp              
    Net::NTP
Radius              
    Authen::Radius
Smtp              
    Email::Send::SMTP::Gmail
Tcp              
    IO::Socket::SSL
Udp              
     
x509              
    IO::Socket::SSL
Database Informix              
    DBI, DBD::Informix
Firebird              
    DBI, DBD::Firebird
MS SQL              
    DBI, DBD::Sybase
MySQL              
    DBI, DBD::mysql
Oracle              
    DBI, DBD::oracle, DateTime
Postgres              
    DBI, DBD::Pg
Hardware ATS Apc      
       
   
PDU Apc      
             
PDU Eaton      
       
   
PDU Raritan      
             
Standard Printers      
             
Hwgste      
             
Sensorip      
             
Sensormetrix Em01        
          LWP::UserAgent, URI, HTTP::Cookies
Serverscheck      
             
Cisco UCS      
             
Dell CMC      
             
Dell iDrac      
             
Dell Openmanage      
          Need 'openmanage agent' on the operating system.  
HP Proliant      
          Need 'HP Insight agent' on the operating system.  
HP Blade Chassis      
             
IBM BladeCenter      
             
IBM HMC
           
   
IBM IMM      
             
Sun hardware
 
     
  Can monitor many sun hardware. Net::Telnet, SNMP
UPS APC      
             
UPS Mge      
             
UPS Standard      
             
UPS Powerware      
             
Network 3com      
             
Alcatel Omniswitch      
             
Arkoon      
             
Aruba      
             
Bluecoat      
             
Brocade      
             
Checkpoint      
             
Cisco      
          Many cisco (2800, Nexus, Wlc, Ironport,...)  
Citrix Netscaler      
             
Dell Powerconnect      
             
Dlink      
             
Extreme      
             
F5 Big-Ip      
             
Fortinet Fortigate      
             
Fritzbox      
             
H3C      
             
Hirschmann      
             
HP Procurve      
             
HP Virtual Connect      
             
Juniper      
          Can monitor 'SSG', 'SA', 'SRX', 'MAG', 'EX', 'Ggsn'.  
Netasq      
             
Oneaccess      
             
Palo Alto      
             
Radware Alteon      
       
   
Redback      
             
Riverbed      
             
Ruggedcom      
             
Securactive      
             
Stonesoft      
             
Operating
System
AIX
           
  Use AIX commands.  
         
         
Freebsd      
          Need 'bsnmpd' agent.  
Linux
           
  Use Linux commands.  
     
             
Solaris
           
  Use Solaris commands.  
         
         
Windows      
             
   
   
   
   
Storage Dell EqualLogic      
             
Dell MD3000              
  Need 'SMcli' command.  
Dell TL2000      
             
Dell ML6000      
             
EMC Celerra
           
  Use appliance commands.  
EMC Clariion              
  Need 'navisphere' command.  
EMC DataDomain      
             
EMC Recoverypoint
           
  Use appliance commands.  
EMC Vplex          
      Use the JSON API. JSON, LWP::UserAgent, URI, HTTP::Cookies
EMC Xtremio          
      Use the JSON API. JSON, LWP::UserAgent, URI, HTTP::Cookies
Fujitsu Eternus DX
           
  Use appliance commands.  
HP 3par
           
  Use appliance commands.  
HP Lefthand      
             
HP MSA2000      
             
HP p2000          
      Use the XML API. XML::XPath, LWP::UserAgent, URI, HTTP::Cookies
IBM DS3000              
  Use 'SMcli' command.  
IBM DS4000              
  Use 'SMcli' command.  
IBM DS5000              
  Use 'SMcli' command.  
IBM TS3100      
             
IBM TS3200      
             
Netapp      
            DateTime
Nimble      
             
Panzura      
             
Qnap      
             
Synology      
             
Violin 3000      
             

How can I remove perfdatas ?

For example, I check TCP connections from a linux in SNMP with following command:

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=tcpcon --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public
OK: Total connections: 1 | 'total'=1;;;0; 'con_closed'=0;;;0; 'con_closeWait'=0;;;0; '  con_synSent'=0;;;0; 'con_established'=1;;;0; 'con_timeWait'=0;;;0; 'con_lastAck'=0;;;0  ; 'con_listen'=5;;;0; 'con_synReceived'=0;;;0; 'con_finWait1'=0;;;0; 'con_finWait2'=0;  ;;0; 'con_closing'=0;;;0;

There are too many perfdatas and I want to keep 'total' perfdata only. I use the option --filter-perfdata='total':

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=tcpcon --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --filter-perfdata='total'
OK: Total connections: 1 | 'total'=1;;;0;

I can use regexp in --filter-perfdata option. So, I can exclude perfdata beginning by 'total':

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=tcpcon --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --filter-perfdata='^(?!(total))'
OK: Total connections: 1 | 'con_closed'=0;;;0; 'con_closeWait'=0;;;0; 'con_synSent'=0;;;0; 'con_established'=1;;;0; 'con_timeWait'=0;;;0; 'con_lastAck'=0;;;0; 'con_listen'=5;;;0; 'con_synReceived'=0;;;0; 'con_finWait1'=0;;;0; 'con_finWait2'=0;;;0; 'con_closing'=0;;;0;

How can I set threshold: critical if value < X ?

"centreon-plugins" can manage Nagios threshold ranges: https://nagios-plugins.org/doc/guidelines.html#THRESHOLDFORMAT

For example, I want to check that 'crond' is running (if there is less than 1 process, critical). I have two ways:

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=processcount --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --process-name=crond --critical=1:
CRITICAL: Number of current processes running: 0 | 'nbproc'=0;;1:;0;

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=processcount --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --process-name=crond --critical=@0:0
CRITICAL: Number of current processes running: 0 | 'nbproc'=0;;@0:0;0;

How can I check a generic SNMP OID value ?

There is a generic SNMP plugin to check it. An example to get 'SysUptime' SNMP OID:

$ perl centreon_plugins.pl --plugin=apps::protocols::snmp::plugin --mode=numeric-value --oid='.1.3.6.1.2.1.1.3.0' --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public

How can I check ipv6 equipment in SNMP ?

To check ipv6 equipment, use the following syntax (udp6:[xxxx]):

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --hostname='udp6:[fe80::250:56ff:feb5:6ae0]' --mode=storage --snmp-version=2c --snmp-community=public

How to use memcached server for retention datas ?

Some plugins need to store datas. Two ways to store it:

  • File on a disk (by default).
  • Memcached server.

To use 'memcached', you must have a memcached server and the CPAN 'Memcached::libmemcached' module installed. You can set the memcached server with the option --memcached:

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=interfaces --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --verbose --add-traffic --memcached=127.0.0.1
OK: All traffic are ok | 'traffic_in_lo'=197.40b/s;;;0;10000000 'traffic_out_lo'=197.40b/s;;;0;10000000 'traffic_in_eth0'=14539.11b/s;;;0;1000000000 'traffic_out_eth0'=399.59b/s;;;0;1000000000 'traffic_in_eth1'=13883.82b/s;;;0;1000000000 'traffic_out_eth1'=1688.66b/s;;;0;1000000000
Interface 'lo' Traffic In : 197.40b/s (0.00 %), Out : 197.40b/s (0.00 %)
Interface 'eth0' Traffic In : 14.54Kb/s (0.00 %), Out : 399.59b/s (0.00 %)
Interface 'eth1' Traffic In : 13.88Kb/s (0.00 %), Out : 1.69Kb/s (0.00 %)

Tip

Local file is used if the memcached server is not responding.

What does --dyn-mode option do ?

With the option, you can use a mode with a plugin. It is commonly used for database checks. For example, I have an application which stores some monitoring information on a database. The developer can use another plugin to create the check (no need to do the SQL connections,... It saves time):

$ perl centreon_plugins.pl --plugin=database::mysql::plugin --dyn-mode=apps::centreon::mysql::mode::pollerdelay --host=10.30.3.75 --username='test' --password='testpw' --verbose
OK: All poller delay for last update are ok | 'delay_Central'=2s;0:300;0:600;0; 'delay_Poller-Engine'=2s;0:300;0:600;0;
Delay for last update of Central is 2 seconds
Delay for last update of Poller-Engine is 2 seconds

Warning

A mode using the following system must notice it (in the help description). So you should open the file with an editor and read at the end the description.

How can I check the plugin version ?

You can check the version of plugins and modes with option --version:

$ perl centreon_plugins.pl --version
Global Version: 20160524
$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --version
Plugin Version: 0.1
$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=storage --version
Mode Version: 1.0

You can also use the option --mode-version to execute the mode only if there is the good version. For example, we want to execute the mode only if the version >= 2.x:

$  perl  centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=storage --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --verbose --mode-version='2.x'
UNKNOWN: Not good version for plugin mode. Excepted at least: 2.x. Get: 1.0

Can I have one standalone Perl file ?

We have done some tests and it will cost around 4% more of execution time. We are going to create a standalone Linux SNMP plugin.

Download the Perl module App::FatPacker on metacpan:

# tar zxvf App-FatPacker-0.010005.tar.gz
# cd App-FatPacker-0.010005
# perl Makefile.PL && make && make install

Create a directory to build it:

# mkdir -p build/plugin
# cd build

Clone centreon-plugins:

# git clone https://github.com/centreon/centreon-plugins.git

fatpack includes pm files under the directory lib:

# mkdir plugin/lib && cd centreon-plugins

Copy the common files for all plugins:

# find . -name "*.pm" -exec sed -i ' /__END__/d' \{\} \;
# cp -R --parent centreon/plugins/{misc,mode,options,output,perfdata,script,statefile,values}.pm centreon/plugins/templates/ centreon/plugins/alternative/ ../plugin/lib/
# cp centreon_plugins.pl ../plugin
# sed -i 's/alternative_fatpacker = 0/alternative_fatpacker = 1/' ../plugin/lib/centreon/plugins/script.pm

Copy files for Linux SNMP plugin:

# cp -R --parent centreon/plugins/{script_snmp,snmp}.pm os/linux/snmp/ snmp_standard/mode/{cpu,cpudetailed,diskio,diskusage,inodes,interfaces,loadaverage,listdiskspath,listinterfaces,liststorages,memory,processcount,storage,swap,ntp,tcpcon,uptime}.pm ../plugin/lib/

Build the standalone Perl file:

# cd ../plugin
# fatpack file centreon_plugins.pl > centreon_linux_snmp.pl

The plugin works in the same way:

# perl centreon_linux_snmp.pl --plugin=os::linux::snmp::plugin --mode=processcount --snmp-community public --snmp-version 2c --hostname=127.0.0.1  --process-name='' --process-status='' --process-args=''

Howto build a standalone Windows executable ?

This is only useful if you want to compile your own centreon_plugins.exe. You won't need to install Perl on your windows server.

Once everything is installed, install CPAN Module PAR::Packer (replace <PERL_INSTALL_DIR>):

cmd> <PERL_INSTALL_DIR>\perl\bin\cpan.bat
cpan> install PAR::Packer

It can take several minutes to install the CPAN Module.

In the parent directory containing the directory centreon-plugins, create a build.bat file (replace <PERL_INSTALL_DIR>). We exclude the module IO::Socket::INET6 (Perl 5.14 has the full set of IPv6 functions as part of its core Socket module).

set PERL_INSTALL_DIR=<PERL_INSTALL_DIR>

chdir /d %~dp0
set PAR_VERBATIM=1

cmd /C %PERL_INSTALL_DIR%\perl\site\bin\pp --lib=centreon-plugins\ -o centreon_plugins.exe centreon-plugins\centreon_plugins.pl ^
--unicode ^
-X IO::Socket::INET6 ^
--link=%PERL_INSTALL_DIR%\c\bin\libxml2-2__.dll ^
--link=%PERL_INSTALL_DIR%\c\bin\libiconv-2__.dll ^
--link=%PERL_INSTALL_DIR%\c\bin\liblzma-5__.dll ^
--link=%PERL_INSTALL_DIR%\c\bin\zlib1__.dll ^
--link=%PERL_INSTALL_DIR%\c\bin\libcrypto-1_1-x64__.dll ^
--link=%PERL_INSTALL_DIR%\c\bin\libssl-1_1-x64__.dll ^
-M IO::Socket::SSL ^
-M Win32::Job ^
-M Email::Send::SMTP::Gmail ^
-M HTTP::ProxyPAC ^
-M JE ^
-M Tie::RefHash::Weak ^
-M XML::LibXML::SAX ^
-M Net::FTPSSL ^
-M Authen::NTLM ^
-M JSON::XS ^
-M apps::backup::netbackup::local::plugin ^
-M apps::backup::netbackup::local::mode::dedupstatus ^
-M apps::backup::netbackup::local::mode::drivecleaning ^
-M apps::backup::netbackup::local::mode::drivestatus ^
-M apps::backup::netbackup::local::mode::jobstatus ^
-M apps::backup::netbackup::local::mode::listpolicies ^
-M apps::backup::netbackup::local::mode::tapeusage ^
-M apps::backup::veeam::local::plugin ^
-M apps::backup::veeam::local::mode::jobstatus ^
-M apps::backup::veeam::local::mode::listjobs ^
-M apps::backup::veeam::local::mode::tapejobs ^
-M apps::centreon::local::plugin ^
-M apps::centreon::local::mode::downtimetrap ^
-M apps::centreon::local::mode::centreonpluginsversion ^
-M apps::citrix::local::plugin ^
-M apps::citrix::local::mode::license ^
-M apps::citrix::local::mode::session ^
-M apps::citrix::local::mode::zone ^
-M apps::citrix::local::mode::folder ^
-M apps::microsoft::activedirectory::local::plugin ^
-M apps::microsoft::activedirectory::local::mode::dcdiag ^
-M apps::microsoft::activedirectory::local::mode::dfsrbacklog ^
-M apps::microsoft::activedirectory::local::mode::netdom ^
-M apps::microsoft::exchange::local::plugin ^
-M apps::microsoft::exchange::local::mode::activesyncmailbox ^
-M apps::microsoft::exchange::local::mode::databases ^
-M apps::microsoft::exchange::local::mode::listdatabases ^
-M apps::microsoft::exchange::local::mode::imapmailbox ^
-M apps::microsoft::exchange::local::mode::mapimailbox ^
-M apps::microsoft::exchange::local::mode::outlookwebservices ^
-M apps::microsoft::exchange::local::mode::owamailbox ^
-M apps::microsoft::exchange::local::mode::queues ^
-M apps::microsoft::exchange::local::mode::replicationhealth ^
-M apps::microsoft::exchange::local::mode::services ^
-M apps::microsoft::hyperv::2012::local::plugin ^
-M apps::microsoft::hyperv::2012::local::mode::listnodevms ^
-M apps::microsoft::hyperv::2012::local::mode::scvmmintegrationservice ^
-M apps::microsoft::hyperv::2012::local::mode::scvmmsnapshot ^
-M apps::microsoft::hyperv::2012::local::mode::scvmmvmstatus ^
-M apps::microsoft::hyperv::2012::local::mode::nodeintegrationservice ^
-M apps::microsoft::hyperv::2012::local::mode::nodereplication ^
-M apps::microsoft::hyperv::2012::local::mode::nodesnapshot ^
-M apps::microsoft::hyperv::2012::local::mode::nodevmstatus ^
-M apps::microsoft::iis::local::plugin ^
-M apps::microsoft::iis::local::mode::listapplicationpools ^
-M apps::microsoft::iis::local::mode::applicationpoolstate ^
-M apps::microsoft::iis::local::mode::listsites ^
-M apps::microsoft::iis::local::mode::webservicestatistics ^
-M apps::microsoft::mscs::local::plugin ^
-M apps::microsoft::mscs::local::mode::listnodes ^
-M apps::microsoft::mscs::local::mode::listresources ^
-M apps::microsoft::mscs::local::mode::networkstatus ^
-M apps::microsoft::mscs::local::mode::nodestatus ^
-M apps::microsoft::mscs::local::mode::resourcestatus ^
-M apps::microsoft::mscs::local::mode::resourcegroupstatus ^
-M apps::microsoft::sccm::local::plugin ^
-M apps::microsoft::sccm::local::mode::databasereplicationstatus ^
-M apps::microsoft::sccm::local::mode::sitestatus ^
-M apps::microsoft::wsus::local::plugin ^
-M apps::microsoft::wsus::local::mode::computersstatus ^
-M apps::microsoft::wsus::local::mode::updatesstatus ^
-M apps::microsoft::wsus::local::mode::synchronisationstatus ^
-M apps::microsoft::wsus::local::mode::serverstatistics ^
-M apps::protocols::ldap::plugin ^
-M apps::protocols::ldap::mode::login ^
-M apps::protocols::ldap::mode::search ^
-M apps::protocols::ftp::plugin ^
-M apps::protocols::ftp::mode::commands ^
-M apps::protocols::ftp::mode::date ^
-M apps::protocols::ftp::mode::filescount ^
-M apps::protocols::ftp::mode::login ^
-M apps::protocols::http::plugin ^
-M apps::protocols::http::mode::expectedcontent ^
-M apps::protocols::http::mode::response ^
-M apps::protocols::tcp::plugin ^
-M apps::protocols::tcp::mode::responsetime ^
-M apps::protocols::x509::plugin ^
-M apps::protocols::x509::mode::certificate ^
-M apps::protocols::x509::mode::validity ^
-M centreon::common::protocols::ldap::lib::ldap ^
-M centreon::common::powershell::exchange::powershell ^
-M centreon::common::powershell::functions ^
-M centreon::common::powershell::hyperv::2012::listnodevms ^
-M centreon::common::powershell::hyperv::2012::nodeintegrationservice ^
-M centreon::common::powershell::hyperv::2012::nodereplication ^
-M centreon::common::powershell::hyperv::2012::nodesnapshot ^
-M centreon::common::powershell::hyperv::2012::nodevmstatus ^
-M centreon::common::powershell::hyperv::2012::scvmmintegrationservice ^
-M centreon::common::powershell::hyperv::2012::scvmmsnapshot ^
-M centreon::common::powershell::hyperv::2012::scvmmvmstatus ^
-M centreon::common::powershell::sccm::databasereplicationstatus ^
-M centreon::common::powershell::sccm::sitestatus ^
-M centreon::common::powershell::veeam::jobstatus ^
-M centreon::common::powershell::veeam::listjobs ^
-M centreon::common::powershell::veeam::tapejobs ^
-M centreon::common::powershell::windows::liststorages ^
-M centreon::common::powershell::wsus::computersstatus ^
-M centreon::common::powershell::wsus::updatesstatus ^
-M centreon::common::powershell::wsus::synchronisationstatus ^
-M centreon::common::powershell::wsus::serverstatistics ^
-M centreon::plugins::alternative::Getopt ^
-M centreon::plugins::backend::http::lwp ^
-M centreon::plugins::backend::http::curl ^
-M centreon::plugins::backend::http::curlconstants ^
-M centreon::plugins::script ^
-M hardware::devices::safenet::hsm::protecttoolkit::plugin ^
-M hardware::devices::safenet::hsm::protecttoolkit::mode::hardware ^
-M hardware::devices::safenet::hsm::protecttoolkit::mode::components::temperature ^
-M hardware::devices::safenet::hsm::protecttoolkit::mode::components::hwstatus ^
-M hardware::devices::safenet::hsm::protecttoolkit::mode::components::memory ^
-M os::windows::local::plugin ^
-M os::windows::local::mode::cmdreturn ^
-M os::windows::local::mode::ntp ^
-M os::windows::local::mode::pendingreboot ^
-M os::windows::local::mode::sessions ^
-M os::windows::local::mode::liststorages ^
-M storage::dell::compellent::local::plugin ^
-M storage::dell::compellent::local::mode::hbausage ^
-M storage::dell::compellent::local::mode::volumeusage ^
--verbose

pause

Add plugins and modes you need in centreon_plugins.exe (the example add some plugins). Eventually, execute build.bat file to create executable centreon_plugins.exe.

If you want to change the executable version and ico file, add following code after PERL_INSTALL_DIR first line:

set ICO_FILE=centreon.ico
set RC_FILE=centreon.rc

chdir /d %~dp0

for /f "tokens=4 delims= " %%i in ('type centreon-plugins\centreon\plugins\script.pm ^| findstr global_version ^| findstr my') do set "VERSION_PLUGIN=%%i"
set VERSION_PLUGIN=%VERSION_PLUGIN:~1,8%

(
echo #define PP_MANIFEST_FILEFLAGS 0
echo #include ^<windows.h^>
echo.
echo CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "winres\\pp.manifest"
echo.
echo VS_VERSION_INFO VERSIONINFO
echo    FILEVERSION        0,0,0,0
echo    PRODUCTVERSION     0,0,0,0
echo    FILEFLAGSMASK      VS_FFI_FILEFLAGSMASK
echo    FILEFLAGS          PP_MANIFEST_FILEFLAGS
echo    FILEOS             VOS_NT_WINDOWS32
echo    FILETYPE           VFT_APP
echo    FILESUBTYPE        VFT2_UNKNOWN
echo BEGIN
echo    BLOCK "StringFileInfo"
echo    BEGIN
echo        BLOCK "000004B0"
echo        BEGIN
echo            VALUE "CompanyName", "Centreon\0"
echo            VALUE "FileDescription", " \0"
echo            VALUE "FileVersion", "1.0.0.0\0"
echo            VALUE "InternalName", " \0"
echo            VALUE "LegalCopyright", " \0"
echo            VALUE "LegalTrademarks", " \0"
echo            VALUE "OriginalFilename", " \0"
echo            VALUE "ProductName", "centreon-plugins\0"
echo            VALUE "ProductVersion", "%VERSION_PLUGIN%.0\0"
echo        END
echo    END
echo    BLOCK "VarFileInfo"
echo    BEGIN
echo        VALUE "Translation", 0x00, 0x04B0
echo    END
echo END
echo.
echo WINEXE ICON winres\\pp.ico
)> %RC_FILE%

for /f "delims=" %%i in ('dir /ad /B %PERL_INSTALL_DIR%\cpan\build\PAR-Packer-*') do set "PAR_PACKER_DIRNAME=%%i"
SET PAR_PACKER_SRC=%PERL_INSTALL_DIR%\cpan\build\%PAR_PACKER_DIRNAME%

copy /Y %ICO_FILE% %PAR_PACKER_SRC%\myldr\winres\pp.ico
copy /Y centreon.rc %PAR_PACKER_SRC%\myldr\winres\pp.rc
del %PAR_PACKER_SRC%\myldr\ppresource.coff
cd /D %PAR_PACKER_SRC%\myldr\ && perl Makefile.PL
cd /D %PAR_PACKER_SRC%\myldr\ && dmake boot.exe
cd /D %PAR_PACKER_SRC%\myldr\ && dmake Static.pm
attrib -R %PERL_INSTALL_DIR%\perl\site\lib\PAR\StrippedPARL\Static.pm
copy /Y %PAR_PACKER_SRC%\myldr\Static.pm %PERL_INSTALL_DIR%\perl\site\lib\PAR\StrippedPARL\Static.pm

You can build a 32 bits binary from a Windows 64 bits:

  • Install Strawberry Perl 5.24.x 32 bits on Windows (Download on http://strawberryperl.com/)
  • Install cpan module PAR::Packer
  • Add following line in the build script : PATH=%PERL_INSTALL_DIR%cbin;%PERL_INSTALL_DIR%perlbin;C:WindowsSystem32

Troubleshooting

SNMP

I get the SNMP error: 'UNKNOWN:.* (tooBig).*'

The following error can happened with some equipments. You can resolve it if you set following options:

  • --subsetleef=20 --maxrepetitions=20

I get the SNMP error: 'UNKNOWN:.*Timeout'

The following error means:

  • Don't have network access to the target SNMP Server (a firewall can block UDP 161).
  • Wrong SNMP community name or SNMP version set.

I get the SNMP error: 'UNKNOWN:.*Cant get a single value'

The following error means: SNMP access is working but you can't retrieve SNMP values. Very possible reasons:

  • SNMP value is not set yet (can be happened when a SNMP server is just started).
  • SNMP value is not implemented by the constructor.
  • SNMP value is set on a specific firmware or OS.

Seems that process check is not working well for some arguments filter

In SNMP, there is a limit in argument length of 128 characters. So, if you try to filter with an argument after 128 characters, it won't work. It can happen with Java arguments. To solve the problem, you should prefer a NRPE check.

Can't access in SNMP v3

First, you need to validate SNMP v3 connection with snmpwalk. When it's working, you set SNMP v3 options in command line. The mapping between 'snmpwalk' options and "centreon-plugins" options:

  • -a => --authprotocol
  • -A => --authpassphrase
  • -u => --snmp-username
  • -x => --privprotocol
  • -X => --privpassphrase
  • -l => not needed (automatic)
  • -e => --securityengineid
  • -E => --contextengineid

Miscellaneous

I get the error: "UNKNOWN: Need to specify '--custommode'."

Some plugins need to set the option --custommode. You can know the value to set with the option --list-custommode. An example:

$ perl centreon_plugins.pl --plugin=storage::ibm::DS3000::cli::plugin --list-custommode
...
Custom Modes Available:
 smcli

$ perl centreon_plugins.pl --plugin=storage::ibm::DS3000::cli::plugin --custommode=smcli --list-mode

I get the error: "UNKNOWN: Cannot write statefile .*"

You must create the directory (with write permissions) to let the plugin stores some datas on disk.

I get the error: "UNKNOWN: Cannot load module 'xxx'."

The problem can be:

  • A prerequisite CPAN module is missing. You need to install it.
  • The CPAN module cannot be loaded because of its path. Perl modules must be installed on some specific paths.

I can't see help messages

"centreon-plugins" files must Unix format (no Windows carriage returns). You can change it with the following command:

$ find . -name "*.p[ml]" -type f -exec dos2unix \{\} \;

Warning

Execute the command in "centreon-plugins" directory.

Command Samples

Windows

Check all disks in SNMP

Warning if space used > 80% and critical if space used > 90%:

$ perl centreon_plugins.pl --plugin=os::windows::snmp::plugin --mode=storage --hostname=xxx.xxx.xxx.xxx --snmp-version=2c --snmp-public=community  --verbose --storage='.*' --name --regexp --display-transform-src='(..).*' --display-transform-dst='$1' --warning=80 --critical=90
OK: All storages are ok. | used_C:'=38623698944B;0:108796887040;0:122396497920;0;135996108800 used_D:'=38623698944B;0:108796887040;0:122396497920;0;135996108800
Storage 'C:' Total: 126.66 GB Used: 35.97 GB (28.40%) Free: 90.69 GB (71.60%)
Storage 'D:' Total: 126.66 GB Used: 35.97 GB (28.40%) Free: 90.69 GB (71.60%)

Warning if space free < 5G and critical if space free < 2G:

$ perl centreon_plugins.pl --plugin=os::windows::snmp::plugin --mode=storage --hostname=xxx.xxx.xxx.xxx --snmp-version=2c --snmp-public=community  --verbose --storage='.*' --name --regexp --display-transform-src='(..).*' --display-transform-dst='$1' --warning=5497558138880: --critical=2199023255552: --units='B' --free
OK: All storages are ok. | 'free_C:'=97372344320B;0:5497558138880;0:2199023255552;0;135996108800 'free_D:'=97372344320B;0:5497558138880;0:2199023255552;0;135996108800
Storage 'C:' Total: 126.66 GB Used: 35.97 GB (28.40%) Free: 90.69 GB (71.60%)
Storage 'D:' Total: 126.66 GB Used: 35.97 GB (28.40%) Free: 90.69 GB (71.60%)

Linux

Check all interface traffics in SNMP

Warning if traffic in/out used > 80% and critical if traffic in/out used > 90%:

$ perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=interfaces --hostname=127.0.0.1 --snmp-version=2c --snmp-community=public --verbose --interface='.*' --name --add-traffic --warning-in-traffic=80 --critical-in-traffic=90 --warning-out-traffic=80 --critical-out-traffic=90
OK: All traffic are ok | 'traffic_in_lo'=126.58b/s;0.00:8000000.00;0.00:9000000.00;0;10000000 'traffic_out_lo'=126.58b/s;0.00:8000000.00;0.00:9000000.00;0;10000000 'traffic_in_eth0'=1872.00b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000 'traffic_out_eth0'=266.32b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000 'traffic_in_eth1'=976.65b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000 'traffic_out_eth1'=1021.68b/s;0.00:800000000.00;0.00:900000000.00;0;1000000000
Interface 'lo' Traffic In : 126.58b/s (0.00 %), Out : 126.58b/s (0.00 %)
Interface 'eth0' Traffic In : 1.87Kb/s (0.00 %), Out : 266.32b/s (0.00 %)
Interface 'eth1' Traffic In : 976.65b/s (0.00 %), Out : 1.02Kb/s (0.00 %)

HTTP Protocol

Check authentification of an application (POST request)

An example for authentification form of demo.centreon.com:

$ perl centreon_plugins.pl --plugin=apps::protocols::http::plugin --mode=expected-content --hostname=demo.centreon.com  --method='POST' --post-param='useralias=admin' --post-param='password=centreon'  --cookies-file='/tmp/lwp_cookies.dat' --urlpath='/centreon/index.php' --expected-string='color_UNREACHABLE'
OK: 'color_UNREACHABLE' is present in content. | 'time'=0.575s;;;0; 'size'=20708B;;;0;

Modbus Protocol

Check 3 holding registers

The content of the modbus.json file can be set directly in --config option (eg. : --config='{ "selection": { "metric1":{...'). The type attribute can have following values:

  • holding (default)
  • coils
  • discrete
  • input
{
    "selection":{
        "metric1":{
            "address": 1,
            "quantity": 1,
            "type": "holding",
            "display": true
        },
        "metric2":{
            "address": 2,
            "quantity": 1,
            "type": "holding",
            "display": true
        },
        "metric3":{
            "address": 3,
            "quantity": 1,
            "type": "holding",
            "display": true
        }
    }
}

The command result:

$ perl centreon_plugins.pl --plugin=apps/protocols/modbus/plugin.pm --mode=numeric-value --tcp-host=10.0.0.1 --config=modbus.json --verbose
OK: All metrics are OK | 'metric1'=0;;;; 'metric2'=41291;;;; 'metric3'=42655;;;;
Metric 'metric1' value is '0'
Metric 'metric2' value is '41291'
Metric 'metric3' value is '42655'

How to change the formatting output ?

There is a command section to change formatting output globally and also to override for each metrics:

{
    "selection":{
        "metric1":{
            "address": 1,
            "quantity": 1,
            "type": "holding",
            "display": true
        },
        "metric2":{
            "address": 2,
            "quantity": 1,
            "type": "holding",
            "display": true
        },
        "metric3":{
            "address": 3,
            "quantity": 1,
            "type": "holding",
            "display": true,
            "formatting": {
                "printf_msg": "Override '%s' value is %.2f",
                "printf_var": "$self->{result_values}->{instance}, $self->{result_values}->{value}"
            }
        }
    },
    "formatting": {
        "printf_msg": "My metric '%s' value is %.2f",
        "printf_var": "$self->{result_values}->{instance}, $self->{result_values}->{value}"
    }
}

The command result:

$ perl centreon_plugins.pl --plugin=apps/protocols/modbus/plugin.pm --mode=numeric-value --tcp-host=10.0.0.1 --config=modbus.json --verbose
OK: All metrics are OK | 'metric1'=0;;;; 'metric2'=41291;;;; 'metric3'=42655;;;;
My Metric 'metric1' value is 0.00
My Metric 'metric2' value is 41291.00
Override 'metric3' value is 42655.00

How to average 4 registers ?

We create following average values: [x1 + x2 / 2 = y] [x3 + x4 / 2 = z]. With the pattern, you can select the metrics. In our case, we get 4 values in one selection. Selected metric names are: metrics.0, metrics.1, metrics.2, metrics.3 (order is preserved).

The aggregation attribute can have following values:

  • avg: returns the average of all the elements.
  • sum: returns the numerical sum of all the elements.
  • min: returns the entry in elements with the lowest numerical value.
  • max: returns the entry in elements with the highest numerical value.
{
    "selection":{
        "metrics":{
            "address": 1,
            "quantity": 4,
            "type": "holding",
            "display": false
        }
    },
    "virtualcurve":{
        "avg1":{
            "pattern": "metrics\\.[01]$",
            "aggregation": "avg",
            "unit": "con"
        },
        "avg2":{
            "pattern": "metrics\\.[23]$",
            "aggregation": "avg",
            "unit": "con"
        }
    }
}

The command result:

$ perl centreon_plugins.pl --plugin=apps/protocols/modbus/plugin.pm --mode=numeric-value --tcp-host=10.0.0.1 --config=modbus.json --verbose
OK: Global metrics are OK | 'avg1'=42192con;;;; 'avg2'=40574con;;;;
Metric 'avg1' value is '42192'
Metric 'avg2' value is '40574'

Apply a custom calculation

There is a custom attribute to applied some change on the value:

{
    "selection":{
        "metrics":{
            "address": 1,
            "quantity": 4,
            "type": "holding",
            "display": false
        }
    },
    "virtualcurve":{
        "avg":{
            "aggregation": "avg",
            "custom": " / 10",
            "unit": "con"
        }
    }
}

The command result:

$ perl centreon_plugins.pl --plugin=apps/protocols/modbus/plugin.pm --mode=numeric-value --tcp-host=10.0.0.1 --config=modbus.json --verbose
OK: Metric 'avg' value is '3072.3' | 'avg'=3072.3con;;;;
Metric 'avg' value is '3072.3'

Multi-service plugin

This mode allow you to concatenate several result of host and/or service check into one check. Can be used to make some aggregation into logical group or gather information from one Centreon to display in another without checking resources twice.

Design of configuration file

{
    "mode":"sqlmatching",
    "selection":{
        "ESX":{
            "host_name_filter":"%clus-esx-n%",
            "service_name_filter":"Esx-Status"
        },
        "XIVO":{
            "host_name_filter":"%xivo%",
            "service_name_filter":"Ping"
        }
    },
    "counters":{
        "totalservices":true,
        "totalhosts":true,
        "groups":true
    },
    "formatting":{
        "groups_global_msg":"Nothing special on groups",
        "host_service_separator":"/",
        "display_details":true
    }
}
  • mode (mandatory) : can be 'sqlmatching' or 'exactmatch'. Linked to the layout of "selection" bloc
  • selection (mandatory) : if we use sqlmatching, we define filters like above, if we use exact match, need to pass a key/value pair corresponding to host/service (example below with two "groups" esx-status/load)
"selection":{
    "esx-status":{
        "esx-n1":"Esx-Status",
        "esx-n2":"Esx-Status",
        "esx-n3":"Esx-Status"
    },
    "esx-load":{
        "esx-n1":"Esx-Memory",
        "esx-n2":"Esx-Memory",
        "esx-n3":"Esx-Memory",
        "esx-n1":"Esx-Cpu",
        "esx-n2":"Esx-Cpu",
        "esx-n3":"Esx-Cpu"
    }
},
  • counters (optionnal) : Contains three keys to choose which counters we should use and consider (totalservices, totalhosts, groups)
  • formatting (optionnal) : Contains three keys, 'groups_global_msg' to define a global OK status message, 'host_service_separator' to define separator used between host and service name in output, 'display_details' to config if plugin should display details of host/service name in the verbose output.

Command line, output, threshold ...

Sample command:

/usr/lib/nagios/plugins/centreon_plugins.pl --plugin database::mysql::plugin --dyn-mode apps::centreon::sql::mode::multiservices --host localhost --username centreon --password c3ntreon --config-file '/root/global-services.json' --verbose

Sample output:

OK: Hosts state summary [up:4][down:2][unreachable:0] - Services state summary [ok:4][warning:0][critical:2][unknown:0] - Nothing special on groups |

Perfdatas:

'total_host_up'=4;;;0; 'total_host_down'=2;;;0; 'total_host_unreachable'=0;;;0; 'total_host_ok'=4;;;0; 'total_host_warning'=0;;;0; 'total_host_critical'=2;;;0; 'total_host_unknown'=0;;;0; 'host_up_ESX'=4;;;0; 'host_down_ESX'=0;;;0; 'host_unreachable_ESX'=0;;;0; 'service_ok_ESX'=4;;;0; 'service_warning_ESX'=0;;;0; 'service_critical_ESX'=0;;;0; 'service_unknown_ESX'=0;;;0; 'host_up_XIVO'=0;;;0; 'host_down_XIVO'=2;;;0; 'host_unreachable_XIVO'=0;;;0; 'service_ok_XIVO'=0;;;0; 'service_warning_XIVO'=0;;;0; 'service_critical_XIVO'=2;;;0; 'service_unknown_XIVO'=0;;;0;

Verbose mode (with display details set as true):

Group 'ESX': HOSTS: [up: 4 (clus-esx-n1.com - clus-esx-n2.com - clus-esx-n3.com - clus-esx-n4.com)][down: 0][unreachable: 0] -      SERVICES: [ok: 4 (clus-esx-n1.com/Esx-Status - clus-esx-n2.com/Esx-Status - clus-esx-n3.com/Esx-Status - clus-esx-n4.com/Esx-Status)][warning: 0][critical: 0][unknown: 0]
Group 'XIVO': HOSTS: [up: 0][down: 2 (srvi-xivo-n1 - srvi-xivo-n2)][unreachable: 0] - SERVICES: [ok: 0][warning: 0][critical: 2 (srvi-xivo-n1/Ping - srvi-xivo-n2/Ping)][unknown: 0]

Concerning the threshold, you can use some example below:

--critical-total '%{total_down} > 4' --critical-groups '%{instance} eq 'ESX' && %{unknown} > 5'

NSClient

You can monitor Windows/Linux system with the Rest API of NSClient. Commands and arguments are the same than NRPE (look the NSClient documentation for more informations):

$ perl centreon_plugins.pl --plugin=apps::nsclient::restapi::plugin --mode=query --hostname="10.30.2.10" --port=443 --legacy-password=centreon --command=check_drivesize --arg="drive=*" --arg="perf-config=used(unit:B)used %(ignored:true)" --arg="filter=type = 'fixed' and name not regexp '.*yst.*'" --arg="warning=total_used>80%" --arg="critical=total_used>90%"
OK All 2 drive(s) are ok | '\\?\Volume{7cd2d555-9868-11e7-8199-806e6f6e6963}\ used'=289468416.000B;293598003.000;330297753.000;0.000;366997504.000 'C:\ used'=23285907456.000B;42654390681.000;47986189516.000;0.000;53317988352.000