«

»

Jul 03

Automating with Telnet

I have a stupid problem, I have a Bitcoin ASIC called a Hex miner. For some reason every 12 hours the thing slows down from 24GH/sec to 5GH/sec. The only way I have found to solve the problem is to power cycle the controller and the unit itself. This would be a pain since I have it in my basement. However I salvaged some old Bay Technologies PDUs in my rack, which means I can power outlets on and off through a telnet session.

I did a little searching and learned how to do some scripting with the unix program “expect”

This is a very specific script, but it did what I need it to do:

#!/usr/bin/expect
spawn telnet xxx.xxx.xxx.xxx 23
expect "Enter Selection>"
send 1\r
expect "RPC-3>"
send "off 1\r"
expect "Turn OFF HEX-WRT? (Y/N)>"
send Y\r
expect "RPC-3>"
send "off 2\r"
expect "Turn OFF HEX-PWR? (Y/N)>"
send "Y\r"
expect "RPC-3>"
send "on 2\r"
expect "Turn ON HEX-PWR? (Y/N)>"
send "Y\r"
expect "RPC-3>"
send "on 1\r"
expect "Turn ON HEX-WRT? (Y/N)>"
send "Y\r"
expect "RPC-3>"
send "menu\r"
expect "Enter Selection>"
send "6\r"

It blazes through resetting the outlets.

        RPC-3 Telnet Host
    Revision F 4.20a, (C) 1999
    Bay Technical Associates
    Unit ID: RPC3-2
  Option(s) installed:
  True RMS Current
  Internal Temperature


  RPC-3 Menu:

    1)...Outlet Control
    2)...Manage Users
    3)...Configuration
    4)...Unit Status
    5)...Reset Unit
    6)...Logout

  Enter Selection>1
  True RMS current:  2.0 Amps
  Maximum Detected:  2.3 Amps

  Internal Temperature: 36.0 C

  Circuit Breaker: On 

  Selection   Outlet    Outlet   Power
    Number     Name     Number   Status
      1       HEX-WRT     1       On 
      2       HEX-PWR     2       On 
      3       Outlet 3    3       On 
      4       Outlet 4    4       On 
      5       Outlet 5    5       On 
      6       Outlet 6    6       On 
      7       Outlet 7    7       On 
      8       Outlet 8    8       On 

  Type "Help" for a list of commands

  RPC-3>off 1

  Turn OFF HEX-WRT? (Y/N)>Y
  True RMS current:  2.1 Amps
  Maximum Detected:  2.3 Amps

  Internal Temperature: 36.0 C

  Circuit Breaker: On 

  Selection   Outlet    Outlet   Power
    Number     Name     Number   Status
      1       HEX-WRT     1       Off
      2       HEX-PWR     2       On 
      3       Outlet 3    3       On 
      4       Outlet 4    4       On 
      5       Outlet 5    5       On 
      6       Outlet 6    6       On 
      7       Outlet 7    7       On 
      8       Outlet 8    8       On 

  Type "Help" for a list of commands

  RPC-3>off 2

  Turn OFF HEX-PWR? (Y/N)>Y
  True RMS current:  0.6 Amps
  Maximum Detected:  2.3 Amps

  Internal Temperature: 36.0 C

  Circuit Breaker: On 

  Selection   Outlet    Outlet   Power
    Number     Name     Number   Status
      1       HEX-WRT     1       Off
      2       HEX-PWR     2       Off
      3       Outlet 3    3       On 
      4       Outlet 4    4       On 
      5       Outlet 5    5       On 
      6       Outlet 6    6       On 
      7       Outlet 7    7       On 
      8       Outlet 8    8       On 

  Type "Help" for a list of commands

  RPC-3>on 2

  Turn ON HEX-PWR? (Y/N)>Y
  True RMS current:  0.7 Amps
  Maximum Detected:  2.3 Amps

  Internal Temperature: 36.0 C

  Circuit Breaker: On 

  Selection   Outlet    Outlet   Power
    Number     Name     Number   Status
      1       HEX-WRT     1       Off
      2       HEX-PWR     2       On 
      3       Outlet 3    3       On 
      4       Outlet 4    4       On 
      5       Outlet 5    5       On 
      6       Outlet 6    6       On 
      7       Outlet 7    7       On 
      8       Outlet 8    8       On 

  Type "Help" for a list of commands

  RPC-3>on 1

  Turn ON HEX-WRT? (Y/N)>Y
  True RMS current:  0.7 Amps
  Maximum Detected:  2.3 Amps

  Internal Temperature: 36.0 C

  Circuit Breaker: On 

  Selection   Outlet    Outlet   Power
    Number     Name     Number   Status
      1       HEX-WRT     1       On 
      2       HEX-PWR     2       On 
      3       Outlet 3    3       On 
      4       Outlet 4    4       On 
      5       Outlet 5    5       On 
      6       Outlet 6    6       On 
      7       Outlet 7    7       On 
      8       Outlet 8    8       On 

  Type "Help" for a list of commands

  RPC-3>menu

  RPC-3 Menu:

    1)...Outlet Control
    2)...Manage Users
    3)...Configuration
    4)...Unit Status
    5)...Reset Unit
    6)...Logout
  Enter Selection>

[root@rackable1 scripts]# 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>