Title: [opsview] [11507] Support "<minimum>%:<maximum>%" throughput values.
Revision
11507
Author
pknight
Date
2013-02-15 17:45:29 +0000 (Fri, 15 Feb 2013)

Log Message

Support "<minimum>%:<maximum>%" throughput values.

Modified Paths

Modified: trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade
===================================================================
--- trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade	2013-02-15 16:37:37 UTC (rev 11506)
+++ trunk/opsview-core/nagios-plugins/check_snmp_interfaces_cascade	2013-02-15 17:45:29 UTC (rev 11507)
@@ -489,7 +489,7 @@
 # Foreach row in db, find interface in hash
 # If not there, ignore (db holds cache for interfaces that no longer exist)
 my $sth = $dbh->prepare( "
-SELECT 
+SELECT
  ifDescr,shortinterfacename,ifIndex,ifAlias,ifName,lastUpdate,
  lastoctetsIn,lastoctetsOut,lasterrorsIn,lasterrorsOut,lastdiscardsIn,lastdiscardsOut,
  lastunicastIn,lastunicastOut,lastnonunicastIn,lastnonunicastOut,
@@ -785,7 +785,7 @@
     my $extra_message = "";
     my $speed_is_zero = 0;
     if ( my $critical = $intdata->{throughput_critical} ) {
-        if ( $critical =~ s/%$//xsm ) {
+        if ( $critical =~ s/%+//g ) {
 
             # Check throughput_in_pct and out_pct
             if ( defined $throughput_in_pct && defined $throughput_out_pct ) {
@@ -808,7 +808,7 @@
         }
     }
     if ( my $warning = $intdata->{throughput_warning} ) {
-        if ( $warning =~ s/%$//xsm ) {
+        if ( $warning =~ s/%+//g ) {
             if ( defined $throughput_in_pct && defined $throughput_out_pct ) {
                 $max_state = $np->max_state(
                     $max_state,

Modified: trunk/opsview-core/share/_javascript_/forms.js
===================================================================
--- trunk/opsview-core/share/_javascript_/forms.js	2013-02-15 16:37:37 UTC (rev 11506)
+++ trunk/opsview-core/share/_javascript_/forms.js	2013-02-15 17:45:29 UTC (rev 11507)
@@ -155,6 +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 = /[\[\]\/£,.@+:;\\{}_#`~!$%^&*|'"<>?()=a-zA-Z ]/; /* whole numbers only */
 
 function blockInvalidKeys(objEvent, chars) {
@@ -175,6 +176,8 @@
 		chars = invalidCharsIP;
 	} else if (chars == 9) {
 		chars = invalidCharsAllowParenthesis;
+	} else if (chars == 10) {
+		chars = integer_percent_colon;
 	} else {
 		chars = invalidChars;
 	}

Modified: trunk/opsview-web/root/admin/host/interfaces
===================================================================
--- trunk/opsview-web/root/admin/host/interfaces	2013-02-15 16:37:37 UTC (rev 11506)
+++ trunk/opsview-web/root/admin/host/interfaces	2013-02-15 17:45:29 UTC (rev 11507)
@@ -23,7 +23,7 @@
   name => "snmp_max_msg_size",
   values => ["0", "1023", "2047", "4095", "8191", "16383", "32767", "65535"],
   default => "0",
-  labels => { 
+  labels => {
     "0" => c.loc("ui.admin.host.edit.label.snmp_max_msg_size.default"),
     "1023" => "1Kio",
     "2047" => "2Kio",
@@ -41,7 +41,7 @@
   name => "tidy_ifdescr_level",
   values => ["0", "1", "2", "3"],
   default => "0",
-  labels => { 
+  labels => {
     "0" => c.loc("ui.admin.host.edit.label.ifDescrLevel.l0"),
     "1" => c.loc("ui.admin.host.edit.label.ifDescrLevel.l1"),
     "2" => c.loc("ui.admin.host.edit.label.ifDescrLevel.l2"),
@@ -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-02-15 16:37:37 UTC (rev 11506)
+++ trunk/opsview-web/root/admin/host/snmpinterfaces	2013-02-15 17:45:29 UTC (rev 11507)
@@ -1,4 +1,4 @@
-[% 
+[%
 # This is a dup of admin/host/interfaces - not sure best practise to reduce usage
 PROCESS edit_functions_base;
 
@@ -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,6)" /></td>[%
+  %]<td><input class="[% args.validation %]" type="text" name="[% threshold %]" value="[% value | html %]" size="6" _onkeypress_="return blockInvalidKeys(event,10)" /></td>[%
 END;
 
 %]
@@ -32,7 +32,7 @@
 <th rowspan="2">
 <input type="checkbox" class="checkbox" _onclick_='j=this.checked;Form.getInputs(this.form,"checkbox","snmpinterfaces").each(function(i){i.checked=j })' name=".ignore"/>
 </th>
-<th rowspan="2" colspan="2" width="200">[% 
+<th rowspan="2" colspan="2" width="200">[%
 help_link(
     section => "snmpinterfaces",
     text => c.loc("ui.admin.host.edit.interfaces.heading.toPoll"),
@@ -45,7 +45,7 @@
 [% c.loc("ui.admin.host.interfaces.validation.error.discards") | html %]
 </div>
 </th>
-<th colspan="2">[% 
+<th colspan="2">[%
 help_link(
     section => "snmpinterfaces",
     anchor => "throughput",
@@ -54,7 +54,7 @@
 %]
 <div class="help">[% c.loc("ui.admin.host.edit.interfaces.heading.help.throughput") | html %]</div>
 </th>
-<th colspan="2">[% 
+<th colspan="2">[%
 help_link(
     section => "snmpinterfaces",
     anchor => "errors",
@@ -63,7 +63,7 @@
 %]
 <div class="help">[% c.loc("ui.admin.host.edit.interfaces.heading.help.errors") | html %]</div>
 </th>
-<th colspan="2">[% 
+<th colspan="2">[%
 help_link(
     section => "snmpinterfaces",
     anchor => "discards",
@@ -81,7 +81,7 @@
 <th width="62">[% c.loc("ui.admin.host.edit.interfaces.heading.warningThreshold") | html %]</th>
 <th width="62">[% c.loc("ui.admin.host.edit.interfaces.heading.criticalThreshold") | html %]</th>
 </tr>
-[% 
+[%
 FOREACH i IN interfaces;
   IF i.interfacename=="";
     default_thresholds=1;
@@ -90,7 +90,7 @@
   END;
   %]<tr><td>
   [% IF default_thresholds==0; %]
-<input type="checkbox" name="snmpinterfaces" class="checkbox" value="[% i.interfacename | html %]" tooltip="[% i.shortinterfacename | html %]" [% 
+<input type="checkbox" name="snmpinterfaces" class="checkbox" value="[% i.interfacename | html %]" tooltip="[% i.shortinterfacename | html %]" [%
   IF i.active; 'checked="checked" '; END %]/>
   [% END %]
 </td><td>
@@ -98,7 +98,7 @@
 <input type="hidden" name="snmpinterfaces_all" value="[% i.interfacename | html %]" />
 [%# This is only set if it is a special interface (ie, duplicate name) %]
 <input type="hidden" name="indexid" value="[% i.indexid %]" />
-[% 
+[%
 IF default_thresholds;
    help_link(
      section => "snmpinterfaces",
@@ -112,7 +112,7 @@
 [% END %]
 </label> [% IF (i.extra_info && !default_thresholds); "<br/>("; i.extra_info | html; ")"; END; %]</td>
 <td width="10">[% IF i.duplicatename; duplicate_help = 1; "<span class='crit_text'>*</span>"; END; %]</td>
-[% 
+[%
 display_threshold(
   threshold => "throughput_warning",
   interface => i,

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

Reply via email to