Title: [opsview] [11642] Revert SNMP threshold changes until we can write unit tests for them.
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2013-03-04 13:53:13 UTC (rev 11641)
+++ trunk/CHANGES	2013-03-04 18:04:44 UTC (rev 11642)
@@ -6,10 +6,8 @@
     PLATFORMS:
     ENHANCEMENTS:
     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
     check_snmp_sysinfo now returns CRITICAL if it cannot connect to SNMP
-    SNMP throughput thresholds now have an expanded syntax to handle input and output throughput separately
     Updated NRPE to 2.14 due to potential security exposure
     Allow authtkt cookie to be set when logging into Opsview REST API
     NOTICES:

Modified: trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade
===================================================================
--- trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade	2013-03-04 13:53:13 UTC (rev 11641)
+++ trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade	2013-03-04 18:04:44 UTC (rev 11642)
@@ -802,22 +802,56 @@
     my $max_state     = 0;
     my $extra_message = "";
     my $speed_is_zero = 0;
-
     if ( my $critical = $intdata->{throughput_critical} ) {
-        ( $max_state, $speed_is_zero ) = calculate_state(
-            critical => $critical,
-            $throughput_in_pct, $throughput_out_pct, $throughput_in,
-            $throughput_out
-        );
+        if ( $critical =~ s/%$//xsm ) {
+
+            # 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
+            );
+        }
     }
     if ( my $warning = $intdata->{throughput_warning} ) {
-        ( $max_state, $speed_is_zero ) = calculate_state(
-            warning => $warning,
-            $throughput_in_pct, $throughput_out_pct, $throughput_in,
-            $throughput_out
-        );
+        if ( $warning =~ s/%$//xsm ) {
+            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,
+                )
+            );
+        }
     }
-
     if ($speed_is_zero) {
         $extra_message =
           " but has an interface speed of 0, so cannot check a percentage threshold";
@@ -888,99 +922,6 @@
     return 1;
 }
 
-sub calculate_state {
-    my ( $type, $criteria,
-        $throughput_in_pct, $throughput_out_pct, $throughput_in,
-        $throughput_out )
-      = @_;
-    $criteria = lc $criteria;
-
-    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-03-04 13:53:13 UTC (rev 11641)
+++ trunk/opsview-core/share/_javascript_/forms.js	2013-03-04 18:04:44 UTC (rev 11642)
@@ -159,7 +159,6 @@
 var invalidTimeperiodChars = /[\[\]`~!$%^&*|'"<>?()=a-zA-Z ]/;     /* timeperiods */
 var invalidCharsIP = /[\[\]`~!$%^&*|'"<>?,()= ]/;
 var integer_percent = /[\[\]\/£,.@+:;\\{}_#`~!$^&*|'"<>?()=a-zA-Z ]/; /* whole numbers with a percent sign */
-var integer_percent_colon_space_ampersand_bar = /[\[\]\/£,@+;\\{}_#`~!$^*'"<>?()=]/;
 var integer = /[\[\]\/£,.@+:;\\{}_#`~!$%^&*|'"<>?()=a-zA-Z ]/; /* whole numbers only */
 
 function blockInvalidKeys(objEvent, chars) {
@@ -180,8 +179,6 @@
 		chars = invalidCharsIP;
 	} else if (chars == 9) {
 		chars = invalidCharsAllowParenthesis;
-	} else if (chars == 10) {
-		chars = integer_percent_colon_space_ampersand_bar;
 	} else {
 		chars = invalidChars;
 	}

Modified: trunk/opsview-web/lib/Opsview/Web/I18N/i_default.po
===================================================================
--- trunk/opsview-web/lib/Opsview/Web/I18N/i_default.po	2013-03-04 13:53:13 UTC (rev 11641)
+++ trunk/opsview-web/lib/Opsview/Web/I18N/i_default.po	2013-03-04 18:04:44 UTC (rev 11642)
@@ -10,10 +10,10 @@
 "PO-Revision-Date: 2009-06-09 14:10+0000\n"
 "Last-Translator: Ton Voon <ton.v...@opsview.com>\n"
 "Language-Team: English <e...@li.org>\n"
+"Language: en\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Language: en\n"
 
 msgid "messages.access.noAuthToChangeService"
 msgstr "You are not authorised to change the state of this service"
@@ -146,9 +146,8 @@
 msgid "messages.auditlog.submitServiceCheck.failed %1"
 msgstr "Failed to submit service check result: %1"
 
-#. ($s->servicename,         $s->hostname,                    $states_by_id->{$state}, $comment,)
 #. ($c->stash->{object}->name,                    $c->stash->{object}->host_object_id->name,                    $states_by_id->{$state},                    $comment,)
-#. ($c->stash->{object}->name,                    $c->stash->{object}->host_object_id->name,                    $states_by_id->{$state},                    $comment,)
+#. ($s->servicename,         $s->hostname,                    $states_by_id->{$state}, $comment,)
 msgid "messages.auditlog.submittingServiceCheckResultOnAs %1 %2 %3 %4"
 msgstr "Submitting service check result: %1 on %2 as %3: %4"
 
@@ -872,7 +871,7 @@
 msgstr "> # per minute in one polling cycle"
 
 msgid "ui.admin.host.edit.interfaces.heading.help.throughput"
-msgstr "max%, min:max%, or bits per second"
+msgstr "> % or bits per second"
 
 msgid "ui.admin.host.edit.interfaces.heading.throughput"
 msgstr "Throughput"
@@ -1372,9 +1371,8 @@
 msgid "ui.admin.list.label.delete.confirm %1"
 msgstr "Are you sure you want to delete `%1`?"
 
-#. ($c->stash->{object}->name)
 #. ($o->name)
-#. ($o->name)
+#. ($c->stash->{object}->name)
 #. (object_name)
 msgid "ui.admin.list.label.edit %1"
 msgstr "Edit %1"
@@ -2518,9 +2516,9 @@
 msgid "ui.downtime.help.commentEmpty"
 msgstr "Comment is empty"
 
+#. (join( "::",                        $c->stash->{object}->hostname,                        $c->stash->{object}->name)
 #. ($c->stash->{object}->name)
 #. (join( "::",                $c->stash->{object}->hostname,                $c->stash->{object}->name)
-#. (join( "::",                        $c->stash->{object}->hostname,                        $c->stash->{object}->name)
 msgid "ui.downtime.help.downtimeDeletedFor %1"
 msgstr "Downtime delete for %1"
 

Modified: trunk/opsview-web/opsview_web.yml.in
===================================================================
--- trunk/opsview-web/opsview_web.yml.in	2013-03-04 13:53:13 UTC (rev 11641)
+++ trunk/opsview-web/opsview_web.yml.in	2013-03-04 18:04:44 UTC (rev 11642)
@@ -79,7 +79,7 @@
   ON_ERROR_SERVE: /usr/local/nagios/share/images/rrderror.png
 
 host_interfaces:
-  default_throughput_critical: 0:50%
+  default_throughput_critical: 50%
   default_errors_critical: 10
   default_discards_critical: 15
 

Modified: trunk/opsview-web/root/admin/host/interfaces
===================================================================
--- trunk/opsview-web/root/admin/host/interfaces	2013-03-04 13:53:13 UTC (rev 11641)
+++ trunk/opsview-web/root/admin/host/interfaces	2013-03-04 18:04:44 UTC (rev 11642)
@@ -73,7 +73,7 @@
 </div>
 <script type="text/_javascript_">
 Validation.add('validate-throughput','', {
-  pattern: new RegExp(/^[-.\d:%]+%?$/)
+  pattern: new RegExp(/^[-\.\d]+%?$/)
 });
 Validation.add('validate-discards','', {
   pattern: new RegExp(/^[-\d]+$/)

Modified: trunk/opsview-web/root/admin/host/snmpinterfaces
===================================================================
--- trunk/opsview-web/root/admin/host/snmpinterfaces	2013-03-04 13:53:13 UTC (rev 11641)
+++ trunk/opsview-web/root/admin/host/snmpinterfaces	2013-03-04 18:04:44 UTC (rev 11642)
@@ -12,7 +12,7 @@
   ELSE;
     value = "-";
   END;
-  %]<td><input class="[% args.validation %]" type="text" name="[% threshold %]" value="[% value | html %]" size="6" _onkeypress_="return blockInvalidKeys(event,10)" /></td>[%
+  %]<td><input class="[% args.validation %]" type="text" name="[% threshold %]" value="[% value | html %]" size="6" _onkeypress_="return blockInvalidKeys(event,6)" /></td>[%
 END;
 
 %]

_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to