New upstream version 2.1.0
This commit is contained in:
parent
e1ab4578a6
commit
75687e089f
37 changed files with 1333 additions and 8079 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/perl -w
|
||||
############################## check_snmp_int ##############
|
||||
my $VERSION = "2.0.0";
|
||||
my $VERSION = "2.1.0";
|
||||
|
||||
# Date : Oct 10 2007
|
||||
# Author : Patrick Proy ( patrick at proy.org )
|
||||
|
@ -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
|
||||
|
@ -229,6 +230,8 @@ sub help {
|
|||
usually 1472,1452,1460 or 1440.
|
||||
-f, --perfparse, --perfdata
|
||||
Performance data output (no output when interface is down).
|
||||
-W, --weather
|
||||
Output data for "weathermap" lines in NagVis with performance data
|
||||
-e, --error
|
||||
Add error & discard to Perfparse output
|
||||
-S, --intspeed
|
||||
|
@ -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();
|
||||
|
@ -718,7 +728,7 @@ for (my $i = 0; $i < $num_int; $i++) {
|
|||
if (defined($o_checkperf) && $int_status == 1) {
|
||||
$temp_file_name = $descr[$i];
|
||||
$temp_file_name =~ s/[ ;\/]/_/g;
|
||||
$temp_file_name = $o_base_dir . $o_host . "." . $temp_file_name;
|
||||
$temp_file_name = $o_base_dir . $o_host . "." . $o_port . "." . $temp_file_name;
|
||||
|
||||
# First, read entire file
|
||||
my @ret_array = read_file($temp_file_name, $n_items_check);
|
||||
|
@ -904,12 +914,12 @@ for (my $i = 0; $i < $num_int; $i++) {
|
|||
$warn_factor /= $speed_real;
|
||||
$warn_factor *= 100; # now turn into displayed % : 0,1 = 10%
|
||||
}
|
||||
$perf_out .= "'" . $descr[$i] . "_in_prct'=";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_in_prct'=";
|
||||
$perf_out .= sprintf("%.0f", $checkperf_out_raw[0] * 800 / $speed_real) . "%;";
|
||||
$perf_out .= ($o_warn[0] != 0) ? sprintf("%.0f", $o_warn[0] * $warn_factor) . ";" : ";";
|
||||
$perf_out .= ($o_crit[0] != 0) ? sprintf("%.0f", $o_crit[0] * $warn_factor) . ";" : ";";
|
||||
$perf_out .= "0;100 ";
|
||||
$perf_out .= "'" . $descr[$i] . "_out_prct'=";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_out_prct'=";
|
||||
$perf_out .= sprintf("%.0f", $checkperf_out_raw[1] * 800 / $speed_real) . "%;";
|
||||
$perf_out .= ($o_warn[1] != 0) ? sprintf("%.0f", $o_warn[1] * $warn_factor) . ";" : ";";
|
||||
$perf_out .= ($o_crit[1] != 0) ? sprintf("%.0f", $o_crit[1] * $warn_factor) . ";" : ";";
|
||||
|
@ -925,12 +935,12 @@ for (my $i = 0; $i < $num_int; $i++) {
|
|||
} else { # just convert from K|M|G bps
|
||||
$warn_factor = (defined($o_meg)) ? 1000000 : (defined($o_gig)) ? 1000000000 : 1000;
|
||||
}
|
||||
$perf_out .= "'" . $descr[$i] . "_in_bps'=";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_in_bps'=";
|
||||
$perf_out .= sprintf("%.0f", $checkperf_out_raw[0] * 8) . ";";
|
||||
$perf_out .= ($o_warn[0] != 0) ? $o_warn[0] * $warn_factor . ";" : ";";
|
||||
$perf_out .= ($o_crit[0] != 0) ? $o_crit[0] * $warn_factor . ";" : ";";
|
||||
$perf_out .= "0;" . $speed_real . " ";
|
||||
$perf_out .= "'" . $descr[$i] . "_out_bps'=";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_out_bps'=";
|
||||
$perf_out .= sprintf("%.0f", $checkperf_out_raw[1] * 8) . ";";
|
||||
$perf_out .= ($o_warn[1] != 0) ? $o_warn[1] * $warn_factor . ";" : ";";
|
||||
$perf_out .= ($o_crit[1] != 0) ? $o_crit[1] * $warn_factor . ";" : ";";
|
||||
|
@ -942,28 +952,32 @@ for (my $i = 0; $i < $num_int; $i++) {
|
|||
} else { # just convert from K|M|G bps
|
||||
$warn_factor = (defined($o_meg)) ? 1048576 : (defined($o_gig)) ? 1073741824 : 1024;
|
||||
}
|
||||
$perf_out .= "'" . $descr[$i] . "_in_Bps'=" . sprintf("%.0f", $checkperf_out_raw[0]) . ";";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_in_Bps'=" . sprintf("%.0f", $checkperf_out_raw[0]) . ";";
|
||||
$perf_out .= ($o_warn[0] != 0) ? $o_warn[0] * $warn_factor . ";" : ";";
|
||||
$perf_out .= ($o_crit[0] != 0) ? $o_crit[0] * $warn_factor . ";" : ";";
|
||||
$perf_out .= "0;" . $speed_real / 8 . " ";
|
||||
$perf_out .= "'" . $descr[$i] . "_out_Bps'=" . sprintf("%.0f", $checkperf_out_raw[1]) . ";";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_out_Bps'=" . sprintf("%.0f", $checkperf_out_raw[1]) . ";";
|
||||
$perf_out .= ($o_warn[1] != 0) ? $o_warn[1] * $warn_factor . ";" : ";";
|
||||
$perf_out .= ($o_crit[1] != 0) ? $o_crit[1] * $warn_factor . ";" : ";";
|
||||
$perf_out .= "0;" . $speed_real / 8 . " ";
|
||||
}
|
||||
}
|
||||
} else { # output in octet counter
|
||||
$perf_out .= "'" . $descr[$i] . "_in_octet'=" . $$result{ $oid_perf_inoct[$i] } . "c ";
|
||||
$perf_out .= "'" . $descr[$i] . "_out_octet'=" . $$result{ $oid_perf_outoct[$i] } . "c ";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_in_octet'=" . $$result{ $oid_perf_inoct[$i] } . "c ";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_out_octet'=" . $$result{ $oid_perf_outoct[$i] } . "c ";
|
||||
}
|
||||
if (defined($o_perfe)) {
|
||||
$perf_out .= "'" . $descr[$i] . "_in_error'=" . $$result{ $oid_perf_inerr[$i] } . "c ";
|
||||
$perf_out .= "'" . $descr[$i] . "_in_discard'=" . $$result{ $oid_perf_indisc[$i] } . "c ";
|
||||
$perf_out .= "'" . $descr[$i] . "_out_error'=" . $$result{ $oid_perf_outerr[$i] } . "c ";
|
||||
$perf_out .= "'" . $descr[$i] . "_out_discard'=" . $$result{ $oid_perf_outdisc[$i] } . "c ";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_in_error'=" . $$result{ $oid_perf_inerr[$i] } . "c ";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_in_discard'=" . $$result{ $oid_perf_indisc[$i] } . "c ";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_out_error'=" . $$result{ $oid_perf_outerr[$i] } . "c ";
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_out_discard'=" . $$result{ $oid_perf_outdisc[$i] } . "c ";
|
||||
}
|
||||
if (defined($o_perfs)) {
|
||||
$perf_out .= "'" . $descr[$i] . "_speed_bps'=" . $speed_real;
|
||||
$perf_out .= "'" . $descr[$i] =~ s/\./_/r . "_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) . " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue