[freeside-commits] branch master updated. 49ff577b9fbb4b017f0652cdfe567b023d7ea4de
Christopher Burger
burgerc at freeside.biz
Tue Apr 10 06:19:02 PDT 2018
The branch, master has been updated
via 49ff577b9fbb4b017f0652cdfe567b023d7ea4de (commit)
from f586fedb42ee93caf7923147c9bc70e0331421dd (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 49ff577b9fbb4b017f0652cdfe567b023d7ea4de
Author: Christopher Burger <burgerc at freeside.biz>
Date: Tue Apr 10 09:18:29 2018 -0400
RT#39115 - added a optional display name for oid
diff --git a/FS/FS/part_export/broadband_snmp_get.pm b/FS/FS/part_export/broadband_snmp_get.pm
index 1a8661286..35dcd3154 100644
--- a/FS/FS/part_export/broadband_snmp_get.pm
+++ b/FS/FS/part_export/broadband_snmp_get.pm
@@ -21,6 +21,7 @@ tie my %options, 'Tie::IxHash',
'snmp_community' => { 'label'=>'Community', 'default'=>'public' },
'snmp_timeout' => { label=>'Timeout (seconds)', 'default'=>1 },
'snmp_oid' => { label=>'Object ID', multiple=>1 },
+ 'snmp_oid_name' => { label=>'Object Name', multiple=>1 },
;
%info = (
@@ -80,6 +81,7 @@ sub snmp_results {
my $vers = $self->option('snmp_version');
my $time = ($self->option('snmp_timeout') || 1) * 1000000;
my @oids = split("\n", $self->option('snmp_oid'));
+ my @oidnames = split("\n", $self->option('snmp_oid_name'));
my %connect = (
'DestHost' => $host,
'Community' => $comm,
@@ -90,7 +92,9 @@ sub snmp_results {
return { 'error' => 'Error creating SNMP session' } unless $snmp;
return { 'error' => $snmp->{'ErrorStr'} } if $snmp->{'ErrorStr'};
my @out;
- foreach my $oid (@oids) {
+ for (my $i=0; $i <= $#oids; $i++) {
+ my $oid = $oids[$i];
+ my $oidname = $oidnames[$i];
$oid = $SNMP::MIB{$oid}->{'objectID'} if $SNMP::MIB{$oid};
my @values;
if ($vers eq '1') {
@@ -115,6 +119,7 @@ sub snmp_results {
next;
}
my %result = map { $_ => $SNMP::MIB{$oid}{$_} } qw( objectID label );
+ $result{'name'} = $oidname;
# unbless @values, for ease of JSON encoding
$result{'values'} = [];
foreach my $value (@values) {
diff --git a/httemplate/edit/elements/part_export/broadband_snmp_get.html b/httemplate/edit/elements/part_export/broadband_snmp_get.html
index faf179acc..a426e617d 100644
--- a/httemplate/edit/elements/part_export/broadband_snmp_get.html
+++ b/httemplate/edit/elements/part_export/broadband_snmp_get.html
@@ -45,20 +45,23 @@ function receive_mib_get(obj, rownum) {
</script>
<table bgcolor="#cccccc" border=0 cellspacing=3>
-<TR><TH>Object ID</TH></TR>
+<TR><TH>Object Name</TH><TH>Object ID</TH></TR>
<TR id="broadband_snmp_get_template">
<TD>
+ <INPUT NAME="oid_name" ID="oid_name" SIZE="25">
+ </TD>
+ <TD>
<INPUT NAME="oid" ID="oid" SIZE="54">
<INPUT TYPE="button" VALUE="..." ID="openselector" onclick="open_select_mib_get(this)">
</TD>
</TR>
<& /elements/auto-table.html,
template_row => 'broadband_snmp_get_template',
- fieldorder => ['oid'],
+ fieldorder => ['oid_name','oid'],
data => \@data,
table => 'snmp',
&>
-<INPUT TYPE="hidden" NAME="multi_options" VALUE="snmp_oid">
+<INPUT TYPE="hidden" NAME="multi_options" VALUE="snmp_oid,snmp_oid_name">
<& foot.html, %opt &>
<%init>
my %opt = @_;
@@ -73,11 +76,13 @@ foreach my $field ( qw(snmp_version snmp_community snmp_timeout) ) {
}
my @oids = split("\n", $part_export->option('snmp_oid'));
+my @oid_names = split("\n", $part_export->option('snmp_oid_name'));
my @data;
while (@oids) {
my @thisrow = (shift(@oids));
- push @data, \@thisrow if grep length($_), @thisrow;
+ my $name = shift(@oid_names);
+ push @data, [$name, \@thisrow] if grep length($_), @thisrow;
}
my $popup_name = 'popup-'.time."-$$-".rand() * 2**32;
diff --git a/httemplate/elements/broadband_snmp_get.html b/httemplate/elements/broadband_snmp_get.html
index 213bc4460..1164504ee 100644
--- a/httemplate/elements/broadband_snmp_get.html
+++ b/httemplate/elements/broadband_snmp_get.html
@@ -26,7 +26,7 @@ function broadband_snmp_get (svcnum) {
if (obj.error) {
var row = document.createElement('tr');
var cell = document.createElement('td');
- cell.colSpan = '2';
+ cell.colSpan = '3';
cell.innerHTML = obj['error'];
row.appendChild(cell);
table.appendChild(row);
@@ -36,6 +36,9 @@ function broadband_snmp_get (svcnum) {
var value = obj['values'][j];
var label = (obj['values'].length > 1) ? (value[0] + '.' + value[1]) : obj['label'];
var cell = document.createElement('td');
+ cell.innerHTML = obj['name'];
+ row.appendChild(cell);
+ cell = document.createElement('td');
cell.innerHTML = label;
row.appendChild(cell);
cell = document.createElement('td');
-----------------------------------------------------------------------
Summary of changes:
FS/FS/part_export/broadband_snmp_get.pm | 7 ++++++-
.../edit/elements/part_export/broadband_snmp_get.html | 13 +++++++++----
httemplate/elements/broadband_snmp_get.html | 5 ++++-
3 files changed, 19 insertions(+), 6 deletions(-)
More information about the freeside-commits
mailing list