add on/off commands
[ktest-util.git] / vzt-pductl
blob29643e05890d90f9d56e9a69e241c0bf747c4c44
1 #! /bin/sh
2 CONFIG="/etc/vzt/vzt-pductl.cfg"
4 ACTION=$1
5 shift
6 PDU_HOST="$1"
7 shift
9 function show_usage
11 echo "$0: pdu control tool"
12 echo "Usage: $0 <lsall/ls/reboot> <pdu_host> [options]"
13 echo "examples:"
14 echo "list all socket status on pdu00.qa"
15 echo " $0 lsall pdu00.qa"
16 echo "get 15th socket power status on pdu00.qa"
17 echo " $0 ls pdu00.qa 15"
18 echo "reboot 15th socket pdu00.qa"
19 echo " $0 reboot pdu00.qa 15"
24 #######################################################################
25 ################### pdu speciffic functions section ###################
27 ##### PowerNet device
28 function power_net_mib
30 pdu_host=$1
31 action=$2
32 host=$3
34 case "$action" in
35 lsall ) snmptable -c private -v 1 $pdu_host -m +PowerNet-MIB \
36 rPDUOutletStatusTable;;
37 ls ) snmpget -c private -v 1 -m +PowerNet-MIB $pdu_host \
38 rPDUOutletControlOutletCommand.$host;;
39 reboot ) snmpset -c private -v 1 -m +PowerNet-MIB $pdu_host \
40 rPDUOutletControlOutletCommand.$host = immediateReboot;;
41 on ) snmpset -c private -v 1 -m +PowerNet-MIB $pdu_host \
42 rPDUOutletControlOutletCommand.$host = immediateOn;;
43 off ) snmpset -c private -v 1 -m +PowerNet-MIB $pdu_host \
44 rPDUOutletControlOutletCommand.$host = immediateOff;;
45 * ) echo "Unknown action";
46 show_usage;
47 exit 1;;
48 esac
53 CFG_FUNCTION=""
54 while read name cfg_func ;do
55 if [ "$name" == "$PDU_HOST" ];then
56 $cfg_func $PDU_HOST $ACTION $@
57 exit 0
58 break
60 done < $CONFIG
61 echo "Cant find $PDU_HOST in $CONFIG file"
62 show_usage
63 exit 1