Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow output for NagVis "weathermap" lines #22

Closed
miken32 opened this issue Nov 28, 2016 · 1 comment
Closed

Allow output for NagVis "weathermap" lines #22

miken32 opened this issue Nov 28, 2016 · 1 comment

Comments

@miken32
Copy link
Contributor

miken32 commented Nov 28, 2016

More info on the expected format is available here. It's a very poor format (would be nice if we could tell it how to parse standard plugin output) but it's very useful for visualizing bandwidth. I made the following changes which should merge nicely without affecting existing users. Of course, Icinga's command-plugins-manubulon.conf file would need to be updated to support this as well.

diff --git a/plugins/check_snmp_int.pl b/plugins/check_snmp_int.pl
index 7bebf10..f612741 100755
--- a/plugins/check_snmp_int.pl
+++ b/plugins/check_snmp_int.pl
@@ -73,6 +73,7 @@ my $o_version = undef;    # print version
 my $o_noreg   = undef;    # Do not use Regexp for name
 my $o_short   = undef;    # set maximum of n chars to be displayed
 my $o_label   = undef;    # add label before speed (in, out, etc...).
+my $o_weather = undef;    # output "weathermap" data for NagVis
 
 # Performance data options
 my $o_perf  = undef;      # Output performance data
@@ -257,6 +258,8 @@ sub help {
    warning level for input / output bandwidth (0 for no warning)
      unit depends on B,M,G,u options
    warning for error & discard input / output in error/min (need -q)
+-W, --weather
+   Output data for "weathermap" lines in NagVis with performance data
 -c, --critical=input,output[,error in,error out,discard in,discard out]
    critical level for input / output bandwidth (0 for no critical)
      unit depends on B,M,G,u options
@@ -353,7 +356,9 @@ sub check_options {
         'delta:i'       => \$o_delta,
         'D'             => \$o_dormant,
         'dormant'       => \$o_dormant,
-        'down'          => \$o_down
+        'down'          => \$o_down,
+        'W'             => \$o_weather,
+        'weather'       => \$o_weather
     );
     if (defined($o_help))    { help();      exit $ERRORS{"UNKNOWN"} }
     if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
@@ -418,6 +423,11 @@ sub check_options {
         print_usage();
         exit $ERRORS{"UNKNOWN"};
     }
+    if (defined($o_weather) && !defined($o_perf)) {
+        print "Cannot output weathermap line data without -f option!\n";
+        print_usage();
+        exit $ERRORS{"UNKNOWN"};
+    }
     if (defined($o_perfr) && defined($o_perfp)) {
         print "-Y and -y options are exclusives\n";
         print_usage();
@@ -963,7 +973,11 @@ for (my $i = 0; $i < $num_int; $i++) {
             $perf_out .= "'" . $descr[$i] . "_out_discard'=" . $$result{ $oid_perf_outdisc[$i] } . "c ";
         }
         if (defined($o_perfs)) {
-            $perf_out .= "'" . $descr[$i] . "_speed_bps'=" . $speed_real;
+            $perf_out .= "'" . $descr[$i] . "_speed_bps'=" . $speed_real . " ";
+        }
+        if (defined($o_weather) && $usable_data == 1) {
+            $perf_out .= "in=" . sprintf("%.0f", $checkperf_out_raw[0]) . ";;;0;" . sprintf("%.0f", $speed_real / 8) . " ";
+            $perf_out .= "out=" . sprintf("%.0f", $checkperf_out_raw[1]) . ";;;0;" . sprintf("%.0f", $speed_real / 8) . " ";
         }
     }
 }
@dnsmichi
Copy link
Collaborator

dnsmichi commented Feb 9, 2017

Send a PR please 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants