Merge pull request #1 from centreon/master

merge
This commit is contained in:
Thibault S 2019-10-21 11:49:22 +02:00 committed by GitHub
commit 2c232f9493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 1570 additions and 292 deletions

View File

@ -31,10 +31,10 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'dcdiag' => 'apps::activedirectory::local::mode::dcdiag',
'dfsr-backlog' => 'apps::activedirectory::local::mode::dfsrbacklog',
'netdom' => 'apps::activedirectory::local::mode::netdom',
);
'dcdiag' => 'apps::activedirectory::local::mode::dcdiag',
'dfsr-backlog' => 'apps::activedirectory::local::mode::dfsrbacklog',
'netdom' => 'apps::activedirectory::local::mode::netdom',
);
return $self;
}

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'dcdiag' => 'apps::activedirectory::wsman::mode::dcdiag',
);
'dcdiag' => 'apps::activedirectory::wsman::mode::dcdiag',
);
return $self;
}

View File

@ -40,16 +40,16 @@ sub new {
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 50 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'ANSIBLE_LOAD_CALLBACK_PLUGINS=true ANSIBLE_STDOUT_CALLBACK=json ansible' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '' },
'hostname:s' => { name => 'hostname' },
'remote' => { name => 'remote' },
'ssh-option:s@' => { name => 'ssh_option' },
'ssh-path:s' => { name => 'ssh_path' },
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
'timeout:s' => { name => 'timeout', default => 50 },
'sudo' => { name => 'sudo' },
'command:s' => { name => 'command', default => 'ANSIBLE_LOAD_CALLBACK_PLUGINS=true ANSIBLE_STDOUT_CALLBACK=json ansible' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '' },
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'CLI OPTIONS', once => 1);
@ -99,7 +99,8 @@ sub execute {
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $options{cmd_options}
command_options => $options{cmd_options},
no_errors => { 4 => 1 }
);
my $raw_results;

View File

@ -32,8 +32,8 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"host-pattern:s" => { name => 'host_pattern', default => 'all' },
"prettify" => { name => 'prettify' },
'host-pattern:s' => { name => 'host_pattern', default => 'all' },
'prettify' => { name => 'prettify' },
});
return $self;

View File

@ -40,15 +40,15 @@ sub new {
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
"host:s" => { name => 'host' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"timeout:s" => { name => 'timeout', default => 50 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'tower-cli' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '' },
"proxyurl:s" => { name => 'proxyurl' },
'host:s' => { name => 'host' },
'username:s' => { name => 'username' },
'password:s' => { name => 'password' },
'timeout:s' => { name => 'timeout', default => 50 },
'sudo' => { name => 'sudo' },
'command:s' => { name => 'command', default => 'tower-cli' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '' },
'proxyurl:s' => { name => 'proxyurl' },
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'TOWERCLI OPTIONS', once => 1);

View File

@ -32,9 +32,9 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"group" => { name => 'group' },
"inventory" => { name => 'inventory' },
"prettify" => { name => 'prettify' },
'group' => { name => 'group' },
'inventory' => { name => 'inventory' },
'prettify' => { name => 'prettify' },
});
return $self;

View File

@ -31,13 +31,13 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'dedup-status' => 'apps::backup::netbackup::local::mode::dedupstatus',
'drive-cleaning' => 'apps::backup::netbackup::local::mode::drivecleaning',
'drive-status' => 'apps::backup::netbackup::local::mode::drivestatus',
'job-status' => 'apps::backup::netbackup::local::mode::jobstatus',
'list-policies' => 'apps::backup::netbackup::local::mode::listpolicies',
'tape-usage' => 'apps::backup::netbackup::local::mode::tapeusage',
);
'dedup-status' => 'apps::backup::netbackup::local::mode::dedupstatus',
'drive-cleaning' => 'apps::backup::netbackup::local::mode::drivecleaning',
'drive-status' => 'apps::backup::netbackup::local::mode::drivestatus',
'job-status' => 'apps::backup::netbackup::local::mode::jobstatus',
'list-policies' => 'apps::backup::netbackup::local::mode::listpolicies',
'tape-usage' => 'apps::backup::netbackup::local::mode::tapeusage',
);
return $self;
}

View File

@ -31,11 +31,11 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'list-vtl' => 'apps::backup::quadstor::local::mode::listvtl',
'vtl-disk-usage' => 'apps::backup::quadstor::local::mode::vtldiskusage',
'vtl-job-status' => 'apps::backup::quadstor::local::mode::vtljobstatus',
'vtl-tape-usage' => 'apps::backup::quadstor::local::mode::vtltapeusage',
);
'list-vtl' => 'apps::backup::quadstor::local::mode::listvtl',
'vtl-disk-usage' => 'apps::backup::quadstor::local::mode::vtldiskusage',
'vtl-job-status' => 'apps::backup::quadstor::local::mode::vtljobstatus',
'vtl-tape-usage' => 'apps::backup::quadstor::local::mode::vtltapeusage',
);
return $self;
}

View File

@ -31,12 +31,12 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'actlog' => 'apps::backup::tsm::local::mode::actlog',
'drives' => 'apps::backup::tsm::local::mode::drives',
'nodes' => 'apps::backup::tsm::local::mode::nodes',
'sessions' => 'apps::backup::tsm::local::mode::sessions',
'volumes' => 'apps::backup::tsm::local::mode::volumes',
);
'actlog' => 'apps::backup::tsm::local::mode::actlog',
'drives' => 'apps::backup::tsm::local::mode::drives',
'nodes' => 'apps::backup::tsm::local::mode::nodes',
'sessions' => 'apps::backup::tsm::local::mode::sessions',
'volumes' => 'apps::backup::tsm::local::mode::volumes',
);
$self->{custom_modes}{api} = 'apps::backup::tsm::local::custom::api';
return $self;

View File

@ -32,8 +32,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'incoming' => 'apps::bluemind::mode::incoming',
);
'incoming' => 'apps::bluemind::mode::incoming',
);
return $self;
}

View File

@ -30,12 +30,12 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'gates' => 'apps::centreon::map4::jmx::mode::gates',
'elements' => 'apps::centreon::map4::jmx::mode::elements',
'sessions' => 'apps::centreon::map4::jmx::mode::sessions',
'event-queue' => 'apps::centreon::map4::jmx::mode::eventqueue',
'event-statistics' => 'apps::centreon::map4::jmx::mode::eventstatistics',
);
'elements' => 'apps::centreon::map4::jmx::mode::elements',
'event-queue' => 'apps::centreon::map4::jmx::mode::eventqueue',
'event-statistics' => 'apps::centreon::map4::jmx::mode::eventstatistics',
'gates' => 'apps::centreon::map4::jmx::mode::gates',
'sessions' => 'apps::centreon::map4::jmx::mode::sessions',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -31,12 +31,13 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'alarms' => 'apps::cisco::cms::restapi::mode::alarms',
'calls' => 'apps::cisco::cms::restapi::mode::calls',
'database-status' => 'apps::cisco::cms::restapi::mode::databasestatus',
'licenses' => 'apps::cisco::cms::restapi::mode::licenses',
'system-status' => 'apps::cisco::cms::restapi::mode::systemstatus',
);
'alarms' => 'apps::cisco::cms::restapi::mode::alarms',
'calls' => 'apps::cisco::cms::restapi::mode::calls',
'database-status' => 'apps::cisco::cms::restapi::mode::databasestatus',
'licenses' => 'apps::cisco::cms::restapi::mode::licenses',
'system-status' => 'apps::cisco::cms::restapi::mode::systemstatus',
);
$self->{custom_modes}{xmlapi} = 'apps::cisco::cms::restapi::custom::xmlapi';
return $self;
}

View File

@ -31,8 +31,9 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'session' => 'apps::cisco::ise::restapi::mode::session',
);
'session' => 'apps::cisco::ise::restapi::mode::session',
);
$self->{custom_modes}{xmlapi} = 'apps::cisco::ise::restapi::custom::xmlapi';
return $self;
}

View File

@ -31,17 +31,17 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'activesync-mailbox' => 'apps::exchange::2010::local::mode::activesyncmailbox',
'databases' => 'apps::exchange::2010::local::mode::databases',
'list-databases' => 'apps::exchange::2010::local::mode::listdatabases',
'imap-mailbox' => 'apps::exchange::2010::local::mode::imapmailbox',
'mapi-mailbox' => 'apps::exchange::2010::local::mode::mapimailbox',
'outlook-webservices' => 'apps::exchange::2010::local::mode::outlookwebservices',
'owa-mailbox' => 'apps::exchange::2010::local::mode::owamailbox',
'queues' => 'apps::exchange::2010::local::mode::queues',
'replication-health' => 'apps::exchange::2010::local::mode::replicationhealth',
'services' => 'apps::exchange::2010::local::mode::services',
);
'activesync-mailbox' => 'apps::exchange::2010::local::mode::activesyncmailbox',
'databases' => 'apps::exchange::2010::local::mode::databases',
'list-databases' => 'apps::exchange::2010::local::mode::listdatabases',
'imap-mailbox' => 'apps::exchange::2010::local::mode::imapmailbox',
'mapi-mailbox' => 'apps::exchange::2010::local::mode::mapimailbox',
'outlook-webservices' => 'apps::exchange::2010::local::mode::outlookwebservices',
'owa-mailbox' => 'apps::exchange::2010::local::mode::owamailbox',
'queues' => 'apps::exchange::2010::local::mode::queues',
'replication-health' => 'apps::exchange::2010::local::mode::replicationhealth',
'services' => 'apps::exchange::2010::local::mode::services',
);
return $self;
}

View File

@ -31,11 +31,11 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'applicationpool-state' => 'apps::iis::local::mode::applicationpoolstate',
'list-applicationpools' => 'apps::iis::local::mode::listapplicationpools',
'list-sites' => 'apps::iis::local::mode::listsites',
'webservice-statistics' => 'apps::iis::local::mode::webservicestatistics',
);
'applicationpool-state' => 'apps::iis::local::mode::applicationpoolstate',
'list-applicationpools' => 'apps::iis::local::mode::listapplicationpools',
'list-sites' => 'apps::iis::local::mode::listsites',
'webservice-statistics' => 'apps::iis::local::mode::webservicestatistics',
);
return $self;
}

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'applicationpool-state' => 'apps::iis::wsman::mode::applicationpoolstate',
'list-applicationpools' => 'apps::iis::wsman::mode::listapplicationpools',
);
'applicationpool-state' => 'apps::iis::wsman::mode::applicationpoolstate',
'list-applicationpools' => 'apps::iis::wsman::mode::listapplicationpools',
);
return $self;
}

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'span-usage' => 'apps::inin::ig::snmp::mode::spanusage',
'stats' => 'apps::inin::ig::snmp::mode::stats',
);
'span-usage' => 'apps::inin::ig::snmp::mode::spanusage',
'stats' => 'apps::inin::ig::snmp::mode::stats',
);
return $self;
}

View File

@ -31,12 +31,12 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'audioengine-usage' => 'apps::inin::mediaserver::snmp::mode::audioengineusage',
'cmdsrv-usage' => 'apps::inin::mediaserver::snmp::mode::cmdsrvusage',
'disk-usage' => 'apps::inin::mediaserver::snmp::mode::diskusage',
'component' => 'apps::inin::mediaserver::snmp::mode::component',
'memory-usage' => 'apps::inin::mediaserver::snmp::mode::memoryusage',
);
'audioengine-usage' => 'apps::inin::mediaserver::snmp::mode::audioengineusage',
'cmdsrv-usage' => 'apps::inin::mediaserver::snmp::mode::cmdsrvusage',
'component' => 'apps::inin::mediaserver::snmp::mode::component',
'disk-usage' => 'apps::inin::mediaserver::snmp::mode::diskusage',
'memory-usage' => 'apps::inin::mediaserver::snmp::mode::memoryusage',
);
return $self;
}

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'cache-usage' => 'apps::java::solr::jmx::mode::cacheusage',
'request-handler-usage' => 'apps::java::solr::jmx::mode::requesthandlerusage',
);
'cache-usage' => 'apps::java::solr::jmx::mode::cacheusage',
'request-handler-usage' => 'apps::java::solr::jmx::mode::requesthandlerusage',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -31,12 +31,12 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'mail-state' => 'apps::lotus::snmp::mode::mailstate',
'mail-time' => 'apps::lotus::snmp::mode::mailtime',
'server-availability' => 'apps::lotus::snmp::mode::serveravailability',
'user-sessions' => 'apps::lotus::snmp::mode::usersessions',
'server-transactions' => 'apps::lotus::snmp::mode::servertransactions',
);
'mail-state' => 'apps::lotus::snmp::mode::mailstate',
'mail-time' => 'apps::lotus::snmp::mode::mailtime',
'server-availability' => 'apps::lotus::snmp::mode::serveravailability',
'server-transactions' => 'apps::lotus::snmp::mode::servertransactions',
'user-sessions' => 'apps::lotus::snmp::mode::usersessions',
);
return $self;
}

View File

@ -31,10 +31,10 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'crm' => 'apps::pacemaker::local::mode::crm',
'constraints' => 'apps::pacemaker::local::mode::constraints',
'clustat' => 'apps::pacemaker::local::mode::clustat',
);
'clustat' => 'apps::pacemaker::local::mode::clustat',
'constraints' => 'apps::pacemaker::local::mode::constraints',
'crm' => 'apps::pacemaker::local::mode::crm',
);
return $self;
}

View File

@ -32,14 +32,14 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'list-nodes' => 'apps::proxmox::ve::restapi::mode::listnodes',
'list-storages' => 'apps::proxmox::ve::restapi::mode::liststorages',
'list-vms' => 'apps::proxmox::ve::restapi::mode::listvms',
'storage-usage' => 'apps::proxmox::ve::restapi::mode::storageusage',
'node-usage' => 'apps::proxmox::ve::restapi::mode::nodeusage',
'version' => 'apps::proxmox::ve::restapi::mode::version',
'vm-usage' => 'apps::proxmox::ve::restapi::mode::vmusage',
);
'list-nodes' => 'apps::proxmox::ve::restapi::mode::listnodes',
'list-storages' => 'apps::proxmox::ve::restapi::mode::liststorages',
'list-vms' => 'apps::proxmox::ve::restapi::mode::listvms',
'node-usage' => 'apps::proxmox::ve::restapi::mode::nodeusage',
'storage-usage' => 'apps::proxmox::ve::restapi::mode::storageusage',
'version' => 'apps::proxmox::ve::restapi::mode::version',
'vm-usage' => 'apps::proxmox::ve::restapi::mode::vmusage',
);
$self->{custom_modes}{api} = 'apps::proxmox::ve::restapi::custom::api';
return $self;

View File

@ -31,11 +31,11 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'http-hits' => 'apps::pvx::restapi::mode::httphits',
'network-connection' => 'apps::pvx::restapi::mode::networkconnection',
'network-user-experience' => 'apps::pvx::restapi::mode::networkuserexperience',
'network-traffic' => 'apps::pvx::restapi::mode::networktraffic',
);
'http-hits' => 'apps::pvx::restapi::mode::httphits',
'network-connection' => 'apps::pvx::restapi::mode::networkconnection',
'network-user-experience' => 'apps::pvx::restapi::mode::networkuserexperience',
'network-traffic' => 'apps::pvx::restapi::mode::networktraffic',
);
$self->{custom_modes}{api} = 'apps::pvx::restapi::custom::api';
return $self;

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'mta-usage' => 'snmp_standard::mode::mtausage',
);
'mta-usage' => 'snmp_standard::mode::mtausage',
);
return $self;
}

View File

@ -31,9 +31,10 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'count-channels' => 'apps::slack::restapi::mode::countchannels',
'count-members' => 'apps::slack::restapi::mode::countmembers',
);
'count-channels' => 'apps::slack::restapi::mode::countchannels',
'count-members' => 'apps::slack::restapi::mode::countmembers',
);
$self->{custom_modes}{restapi} = 'apps::slack::restapi::custom::api';
return $self;
}

View File

@ -31,20 +31,20 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'class-count' => 'centreon::common::jvm::mode::classcount',
'connector-usage' => 'apps::tomcat::jmx::mode::connectorusage',
'cpu-load' => 'centreon::common::jvm::mode::cpuload',
'datasource-usage' => 'apps::tomcat::jmx::mode::datasourceusage',
'fd-usage' => 'centreon::common::jvm::mode::fdusage',
'gc-usage' => 'centreon::common::jvm::mode::gcusage',
'list-datasources' => 'apps::tomcat::jmx::mode::listdatasources',
'list-webapps' => 'apps::tomcat::jmx::mode::listwebapps',
'load-average' => 'centreon::common::jvm::mode::loadaverage',
'memory' => 'centreon::common::jvm::mode::memory',
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
'threads' => 'centreon::common::jvm::mode::threads',
'webapps-sessions' => 'apps::tomcat::jmx::mode::webappssessions',
);
'class-count' => 'centreon::common::jvm::mode::classcount',
'connector-usage' => 'apps::tomcat::jmx::mode::connectorusage',
'cpu-load' => 'centreon::common::jvm::mode::cpuload',
'datasource-usage' => 'apps::tomcat::jmx::mode::datasourceusage',
'fd-usage' => 'centreon::common::jvm::mode::fdusage',
'gc-usage' => 'centreon::common::jvm::mode::gcusage',
'list-datasources' => 'apps::tomcat::jmx::mode::listdatasources',
'list-webapps' => 'apps::tomcat::jmx::mode::listwebapps',
'load-average' => 'centreon::common::jvm::mode::loadaverage',
'memory' => 'centreon::common::jvm::mode::memory',
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
'threads' => 'centreon::common::jvm::mode::threads',
'webapps-sessions' => 'apps::tomcat::jmx::mode::webappssessions',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'node-usage' => 'apps::video::openheadend::snmp::mode::nodeusage',
'operation-status' => 'apps::video::openheadend::snmp::mode::operationstatus',
);
'node-usage' => 'apps::video::openheadend::snmp::mode::nodeusage',
'operation-status' => 'apps::video::openheadend::snmp::mode::operationstatus',
);
return $self;
}

View File

@ -31,13 +31,13 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'broadcaster-input-usage' => 'apps::video::zixi::restapi::mode::broadcasterinputusage',
'broadcaster-license-usage' => 'apps::video::zixi::restapi::mode::broadcasterlicenseusage',
'broadcaster-output-usage' => 'apps::video::zixi::restapi::mode::broadcasteroutputusage',
'broadcaster-system-usage' => 'apps::video::zixi::restapi::mode::broadcastersystemusage',
'feeder-input-usage' => 'apps::video::zixi::restapi::mode::feederinputusage',
'feeder-output-usage' => 'apps::video::zixi::restapi::mode::feederoutputusage',
);
'broadcaster-input-usage' => 'apps::video::zixi::restapi::mode::broadcasterinputusage',
'broadcaster-license-usage' => 'apps::video::zixi::restapi::mode::broadcasterlicenseusage',
'broadcaster-output-usage' => 'apps::video::zixi::restapi::mode::broadcasteroutputusage',
'broadcaster-system-usage' => 'apps::video::zixi::restapi::mode::broadcastersystemusage',
'feeder-input-usage' => 'apps::video::zixi::restapi::mode::feederinputusage',
'feeder-output-usage' => 'apps::video::zixi::restapi::mode::feederoutputusage',
);
$self->{custom_modes}{api} = 'apps::video::zixi::restapi::custom::api';
return $self;

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'hardware' => 'apps::vmware::wsman::mode::hardware',
);
'hardware' => 'apps::vmware::wsman::mode::hardware',
);
return $self;
}

View File

@ -31,10 +31,10 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'channel-usage' => 'apps::voip::asterisk::ami::mode::channelusage',
'dahdi-status' => 'apps::voip::asterisk::ami::mode::dahdistatus',
'sip-peers-usage' => 'apps::voip::asterisk::ami::mode::sippeersusage',
);
'channel-usage' => 'apps::voip::asterisk::ami::mode::channelusage',
'dahdi-status' => 'apps::voip::asterisk::ami::mode::dahdistatus',
'sip-peers-usage' => 'apps::voip::asterisk::ami::mode::sippeersusage',
);
$self->{custom_modes}{api} = 'apps::voip::asterisk::ami::custom::api';
return $self;

View File

@ -63,16 +63,19 @@ sub check_fan_envmon {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonFanStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance));
next if ($self->check_filter(section => 'fan', instance => $instance, name => $result->{ciscoEnvMonFanStatusDescr}));
next if ($result->{ciscoEnvMonFanState} =~ /not present/i &&
$self->absent_problem(section => 'fan', instance => $instance));
$self->absent_problem(section => 'fan', instance => $instance, name => $result->{ciscoEnvMonFanStatusDescr}));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is %s [instance: %s].",
$result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState},
$instance
));
my $exit = $self->get_severity(section => 'fan', value => $result->{ciscoEnvMonFanState});
$self->{output}->output_add(
long_msg => sprintf(
"fan '%s' status is %s [instance: %s].",
$result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState},
$instance
)
);
my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $result->{ciscoEnvMonFanState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("fan '%s' status is %s",
@ -94,12 +97,16 @@ sub check_fan_entity {
my $fan_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFanTrayOperStatus}, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance));
next if ($self->check_filter(section => 'fan', instance => $instance, name => $fan_descr));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is %s [instance: %s]",
$fan_descr, $result->{cefcFanTrayOperStatus}, $instance));
my $exit = $self->get_severity(section => 'fan', value => $result->{cefcFanTrayOperStatus});
$self->{output}->output_add(
long_msg => sprintf(
"Fan '%s' status is %s [instance: %s]",
$fan_descr, $result->{cefcFanTrayOperStatus}, $instance
)
);
my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $result->{cefcFanTrayOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s/%s' status is %s", $fan_descr, $instance, $result->{cefcFanTrayOperStatus}));
@ -118,4 +125,4 @@ sub check {
check_fan_entity($self);
}
1;
1;

View File

@ -79,12 +79,12 @@ sub check {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcModuleOperStatus}, instance => $instance);
my $module_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
next if ($self->check_filter(section => 'module', instance => $instance));
next if ($self->check_filter(section => 'module', instance => $instance, name => $module_descr));
$self->{components}->{module}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s]",
$module_descr, $result->{cefcModuleOperStatus}, $instance));
my $exit = $self->get_severity(section => 'module', value => $result->{cefcModuleOperStatus});
my $exit = $self->get_severity(section => 'module', instance => $instance, value => $result->{cefcModuleOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Module '%s/%s' status is %s", $module_descr,
@ -93,4 +93,4 @@ sub check {
}
}
1;
1;

View File

@ -61,12 +61,12 @@ sub check {
next;
}
next if ($self->check_filter(section => 'physical', instance => $instance));
next if ($self->check_filter(section => 'physical', instance => $instance, name => $physical_descr));
$self->{components}->{physical}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Physical '%s' status is %s [instance: %s]",
$physical_descr, $result->{cefcPhysicalStatus}, $instance));
my $exit = $self->get_severity(section => 'physical', value => $result->{cefcPhysicalStatus});
my $exit = $self->get_severity(section => 'physical', instance => $instance, value => $result->{cefcPhysicalStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Physical '%s/%s' status is %s", $physical_descr,
@ -75,4 +75,4 @@ sub check {
}
}
1;
1;

View File

@ -79,16 +79,16 @@ sub check_psu_envmon {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonSupplyStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance));
next if ($self->check_filter(section => 'psu', instance => $instance, name => $result->{ciscoEnvMonSupplyStatusDescr}));
next if ($result->{ciscoEnvMonSupplyState} =~ /not present/i &&
$self->absent_problem(section => 'psu', instance => $instance));
$self->absent_problem(section => 'psu', instance => $instance, name => $result->{ciscoEnvMonSupplyStatusDescr}));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s] [source: %s]",
$result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState},
$instance, $result->{ciscoEnvMonSupplySource}
));
my $exit = $self->get_severity(section => 'psu', value => $result->{ciscoEnvMonSupplyState});
my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $result->{ciscoEnvMonSupplyState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is %s",
@ -110,12 +110,12 @@ sub check_psu_entity {
my $psu_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFRUPowerOperStatus}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance));
next if ($self->check_filter(section => 'psu', instance => $instance, name => $psu_descr));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s]",
$psu_descr, $result->{cefcFRUPowerOperStatus}, $instance));
my $exit = $self->get_severity(section => 'psu', value => $result->{cefcFRUPowerOperStatus});
my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $result->{cefcFRUPowerOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s/%s' status is %s", $psu_descr, $instance, $result->{cefcFRUPowerOperStatus}));
@ -134,4 +134,4 @@ sub check {
check_psu_entity($self);
}
1;
1;

View File

@ -59,22 +59,26 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonTemperatureStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance));
next if ($self->check_filter(section => 'temperature', instance => $instance, name => $result->{ciscoEnvMonTemperatureStatusDescr}));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is %s [instance: %s] [value: %s C]",
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState},
$instance, defined($result->{ciscoEnvMonTemperatureStatusValue}) ? $result->{ciscoEnvMonTemperatureStatusValue} : '-'));
my $exit = $self->get_severity(section => 'temperature', value => $result->{ciscoEnvMonTemperatureState});
$self->{output}->output_add(
long_msg => sprintf(
"Temperature '%s' status is %s [instance: %s] [value: %s C]",
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState},
$instance, defined($result->{ciscoEnvMonTemperatureStatusValue}) ? $result->{ciscoEnvMonTemperatureStatusValue} : '-'
)
);
my $exit = $self->get_severity(section => 'temperature', instance => $instance, value => $result->{ciscoEnvMonTemperatureState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' status is %s",
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState}));
}
next if (!defined($result->{ciscoEnvMonTemperatureStatusValue}));
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{ciscoEnvMonTemperatureStatusValue});
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, name => $result->{ciscoEnvMonTemperatureStatusDescr}, value => $result->{ciscoEnvMonTemperatureStatusValue});
if ($checked == 0) {
my $warn_th = undef;
my $crit_th = '~:' . $result->{ciscoEnvMonTemperatureThreshold};

View File

@ -60,13 +60,13 @@ sub check {
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonVoltageStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'voltage', instance => $instance));
next if ($self->check_filter(section => 'voltage', instance => $instance, name => $result->{ciscoEnvMonVoltageStatusDescr}));
$self->{components}->{voltage}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Voltage '%s' status is %s [instance: %s] [value: %s C]",
$result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState},
$instance, $result->{ciscoEnvMonVoltageStatusValue}));
my $exit = $self->get_severity(section => 'voltage', value => $result->{ciscoEnvMonVoltageState});
my $exit = $self->get_severity(section => 'voltage', instance => $instance, value => $result->{ciscoEnvMonVoltageState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Voltage '%s' status is %s",
@ -74,7 +74,7 @@ sub check {
}
$result->{ciscoEnvMonVoltageStatusValue} = $result->{ciscoEnvMonVoltageStatusValue} / 1000;
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{ciscoEnvMonVoltageStatusValue});
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, name => $result->{ciscoEnvMonVoltageStatusDescr}, value => $result->{ciscoEnvMonVoltageStatusValue});
if ($checked == 0) {
my $warn_th = undef;
my $crit_th = ((defined($result->{ciscoEnvMonVoltageThresholdLow}) && $result->{ciscoEnvMonVoltageThresholdLow} =~ /\d/) ? sprintf("%.3f", $result->{ciscoEnvMonVoltageThresholdLow} / 1000) : 0) . ':' .

View File

@ -164,6 +164,10 @@ Can be: 'fan', 'psu', 'temperature', 'voltage', 'module', 'physical', 'sensor'.
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu)
Can also exclude specific instance: --filter=fan,1
=item B<--add-name-instance>
Add literal description for instance value (used in filter, absent-problem and threshold options).
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)

View File

@ -127,8 +127,11 @@ sub check_options {
sub execute {
my ($self, %options) = @_;
my $cmd_options = $options{cmd_options};
$cmd_options .= " --debug" if ($self->{output}->is_debug());
$self->{output}->output_add(long_msg => "Command line: '" . $self->{option_results}->{command} . " " . $options{cmd_options} . "'", debug => 1);
$self->{output}->output_add(long_msg => "Command line: '" . $self->{option_results}->{command} . " " . $cmd_options . "'", debug => 1);
my ($response) = centreon::plugins::misc::execute(
output => $self->{output},
@ -136,8 +139,8 @@ sub execute {
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $options{cmd_options},
redirect_stderr => 0
command_options => $cmd_options,
redirect_stderr => ($self->{output}->is_debug()) ? 0 : 1
);
my $raw_results;

View File

@ -0,0 +1,235 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package cloud::aws::elb::application::mode::connections;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my %metrics_mapping = (
'ActiveConnectionCount' => { # Minimum, Maximum, and Average all return 1.
'output' => 'Active Connection',
'label' => 'connection-active',
'nlabel' => 'elb.connection.active.count',
},
'NewConnectionCount' => { # Minimum, Maximum, and Average all return 1.
'output' => 'New Connection',
'label' => 'connection-new',
'nlabel' => 'elb.connection.new.count',
},
'RejectedConnectionCount' => { # Minimum, Maximum, and Average all return 1.
'output' => 'Rejected Connection',
'label' => 'connection-rejected',
'nlabel' => 'elb.rejected.new.count',
},
'TargetConnectionErrorCount' => { # Minimum, Maximum, and Average all return 1.
'output' => 'Target Connection Error',
'label' => 'target-connection-error',
'nlabel' => 'elb.target.connection.error.count',
},
);
sub prefix_metric_output {
my ($self, %options) = @_;
my $availability_zone = "";
if (defined($options{instance_value}->{availability_zone}) && $options{instance_value}->{availability_zone} ne '') {
$availability_zone = "[$options{instance_value}->{availability_zone}] ";
}
return "ELB '" . $options{instance_value}->{display} . "' " . $availability_zone;
}
sub prefix_statistics_output {
my ($self, %options) = @_;
return "Statistic '" . $options{instance_value}->{display} . "' Metrics ";
}
sub long_output {
my ($self, %options) = @_;
my $availability_zone = "";
if (defined($options{instance_value}->{availability_zone}) && $options{instance_value}->{availability_zone} ne '') {
$availability_zone = "[$options{instance_value}->{availability_zone}] ";
}
return "Checking '" . $options{instance_value}->{display} . "' " . $availability_zone;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output',
message_multiple => 'All elb metrics are ok', indent_long_output => ' ',
group => [
{ name => 'statistics', display_long => 1, cb_prefix_output => 'prefix_statistics_output',
message_multiple => 'All metrics are ok', type => 1, skipped_code => { -10 => 1 } },
]
}
];
foreach my $metric (keys %metrics_mapping) {
my $entry = {
label => $metrics_mapping{$metric}->{label},
nlabel => $metrics_mapping{$metric}->{nlabel},
set => {
key_values => [ { name => $metric }, { name => 'display' } ],
output_template => $metrics_mapping{$metric}->{output} . ': %.2f',
perfdatas => [
{ value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 }
],
}
};
push @{$self->{maps_counters}->{statistics}}, $entry;
}
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"availability-zone:s" => { name => 'availability_zone' },
"filter-metric:s" => { name => 'filter_metric' },
"statistic:s@" => { name => 'statistic' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (!defined($self->{option_results}->{name}) || $self->{option_results}->{name} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --name option.");
$self->{output}->option_exit();
}
foreach my $instance (@{$self->{option_results}->{name}}) {
if ($instance ne '') {
push @{$self->{aws_instance}}, $instance;
}
}
$self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600;
$self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60;
$self->{aws_statistics} = ['Sum'];
if (defined($self->{option_results}->{statistic})) {
$self->{aws_statistics} = [];
foreach my $stat (@{$self->{option_results}->{statistic}}) {
if ($stat ne '') {
push @{$self->{aws_statistics}}, ucfirst(lc($stat));
}
}
}
foreach my $metric (keys %metrics_mapping) {
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
&& $metric !~ /$self->{option_results}->{filter_metric}/);
push @{$self->{aws_metrics}}, $metric;
}
}
sub manage_selection {
my ($self, %options) = @_;
my %metric_results;
foreach my $instance (@{$self->{aws_instance}}) {
push @{$self->{aws_dimensions}}, { Name => 'LoadBalancer', Value => $instance };
if (defined($self->{option_results}->{availability_zone}) && $self->{option_results}->{availability_zone} ne '') {
push @{$self->{aws_dimensions}}, { Name => 'AvailabilityZone', Value => $self->{option_results}->{availability_zone} };
}
$metric_results{$instance} = $options{custom}->cloudwatch_get_metrics(
region => $self->{option_results}->{region},
namespace => 'AWS/ApplicationELB',
dimensions => $self->{aws_dimensions},
metrics => $self->{aws_metrics},
statistics => $self->{aws_statistics},
timeframe => $self->{aws_timeframe},
period => $self->{aws_period},
);
foreach my $metric (@{$self->{aws_metrics}}) {
foreach my $statistic (@{$self->{aws_statistics}}) {
next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && !defined($self->{option_results}->{zeroed}));
$self->{metrics}->{$instance}->{display} = $instance;
$self->{metrics}->{$instance}->{availability_zone} = $self->{option_results}->{availability_zone};
$self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic;
$self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? $metric_results{$instance}->{$metric}->{lc($statistic)} : 0;
}
}
}
if (scalar(keys %{$self->{metrics}}) <= 0) {
$self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values');
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check Application ELB connections metrics.
Example:
perl centreon_plugins.pl --plugin=cloud::aws::elb::application::plugin --custommode=paws --mode=connections
--region='eu-west-1' --name='app/AppProd/7c8ecfbd1093c5bd' --critical-connection-rejected='10' --verbose
See 'https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-cloudwatch-metrics.html' for more informations.
Default statistic: 'sum' / Most usefull statistics: 'sum'.
=over 8
=item B<--name>
Set the instance name (Required) (Can be multiple).
=item B<--availability-zone>
Add Availability Zone dimension.
=item B<--filter-metric>
Filter metrics (Can be: ActiveConnectionCount', 'NewConnectionCount',
'RejectedConnectionCount', 'TargetConnectionErrorCount')
(Can be a regexp).
=item B<--warning-*> B<--critical-*>
Thresholds warning (Can be: 'connection-active', 'connection-new',
'connection-rejected', 'target-connection-error').
=back
=cut

View File

@ -0,0 +1,111 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package cloud::aws::elb::application::mode::discovery;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use JSON::XS;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
"prettify" => { name => 'prettify' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub run {
my ($self, %options) = @_;
my @disco_data;
my $disco_stats;
$disco_stats->{start_time} = time();
my $load_balancers = $options{custom}->discovery(
region => $self->{option_results}->{region},
service => 'elbv2',
command => 'describe-load-balancers'
);
foreach my $load_balancer (@{$load_balancers->{LoadBalancers}}) {
next if (!defined($load_balancer->{LoadBalancerArn}) || $load_balancer->{Type} ne 'application');
my %elb;
$elb{type} = "application";
$elb{name} = $1 if ($load_balancer->{LoadBalancerArn} =~ /arn:aws:elasticloadbalancing:.*:loadbalancer\/(.*)/);
$elb{dns_name} = $load_balancer->{DNSName};
$elb{availability_zones} = $load_balancer->{AvailabilityZones};
$elb{vpc_id} = $load_balancer->{VpcId};
$elb{security_groups} = $load_balancer->{SecurityGroups};
$elb{state} = $load_balancer->{State}->{Code};
push @disco_data, \%elb;
}
$disco_stats->{end_time} = time();
$disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time};
$disco_stats->{discovered_items} = @disco_data;
$disco_stats->{results} = \@disco_data;
my $encoded_data;
eval {
if (defined($self->{option_results}->{prettify})) {
$encoded_data = JSON::XS->new->utf8->pretty->encode($disco_stats);
} else {
$encoded_data = JSON::XS->new->utf8->encode($disco_stats);
}
};
if ($@) {
$encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}';
}
$self->{output}->output_add(short_msg => $encoded_data);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1);
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Application ELB discovery.
=over 8
=item B<--prettify>
Prettify JSON output.
=back
=cut

View File

@ -0,0 +1,250 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package cloud::aws::elb::application::mode::httpcodes;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my %metrics_mapping = (
'HTTPCode_Target_2XX_Count' => { # Minimum, Maximum, and Average all return 1.
'output' => 'Target HTTP 2XXs',
'label' => 'httpcode-target-2xx',
'nlabel' => 'elb.httpcode.target.2xx.count',
},
'HTTPCode_Target_3XX_Count' => { # Minimum, Maximum, and Average all return 1.
'output' => 'Target HTTP 3XXs',
'label' => 'httpcode-target-3xx',
'nlabel' => 'elb.httpcode.target.3xx.count',
},
'HTTPCode_Target_4XX_Count' => { # Minimum, Maximum, and Average all return 1.
'output' => 'Target HTTP 4XXs',
'label' => 'httpcode-target-4xx',
'nlabel' => 'elb.httpcode.target.4xx.count',
},
'HTTPCode_Target_5XX_Count' => { # Minimum, Maximum, and Average all return 1.
'output' => 'Target HTTP 5XXs',
'label' => 'httpcode-target-5xx',
'nlabel' => 'elb.httpcode.target.5xx.count',
},
'HTTPCode_ELB_3XX_Count' => { # Minimum, Maximum, and Average all return 1.
'output' => 'ELB HTTP 3XXs',
'label' => 'httpcode-elb-3xx',
'nlabel' => 'elb.httpcode.elb.3xx.count',
},
'HTTPCode_ELB_4XX_Count' => { # Minimum, Maximum, and Average all return 1.
'output' => 'ELB HTTP 4XXs',
'label' => 'httpcode-elb-4xx',
'nlabel' => 'elb.httpcode.elb.4xx.count',
},
'HTTP_Redirect_Count' => { # Minimum, Maximum, and Average all return 1.
'output' => 'HTTP Redirect',
'label' => 'http-redirect',
'nlabel' => 'elb.http.redirect.count',
},
);
sub prefix_metric_output {
my ($self, %options) = @_;
my $availability_zone = "";
if (defined($options{instance_value}->{availability_zone}) && $options{instance_value}->{availability_zone} ne '') {
$availability_zone = "[$options{instance_value}->{availability_zone}] ";
}
return "ELB '" . $options{instance_value}->{display} . "' " . $availability_zone;
}
sub prefix_statistics_output {
my ($self, %options) = @_;
return "Statistic '" . $options{instance_value}->{display} . "' Metrics ";
}
sub long_output {
my ($self, %options) = @_;
my $availability_zone = "";
if (defined($options{instance_value}->{availability_zone}) && $options{instance_value}->{availability_zone} ne '') {
$availability_zone = "[$options{instance_value}->{availability_zone}] ";
}
return "Checking '" . $options{instance_value}->{display} . "' " . $availability_zone;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output',
message_multiple => 'All elb metrics are ok', indent_long_output => ' ',
group => [
{ name => 'statistics', display_long => 1, cb_prefix_output => 'prefix_statistics_output',
message_multiple => 'All metrics are ok', type => 1, skipped_code => { -10 => 1 } },
]
}
];
foreach my $metric (keys %metrics_mapping) {
my $entry = {
label => $metrics_mapping{$metric}->{label},
nlabel => $metrics_mapping{$metric}->{nlabel},
set => {
key_values => [ { name => $metric }, { name => 'display' } ],
output_template => $metrics_mapping{$metric}->{output} . ': %.2f',
perfdatas => [
{ value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 }
],
}
};
push @{$self->{maps_counters}->{statistics}}, $entry;
}
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"availability-zone:s" => { name => 'availability_zone' },
"filter-metric:s" => { name => 'filter_metric' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (!defined($self->{option_results}->{name}) || $self->{option_results}->{name} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --name option.");
$self->{output}->option_exit();
}
foreach my $instance (@{$self->{option_results}->{name}}) {
if ($instance ne '') {
push @{$self->{aws_instance}}, $instance;
}
}
$self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600;
$self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60;
$self->{aws_statistics} = ['Sum'];
if (defined($self->{option_results}->{statistic})) {
$self->{aws_statistics} = [];
foreach my $stat (@{$self->{option_results}->{statistic}}) {
if ($stat ne '') {
push @{$self->{aws_statistics}}, ucfirst(lc($stat));
}
}
}
foreach my $metric (keys %metrics_mapping) {
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
&& $metric !~ /$self->{option_results}->{filter_metric}/);
push @{$self->{aws_metrics}}, $metric;
}
}
sub manage_selection {
my ($self, %options) = @_;
my %metric_results;
foreach my $instance (@{$self->{aws_instance}}) {
push @{$self->{aws_dimensions}}, { Name => 'LoadBalancer', Value => $instance };
if (defined($self->{option_results}->{availability_zone}) && $self->{option_results}->{availability_zone} ne '') {
push @{$self->{aws_dimensions}}, { Name => 'AvailabilityZone', Value => $self->{option_results}->{availability_zone} };
}
$metric_results{$instance} = $options{custom}->cloudwatch_get_metrics(
region => $self->{option_results}->{region},
namespace => 'AWS/ApplicationELB',
dimensions => $self->{aws_dimensions},
metrics => $self->{aws_metrics},
statistics => $self->{aws_statistics},
timeframe => $self->{aws_timeframe},
period => $self->{aws_period},
);
foreach my $metric (@{$self->{aws_metrics}}) {
foreach my $statistic (@{$self->{aws_statistics}}) {
next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && !defined($self->{option_results}->{zeroed}));
$self->{metrics}->{$instance}->{display} = $instance;
$self->{metrics}->{$instance}->{availability_zone} = $self->{option_results}->{availability_zone};
$self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic;
$self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? $metric_results{$instance}->{$metric}->{lc($statistic)} : 0;
}
}
}
if (scalar(keys %{$self->{metrics}}) <= 0) {
$self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values');
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check Application ELB HTTP codes metrics.
Example:
perl centreon_plugins.pl --plugin=cloud::aws::elb::application::plugin --custommode=paws --mode=http-codes
--region='eu-west-1' --name='app/AppProd/7c8ecfbd1093c5bd' --critical-httpcode-target-4xx='10' --verbose
See 'https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-cloudwatch-metrics.html' for more informations.
Default statistic: 'sum' / Most usefull statistics: 'sum'.
=over 8
=item B<--name>
Set the instance name (Required) (Can be multiple).
=item B<--availability-zone>
Add Availability Zone dimension.
=item B<--filter-metric>
Filter metrics (Can be: 'HTTPCode_Target_2XX_Count', 'HTTPCode_Target_3XX_Count',
'HTTPCode_Target_4XX_Count', 'HTTPCode_Target_5XX_Count', 'HTTPCode_ELB_3XX_Count',
'HTTPCode_ELB_4XX_Count', 'HTTP_Redirect_Count')
(Can be a regexp).
=item B<--warning-*> B<--critical-*>
Thresholds warning (Can be: 'httpcode-target-2xx', 'httpcode-target-3xx', 'httpcode-target-4xx',
'httpcode-target-5xx', 'httpcode-elb-3xx', 'httpcode-elb-4xx', 'http-redirect')
=back
=cut

View File

@ -0,0 +1,223 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package cloud::aws::elb::application::mode::targetshealth;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my %metrics_mapping = (
'HealthyHostCount' => {
'output' => 'Healthy Hosts',
'label' => 'healthyhostcount',
'nlabel' => 'elb.healthyhostcount.count',
},
'UnHealthyHostCount' => {
'output' => 'Unhealthy Hosts',
'label' => 'unhealthyhostcount',
'nlabel' => 'elb.unhealthyhostcount.count',
},
);
sub prefix_metric_output {
my ($self, %options) = @_;
my $availability_zone = "";
if (defined($options{instance_value}->{availability_zone}) && $options{instance_value}->{availability_zone} ne '') {
$availability_zone = "[$options{instance_value}->{availability_zone}] ";
}
return "ELB '" . $options{instance_value}->{display} . "' " . $availability_zone;
}
sub prefix_statistics_output {
my ($self, %options) = @_;
return "Statistic '" . $options{instance_value}->{display} . "' Metrics ";
}
sub long_output {
my ($self, %options) = @_;
my $availability_zone = "";
if (defined($options{instance_value}->{availability_zone}) && $options{instance_value}->{availability_zone} ne '') {
$availability_zone = "[$options{instance_value}->{availability_zone}] ";
}
return "Checking '" . $options{instance_value}->{display} . "' " . $availability_zone;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output',
message_multiple => 'All elb metrics are ok', indent_long_output => ' ',
group => [
{ name => 'statistics', display_long => 1, cb_prefix_output => 'prefix_statistics_output',
message_multiple => 'All metrics are ok', type => 1, skipped_code => { -10 => 1 } },
]
}
];
foreach my $metric (keys %metrics_mapping) {
my $entry = {
label => $metrics_mapping{$metric}->{label},
nlabel => $metrics_mapping{$metric}->{nlabel},
set => {
key_values => [ { name => $metric }, { name => 'display' } ],
output_template => $metrics_mapping{$metric}->{output} . ': %.2f',
perfdatas => [
{ value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 }
],
}
};
push @{$self->{maps_counters}->{statistics}}, $entry;
}
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"availability-zone:s" => { name => 'availability_zone' },
"filter-metric:s" => { name => 'filter_metric' },
"statistic:s@" => { name => 'statistic' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (!defined($self->{option_results}->{name}) || $self->{option_results}->{name} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --name option.");
$self->{output}->option_exit();
}
foreach my $instance (@{$self->{option_results}->{name}}) {
if ($instance ne '') {
push @{$self->{aws_instance}}, $instance;
}
}
$self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600;
$self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60;
$self->{aws_statistics} = ['Average'];
if (defined($self->{option_results}->{statistic})) {
$self->{aws_statistics} = [];
foreach my $stat (@{$self->{option_results}->{statistic}}) {
if ($stat ne '') {
push @{$self->{aws_statistics}}, ucfirst(lc($stat));
}
}
}
foreach my $metric (keys %metrics_mapping) {
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
&& $metric !~ /$self->{option_results}->{filter_metric}/);
push @{$self->{aws_metrics}}, $metric;
}
}
sub manage_selection {
my ($self, %options) = @_;
my %metric_results;
foreach my $instance (@{$self->{aws_instance}}) {
push @{$self->{aws_dimensions}}, { Name => 'LoadBalancer', Value => $instance };
if (defined($self->{option_results}->{availability_zone}) && $self->{option_results}->{availability_zone} ne '') {
push @{$self->{aws_dimensions}}, { Name => 'AvailabilityZone', Value => $self->{option_results}->{availability_zone} };
}
$metric_results{$instance} = $options{custom}->cloudwatch_get_metrics(
region => $self->{option_results}->{region},
namespace => 'AWS/ApplicationELB',
dimensions => $self->{aws_dimensions},
metrics => $self->{aws_metrics},
statistics => $self->{aws_statistics},
timeframe => $self->{aws_timeframe},
period => $self->{aws_period},
);
foreach my $metric (@{$self->{aws_metrics}}) {
foreach my $statistic (@{$self->{aws_statistics}}) {
next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && !defined($self->{option_results}->{zeroed}));
$self->{metrics}->{$instance}->{display} = $instance;
$self->{metrics}->{$instance}->{availability_zone} = $self->{option_results}->{availability_zone};
$self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic;
$self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? $metric_results{$instance}->{$metric}->{lc($statistic)} : 0;
}
}
}
if (scalar(keys %{$self->{metrics}}) <= 0) {
$self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values');
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check Application ELB targets health.
Example:
perl centreon_plugins.pl --plugin=cloud::aws::elb::application::plugin --custommode=paws --mode=targets-health
--region='eu-west-1' --name='app/AppProd/7c8ecfbd1093c5bd' --critical-unhealthyhostcount='10' --verbose
See 'https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-cloudwatch-metrics.html' for more informations.
Default statistic: 'average' / Most usefull statistics: 'average', 'minimum', 'maximum'.
=over 8
=item B<--name>
Set the instance name (Required) (Can be multiple).
=item B<--availability-zone>
Add Availability Zone dimension.
=item B<--filter-metric>
Filter metrics (Can be: 'HealthyHostCount', 'UnHealthyHostCount')
(Can be a regexp).
=item B<--warning-*> B<--critical-*>
Thresholds warning (Can be: 'healthyhostcount', 'unhealthyhostcount').
=back
=cut

View File

@ -0,0 +1,53 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package cloud::aws::elb::application::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_custom);
sub new {
my ( $class, %options ) = @_;
my $self = $class->SUPER::new( package => __PACKAGE__, %options );
bless $self, $class;
$self->{version} = '0.1';
%{ $self->{modes} } = (
'connections' => 'cloud::aws::elb::application::mode::connections',
'discovery' => 'cloud::aws::elb::application::mode::discovery',
'http-codes' => 'cloud::aws::elb::application::mode::httpcodes',
'targets-health' => 'cloud::aws::elb::application::mode::targetshealth',
);
$self->{custom_modes}{paws} = 'cloud::aws::custom::paws';
$self->{custom_modes}{awscli} = 'cloud::aws::custom::awscli';
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Amazon Application Elastic Load Balancing (Amazon Application ELB).
=cut

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package cloud::aws::elb::mode::discovery;
package cloud::aws::elb::classic::mode::discovery;
use base qw(centreon::plugins::mode);
@ -60,7 +60,7 @@ sub run {
foreach my $load_balancer (@{$load_balancers->{LoadBalancerDescriptions}}) {
next if (!defined($load_balancer->{LoadBalancerName}));
my %elb;
$elb{type} = "elb";
$elb{type} = "classic";
$elb{name} = $load_balancer->{LoadBalancerName};
$elb{dns_name} = $load_balancer->{DNSName};
$elb{availability_zones} = $load_balancer->{AvailabilityZones};
@ -99,7 +99,7 @@ __END__
=head1 MODE
ELB discovery.
Classic ELB discovery.
=over 8

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package cloud::aws::elb::mode::httpcodes;
package cloud::aws::elb::classic::mode::httpcodes;
use base qw(centreon::plugins::templates::counter);
@ -234,10 +234,10 @@ __END__
=head1 MODE
Check ELB http codes.
Check Classic ELB HTTP codes metrics.
Example:
perl centreon_plugins.pl --plugin=cloud::aws::elb::plugin --custommode=paws --mode=http-codes --region='eu-west-1'
perl centreon_plugins.pl --plugin=cloud::aws::elb::classic::plugin --custommode=paws --mode=http-codes --region='eu-west-1'
--type='loadbalancer' --name='elb-www-fr' --critical-httpcode-backend-4xx='10' --verbose
See 'https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-cloudwatch-metrics.html' for more informations.
@ -264,18 +264,12 @@ Filter metrics (Can be: 'HTTPCode_Backend_2XX', 'HTTPCode_Backend_3XX', 'HTTPCod
'HTTPCode_Backend_5XX', 'HTTPCode_ELB_4XX', 'HTTPCode_ELB_5XX', 'BackendConnectionErrors')
(Can be a regexp).
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Thresholds warning (Can be: 'httpcode-backend-2xx', 'httpcode-backend-3xx',
'httpcode-backend-4xx', 'httpcode-backend-5xx', 'httpcode-elb-4xx',
'httpcode-elb-5xx', 'backendconnectionerrors')
=item B<--critical-*>
Thresholds critical (Can be: 'httpcode-backend-2xx', 'httpcode-backend-3xx',
'httpcode-backend-4xx', 'httpcode-backend-5xx', 'httpcode-elb-4xx',
'httpcode-elb-5xx', 'backendconnectionerrors')
=back
=cut

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package cloud::aws::elb::mode::performances;
package cloud::aws::elb::classic::mode::performances;
use base qw(centreon::plugins::templates::counter);
@ -209,11 +209,11 @@ __END__
=head1 MODE
Check ELB performances.
Check Classic ELB performances.
Example:
perl centreon_plugins.pl --plugin=cloud::aws::elb::plugin --custommode=paws --mode=performances --region='eu-west-1'
--type='loadbalancer' --name='elb-www-fr' --critical-requestcount='10' --verbose
perl centreon_plugins.pl --plugin=cloud::aws::elb::classic::plugin --custommode=paws --mode=performances
--region='eu-west-1' --type='loadbalancer' --name='elb-www-fr' --critical-requestcount='10' --verbose
See 'https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-cloudwatch-metrics.html' for more informations.
@ -238,14 +238,10 @@ Add Availability Zone dimension (only with --type='loadbalancer').
Filter metrics (Can be: 'RequestCount', 'Latency')
(Can be a regexp).
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Thresholds warning (Can be: 'requestcount', 'latency').
=item B<--critical-*>
Thresholds critical (Can be: 'requestcount', 'latency').
=back
=cut

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package cloud::aws::elb::mode::queues;
package cloud::aws::elb::classic::mode::queues;
use base qw(centreon::plugins::templates::counter);
@ -210,10 +210,10 @@ __END__
=head1 MODE
Check ELB surge queue.
Check Classic ELB surge queue.
Example:
perl centreon_plugins.pl --plugin=cloud::aws::elb::plugin --custommode=paws --mode=queues --region='eu-west-1'
perl centreon_plugins.pl --plugin=cloud::aws::elb::classic::plugin --custommode=paws --mode=queues --region='eu-west-1'
--type='loadbalancer' --name='elb-www-fr' --critical-spillovercount-sum='10' --verbose
See 'https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-cloudwatch-metrics.html' for more informations.
@ -239,15 +239,9 @@ Add Availability Zone dimension (only with --type='loadbalancer').
Filter metrics (Can be: 'SpilloverCount', 'SurgeQueueLength')
(Can be a regexp).
=item B<--warning-$metric$-$statistic$>
=item B<--warning-*> B<--critical-*>
Thresholds warning ($metric$ can be: 'spillovercount', 'surgequeuelength',
$statistic$ can be: 'minimum', 'maximum', 'average', 'sum').
=item B<--critical-$metric$-$statistic$>
Thresholds critical ($metric$ can be: 'spillovercount', 'surgequeuelength',
$statistic$ can be: 'minimum', 'maximum', 'average', 'sum').
Thresholds warning (Can be: 'spillovercount', 'surgequeuelength').
=back

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package cloud::aws::elb::mode::targetshealth;
package cloud::aws::elb::classic::mode::targetshealth;
use base qw(centreon::plugins::templates::counter);
@ -210,10 +210,10 @@ __END__
=head1 MODE
Check ELB instances health.
Check Classic ELB instances health.
Example:
perl centreon_plugins.pl --plugin=cloud::aws::elb::plugin --custommode=paws --mode=instancehealth --region='eu-west-1'
perl centreon_plugins.pl --plugin=cloud::aws::elb::classic::plugin --custommode=paws --mode=instancehealth --region='eu-west-1'
--type='loadbalancer' --name='elb-www-fr' --critical-healthyhostcount='10' --verbose
See 'https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-cloudwatch-metrics.html' for more informations.
@ -239,14 +239,10 @@ Add Availability Zone dimension (only with --type='loadbalancer').
Filter metrics (Can be: 'HealthyHostCount', 'UnHealthyHostCount')
(Can be a regexp).
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Thresholds warning (Can be: 'healthyhostcount', 'unhealthyhostcount').
=item B<--critical-*>
Thresholds critical (Can be: 'healthyhostcount', 'unhealthyhostcount').
=back
=cut

View File

@ -0,0 +1,54 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package cloud::aws::elb::classic::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_custom);
sub new {
my ( $class, %options ) = @_;
my $self = $class->SUPER::new( package => __PACKAGE__, %options );
bless $self, $class;
$self->{version} = '0.1';
%{ $self->{modes} } = (
'discovery' => 'cloud::aws::elb::classic::mode::discovery',
'http-codes' => 'cloud::aws::elb::classic::mode::httpcodes',
'performances' => 'cloud::aws::elb::classic::mode::performances',
'queues' => 'cloud::aws::elb::classic::mode::queues',
'targets-health' => 'cloud::aws::elb::classic::mode::targetshealth',
);
$self->{custom_modes}{paws} = 'cloud::aws::custom::paws';
$self->{custom_modes}{awscli} = 'cloud::aws::custom::awscli';
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Amazon Classic Elastic Load Balancing (Amazon Classic ELB).
=cut

View File

@ -0,0 +1,111 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package cloud::aws::elb::network::mode::discovery;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use JSON::XS;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
"prettify" => { name => 'prettify' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub run {
my ($self, %options) = @_;
my @disco_data;
my $disco_stats;
$disco_stats->{start_time} = time();
my $load_balancers = $options{custom}->discovery(
region => $self->{option_results}->{region},
service => 'elbv2',
command => 'describe-load-balancers'
);
foreach my $load_balancer (@{$load_balancers->{LoadBalancers}}) {
next if (!defined($load_balancer->{LoadBalancerArn}) || $load_balancer->{Type} ne 'network');
my %elb;
$elb{type} = "network";
$elb{name} = $1 if ($load_balancer->{LoadBalancerArn} =~ /arn:aws:elasticloadbalancing:.*:loadbalancer\/(.*)/);
$elb{dns_name} = $load_balancer->{DNSName};
$elb{availability_zones} = $load_balancer->{AvailabilityZones};
$elb{vpc_id} = $load_balancer->{VpcId};
$elb{security_groups} = $load_balancer->{SecurityGroups};
$elb{state} = $load_balancer->{State}->{Code};
push @disco_data, \%elb;
}
$disco_stats->{end_time} = time();
$disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time};
$disco_stats->{discovered_items} = @disco_data;
$disco_stats->{results} = \@disco_data;
my $encoded_data;
eval {
if (defined($self->{option_results}->{prettify})) {
$encoded_data = JSON::XS->new->utf8->pretty->encode($disco_stats);
} else {
$encoded_data = JSON::XS->new->utf8->encode($disco_stats);
}
};
if ($@) {
$encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}';
}
$self->{output}->output_add(short_msg => $encoded_data);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1);
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Network ELB discovery.
=over 8
=item B<--prettify>
Prettify JSON output.
=back
=cut

View File

@ -0,0 +1,223 @@
#
# Copyright 2019 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package cloud::aws::elb::network::mode::targetshealth;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my %metrics_mapping = (
'HealthyHostCount' => {
'output' => 'Healthy Hosts',
'label' => 'healthyhostcount',
'nlabel' => 'elb.healthyhostcount.count',
},
'UnHealthyHostCount' => {
'output' => 'Unhealthy Hosts',
'label' => 'unhealthyhostcount',
'nlabel' => 'elb.unhealthyhostcount.count',
},
);
sub prefix_metric_output {
my ($self, %options) = @_;
my $availability_zone = "";
if (defined($options{instance_value}->{availability_zone}) && $options{instance_value}->{availability_zone} ne '') {
$availability_zone = "[$options{instance_value}->{availability_zone}] ";
}
return "ELB '" . $options{instance_value}->{display} . "' " . $availability_zone;
}
sub prefix_statistics_output {
my ($self, %options) = @_;
return "Statistic '" . $options{instance_value}->{display} . "' Metrics ";
}
sub long_output {
my ($self, %options) = @_;
my $availability_zone = "";
if (defined($options{instance_value}->{availability_zone}) && $options{instance_value}->{availability_zone} ne '') {
$availability_zone = "[$options{instance_value}->{availability_zone}] ";
}
return "Checking '" . $options{instance_value}->{display} . "' " . $availability_zone;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output',
message_multiple => 'All elb metrics are ok', indent_long_output => ' ',
group => [
{ name => 'statistics', display_long => 1, cb_prefix_output => 'prefix_statistics_output',
message_multiple => 'All metrics are ok', type => 1, skipped_code => { -10 => 1 } },
]
}
];
foreach my $metric (keys %metrics_mapping) {
my $entry = {
label => $metrics_mapping{$metric}->{label},
nlabel => $metrics_mapping{$metric}->{nlabel},
set => {
key_values => [ { name => $metric }, { name => 'display' } ],
output_template => $metrics_mapping{$metric}->{output} . ': %.2f',
perfdatas => [
{ value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 }
],
}
};
push @{$self->{maps_counters}->{statistics}}, $entry;
}
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
"name:s@" => { name => 'name' },
"availability-zone:s" => { name => 'availability_zone' },
"filter-metric:s" => { name => 'filter_metric' },
"statistic:s@" => { name => 'statistic' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (!defined($self->{option_results}->{name}) || $self->{option_results}->{name} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --name option.");
$self->{output}->option_exit();
}
foreach my $instance (@{$self->{option_results}->{name}}) {
if ($instance ne '') {
push @{$self->{aws_instance}}, $instance;
}
}
$self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600;
$self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60;
$self->{aws_statistics} = ['Average'];
if (defined($self->{option_results}->{statistic})) {
$self->{aws_statistics} = [];
foreach my $stat (@{$self->{option_results}->{statistic}}) {
if ($stat ne '') {
push @{$self->{aws_statistics}}, ucfirst(lc($stat));
}
}
}
foreach my $metric (keys %metrics_mapping) {
next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
&& $metric !~ /$self->{option_results}->{filter_metric}/);
push @{$self->{aws_metrics}}, $metric;
}
}
sub manage_selection {
my ($self, %options) = @_;
my %metric_results;
foreach my $instance (@{$self->{aws_instance}}) {
push @{$self->{aws_dimensions}}, { Name => 'LoadBalancer', Value => $instance };
if (defined($self->{option_results}->{availability_zone}) && $self->{option_results}->{availability_zone} ne '') {
push @{$self->{aws_dimensions}}, { Name => 'AvailabilityZone', Value => $self->{option_results}->{availability_zone} };
}
$metric_results{$instance} = $options{custom}->cloudwatch_get_metrics(
region => $self->{option_results}->{region},
namespace => 'AWS/ApplicationELB',
dimensions => $self->{aws_dimensions},
metrics => $self->{aws_metrics},
statistics => $self->{aws_statistics},
timeframe => $self->{aws_timeframe},
period => $self->{aws_period},
);
foreach my $metric (@{$self->{aws_metrics}}) {
foreach my $statistic (@{$self->{aws_statistics}}) {
next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && !defined($self->{option_results}->{zeroed}));
$self->{metrics}->{$instance}->{display} = $instance;
$self->{metrics}->{$instance}->{availability_zone} = $self->{option_results}->{availability_zone};
$self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic;
$self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? $metric_results{$instance}->{$metric}->{lc($statistic)} : 0;
}
}
}
if (scalar(keys %{$self->{metrics}}) <= 0) {
$self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values');
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check Network ELB targets health.
Example:
perl centreon_plugins.pl --plugin=cloud::aws::elb::network::plugin --custommode=paws --mode=targets-health
--region='eu-west-1' --name='net/NetProd/7c8ecfbd1093c5bd' --critical-unhealthyhostcount='10' --verbose
See 'https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-cloudwatch-metrics.html' for more informations.
Default statistic: 'average' / Most usefull statistics: 'average', 'minimum', 'maximum'.
=over 8
=item B<--name>
Set the instance name (Required) (Can be multiple).
=item B<--availability-zone>
Add Availability Zone dimension.
=item B<--filter-metric>
Filter metrics (Can be: 'HealthyHostCount', 'UnHealthyHostCount')
(Can be a regexp).
=item B<--warning-*> B<--critical-*>
Thresholds warning (Can be: 'healthyhostcount', 'unhealthyhostcount').
=back
=cut

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package cloud::aws::elb::plugin;
package cloud::aws::elb::network::plugin;
use strict;
use warnings;
@ -31,11 +31,8 @@ sub new {
$self->{version} = '0.1';
%{ $self->{modes} } = (
'discovery' => 'cloud::aws::elb::mode::discovery',
'http-codes' => 'cloud::aws::elb::mode::httpcodes',
'performances' => 'cloud::aws::elb::mode::performances',
'queues' => 'cloud::aws::elb::mode::queues',
'targets-health' => 'cloud::aws::elb::mode::targetshealth',
'discovery' => 'cloud::aws::elb::network::mode::discovery',
'targets-health' => 'cloud::aws::elb::network::mode::targetshealth',
);
$self->{custom_modes}{paws} = 'cloud::aws::custom::paws';
@ -49,6 +46,6 @@ __END__
=head1 PLUGIN DESCRIPTION
Check Amazon Elastic Load Balancing (Amazon ELB).
Check Amazon Network Elastic Load Balancing (Amazon Network ELB).
=cut

View File

@ -20,54 +20,75 @@
package snmp_standard::mode::ntp;
use base qw(centreon::plugins::mode);
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::misc;
use DateTime;
sub custom_usage_output {
my ($self, %options) = @_;
return sprintf(
'Time offset %d second(s): %s',
$self->{result_values}->{offset_absolute},
$self->{result_values}->{date_absolute}
);
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'offset', type => 0 }
];
$self->{maps_counters}->{offset} = [
{ label => 'offset', nlabel => 'time.offset.seconds', set => {
key_values => [ { name => 'offset' }, { name => 'date' } ],
closure_custom_output => $self->can('custom_usage_output'),
perfdatas => [
{ label => 'offset', value => 'offset_absolute', template => '%d', unit => 's' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"ntp-hostname:s" => { name => 'ntp_hostname' },
"ntp-port:s" => { name => 'ntp_port', default => 123 },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timezone:s" => { name => 'timezone' },
});
$options{options}->add_options(arguments => {
'ntp-hostname:s' => { name => 'ntp_hostname' },
'ntp-port:s' => { name => 'ntp_port', default => 123 },
'timezone:s' => { name => 'timezone' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
$self->SUPER::check_options(%options);
if (defined($self->{option_results}->{ntp_hostname})) {
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Net::NTP',
error_msg => "Cannot load module 'Net::NTP'.");
centreon::plugins::misc::mymodule_load(
output => $self->{output}, module => 'Net::NTP',
error_msg => "Cannot load module 'Net::NTP'."
);
}
}
sub run {
sub manage_selection {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{offset} = {};
my ($ref_time, $distant_time);
my $oid_hrSystemDate = '.1.3.6.1.2.1.25.1.2.0';
my $result = $self->{snmp}->get_leef(oids => [ $oid_hrSystemDate ], nothing_quit => 1);
my $result = $options{snmp}->get_leef(oids => [ $oid_hrSystemDate ], nothing_quit => 1);
if (defined($self->{option_results}->{ntp_hostname}) && $self->{option_results}->{ntp_hostname} ne '') {
my %ntp;
@ -75,8 +96,10 @@ sub run {
%ntp = Net::NTP::get_ntp_response($self->{option_results}->{ntp_hostname}, $self->{option_results}->{ntp_port});
};
if ($@) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => "Couldn't connect to ntp server: " . $@);
$self->{output}->output_add(
severity => 'UNKNOWN',
short_msg => "Couldn't connect to ntp server: " . $@
);
$self->{output}->display();
$self->{output}->exit();
}
@ -85,7 +108,7 @@ sub run {
} else {
$ref_time = time();
}
my @remote_date = unpack 'n C6 a C2', $result->{$oid_hrSystemDate};
my $timezone = 'UTC';
if (defined($self->{option_results}->{timezone}) && $self->{option_results}->{timezone} ne '') {
@ -93,7 +116,7 @@ sub run {
} elsif (defined($remote_date[9])) {
$timezone = sprintf("%s%02d%02d", $remote_date[7], $remote_date[8], $remote_date[9]); # format +0630
}
my $tz = centreon::plugins::misc::set_timezone(name => $timezone);
my $dt = DateTime->new(
year => $remote_date[0],
@ -105,24 +128,20 @@ sub run {
%$tz
);
$distant_time = $dt->epoch;
my $diff = $distant_time - $ref_time;
my $remote_date_formated = sprintf("%02d-%02d-%02dT%02d:%02d:%02d (%s)", $remote_date[0], $remote_date[1], $remote_date[2],
$remote_date[3], $remote_date[4], $remote_date[5], $timezone);
my $exit = $self->{perfdata}->threshold_check(value => $diff,
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Time offset %d second(s) : %s", $diff, $remote_date_formated));
$self->{output}->perfdata_add(label => 'offset', unit => 's',
value => sprintf("%d", $diff),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
);
my $offset = $distant_time - $ref_time;
my $remote_date_formated = sprintf(
'Local Time : %02d-%02d-%02dT%02d:%02d:%02d (%s)',
$remote_date[0], $remote_date[1], $remote_date[2],
$remote_date[3], $remote_date[4], $remote_date[5], $timezone
);
$self->{output}->display();
$self->{output}->exit();
my $formated_offset = sprintf("%d", $offset);
$self->{offset} = {
offset => $formated_offset,
date => $remote_date_formated,
};
}
1;
@ -137,13 +156,13 @@ Use threshold with (+-) 2 seconds offset (minimum).
=over 8
=item B<--warning>
=item B<--warning-offset>
Threshold warning.
Time offset warning threshold (in seconds).
=item B<--critical>
=item B<--critical-offset>
Threshold critical.
Time offset critical Threshold (in seconds).
=item B<--ntp-hostname>

View File

@ -31,10 +31,10 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'hardware' => 'snmp_standard::mode::hardwarefibrealliance',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
);
'hardware' => 'snmp_standard::mode::hardwarefibrealliance',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
);
return $self;
}