FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
infra-bits
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Information Services
Servers and Storage
infra-bits
Commits
bfa66e76
Commit
bfa66e76
authored
11 years ago
by
Ben Harris
Browse files
Options
Downloads
Patches
Plain Diff
Tag ucs-infra-bits 1.37.
parent
1776df6b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/Ucam/Infra/APCRPDU.pm
+10
-0
10 additions, 0 deletions
lib/Ucam/Infra/APCRPDU.pm
lib/Ucam/Infra/DominionPX.pm
+10
-0
10 additions, 0 deletions
lib/Ucam/Infra/DominionPX.pm
pdu
+67
-12
67 additions, 12 deletions
pdu
with
87 additions
and
12 deletions
lib/Ucam/Infra/APCRPDU.pm
+
10
−
0
View file @
bfa66e76
...
...
@@ -27,6 +27,16 @@ sub getstatus {
return
$val
;
}
sub
getvers
{
my
(
$self
)
=
@_
;
return
$self
->
snmp
->
get
("
sPDUIdentFirmwareRev.0
");
}
sub
getmodel
{
my
(
$self
)
=
@_
;
return
$self
->
snmp
->
get
("
sPDUIdentModelNumber.0
");
}
sub
power_state
{
my
(
$self
,
$outlet
)
=
@_
;
my
$val
=
$self
->
snmp
->
get
("
rPDUOutletStatusOutletState.
$outlet
");
...
...
This diff is collapsed.
Click to expand it.
lib/Ucam/Infra/DominionPX.pm
+
10
−
0
View file @
bfa66e76
...
...
@@ -40,6 +40,16 @@ sub getstatus {
return
sprintf
("
%s (%.2f A)
",
$val
,
$current
);
}
sub
getvers
{
my
(
$self
)
=
@_
;
return
$self
->
{'
Ucam::Infra::DominionPX::ver
'};
}
sub
getmodel
{
my
(
$self
)
=
@_
;
return
$self
->
snmp
->
get
("
objectName.0
");
}
sub
power_state
{
my
(
$self
,
$outlet
)
=
@_
;
$outlet
=
$self
->
mapoutlet
(
$outlet
);
...
...
This diff is collapsed.
Click to expand it.
pdu
+
67
−
12
View file @
bfa66e76
#! /usr/bin/perl
use
warnings
;
use
strict
;
=head1 NAME
pdu - Control and monitor power distribution units
=cut
use
Getopt::
Std
;
use
Getopt::
Long
2.33
qw/:config posix_default bundling/
;
use
Pod::
Usage
;
use
Ucam::Infra::PDU::
Outlet
;
=head1 SYNOPSIS
pdu [-d|-r|-u] <outlet> ...
pdu [-d|-r|-u]
{ -a |
<outlet> ...
}
=cut
$
Getopt::Std::
STANDARD_HELP_VERSION
=
1
;
my
%opts
;
getopts
('
dru
',
\
%opts
);
my
$listpdus
;
GetOptions
("
d
"
=>
\
$opts
{
d
},
"
r
"
=>
\
$opts
{
r
},
"
u
"
=>
\
$opts
{
u
},
"
a
"
=>
\
$opts
{
a
},
"
l
"
=>
\
$listpdus
,
"
V
"
=>
\
$opts
{
V
})
or
pod2usage
(
2
);
if
(
$opts
{
a
}
&&
@ARGV
||
!
$opts
{
a
}
&&
!
@ARGV
)
{
pod2usage
(
2
);
}
=head1 DESCRIPTION
The C<pdu> utility provides a means of monitoring and controlling networked
...
...
@@ -33,22 +45,63 @@ particular box can be named by omitting the PSU designation, so C<easton>
names all outlets supplying Easton.
Outlets can also be named by PDU name and outlet number, like
C<pdu-n9-o:14>, or just by PDU name.
C<pdu-n9-o:14>, or just by PDU name. Finally, C<-a> means "all
outlets on all PDUs".
To query the state of an outlet, or set of outlets, use:
pdu
[
outlet ...
]
pdu outlet ...
To power-cycle an outlet, use:
pdu -r
[
outlet ...
]
pdu -r outlet ...
Power can be turned on and off using C<-u> and C<-d>, but for various
reasons these are dangerous and should not be used.
Model and version information for PDUs can be requested using the
C<-V> option:
pdu -V pdu ...
As with outlets, C<-a> works with C<-V> to get version information for
all PDUs.
Similarly, a list of know PDUs can be requested using:
pdu -la
=cut
my
@outlets
=
Ucam::Infra::PDU::
Outlet
->
find
(
@ARGV
);
my
@outlets
;
if
(
!!
$opts
{
V
}
+
!!
$opts
{
u
}
+
!!
$opts
{
d
}
+
!!
$listpdus
>
1
)
{
pod2usage
(
2
);
}
if
(
$opts
{
V
}
||
$listpdus
)
{
my
@pdu
;
if
(
$opts
{
a
})
{
@pdu
=
Ucam::Infra::PDU::
Any
->
retrieve_all
();
}
else
{
@pdu
=
map
(
Ucam::Infra::PDU::
Any
->
search
(
pduname
=>
$_
),
@ARGV
);
}
for
my
$pdu
(
@pdu
)
{
if
(
$opts
{
V
})
{
printf
("
%-11s %-10s %s
\n
",
$pdu
->
pduname
.
"
:
",
$pdu
->
getmodel
,
$pdu
->
getvers
);
}
else
{
print
(
$pdu
->
pduname
,
"
\n
");
}
}
exit
0
;
}
if
(
$opts
{
a
})
{
@outlets
=
Ucam::Infra::PDU::
Outlet
->
retrieve_all
();
}
else
{
@outlets
=
Ucam::Infra::PDU::
Outlet
->
find
(
@ARGV
);
}
my
$status
=
0
;
...
...
@@ -58,14 +111,16 @@ foreach my $row (@outlets) {
(
$pduname
,
$outlet
,
$box
,
$psu
)
=
(
$row
->
pdu
,
$row
->
outlet
,
$row
->
boxname
,
$row
->
psuname
);
my
$pdu
=
$row
->
pdu
;
$val
=
$pdu
->
getstatus
(
$outlet
);
unless
(
defined
(
$val
)
&&
$s
->
{
ErrorInd
}
==
0
)
{
my
$val
=
$pdu
->
getstatus
(
$outlet
);
unless
(
defined
(
$val
))
{
die
"
snmp get failed
\n
";
}
if
(
defined
$psu
)
{
printf
"
%30s (%9s:%-2d): %s
",
"
$box
:
$psu
",
$pduname
,
$outlet
,
$val
;
}
els
e
{
}
els
if
(
defined
$box
)
{
printf
"
%30s (%9s:%-2d): %s
",
$box
,
$pduname
,
$outlet
,
$val
;
}
else
{
printf
"
%30s (%9s:%-2d): %s
",
"",
$pduname
,
$outlet
,
$val
;
}
if
(
$opts
{
u
})
{
$pdu
->
on
(
$outlet
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment