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->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'dcdiag' => 'apps::activedirectory::local::mode::dcdiag', 'dcdiag' => 'apps::activedirectory::local::mode::dcdiag',
'dfsr-backlog' => 'apps::activedirectory::local::mode::dfsrbacklog', 'dfsr-backlog' => 'apps::activedirectory::local::mode::dfsrbacklog',
'netdom' => 'apps::activedirectory::local::mode::netdom', 'netdom' => 'apps::activedirectory::local::mode::netdom',
); );
return $self; return $self;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,8 +31,9 @@ sub new {
$self->{version} = '1.0'; $self->{version} = '1.0';
%{$self->{modes}} = ( %{$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'; $self->{custom_modes}{xmlapi} = 'apps::cisco::ise::restapi::custom::xmlapi';
return $self; return $self;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,10 +31,10 @@ sub new {
$self->{version} = '1.0'; $self->{version} = '1.0';
%{$self->{modes}} = ( %{$self->{modes}} = (
'channel-usage' => 'apps::voip::asterisk::ami::mode::channelusage', 'channel-usage' => 'apps::voip::asterisk::ami::mode::channelusage',
'dahdi-status' => 'apps::voip::asterisk::ami::mode::dahdistatus', 'dahdi-status' => 'apps::voip::asterisk::ami::mode::dahdistatus',
'sip-peers-usage' => 'apps::voip::asterisk::ami::mode::sippeersusage', 'sip-peers-usage' => 'apps::voip::asterisk::ami::mode::sippeersusage',
); );
$self->{custom_modes}{api} = 'apps::voip::asterisk::ami::custom::api'; $self->{custom_modes}{api} = 'apps::voip::asterisk::ami::custom::api';
return $self; 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); 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 && 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->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is %s [instance: %s].", $self->{output}->output_add(
$result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState}, long_msg => sprintf(
$instance "fan '%s' status is %s [instance: %s].",
)); $result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState},
my $exit = $self->get_severity(section => 'fan', value => $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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("fan '%s' status is %s", 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 $fan_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFanTrayOperStatus}, instance => $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->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is %s [instance: %s]", $self->{output}->output_add(
$fan_descr, $result->{cefcFanTrayOperStatus}, $instance)); long_msg => sprintf(
my $exit = $self->get_severity(section => 'fan', value => $result->{cefcFanTrayOperStatus}); "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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s/%s' status is %s", $fan_descr, $instance, $result->{cefcFanTrayOperStatus})); short_msg => sprintf("Fan '%s/%s' status is %s", $fan_descr, $instance, $result->{cefcFanTrayOperStatus}));

View File

@ -79,12 +79,12 @@ sub check {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcModuleOperStatus}, instance => $instance); 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}; 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->{components}->{module}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s]", $self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s]",
$module_descr, $result->{cefcModuleOperStatus}, $instance)); $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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Module '%s/%s' status is %s", $module_descr, short_msg => sprintf("Module '%s/%s' status is %s", $module_descr,

View File

@ -61,12 +61,12 @@ sub check {
next; 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->{components}->{physical}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Physical '%s' status is %s [instance: %s]", $self->{output}->output_add(long_msg => sprintf("Physical '%s' status is %s [instance: %s]",
$physical_descr, $result->{cefcPhysicalStatus}, $instance)); $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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Physical '%s/%s' status is %s", $physical_descr, short_msg => sprintf("Physical '%s/%s' status is %s", $physical_descr,

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); 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 && 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->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s] [source: %s]", $self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s] [source: %s]",
$result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState}, $result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState},
$instance, $result->{ciscoEnvMonSupplySource} $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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is %s", 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 $psu_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFRUPowerOperStatus}, instance => $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->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s]", $self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s]",
$psu_descr, $result->{cefcFRUPowerOperStatus}, $instance)); $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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s/%s' status is %s", $psu_descr, $instance, $result->{cefcFRUPowerOperStatus})); short_msg => sprintf("Power supply '%s/%s' status is %s", $psu_descr, $instance, $result->{cefcFRUPowerOperStatus}));

View File

@ -59,13 +59,17 @@ sub check {
my $instance = $1; my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonTemperatureStatusEntry}, instance => $instance); 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->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is %s [instance: %s] [value: %s C]", $self->{output}->output_add(
$result->{ciscoEnvMonTemperatureStatusDescr}, $result->{ciscoEnvMonTemperatureState}, long_msg => sprintf(
$instance, defined($result->{ciscoEnvMonTemperatureStatusValue}) ? $result->{ciscoEnvMonTemperatureStatusValue} : '-')); "Temperature '%s' status is %s [instance: %s] [value: %s C]",
my $exit = $self->get_severity(section => 'temperature', value => $result->{ciscoEnvMonTemperatureState}); $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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' status is %s", short_msg => sprintf("Temperature '%s' status is %s",
@ -74,7 +78,7 @@ sub check {
next if (!defined($result->{ciscoEnvMonTemperatureStatusValue})); 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) { if ($checked == 0) {
my $warn_th = undef; my $warn_th = undef;
my $crit_th = '~:' . $result->{ciscoEnvMonTemperatureThreshold}; my $crit_th = '~:' . $result->{ciscoEnvMonTemperatureThreshold};

View File

@ -60,13 +60,13 @@ sub check {
my $instance = $1; my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonVoltageStatusEntry}, instance => $instance); 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->{components}->{voltage}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Voltage '%s' status is %s [instance: %s] [value: %s C]", $self->{output}->output_add(long_msg => sprintf("Voltage '%s' status is %s [instance: %s] [value: %s C]",
$result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState}, $result->{ciscoEnvMonVoltageStatusDescr}, $result->{ciscoEnvMonVoltageState},
$instance, $result->{ciscoEnvMonVoltageStatusValue})); $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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Voltage '%s' status is %s", short_msg => sprintf("Voltage '%s' status is %s",
@ -74,7 +74,7 @@ sub check {
} }
$result->{ciscoEnvMonVoltageStatusValue} = $result->{ciscoEnvMonVoltageStatusValue} / 1000; $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) { if ($checked == 0) {
my $warn_th = undef; my $warn_th = undef;
my $crit_th = ((defined($result->{ciscoEnvMonVoltageThresholdLow}) && $result->{ciscoEnvMonVoltageThresholdLow} =~ /\d/) ? sprintf("%.3f", $result->{ciscoEnvMonVoltageThresholdLow} / 1000) : 0) . ':' . 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) Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu)
Can also exclude specific instance: --filter=fan,1 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> =item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list) Return an error if an entity is not 'present' (default is skipping) (comma seperated list)

View File

@ -128,7 +128,10 @@ sub check_options {
sub execute { sub execute {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{output}->output_add(long_msg => "Command line: '" . $self->{option_results}->{command} . " " . $options{cmd_options} . "'", debug => 1); 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} . " " . $cmd_options . "'", debug => 1);
my ($response) = centreon::plugins::misc::execute( my ($response) = centreon::plugins::misc::execute(
output => $self->{output}, output => $self->{output},
@ -136,8 +139,8 @@ sub execute {
sudo => $self->{option_results}->{sudo}, sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $options{cmd_options}, command_options => $cmd_options,
redirect_stderr => 0 redirect_stderr => ($self->{output}->is_debug()) ? 0 : 1
); );
my $raw_results; 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. # limitations under the License.
# #
package cloud::aws::elb::mode::discovery; package cloud::aws::elb::classic::mode::discovery;
use base qw(centreon::plugins::mode); use base qw(centreon::plugins::mode);
@ -60,7 +60,7 @@ sub run {
foreach my $load_balancer (@{$load_balancers->{LoadBalancerDescriptions}}) { foreach my $load_balancer (@{$load_balancers->{LoadBalancerDescriptions}}) {
next if (!defined($load_balancer->{LoadBalancerName})); next if (!defined($load_balancer->{LoadBalancerName}));
my %elb; my %elb;
$elb{type} = "elb"; $elb{type} = "classic";
$elb{name} = $load_balancer->{LoadBalancerName}; $elb{name} = $load_balancer->{LoadBalancerName};
$elb{dns_name} = $load_balancer->{DNSName}; $elb{dns_name} = $load_balancer->{DNSName};
$elb{availability_zones} = $load_balancer->{AvailabilityZones}; $elb{availability_zones} = $load_balancer->{AvailabilityZones};
@ -99,7 +99,7 @@ __END__
=head1 MODE =head1 MODE
ELB discovery. Classic ELB discovery.
=over 8 =over 8

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
# #
package cloud::aws::elb::mode::httpcodes; package cloud::aws::elb::classic::mode::httpcodes;
use base qw(centreon::plugins::templates::counter); use base qw(centreon::plugins::templates::counter);
@ -234,10 +234,10 @@ __END__
=head1 MODE =head1 MODE
Check ELB http codes. Check Classic ELB HTTP codes metrics.
Example: 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 --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. 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') 'HTTPCode_Backend_5XX', 'HTTPCode_ELB_4XX', 'HTTPCode_ELB_5XX', 'BackendConnectionErrors')
(Can be a regexp). (Can be a regexp).
=item B<--warning-*> =item B<--warning-*> B<--critical-*>
Thresholds warning (Can be: 'httpcode-backend-2xx', 'httpcode-backend-3xx', Thresholds warning (Can be: 'httpcode-backend-2xx', 'httpcode-backend-3xx',
'httpcode-backend-4xx', 'httpcode-backend-5xx', 'httpcode-elb-4xx', 'httpcode-backend-4xx', 'httpcode-backend-5xx', 'httpcode-elb-4xx',
'httpcode-elb-5xx', 'backendconnectionerrors') '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 =back
=cut =cut

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
# #
package cloud::aws::elb::mode::performances; package cloud::aws::elb::classic::mode::performances;
use base qw(centreon::plugins::templates::counter); use base qw(centreon::plugins::templates::counter);
@ -209,11 +209,11 @@ __END__
=head1 MODE =head1 MODE
Check ELB performances. Check Classic ELB performances.
Example: Example:
perl centreon_plugins.pl --plugin=cloud::aws::elb::plugin --custommode=paws --mode=performances --region='eu-west-1' perl centreon_plugins.pl --plugin=cloud::aws::elb::classic::plugin --custommode=paws --mode=performances
--type='loadbalancer' --name='elb-www-fr' --critical-requestcount='10' --verbose --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. 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') Filter metrics (Can be: 'RequestCount', 'Latency')
(Can be a regexp). (Can be a regexp).
=item B<--warning-*> =item B<--warning-*> B<--critical-*>
Thresholds warning (Can be: 'requestcount', 'latency'). Thresholds warning (Can be: 'requestcount', 'latency').
=item B<--critical-*>
Thresholds critical (Can be: 'requestcount', 'latency').
=back =back
=cut =cut

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
# #
package cloud::aws::elb::mode::queues; package cloud::aws::elb::classic::mode::queues;
use base qw(centreon::plugins::templates::counter); use base qw(centreon::plugins::templates::counter);
@ -210,10 +210,10 @@ __END__
=head1 MODE =head1 MODE
Check ELB surge queue. Check Classic ELB surge queue.
Example: 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 --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. 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') Filter metrics (Can be: 'SpilloverCount', 'SurgeQueueLength')
(Can be a regexp). (Can be a regexp).
=item B<--warning-$metric$-$statistic$> =item B<--warning-*> B<--critical-*>
Thresholds warning ($metric$ can be: 'spillovercount', 'surgequeuelength', Thresholds warning (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').
=back =back

View File

@ -18,7 +18,7 @@
# limitations under the License. # limitations under the License.
# #
package cloud::aws::elb::mode::targetshealth; package cloud::aws::elb::classic::mode::targetshealth;
use base qw(centreon::plugins::templates::counter); use base qw(centreon::plugins::templates::counter);
@ -210,10 +210,10 @@ __END__
=head1 MODE =head1 MODE
Check ELB instances health. Check Classic ELB instances health.
Example: 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 --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. 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') Filter metrics (Can be: 'HealthyHostCount', 'UnHealthyHostCount')
(Can be a regexp). (Can be a regexp).
=item B<--warning-*> =item B<--warning-*> B<--critical-*>
Thresholds warning (Can be: 'healthyhostcount', 'unhealthyhostcount'). Thresholds warning (Can be: 'healthyhostcount', 'unhealthyhostcount').
=item B<--critical-*>
Thresholds critical (Can be: 'healthyhostcount', 'unhealthyhostcount').
=back =back
=cut =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. # limitations under the License.
# #
package cloud::aws::elb::plugin; package cloud::aws::elb::network::plugin;
use strict; use strict;
use warnings; use warnings;
@ -31,11 +31,8 @@ sub new {
$self->{version} = '0.1'; $self->{version} = '0.1';
%{ $self->{modes} } = ( %{ $self->{modes} } = (
'discovery' => 'cloud::aws::elb::mode::discovery', 'discovery' => 'cloud::aws::elb::network::mode::discovery',
'http-codes' => 'cloud::aws::elb::mode::httpcodes', 'targets-health' => 'cloud::aws::elb::network::mode::targetshealth',
'performances' => 'cloud::aws::elb::mode::performances',
'queues' => 'cloud::aws::elb::mode::queues',
'targets-health' => 'cloud::aws::elb::mode::targetshealth',
); );
$self->{custom_modes}{paws} = 'cloud::aws::custom::paws'; $self->{custom_modes}{paws} = 'cloud::aws::custom::paws';
@ -49,6 +46,6 @@ __END__
=head1 PLUGIN DESCRIPTION =head1 PLUGIN DESCRIPTION
Check Amazon Elastic Load Balancing (Amazon ELB). Check Amazon Network Elastic Load Balancing (Amazon Network ELB).
=cut =cut

View File

@ -20,54 +20,75 @@
package snmp_standard::mode::ntp; package snmp_standard::mode::ntp;
use base qw(centreon::plugins::mode); use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
use centreon::plugins::misc; use centreon::plugins::misc;
use DateTime; 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 { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'ntp-hostname:s' => { name => 'ntp_hostname' },
"ntp-hostname:s" => { name => 'ntp_hostname' }, 'ntp-port:s' => { name => 'ntp_port', default => 123 },
"ntp-port:s" => { name => 'ntp_port', default => 123 }, 'timezone:s' => { name => 'timezone' },
"warning:s" => { name => 'warning' }, });
"critical:s" => { name => 'critical' },
"timezone:s" => { name => 'timezone' },
});
return $self; return $self;
} }
sub check_options { sub check_options {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->SUPER::init(%options); $self->SUPER::check_options(%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();
}
if (defined($self->{option_results}->{ntp_hostname})) { if (defined($self->{option_results}->{ntp_hostname})) {
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'Net::NTP', centreon::plugins::misc::mymodule_load(
error_msg => "Cannot load module 'Net::NTP'."); output => $self->{output}, module => 'Net::NTP',
error_msg => "Cannot load module 'Net::NTP'."
);
} }
} }
sub run { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{snmp} = $options{snmp}; $self->{offset} = {};
my ($ref_time, $distant_time); my ($ref_time, $distant_time);
my $oid_hrSystemDate = '.1.3.6.1.2.1.25.1.2.0'; 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 '') { if (defined($self->{option_results}->{ntp_hostname}) && $self->{option_results}->{ntp_hostname} ne '') {
my %ntp; my %ntp;
@ -75,8 +96,10 @@ sub run {
%ntp = Net::NTP::get_ntp_response($self->{option_results}->{ntp_hostname}, $self->{option_results}->{ntp_port}); %ntp = Net::NTP::get_ntp_response($self->{option_results}->{ntp_hostname}, $self->{option_results}->{ntp_port});
}; };
if ($@) { if ($@) {
$self->{output}->output_add(severity => 'UNKNOWN', $self->{output}->output_add(
short_msg => "Couldn't connect to ntp server: " . $@); severity => 'UNKNOWN',
short_msg => "Couldn't connect to ntp server: " . $@
);
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
} }
@ -106,23 +129,19 @@ sub run {
); );
$distant_time = $dt->epoch; $distant_time = $dt->epoch;
my $diff = $distant_time - $ref_time; my $offset = $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], my $remote_date_formated = sprintf(
$remote_date[3], $remote_date[4], $remote_date[5], $timezone); '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
);
my $exit = $self->{perfdata}->threshold_check(value => $diff, my $formated_offset = sprintf("%d", $offset);
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', $self->{offset} = {
value => sprintf("%d", $diff), offset => $formated_offset,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), date => $remote_date_formated,
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), };
);
$self->{output}->display();
$self->{output}->exit();
} }
1; 1;
@ -137,13 +156,13 @@ Use threshold with (+-) 2 seconds offset (minimum).
=over 8 =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> =item B<--ntp-hostname>

View File

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