/monitoring/NOCpulsePlugins/Windows/InterfaceTraffic.pm
https://github.com/colloquium/spacewalk · Perl · 31 lines · 20 code · 11 blank · 0 comment · 3 complexity · 038515f33c929c158b35c30ba67e563c MD5 · raw file
- package Windows::InterfaceTraffic;
- use strict;
- use NOCpulse::Probe::DataSource::WindowsCommand;
- sub run {
- my %args = @_;
- my $result = $args{result};
- my %params = %{$args{params}};
- my $interface = $params{interface_0};
- my $command = $args{data_source_factory}->windows_command(%params);
- my $input_bytes = $command->perf_data('Network Interface', 'Bytes Received/sec', $interface);
- my $output_bytes = $command->perf_data('Network Interface', 'Bytes Sent/sec', $interface);
- if ((defined($input_bytes)) && (defined($output_bytes))) {
- $result->context("Interface $interface");
- $result->metric_value('in_bit_rt', $input_bytes, '%.3f');
- $result->metric_value('out_bit_rt', $output_bytes, '%.3f');
- } else {
- $result->user_data_not_found('Interface', $interface);
- }
- }
- 1;