/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

  1. package Windows::InterfaceTraffic;
  2. use strict;
  3. use NOCpulse::Probe::DataSource::WindowsCommand;
  4. sub run {
  5. my %args = @_;
  6. my $result = $args{result};
  7. my %params = %{$args{params}};
  8. my $interface = $params{interface_0};
  9. my $command = $args{data_source_factory}->windows_command(%params);
  10. my $input_bytes = $command->perf_data('Network Interface', 'Bytes Received/sec', $interface);
  11. my $output_bytes = $command->perf_data('Network Interface', 'Bytes Sent/sec', $interface);
  12. if ((defined($input_bytes)) && (defined($output_bytes))) {
  13. $result->context("Interface $interface");
  14. $result->metric_value('in_bit_rt', $input_bytes, '%.3f');
  15. $result->metric_value('out_bit_rt', $output_bytes, '%.3f');
  16. } else {
  17. $result->user_data_not_found('Interface', $interface);
  18. }
  19. }
  20. 1;