Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2013-02-21 14:59:10 UTC (rev 11564)
+++ trunk/CHANGES 2013-02-21 15:45:11 UTC (rev 11565)
@@ -7,6 +7,7 @@
Allow tracing of individual hosts in check_snmp_interfaces_cascade
Allow specifying a throughput range for SNMP alerts
Restore clicking on product name in footer to get build version information
+ SNMP throughput thresholds now have an expanded syntax to handle input and output throughput separately
NOTICES:
FIXES:
Fixed incorrect SNMP version definition and timeout values
Modified: trunk/opsview-core/bin/db_opsview
===================================================================
--- trunk/opsview-core/bin/db_opsview 2013-02-21 14:59:10 UTC (rev 11564)
+++ trunk/opsview-core/bin/db_opsview 2013-02-21 15:45:11 UTC (rev 11565)
@@ -745,8 +745,8 @@
interfacename varchar(255) NOT NULL, # Need to use ->actual_interface_name_and_index to get actual ifdescr field
shortinterfacename varchar(52) NOT NULL,
active int DEFAULT 0,
- throughput_warning varchar(30),
- throughput_critical varchar(30),
+ throughput_warning varchar(255),
+ throughput_critical varchar(255),
errors_warning varchar(30),
errors_critical varchar(30),
discards_warning varchar(30),
Modified: trunk/opsview-core/installer/upgradedb_opsview.pl
===================================================================
--- trunk/opsview-core/installer/upgradedb_opsview.pl 2013-02-21 14:59:10 UTC (rev 11564)
+++ trunk/opsview-core/installer/upgradedb_opsview.pl 2013-02-21 15:45:11 UTC (rev 11565)
@@ -4680,6 +4680,22 @@
$db->updated;
}
+unless (
+ $db->is_installed(
+ '20130221snmpthro', "Increasing the size of snmp.throughput_*",
+ 'all'
+ )
+ )
+{
+ $dbh->do(
+ q[ ALTER TABLE hostsnmpinterfaces
+ MODIFY throughput_warning VARCHAR(255) DEFAULT NULL,
+ MODIFY throughput_critical VARCHAR(255) DEFAULT NULL
+ ]
+ );
+ $db->updated;
+}
+
# PLACEHOLDER
# For future upgrade of Opsview Core where you cannot have an automatic Opsview reload
# We mark this upgrade lock file so that post installs do not generate an unactivated configuration
Modified: trunk/opsview-core/lib/Opsview/Schema/Hostsnmpinterfaces.pm
===================================================================
--- trunk/opsview-core/lib/Opsview/Schema/Hostsnmpinterfaces.pm 2013-02-21 14:59:10 UTC (rev 11564)
+++ trunk/opsview-core/lib/Opsview/Schema/Hostsnmpinterfaces.pm 2013-02-21 15:45:11 UTC (rev 11565)
@@ -41,14 +41,14 @@
data_type => "VARCHAR",
default_value => undef,
is_nullable => 1,
- size => 30,
+ size => 255,
},
"throughput_critical",
{
data_type => "VARCHAR",
default_value => undef,
is_nullable => 1,
- size => 30,
+ size => 255,
},
"errors_warning",
{
Modified: trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade
===================================================================
--- trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade 2013-02-21 14:59:10 UTC (rev 11564)
+++ trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade 2013-02-21 15:45:11 UTC (rev 11565)
@@ -802,56 +802,22 @@
my $max_state = 0;
my $extra_message = "";
my $speed_is_zero = 0;
+
if ( my $critical = $intdata->{throughput_critical} ) {
- if ( $critical =~ s/%+//g ) {
-
- # Check throughput_in_pct and out_pct
- if ( defined $throughput_in_pct && defined $throughput_out_pct ) {
- $max_state = $np->check_threshold(
- check => [ $throughput_in_pct, $throughput_out_pct ],
- warning => undef,
- critical => $critical
- );
- }
- else {
- $speed_is_zero = 1;
- }
- }
- else {
- $max_state = $np->check_threshold(
- check => [ $throughput_in, $throughput_out ],
- warning => undef,
- critical => $critical
- );
- }
+ ( $max_state, $speed_is_zero ) = calculate_state(
+ critical => $critical,
+ $throughput_in_pct, $throughput_out_pct, $throughput_in,
+ $throughput_out
+ );
}
if ( my $warning = $intdata->{throughput_warning} ) {
- if ( $warning =~ s/%+//g ) {
- if ( defined $throughput_in_pct && defined $throughput_out_pct ) {
- $max_state = $np->max_state(
- $max_state,
- $np->check_threshold(
- check => [ $throughput_in_pct, $throughput_out_pct ],
- warning => $warning,
- critical => undef,
- )
- );
- }
- else {
- $speed_is_zero = 1;
- }
- }
- else {
- $max_state = $np->max_state(
- $max_state,
- $np->check_threshold(
- check => [ $throughput_in, $throughput_out ],
- warning => $warning,
- critical => undef,
- )
- );
- }
+ ( $max_state, $speed_is_zero ) = calculate_state(
+ warning => $warning,
+ $throughput_in_pct, $throughput_out_pct, $throughput_in,
+ $throughput_out
+ );
}
+
if ($speed_is_zero) {
$extra_message =
" but has an interface speed of 0, so cannot check a percentage threshold";
@@ -922,6 +888,99 @@
return 1;
}
+sub calculate_state {
+ my ( $type, $criteria,
+ $throughput_in_pct, $throughput_out_pct, $throughput_in,
+ $throughput_out )
+ = @_;
+ $criteria = lc $criteria;
+ print $criteria, "\n";
+
+ my ( $input, $conjunction, $output );
+ if ( $criteria =~ /^\s*in\s+([\d:%]+)\s+(and|or)\s+out\s+([\d:%]+)\s*$/ ) {
+ ( $input, $conjunction, $output ) = ( $1, $2, $3 );
+ }
+ elsif ( $criteria =~ /^\s*in\s+([\d:%]+)\s*$/ ) {
+ $input = $1;
+ }
+ elsif ( $criteria =~ /^\s*out\s+([\d:%]+)\s*$/ ) {
+ $output = $1;
+ }
+ elsif ( $criteria =~ /^\s*([\d:%]+)\s*$/ ) {
+ $input = $output = $1;
+ $conjunction = 'or';
+ }
+ $input =~ s/%+//g if defined $input;
+ $output =~ s/%+//g if defined $output;
+
+ my ( $max_state, $speed_is_zero ) = ( 0, 0 );
+
+ if ( $criteria =~ /%/
+ and not( defined $throughput_in_pct and defined $throughput_out_pct ) )
+ {
+ $speed_is_zero = 1;
+ }
+
+ # If we're only checking input.
+ elsif ( not defined $output and defined $throughput_in_pct ) {
+ $max_state = $np->check_threshold(
+ check => ( $criteria =~ /%/ ? $throughput_in_pct : $throughput_in ),
+ warning => ( $type eq 'warning' ? $input : undef ),
+ critical => ( $type eq 'critical' ? $input : undef ),
+ );
+ }
+
+ # If we're only checking output.
+ elsif ( not defined $input and defined $throughput_out_pct ) {
+ $max_state = $np->check_threshold(
+ check =>
+ ( $criteria =~ /%/ ? $throughput_out_pct : $throughput_out ),
+ warning => ( $type eq 'warning' ? $output : undef ),
+ critical => ( $type eq 'critical' ? $output : undef ),
+ );
+ }
+
+ # We're checking everything.
+ elsif ( defined $input
+ and defined $output
+ and defined $throughput_in_pct
+ and defined $throughput_out_pct )
+ {
+
+ my $max_state_input = $np->check_threshold(
+ check => ( $criteria =~ /%/ ? $throughput_in_pct : $throughput_in ),
+ warning => ( $type eq 'warning' ? $input : undef ),
+ critical => ( $type eq 'critical' ? $input : undef ),
+ );
+
+ my $max_state_output = $np->check_threshold(
+ check =>
+ ( $criteria =~ /%/ ? $throughput_out_pct : $throughput_out ),
+ warning => ( $type eq 'warning' ? $output : undef ),
+ critical => ( $type eq 'critical' ? $output : undef ),
+ );
+
+ if ( $conjunction eq 'and' ) {
+ if ( $max_state_input and $max_state_output ) {
+ $max_state =
+ $max_state_input > $max_state_output
+ ? $max_state_input
+ : $max_state_output;
+ }
+ }
+ elsif ( $conjunction eq 'or' ) {
+ if ( $max_state_input or $max_state_output ) {
+ $max_state =
+ $max_state_input ? $max_state_input : $max_state_output;
+ }
+ }
+
+ }
+ else { $speed_is_zero = 1; }
+
+ return ( $max_state, $speed_is_zero );
+}
+
sub do_errors_checks {
my ( $intdata, $duration, $results ) = @_;
my $servicename = "Errors: " . $intdata->{shortinterfacename};
Modified: trunk/opsview-core/share/_javascript_/forms.js
===================================================================
--- trunk/opsview-core/share/_javascript_/forms.js 2013-02-21 14:59:10 UTC (rev 11564)
+++ trunk/opsview-core/share/_javascript_/forms.js 2013-02-21 15:45:11 UTC (rev 11565)
@@ -155,7 +155,7 @@
var invalidTimeperiodChars = /[\[\]`~!$%^&*|'"<>?()=a-zA-Z ]/; /* timeperiods */
var invalidCharsIP = /[\[\]`~!$%^&*|'"<>?,()= ]/;
var integer_percent = /[\[\]\/£,.@+:;\\{}_#`~!$^&*|'"<>?()=a-zA-Z ]/; /* whole numbers with a percent sign */
-var integer_percent_colon = /[\[\]\/£,.@+;\\{}_#`~!$^&*|'"<>?()=a-zA-Z ]/; /* whole numbers with a percent sign and colon */
+var integer_percent_colon_space_ampersand_bar_uppercaseletter = /[\[\]\/£,.@+;\\{}_#`~!$^*'"<>?()=a-z]/; /* as integer_percent, plus some */
var integer = /[\[\]\/£,.@+:;\\{}_#`~!$%^&*|'"<>?()=a-zA-Z ]/; /* whole numbers only */
function blockInvalidKeys(objEvent, chars) {
@@ -177,7 +177,7 @@
} else if (chars == 9) {
chars = invalidCharsAllowParenthesis;
} else if (chars == 10) {
- chars = integer_percent_colon;
+ chars = integer_percent_colon_space_ampersand_bar_uppercaseletter;
} else {
chars = invalidChars;
}
Modified: trunk/opsview-core/t/var/opsview.test.db
===================================================================
--- trunk/opsview-core/t/var/opsview.test.db 2013-02-21 14:59:10 UTC (rev 11564)
+++ trunk/opsview-core/t/var/opsview.test.db 2013-02-21 15:45:11 UTC (rev 11565)
@@ -825,8 +825,8 @@
`hostid` int(11) NOT NULL DEFAULT '0',
`interfacename` varchar(255) NOT NULL DEFAULT '',
`active` int(11) DEFAULT '0',
- `throughput_warning` varchar(30) DEFAULT NULL,
- `throughput_critical` varchar(30) DEFAULT NULL,
+ `throughput_warning` varchar(255) DEFAULT NULL,
+ `throughput_critical` varchar(255) DEFAULT NULL,
`errors_warning` varchar(30) DEFAULT NULL,
`errors_critical` varchar(30) DEFAULT NULL,
`discards_warning` varchar(30) DEFAULT NULL,
@@ -2062,6 +2062,7 @@
INSERT INTO `schema_version` VALUES ('20130115envvars','all','Support for envvars in plugins','2013-01-15 09:37:25',0);
INSERT INTO `schema_version` VALUES ('20130122snmpport','all','Increasing the size of snmp_port','2013-01-22 10:18:48',0);
INSERT INTO `schema_version` VALUES ('20130204baduuid','all','Checking for bad UUID','2013-02-04 14:40:14',0);
+INSERT INTO `schema_version` VALUES ('20130221snmpthro','all','Increasing the size of snmp.throughput_*','2013-02-21 15:30:52',0);
INSERT INTO `schema_version` VALUES ('3.0','4',NULL,NULL,NULL);
INSERT INTO `schema_version` VALUES ('3.1','4',NULL,NULL,NULL);
INSERT INTO `schema_version` VALUES ('3.11','15',NULL,NULL,NULL);