enh(bind9/web): add counters, and some rewrites (#2788)
This commit is contained in:
parent
250e391136
commit
c1e15de68b
|
@ -38,7 +38,7 @@ sub new {
|
||||||
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
||||||
$options{output}->option_exit();
|
$options{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
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' },
|
||||||
|
@ -79,7 +79,7 @@ sub check_options {
|
||||||
$self->{unknown_status} = (defined($self->{option_results}->{unknown_status})) ? $self->{option_results}->{unknown_status} : undef;
|
$self->{unknown_status} = (defined($self->{option_results}->{unknown_status})) ? $self->{option_results}->{unknown_status} : undef;
|
||||||
$self->{warning_status} = (defined($self->{option_results}->{warning_status})) ? $self->{option_results}->{warning_status} : undef;
|
$self->{warning_status} = (defined($self->{option_results}->{warning_status})) ? $self->{option_results}->{warning_status} : undef;
|
||||||
$self->{critical_status} = (defined($self->{option_results}->{critical_status})) ? $self->{option_results}->{critical_status} : undef;
|
$self->{critical_status} = (defined($self->{option_results}->{critical_status})) ? $self->{option_results}->{critical_status} : undef;
|
||||||
|
|
||||||
if (!defined($self->{hostname})) {
|
if (!defined($self->{hostname})) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to specify hostname option.");
|
$self->{output}->add_option_msg(short_msg => "Need to specify hostname option.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
@ -116,7 +116,7 @@ sub settings {
|
||||||
|
|
||||||
sub load_response {
|
sub load_response {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
if ($self->{response_type} eq 'xml') {
|
if ($self->{response_type} eq 'xml') {
|
||||||
centreon::plugins::misc::mymodule_load(
|
centreon::plugins::misc::mymodule_load(
|
||||||
output => $self->{output}, module => 'XML::XPath',
|
output => $self->{output}, module => 'XML::XPath',
|
||||||
|
@ -137,7 +137,7 @@ sub request {
|
||||||
|
|
||||||
$self->settings();
|
$self->settings();
|
||||||
my $response = $self->{http}->request();
|
my $response = $self->{http}->request();
|
||||||
|
|
||||||
my ($content_type) = $self->{http}->get_header(name => 'Content-Type');
|
my ($content_type) = $self->{http}->get_header(name => 'Content-Type');
|
||||||
if (!defined($content_type) || $content_type !~ /(xml|json)/i) {
|
if (!defined($content_type) || $content_type !~ /(xml|json)/i) {
|
||||||
$self->{output}->add_option_msg(short_msg => "content-type not set");
|
$self->{output}->add_option_msg(short_msg => "content-type not set");
|
||||||
|
@ -149,7 +149,7 @@ sub request {
|
||||||
$self->{output}->add_option_msg(short_msg => "json format unsupported");
|
$self->{output}->add_option_msg(short_msg => "json format unsupported");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->load_response(response => $response);
|
$self->load_response(response => $response);
|
||||||
my $method = $self->can("get_api_version_$self->{response_type}");
|
my $method = $self->can("get_api_version_$self->{response_type}");
|
||||||
if (!defined($method)) {
|
if (!defined($method)) {
|
||||||
|
@ -161,13 +161,13 @@ sub request {
|
||||||
$self->{output}->add_option_msg(short_msg => "cannot get api version");
|
$self->{output}->add_option_msg(short_msg => "cannot get api version");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{api_version} = $1;
|
$self->{api_version} = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_api_version_xml {
|
sub get_api_version_xml {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
my $nodesets = $self->{xpath_response}->find('//statistics/@version');
|
my $nodesets = $self->{xpath_response}->find('//statistics/@version');
|
||||||
my $node = $nodesets->get_node(1);
|
my $node = $nodesets->get_node(1);
|
||||||
|
@ -176,14 +176,14 @@ sub get_api_version_xml {
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Cannot lookup: $@");
|
$self->{output}->add_option_msg(short_msg => "Cannot lookup: $@");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub load_memory_xml_v3 {
|
sub load_memory_xml_v3 {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $memory = {};
|
my $memory = {};
|
||||||
|
|
||||||
my $nodesets = $self->{xpath_response}->find('//memory/summary');
|
my $nodesets = $self->{xpath_response}->find('//memory/summary');
|
||||||
my $node_memory = $nodesets->get_node(1);
|
my $node_memory = $nodesets->get_node(1);
|
||||||
foreach my $node ($node_memory->getChildNodes()) {
|
foreach my $node ($node_memory->getChildNodes()) {
|
||||||
|
@ -196,13 +196,13 @@ sub load_memory_xml_v3 {
|
||||||
$memory->{in_use} = $node->string_value;
|
$memory->{in_use} = $node->string_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $memory;
|
return $memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub load_memory_xml_v2 {
|
sub load_memory_xml_v2 {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return $self->load_memory_xml_v3();
|
return $self->load_memory_xml_v3();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,13 +224,13 @@ sub load_zones_xml_v3 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $zones;
|
return $zones;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub load_zones_xml_v2 {
|
sub load_zones_xml_v2 {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $zones = {};
|
my $zones = {};
|
||||||
my $nodesets = $self->{xpath_response}->find('//views//zones/zone');
|
my $nodesets = $self->{xpath_response}->find('//views//zones/zone');
|
||||||
foreach my $node ($nodesets->get_nodelist()) {
|
foreach my $node ($nodesets->get_nodelist()) {
|
||||||
|
@ -248,7 +248,7 @@ sub load_zones_xml_v2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($name)) {
|
if (defined($name)) {
|
||||||
$zones->{$name}->{counters}->{rcode} = $counters;
|
$zones->{$name}->{counters}->{rcode} = $counters;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ sub load_zones_xml_v2 {
|
||||||
|
|
||||||
sub load_server_xml_v3 {
|
sub load_server_xml_v3 {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $server = { counters => { } };
|
my $server = { counters => { } };
|
||||||
my $nodesets = $self->{xpath_response}->find('//server//counters');
|
my $nodesets = $self->{xpath_response}->find('//server//counters');
|
||||||
foreach my $node ($nodesets->get_nodelist()) {
|
foreach my $node ($nodesets->get_nodelist()) {
|
||||||
|
@ -272,63 +272,63 @@ sub load_server_xml_v3 {
|
||||||
$server->{counters}->{$type}->{$counter_name} = $counter_node->string_value;
|
$server->{counters}->{$type}->{$counter_name} = $counter_node->string_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $server;
|
return $server;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub load_server_xml_v2 {
|
sub load_server_xml_v2 {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $server = { counters => { opcode => {}, nsstat => {}, qtype => {} } };
|
my $server = { counters => { opcode => {}, nsstat => {}, qtype => {} } };
|
||||||
|
|
||||||
my $nodesets = $self->{xpath_response}->find('//server//opcode');
|
my $nodesets = $self->{xpath_response}->find('//server//opcode');
|
||||||
foreach my $node ($nodesets->get_nodelist()) {
|
foreach my $node ($nodesets->get_nodelist()) {
|
||||||
my ($name, $value);
|
my ($name, $value);
|
||||||
foreach my $counter_node ($node->getChildNodes()) {
|
foreach my $counter_node ($node->getChildNodes()) {
|
||||||
my $tag_name = $counter_node->getLocalName();
|
my $tag_name = $counter_node->getLocalName();
|
||||||
next if (!defined($tag_name));
|
next if (!defined($tag_name));
|
||||||
|
|
||||||
$name = $counter_node->string_value if ($tag_name eq 'name');
|
$name = $counter_node->string_value if ($tag_name eq 'name');
|
||||||
$value = $counter_node->string_value if ($tag_name eq 'counter');
|
$value = $counter_node->string_value if ($tag_name eq 'counter');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($name) && defined($value)) {
|
if (defined($name) && defined($value)) {
|
||||||
$server->{counters}->{opcode}->{$name} = $value;
|
$server->{counters}->{opcode}->{$name} = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$nodesets = $self->{xpath_response}->find('//server//rdtype');
|
$nodesets = $self->{xpath_response}->find('//server//rdtype');
|
||||||
foreach my $node ($nodesets->get_nodelist()) {
|
foreach my $node ($nodesets->get_nodelist()) {
|
||||||
my ($name, $value);
|
my ($name, $value);
|
||||||
foreach my $counter_node ($node->getChildNodes()) {
|
foreach my $counter_node ($node->getChildNodes()) {
|
||||||
my $tag_name = $counter_node->getLocalName();
|
my $tag_name = $counter_node->getLocalName();
|
||||||
next if (!defined($tag_name));
|
next if (!defined($tag_name));
|
||||||
|
|
||||||
$name = $counter_node->string_value if ($tag_name eq 'name');
|
$name = $counter_node->string_value if ($tag_name eq 'name');
|
||||||
$value = $counter_node->string_value if ($tag_name eq 'counter');
|
$value = $counter_node->string_value if ($tag_name eq 'counter');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($name) && defined($value)) {
|
if (defined($name) && defined($value)) {
|
||||||
$server->{counters}->{qtype}->{$name} = $value;
|
$server->{counters}->{qtype}->{$name} = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$nodesets = $self->{xpath_response}->find('//server//nsstat');
|
$nodesets = $self->{xpath_response}->find('//server//nsstat');
|
||||||
foreach my $node ($nodesets->get_nodelist()) {
|
foreach my $node ($nodesets->get_nodelist()) {
|
||||||
my ($name, $value);
|
my ($name, $value);
|
||||||
foreach my $counter_node ($node->getChildNodes()) {
|
foreach my $counter_node ($node->getChildNodes()) {
|
||||||
my $tag_name = $counter_node->getLocalName();
|
my $tag_name = $counter_node->getLocalName();
|
||||||
next if (!defined($tag_name));
|
next if (!defined($tag_name));
|
||||||
|
|
||||||
$name = $counter_node->string_value if ($tag_name eq 'name');
|
$name = $counter_node->string_value if ($tag_name eq 'name');
|
||||||
$value = $counter_node->string_value if ($tag_name eq 'counter');
|
$value = $counter_node->string_value if ($tag_name eq 'counter');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($name) && defined($value)) {
|
if (defined($name) && defined($value)) {
|
||||||
$server->{counters}->{nsstat}->{$name} = $value;
|
$server->{counters}->{nsstat}->{$name} = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $server;
|
return $server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ sub get_memory {
|
||||||
$self->{output}->add_option_msg(short_msg => "method 'load_memory_$self->{response_type}_v$self->{api_version}' unsupported");
|
$self->{output}->add_option_msg(short_msg => "method 'load_memory_$self->{response_type}_v$self->{api_version}' unsupported");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
my $memory = $self->$method();
|
my $memory = $self->$method();
|
||||||
if (!defined($memory->{in_use})) {
|
if (!defined($memory->{in_use})) {
|
||||||
$self->{output}->add_option_msg(short_msg => "cannot find memory information");
|
$self->{output}->add_option_msg(short_msg => "cannot find memory information");
|
||||||
|
@ -360,7 +360,7 @@ sub get_zones {
|
||||||
$self->{output}->add_option_msg(short_msg => "method 'load_zones_$self->{response_type}_v$self->{api_version}' unsupported");
|
$self->{output}->add_option_msg(short_msg => "method 'load_zones_$self->{response_type}_v$self->{api_version}' unsupported");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
my $zones = $self->$method();
|
my $zones = $self->$method();
|
||||||
if (scalar(keys %{$zones}) == 0) {
|
if (scalar(keys %{$zones}) == 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => "cannot find zones information");
|
$self->{output}->add_option_msg(short_msg => "cannot find zones information");
|
||||||
|
@ -379,7 +379,7 @@ sub get_server {
|
||||||
$self->{output}->add_option_msg(short_msg => "method 'load_server_$self->{response_type}_v$self->{api_version}' unsupported");
|
$self->{output}->add_option_msg(short_msg => "method 'load_server_$self->{response_type}_v$self->{api_version}' unsupported");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
my $server = $self->$method();
|
my $server = $self->$method();
|
||||||
if (scalar(keys %{$server->{counters}}) == 0) {
|
if (scalar(keys %{$server->{counters}}) == 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => "cannot find server information");
|
$self->{output}->add_option_msg(short_msg => "cannot find server information");
|
||||||
|
|
|
@ -26,76 +26,189 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Digest::MD5 qw(md5_hex);
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
my $default_filter_counters = "opcode-query|opcode-iquery|opcode-status|opcode-notify|opcode-update";
|
||||||
|
$default_filter_counters .= "|qtype-a|qtype-aaaa|qtype-cname|qtype-mx|qtype-txt|qtype-soa|qtype-ptr";
|
||||||
|
$default_filter_counters .= "|nsstat-requestv4|nsstat-requestv6";
|
||||||
|
|
||||||
|
# From Bind 9.11.5 counter list
|
||||||
|
# opcode = completed
|
||||||
|
# rcode = not started
|
||||||
|
# qtype = completed
|
||||||
|
# nsstat = completed
|
||||||
|
# zonestat = completed
|
||||||
|
# resstat = not started
|
||||||
|
|
||||||
|
# Counter name, message, nlabel
|
||||||
|
my @map = (
|
||||||
|
['opcode-query', 'opcode query : %s', 'opcode.query.count'],
|
||||||
|
['opcode-iquery', 'opcode iquery : %s', 'opcode.iquery.count'],
|
||||||
|
['opcode-status', 'opcode status : %s', 'opcode.status.count'],
|
||||||
|
['opcode-notify', 'opcode notify : %s', 'opcode.notify.count'],
|
||||||
|
['opcode-update', 'opcode update : %s', 'opcode.update.count'],
|
||||||
|
['qtype-a', 'qtype A : %s', 'qtype.a.count'],
|
||||||
|
['qtype-ns', 'qtype NS : %s', 'qtype.ns.count'],
|
||||||
|
['qtype-cname', 'qtype CNAME : %s', 'qtype.cname.count'],
|
||||||
|
['qtype-soa', 'qtype SOA : %s', 'qtype.soa.count'],
|
||||||
|
['qtype-null', 'qtype NULL : %s', 'qtype.null.count'],
|
||||||
|
['qtype-wks', 'qtype WKS : %s', 'qtype.wks.count'],
|
||||||
|
['qtype-ptr', 'qtype PTR : %s', 'qtype.ptr.count'],
|
||||||
|
['qtype-hinfo', 'qtype HINFO : %s', 'qtype.hinfo.count'],
|
||||||
|
['qtype-mx', 'qtype MX : %s', 'qtype.mx.count'],
|
||||||
|
['qtype-txt', 'qtype TXT : %s', 'qtype.txt.count'],
|
||||||
|
['qtype-aaaa', 'qtype AAAA : %s', 'qtype.aaaa.count'],
|
||||||
|
['qtype-srv', 'qtype SRV : %s', 'qtype.srv.count'],
|
||||||
|
['qtype-naptr', 'qtype NAPTR : %s', 'qtype.naptr.count'],
|
||||||
|
['qtype-a6', 'qtype A6 : %s', 'qtype.a6.count'],
|
||||||
|
['qtype-ds', 'qtype DS : %s', 'qtype.ds.count'],
|
||||||
|
['qtype-rrsig', 'qtype RRSIG : %s', 'qtype.rrsig.count'],
|
||||||
|
['qtype-nsec', 'qtype NSEC : %s', 'qtype.nsec.count'],
|
||||||
|
['qtype-dnskey', 'qtype DNSKEY : %s', 'qtype.dnskey.count'],
|
||||||
|
['qtype-tlsa', 'qtype TLSA : %s', 'qtype.tlsa.count'],
|
||||||
|
['qtype-cds', 'qtype CDS : %s', 'qtype.cds.count'],
|
||||||
|
['qtype-type65', 'qtype TYPE65 : %s', 'qtype.type65.count'],
|
||||||
|
['qtype-spf', 'qtype SPF : %s', 'qtype.spf.count'],
|
||||||
|
['qtype-axfr', 'qtype AXFR : %s', 'qtype.axfr.count'],
|
||||||
|
['qtype-any', 'qtype ANY : %s', 'qtype.any.count'],
|
||||||
|
['qtype-others', 'qtype Others : %s', 'qtype.others.count'],
|
||||||
|
['nsstat-requestv4', 'nsstat Request v4 : %s', 'nsstat.requestv4.count'],
|
||||||
|
['nsstat-requestv6', 'nsstat Request v6 : %s', 'nsstat.requestv6.count'],
|
||||||
|
['nsstat-reqedns0', 'nsstat ReqEdns0 : %s', 'nsstat.reqedns0.count'],
|
||||||
|
['nsstat-reqbadednsver', 'nsstat ReqBadEDNSVer : %s', 'nsstat.reqbadednsver.count'],
|
||||||
|
['nsstat-reqtsig', 'nsstat ReqTSIG : %s', 'nsstat.reqtsig.count'],
|
||||||
|
['nsstat-reqsig0', 'nsstat ReqSIG0 : %s', 'nsstat.reqsig0.count'],
|
||||||
|
['nsstat-reqbadsig', 'nsstat ReqBadSIG : %s', 'nsstat.reqbadsig.count'],
|
||||||
|
['nsstat-reqtcp', 'nsstat ReqTCP : %s', 'nsstat.reqtcp.count'],
|
||||||
|
['nsstat-authqryrej', 'nsstat AuthQryRej : %s', 'nsstat.authqryrej.count'],
|
||||||
|
['nsstat-recqryrej', 'nsstat RecQryRej : %s', 'nsstat.recqryrej.count'],
|
||||||
|
['nsstat-xfrrej', 'nsstat XfrRej : %s', 'nsstat.xfrrej.count'],
|
||||||
|
['nsstat-updaterej', 'nsstat UpdateRej : %s', 'nsstat.updaterej.count'],
|
||||||
|
['nsstat-response', 'nsstat Response : %s', 'nsstat.response.count'],
|
||||||
|
['nsstat-truncatedresp', 'nsstat TruncatedResp : %s', 'nsstat.truncatedresp.count'],
|
||||||
|
['nsstat-respedns0', 'nsstat RespEDNS0 : %s', 'nsstat.respedns0.count'],
|
||||||
|
['nsstat-resptsig', 'nsstat RespTSIG : %s', 'nsstat.resptsig.count'],
|
||||||
|
['nsstat-respsig0', 'nsstat RespSIG0 : %s', 'nsstat.respsig0.count'],
|
||||||
|
['nsstat-qrysuccess', 'nsstat QrySuccess : %s', 'nsstat.qrysuccess.count'],
|
||||||
|
['nsstat-qryauthans', 'nsstat QryAuthAns : %s', 'nsstat.qryauthans.count'],
|
||||||
|
['nsstat-qrynoauthans', 'nsstat QryNoauthAns : %s', 'nsstat.qrynoauthans.count'],
|
||||||
|
['nsstat-qryreferral', 'nsstat QryReferral : %s', 'nsstat.qryreferral.count'],
|
||||||
|
['nsstat-qrynxrrset', 'nsstat QryNxrrset : %s', 'nsstat.qrynxrrset.count'],
|
||||||
|
['nsstat-qryservfail', 'nsstat QrySERVFAIL : %s', 'nsstat.qryservfail.count'],
|
||||||
|
['nsstat-qryformerr', 'nsstat QryFORMERR : %s', 'nsstat.qryformerr.count'],
|
||||||
|
['nsstat-qrynxdomain', 'nsstat QryNXDOMAIN : %s', 'nsstat.qrynxdomain.count'],
|
||||||
|
['nsstat-qryrecursion', 'nsstat QryRecursion : %s', 'nsstat.qryrecursion.count'],
|
||||||
|
['nsstat-qryduplicate', 'nsstat QryDuplicate : %s', 'nsstat.qryduplicate.count'],
|
||||||
|
['nsstat-qrydropped', 'nsstat QryDropped : %s', 'nsstat.qrydropped.count'],
|
||||||
|
['nsstat-qryfailure', 'nsstat QryFailure : %s', 'nsstat.qryfailure.count'],
|
||||||
|
['nsstat-xfrreqdone', 'nsstat XfrReqDone : %s', 'nsstat.xfrreqdone.count'],
|
||||||
|
['nsstat-updatereqfwd', 'nsstat UpdateReqFwd : %s', 'nsstat.updatereqfwd.count'],
|
||||||
|
['nsstat-updaterespfwd', 'nsstat UpdateRespFwd : %s', 'nsstat.updaterespfwd.count'],
|
||||||
|
['nsstat-updatefwdfail', 'nsstat UpdateFwdFail : %s', 'nsstat.updatefwdfail.count'],
|
||||||
|
['nsstat-updatedone', 'nsstat UpdateDone : %s', 'nsstat.updatedone.count'],
|
||||||
|
['nsstat-updatefail', 'nsstat UpdateFail : %s', 'nsstat.updatefail.count'],
|
||||||
|
['nsstat-updatebadprereq', 'nsstat UpdateBadPrereq : %s', 'nsstat.updatebadprereq.count'],
|
||||||
|
['nsstat-recursclients', 'nsstat RecursClients : %s', 'nsstat.recursclients.count'],
|
||||||
|
['nsstat-dns64', 'nsstat RateDropped : %s', 'nsstat.ratedropped.count'],
|
||||||
|
['nsstat-ratedropped', 'nsstat RateDropped : %s', 'nsstat.ratedropped.count'],
|
||||||
|
['nsstat-rateslipped', 'nsstat RateSlipped : %s', 'nsstat.rateslipped.count'],
|
||||||
|
['nsstat-rpzrewrites', 'nsstat RPZRewrites : %s', 'nsstat.rpzrewrites.count'],
|
||||||
|
['nsstat-qryudp', 'nsstat QryUDP : %s', 'nsstat.qryudp.count'],
|
||||||
|
['nsstat-qrytcp', 'nsstat QryTCP : %s', 'nsstat.qrytcp.count'],
|
||||||
|
['nsstat-nsidopt', 'nsstat NSIDOpt : %s', 'nsstat.nsidopt.count'],
|
||||||
|
['nsstat-expireopt', 'nsstat ExpireOpt : %s', 'nsstat.expireopt.count'],
|
||||||
|
['nsstat-otheropt', 'nsstat OtherOpt : %s', 'nsstat.otheropt.count'],
|
||||||
|
['nsstat-cookiein', 'nsstat CookieIn : %s', 'nsstat.cookiein.count'],
|
||||||
|
['nsstat-cookienew ', 'nsstat CookieNew : %s', 'nsstat.cookienew .count'],
|
||||||
|
['nsstat-cookiebadsize', 'nsstat CookieBadSize : %s', 'nsstat.cookiebadsize.count'],
|
||||||
|
['nsstat-cookiebadtime', 'nsstat CookieBadTime : %s', 'nsstat.cookiebadtime.count'],
|
||||||
|
['nsstat-cookienomatch', 'nsstat CookieNoMatch : %s', 'nsstat.cookienomatch.count'],
|
||||||
|
['nsstat-cookiematch', 'nsstat CookieMatch : %s', 'nsstat.cookiematch.count'],
|
||||||
|
['nsstat-ecsopt', 'nsstat ECSOpt : %s', 'nsstat.ecsopt.count'],
|
||||||
|
['nsstat-qrynxredir', 'nsstat QryNXRedir : %s', 'nsstat.qrynxredir.count'],
|
||||||
|
['nsstat-qrynxredirrlookup', 'nsstat QryNXRedirRLookup : %s', 'nsstat.qrynxredirrlookup.count'],
|
||||||
|
['nsstat-qrybadcookie', 'nsstat QryBADCOOKIE : %s', 'nsstat.qrybadcookie.count'],
|
||||||
|
['nsstat-keytagopt', 'nsstat KeyTagOpt : %s', 'nsstat.keytagopt.count'],
|
||||||
|
['zonestat-keytagopt', 'zonestat NotifyOutv4 : %s', 'zonestat.notifyoutv4.count'],
|
||||||
|
['zonestat-notifyoutv6', 'zonestat NotifyOutv6 : %s', 'zonestat.notifyoutv6.count'],
|
||||||
|
['zonestat-notifyinv4', 'zonestat NotifyInv4 : %s', 'zonestat.notifyinv4.count'],
|
||||||
|
['zonestat-notifyinv6', 'zonestat NotifyInv6 : %s', 'zonestat.notifyinv6.count'],
|
||||||
|
['zonestat-notifyrej', 'zonestat NotifyRej : %s', 'zonestat.notifyrej.count'],
|
||||||
|
['zonestat-soaoutv4', 'zonestat SOAOutv4 : %s', 'zonestat.soaoutv4.count'],
|
||||||
|
['zonestat-soaoutv6', 'zonestat SOAOutv6 : %s', 'zonestat.soaoutv6.count'],
|
||||||
|
['zonestat-axfrreqv4', 'zonestat AXFRReqv4 : %s', 'zonestat.axfrreqv4.count'],
|
||||||
|
['zonestat-axfrreqv6', 'zonestat AXFRReqv6 : %s', 'zonestat.axfrreqv6.count'],
|
||||||
|
['zonestat-ixfrreqv4', 'zonestat IXFRReqv4 : %s', 'zonestat.ixfrreqv4.count'],
|
||||||
|
['zonestat-ixfrreqv6', 'zonestat IXFRReqv6 : %s', 'zonestat.ixfrreqv6.count'],
|
||||||
|
['zonestat-xfrsuccess', 'zonestat XfrSuccess : %s', 'zonestat.xfrsuccess.count'],
|
||||||
|
['zonestat-xfrfail', 'zonestat XfrFail : %s', 'zonestat.xfrfail.count'],
|
||||||
|
);
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters_type} = [
|
$self->{maps_counters_type} = [
|
||||||
{ name => 'server', type => 0, skipped_code => { -1 => 1, -10 => 1, 11 => -1 } }
|
{ name => 'server', type => 0, skipped_code => { -1 => 1, -10 => 1, 11 => -1 } }
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{server} = [];
|
|
||||||
|
|
||||||
my @map = (
|
$self->{maps_counters}->{server} = [];
|
||||||
['opcode_query', 'opcode query : %s', 'opcode-query'],
|
|
||||||
['opcode_iquery', 'opcode iquery : %s', 'opcode-iquery'],
|
|
||||||
['opcode_status', 'opcode status : %s', 'opcode-status'],
|
|
||||||
['opcode_notify', 'opcode notify : %s', 'opcode-notify'],
|
|
||||||
['opcode_update', 'opcode update : %s', 'opcode-update'],
|
|
||||||
['qtype_a', 'qtype A : %s', 'qtype-a'],
|
|
||||||
['qtype_cname', 'qtype CNAME : %s', 'qtype-cname'],
|
|
||||||
['qtype_mx', 'qtype MX : %s', 'qtype-mx'],
|
|
||||||
['qtype_txt', 'qtype TXT : %s', 'qtype-txt'],
|
|
||||||
['qtype_soa', 'qtype SOA : %s', 'qtype-soa'],
|
|
||||||
['qtype_ptr', 'qtype PTR : %s', 'qtype-ptr'],
|
|
||||||
['qtype_ns', 'qtype NS : %s', 'qtype-ns'],
|
|
||||||
['nsstat_requestv4', 'nsstat request v4 : %s', 'nsstat-requestv4'],
|
|
||||||
['nsstat_requestv6', 'nsstat request v6 : %s', 'nsstat-requestv6'],
|
|
||||||
);
|
|
||||||
|
|
||||||
for (my $i = 0; $i < scalar(@map); $i++) {
|
for (my $i = 0; $i < scalar(@map); $i++) {
|
||||||
my $perf_label = $map[$i]->[2];
|
my $perf_label = $map[$i]->[0];
|
||||||
$perf_label =~ s/-/_/g;
|
$perf_label =~ s/-/_/g;
|
||||||
push @{$self->{maps_counters}->{server}}, { label => $map[$i]->[2], display_ok => 0, set => {
|
|
||||||
key_values => [ { name => $map[$i]->[0], diff => 1 } ],
|
push @{$self->{maps_counters}->{server}}, {
|
||||||
output_template => $map[$i]->[1],
|
label => $map[$i]->[0], nlabel => => $map[$i]->[2], display_ok => 0,
|
||||||
perfdatas => [
|
set => {
|
||||||
{ label => $perf_label, value => $map[$i]->[0] , template => '%s', min => 0 },
|
key_values => [ { name => $perf_label, diff => 1 } ],
|
||||||
],
|
output_template => $map[$i]->[1],
|
||||||
}
|
perfdatas => [
|
||||||
};
|
{ label => $perf_label, value => $perf_label , template => '%s', min => 0 },
|
||||||
}
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
|
if ( ! defined($self->{option_results}->{filter_counters}) ) {
|
||||||
|
$self->{option_results}->{filter_counters} = $default_filter_counters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $result = $options{custom}->get_server();
|
my $result = $options{custom}->get_server();
|
||||||
$self->{server} = { };
|
$self->{server} = { };
|
||||||
|
|
||||||
# Not present in response if no request on the server
|
# Init for all vars, some are not present in response if no request on the server
|
||||||
foreach ('a', 'cname', 'mx', 'txt', 'soa', 'ptr', 'ns', 'any') {
|
for (my $i = 0; $i < scalar(@map); $i++) {
|
||||||
$self->{server}->{'qtype_' . $_} = 0;
|
my $perf_label = $map[$i]->[0];
|
||||||
|
$perf_label =~ s/-/_/g;
|
||||||
|
$self->{server}->{$perf_label} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
$self->{output}->output_add(severity => 'OK',
|
||||||
short_msg => 'All bind9 counters are ok');
|
short_msg => 'All Bind 9 counters are ok');
|
||||||
|
|
||||||
foreach my $type (keys %{$result->{counters}}) {
|
foreach my $type (keys %{$result->{counters}}) {
|
||||||
foreach my $counter (keys %{$result->{counters}->{$type}}) {
|
foreach my $counter (keys %{$result->{counters}->{$type}}) {
|
||||||
$self->{server}->{lc($type) . '_' . lc($counter)} = $result->{counters}->{$type}->{$counter};
|
$self->{server}->{lc($type) . '_' . lc($counter)} = $result->{counters}->{$type}->{$counter};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{cache_name} = "bind9_" . $self->{mode} . '_' . $options{custom}->get_uniq_id() . '_' .
|
$self->{cache_name} = "bind9_" . $self->{mode} . '_' . $options{custom}->get_uniq_id() . '_' .
|
||||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||||
}
|
}
|
||||||
|
@ -106,21 +219,21 @@ __END__
|
||||||
|
|
||||||
=head1 MODE
|
=head1 MODE
|
||||||
|
|
||||||
Check bind global server usage.
|
Check Bind global server usage.
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--filter-counters>
|
=item B<--filter-counters>
|
||||||
|
|
||||||
Only display some counters (regexp can be used).
|
Only display some counters (regexp can be used).
|
||||||
Example: --filter-counters='request'
|
Example: --filter-counters='nsstat-requestv6'
|
||||||
|
|
||||||
|
Show the full list with --list-counters.
|
||||||
|
|
||||||
=item B<--warning-*> B<--critical-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Thresholds.
|
Thresholds.
|
||||||
Can be: 'opcode-query', 'opcode-iquery', 'opcode-status', 'opcode-notify', 'opcode-update',
|
Can be any of the selected counters.
|
||||||
'qtype-a', 'qtype-cname', 'qtype-mx', 'qtype-txt', 'qtype-soa', 'qtype-ptr', 'qtype-ns', 'qtype-any',
|
|
||||||
'nsstat-requestv4', 'nsstat-requestv6'.
|
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.1';
|
||||||
%{$self->{modes}} = (
|
%{$self->{modes}} = (
|
||||||
'memory-usage' => 'apps::bind9::web::mode::memoryusage',
|
'memory-usage' => 'apps::bind9::web::mode::memoryusage',
|
||||||
'server-usage' => 'apps::bind9::web::mode::serverusage',
|
'server-usage' => 'apps::bind9::web::mode::serverusage',
|
||||||
|
|
Loading…
Reference in New Issue