Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-devel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
143
Issues
143
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
emulab
emulab-devel
Commits
ac33e3fd
Commit
ac33e3fd
authored
Mar 28, 2006
by
Mike Hibler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support 'status' command on APC power controllers
parent
c7f8572e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
8 deletions
+60
-8
tbsetup/power.in
tbsetup/power.in
+30
-6
tbsetup/snmpit_apc.pm
tbsetup/snmpit_apc.pm
+30
-2
No files found.
tbsetup/power.in
View file @
ac33e3fd
...
...
@@ -360,6 +360,7 @@ sub byname() {
sub
dostatus
(@)
{
my
@wanted
=
@_
;
my
%ctrls
=
();
my
%IPs
=
();
my
$errors
=
0
;
if
(
$ELABINELAB
)
{
...
...
@@ -372,12 +373,14 @@ sub dostatus(@) {
#
# Fetch all possible power controllers
#
my
$result
=
DBQueryFatal
("
select n.node_id,t.type
"
.
"
from nodes as n
"
.
"
left join node_types as t on n.type=t.type
"
.
"
where n.role='powerctrl'
");
while
(
my
(
$ctrl
,
$type
)
=
$result
->
fetchrow
())
{
my
$result
=
DBQueryFatal
("
select n.node_id,t.type,i.IP
"
.
"
from nodes as n
"
.
"
left join node_types as t on n.type=t.type
"
.
"
left join interfaces as i on n.node_id=i.node_id
"
.
"
where n.role='powerctrl'
");
while
(
my
(
$ctrl
,
$type
,
$IP
)
=
$result
->
fetchrow
())
{
$ctrls
{
$ctrl
}
=
$type
;
$IPs
{
$ctrl
}
=
$IP
;
}
@wanted
=
sort
byname
keys
(
%ctrls
)
...
...
@@ -415,7 +418,28 @@ sub dostatus(@) {
for
my
$ctrl
(
@nwanted
)
{
my
%status
;
if
(
$ctrls
{
$ctrl
}
=~
/^RPC/
)
{
if
(
$ctrls
{
$ctrl
}
eq
"
APC
")
{
my
$device
=
new
snmpit_apc
(
$IPs
{
$ctrl
},
$verbose
);
if
(
!
defined
$device
)
{
warn
"
Unable to contact controller
$ctrl
.
\n
";
$errors
++
;
next
;
}
else
{
print
"
Calling device->status()
\n
"
if
$verbose
>
1
;
if
(
$device
->
status
(
\
%status
))
{
print
"
Could not get status for
$ctrl
.
\n
";
$errors
++
;
next
;
}
}
for
my
$outlet
(
1
..
20
)
{
my
$ostr
=
"
outlet
$outlet
";
print
"
$ctrl
Outlet
$outlet
:
",
$status
{
$ostr
},
"
\n
"
if
(
defined
(
$status
{
$ostr
}));
}
print
"
\n
";
}
elsif
(
$ctrls
{
$ctrl
}
=~
/^RPC/
)
{
if
(
rpc27status
(
$ctrl
,
\
%status
))
{
print
"
Could not get status for
$ctrl
.
\n
";
$errors
++
;
...
...
tbsetup/snmpit_apc.pm
View file @
ac33e3fd
...
...
@@ -2,14 +2,14 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# Copyright (c) 2000-2003
, 2006
University of Utah and the Flux Group.
# All rights reserved.
#
#
# snmpit module for APC MasterSwitch power controllers
#
# supports new(ip), power(on|off|cyc[le],port)
# supports new(ip), power(on|off|cyc[le],port)
, status
#
package
snmpit_apc
;
...
...
@@ -85,6 +85,34 @@ sub power {
return
$errors
;
}
sub
status
{
my
$self
=
shift
;
my
$statusp
=
shift
;
my
%status
;
my
$StatOID
=
"
.1.3.6.1.4.1.318.1.1.4.2.2
";
my
$Status
=
0
;
$Status
=
$self
->
{
SESS
}
->
get
([[
$StatOID
,
0
]]);
if
(
!
defined
$Status
)
{
print
STDERR
$self
->
{
DEVICENAME
},
"
: no answer from device
\n
";
return
1
;
}
print
("
Status is '
$Status
'
\n
")
if
$self
->
{
DEBUG
};
if
(
$statusp
)
{
my
@stats
=
split
'
\s+
',
$Status
;
my
$o
=
1
;
foreach
my
$ostat
(
@stats
)
{
my
$outlet
=
"
outlet
$o
";
$status
{
$outlet
}
=
$ostat
;
$o
++
;
}
%$statusp
=
%status
;
}
return
0
;
}
sub
UpdateField
{
my
(
$self
,
$OID
,
$port
,
$val
)
=
@_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment