projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f586fed
)
RT#39115 - added a optional display name for oid
author
Christopher Burger
<burgerc@freeside.biz>
Tue, 10 Apr 2018 13:18:29 +0000
(09:18 -0400)
committer
Christopher Burger
<burgerc@freeside.biz>
Tue, 10 Apr 2018 13:18:29 +0000
(09:18 -0400)
FS/FS/part_export/broadband_snmp_get.pm
patch
|
blob
|
history
httemplate/edit/elements/part_export/broadband_snmp_get.html
patch
|
blob
|
history
httemplate/elements/broadband_snmp_get.html
patch
|
blob
|
history
diff --git
a/FS/FS/part_export/broadband_snmp_get.pm
b/FS/FS/part_export/broadband_snmp_get.pm
index
1a86612
..
35dcd31
100644
(file)
--- 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_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 = (
;
%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 $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,
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;
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') {
$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 );
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) {
# 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
faf179a
..
a426e61
100644
(file)
--- 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>
</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>
<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',
<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',
&>
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 = @_;
<& 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 @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));
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;
}
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
213bc44
..
1164504
100644
(file)
--- 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');
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);
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');
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');
cell.innerHTML = label;
row.appendChild(cell);
cell = document.createElement('td');