Apps squid snmp metricsv2 (#2823)
* enh(plugin): Squid SNMP metricsv2 * enh(plugin): Squid SNMP metricsv2 * nlabel names fix
This commit is contained in:
parent
d41f68617a
commit
deb7a381b7
|
@ -33,43 +33,39 @@ sub set_counters {
|
|||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'cpu', set => {
|
||||
{ label => 'cpu', nlabel => 'cpu.cache.utilization.percentage', set => {
|
||||
key_values => [ { name => 'cacheCpuUsage' } ],
|
||||
output_template => 'Cpu usage : %s %%',
|
||||
perfdatas => [
|
||||
{ label => 'cpu', value => 'cacheCpuUsage', template => '%s',
|
||||
min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
{ label => 'cpu', template => '%s', min => 0, max => 100, unit => '%' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'memory', set => {
|
||||
{ label => 'memory', nlabel => 'memory.cache.usage.bytes', set => {
|
||||
key_values => [ { name => 'cacheMemUsage' } ],
|
||||
output_template => 'Memory usage : %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ label => 'memory', value => 'cacheMemUsage', template => '%s',
|
||||
min => 0, unit => 'B' },
|
||||
],
|
||||
{ label => 'memory', template => '%s', min => 0, unit => 'B' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'fd', set => {
|
||||
{ label => 'fd', nlabel => 'cache.filedescriptors.count', set => {
|
||||
key_values => [ { name => 'cacheCurrentFileDescrCnt' } ],
|
||||
output_template => 'Number of file descriptors : %s',
|
||||
perfdatas => [
|
||||
{ label => 'fd', value => 'cacheCurrentFileDescrCnt', template => '%s',
|
||||
min => 0 },
|
||||
],
|
||||
{ label => 'fd', template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'object', set => {
|
||||
{ label => 'object', nlabel => 'cache.objects.count', set => {
|
||||
key_values => [ { name => 'cacheNumObjCount' } ],
|
||||
output_template => 'Number of object stored : %s',
|
||||
perfdatas => [
|
||||
{ label => 'objects', value => 'cacheNumObjCount', template => '%s',
|
||||
min => 0 },
|
||||
],
|
||||
{ label => 'objects', template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -78,9 +74,8 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
|
|
@ -39,112 +39,6 @@ sub custom_data_calc {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global_http', type => 0, cb_prefix_output => 'prefix_http_output', skipped_code => { -10 => 1 } },
|
||||
{ name => 'global_icp', type => 0, cb_prefix_output => 'prefix_icp_output', skipped_code => { -10 => 1 } },
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_server_output', skipped_code => { -10 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global_http} = [
|
||||
{ label => 'http-hits-rate', set => {
|
||||
key_values => [ { name => 'cacheProtoClientHttpRequests', diff => 1 }, { name => 'cacheHttpHits', diff => 1 } ],
|
||||
closure_custom_calc => $self->can('custom_data_calc'),
|
||||
output_template => 'hits rate : %.2f %%', output_use => 'hits_prct', threshold_use => 'hits_prct',
|
||||
perfdatas => [
|
||||
{ label => 'http_hits_rate', value => 'hits_prct', template => '%.2f', min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'http-errors', set => {
|
||||
key_values => [ { name => 'cacheHttpErrors', diff => 1 } ],
|
||||
output_template => 'errors : %s',
|
||||
perfdatas => [
|
||||
{ label => 'http_errors', template => '%s',
|
||||
min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'http-traffic-in', set => {
|
||||
key_values => [ { name => 'cacheHttpInKb', per_second => 1 } ],
|
||||
output_template => 'traffic in : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'http_traffic_in', template => '%s',
|
||||
min => 0, unit => 'b/s' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'http-traffic-out', set => {
|
||||
key_values => [ { name => 'cacheHttpOutKb', per_second => 1 } ],
|
||||
output_template => 'traffic Out : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'http_traffic_out', template => '%s',
|
||||
min => 0, unit => 'b/s' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global_icp} = [
|
||||
{ label => 'icp-traffic-in', set => {
|
||||
key_values => [ { name => 'cacheIcpKbRecv', per_second => 1 } ],
|
||||
output_template => 'traffic in : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'icp_traffic_in', template => '%s',
|
||||
min => 0, unit => 'b/s' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'icp-traffic-out', set => {
|
||||
key_values => [ { name => 'cacheIcpKbSent', per_second => 1 } ],
|
||||
output_template => 'traffic Out : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'icp_traffic_out', template => '%s',
|
||||
min => 0, unit => 'b/s' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'server-traffic-in', set => {
|
||||
key_values => [ { name => 'cacheServerInKb', per_second => 1 } ],
|
||||
output_template => 'traffic in : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'server_traffic_in', template => '%s',
|
||||
min => 0, unit => 'b/s' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'server-traffic-out', set => {
|
||||
key_values => [ { name => 'cacheServerOutKb', per_second => 1 } ],
|
||||
output_template => 'traffic Out : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'server_traffic_out', template => '%s',
|
||||
min => 0, unit => 'b/s' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'clients', set => {
|
||||
key_values => [ { name => 'cacheClients' } ],
|
||||
output_template => 'current number of clients : %s',
|
||||
perfdatas => [
|
||||
{ label => 'clients', template => '%s', min => 0 },
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_http_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -163,6 +57,104 @@ sub prefix_server_output {
|
|||
return "Server ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global_http', type => 0, cb_prefix_output => 'prefix_http_output', skipped_code => { -10 => 1 } },
|
||||
{ name => 'global_icp', type => 0, cb_prefix_output => 'prefix_icp_output', skipped_code => { -10 => 1 } },
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_server_output', skipped_code => { -10 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global_http} = [
|
||||
{ label => 'http-hits-rate', nlabel => 'http.hits.percentage', set => {
|
||||
key_values => [ { name => 'cacheProtoClientHttpRequests', diff => 1 }, { name => 'cacheHttpHits', diff => 1 } ],
|
||||
closure_custom_calc => $self->can('custom_data_calc'),
|
||||
output_template => 'hits rate : %.2f %%', output_use => 'hits_prct', threshold_use => 'hits_prct',
|
||||
perfdatas => [
|
||||
{ label => 'http_hits_rate'template => '%.2f', min => 0, max => 100, unit => '%' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'http-errors', nlabel => 'http.errors.count', set => {
|
||||
key_values => [ { name => 'cacheHttpErrors', diff => 1 } ],
|
||||
output_template => 'errors : %s',
|
||||
perfdatas => [
|
||||
{ label => 'http_errors', template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'http-traffic-in', nlabel => 'http.traffic.in.bitspersecond', set => {
|
||||
key_values => [ { name => 'cacheHttpInKb', per_second => 1 } ],
|
||||
output_template => 'traffic in : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'http_traffic_in', template => '%s', min => 0, unit => 'b/s' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'http-traffic-out', nlabel => 'http.traffic.out.bitspersecond', set => {
|
||||
key_values => [ { name => 'cacheHttpOutKb', per_second => 1 } ],
|
||||
output_template => 'traffic Out : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'http_traffic_out', template => '%s', min => 0, unit => 'b/s' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global_icp} = [
|
||||
{ label => 'icp-traffic-in', nlabel => 'icp.traffic.in.bitspersecond', set => {
|
||||
key_values => [ { name => 'cacheIcpKbRecv', per_second => 1 } ],
|
||||
output_template => 'traffic in : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'icp_traffic_in', template => '%s', min => 0, unit => 'b/s' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'icp-traffic-out', nlabel => 'icp.traffic.out.bitspersecond', set => {
|
||||
key_values => [ { name => 'cacheIcpKbSent', per_second => 1 } ],
|
||||
output_template => 'traffic Out : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'icp_traffic_out', template => '%s', min => 0, unit => 'b/s' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'server-traffic-in', nlabel => 'server.traffic.in.bitspersecond', set => {
|
||||
key_values => [ { name => 'cacheServerInKb', per_second => 1 } ],
|
||||
output_template => 'traffic in : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'server_traffic_in', template => '%s', min => 0, unit => 'b/s' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'server-traffic-out', nlabel => 'server.traffic.out.bitspersecond', set => {
|
||||
key_values => [ { name => 'cacheServerOutKb', per_second => 1 } ],
|
||||
output_template => 'traffic Out : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'server_traffic_out', template => '%s', min => 0, unit => 'b/s' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'clients', nlabel => 'clients.count', set => {
|
||||
key_values => [ { name => 'cacheClients' } ],
|
||||
output_template => 'current number of clients : %s',
|
||||
perfdatas => [
|
||||
{ label => 'clients', template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
|
|
|
@ -30,10 +30,10 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
%{$self->{modes} => {
|
||||
'cache-usage' => 'apps::squid::snmp::mode::cacheusage',
|
||||
'protocol-stats' => 'apps::squid::snmp::mode::protocolstats',
|
||||
);
|
||||
};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue