Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cyberpdu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Dufresne
cyberpdu
Commits
adaa654d
Commit
adaa654d
authored
Feb 05, 2019
by
Nicolas Dufresne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
+86
-0
README.md
README.md
+13
-0
cyberpdu
cyberpdu
+73
-0
No files found.
README.md
0 → 100644
View file @
adaa654d
## Cyper Power PDU remote control
This is a command wrapper around net-snmp-utils, you need to install
these command line utility first. To use this software:
./cyberpdu
<pdu-ip>
<socket-name>
(on|off|reset)
The name are configured form the Web UI and the reset delay is also
configured there.
## TODO
-
Allow socket number to be used
cyberpdu
0 → 100755
View file @
adaa654d
#!/bin/bash
# Ultra dummy script to control CyberPower PDUs
# Tested with PDU20SWHVIEC8FNET (firmware 2.1.6)
# Copyright (c) 2016 Jiri Pirko <jiri@resnulli.us>
# Ported to PDU15SW8FNET (firmware 2.1.7)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# Here are couple of examples of manual snmpwalk and snmpset commands:
# $ snmpwalk -v 1 -c private $host enterprises
# to list names:
# $ snmpwalk -v 1 -c private $host SNMPv2-SMI::enterprises.3808.1.1.3.3.3.1.1.2
# to list on/off states:
# $ snmpwalk -v 1 -c private $host SNMPv2-SMI::enterprises.3808.1.1.3.3.3.1.1.4
# to turn outlet "1" off:
# $ snmpset -v 1 -c private $host SNMPv2-SMI::enterprises.3808.1.1.3.3.3.1.1.4.1 i 2
# to turn outlet "1" on:
# $ snmpset -v 1 -c private $host SNMPv2-SMI::enterprises.3808.1.1.3.3.3.1.1.4.1 i 1
if
[
$#
-eq
0
]
;
then
echo
"Usage: cyberpdu HOSTNAME"
echo
" cyberpdu HOSTNAME OUTLETNAME"
echo
" cyberpdu HOSTNAME OUTLETNAME {on | off}"
exit
fi
PDUHOST
=
$1
PDUNAMESPATH
=
"SNMPv2-SMI::enterprises.3808.1.1.3.3.3.1.1.2"
PDUONOFFPATH
=
"SNMPv2-SMI::enterprises.3808.1.1.3.3.3.1.1.4"
mapfile
-t
nameslines < <
(
snmpwalk
-v
1
-c
private
$PDUHOST
${
PDUNAMESPATH
}
)
declare
-A
map
for
line
in
"
${
nameslines
[@]
}
"
do
num
=
`
echo
$line
|
cut
-d
"."
-f
11 |
cut
-d
" "
-f1
`
name
=
`
echo
$line
|
sed
's/.*STRING: "\(.*\)"/\1/'
`
if
[
$#
-gt
1
]
&&
[
"
$2
"
!=
"
$name
"
]
;
then
continue
fi
onofflines
=(
$(
snmpwalk
-v
1
-c
private
$PDUHOST
${
PDUONOFFPATH
}
.
$num
|sed
-e
's/.*\.[0-9]\+\.\([0-9]\+\).*INTEGER: \(.*\)/\1:\2/'
)
)
onoff
=
`
echo
${
onofflines
[0]
}
|
cut
-d
":"
-f
2
`
echo
-n
"
$name
is "
if
[
"
$onoff
"
-eq
"1"
]
;
then
echo
"on"
else
echo
"off"
fi
if
[
$#
-le
2
]
;
then
continue
;
fi
if
[
"
$3
"
=
"on"
]
;
then
onoffval
=
1
elif
[
"
$3
"
=
"off"
]
;
then
onoffval
=
2
elif
[
"
$3
"
=
"reset"
]
;
then
onoffval
=
3
else
echo
"Desired power state must be
\"
on
\"
or
\"
off
\"
"
exit
fi
echo
"turning
$3
"
snmpset
-v
1
-c
private
$PDUHOST
${
PDUONOFFPATH
}
.
$num
i
$onoffval
>
/dev/null
done
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