Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Background

I am used to restart my servers on a scheduled basis. Now I want the same for my ADSL router.

This is my reason: When a random failure occurs, I am used to normally try to reboot the servers , interfaces and related equipments (if possible) as the first step before any other troubleshooting (e.g: changing configurations, etc). In fact there are times that this corrects the problem (The service starts working as expected). This may be because when a system is long time up (sometimes, depending on the software and services), it may become unresponsive or faulty. May be the software fails to release some memory, unlock some resources , etc

Now for some services which scheduled down time is acceptable during non-work hours, I schedule the automatic restart. This way, such type of problems appear less frequently. And now if a problem occurs during work-hours, I don't need to restart the whole service, instead I will resume troubleshooting like after I had restarted them.

What we have

This is a Billion 5000 Series router and supports TELNET, HTTP and SNMP for management.

Telnet method (Updated)

This is possible to reboot the router via telnet command:

C:\>telnet 192.168.1.1
    Password:********
    router>set reboot

So near, just need a script that automatically telnets, pushes password characters and issues the 'set reboot' command. [The approach of using expect suggested by SvenW]

HTTP method

Good to mention that I utilize a software[1] application for monitoring my ADSL connection speed and noise margin via HTTP interface (the software itself, instead of a browser application, connects, logs in unattendedly and reads the values from HTTP interface and display them in a graph!).

I wonder if it is possible to achieve the SysRestart with similar approach (A script that automatically logs in and clicks the SysRestart button!)

The restart page:

SNMP Method

The router also has support for SNMP v2 read and write communities. I thought it might be possible to perform it this way.

In fact, by some search I found[2] that some people use SNMP to restart their devices (But I can't find an OID for my router to pass for performing a reset)

For example it appear that those who have one of these devices can reboot them using these OIDs:

'.1.3.6.1.4.1.207.8.4.4.3.2.0',    # Allied Telesyn restart
'.1.3.6.1.4.1.11.2.14.11.1.4.1.0', # Hewlett-Packard hpicfReset
'.1.3.6.1.4.1.9.5.1.1.9.0',        # Cisco CatOS sysReset
'.1.3.6.1.4.1.9.2.9.9.0',          # Cisco IOS tsMsgSend
'.1.3.6.1.4.1.529.9.8.0.0'         # Ascend sysReset

SNMP Walk

Using SNMP walk I could get a list of more than five hundred OIDs such as:

.1.3.6.1.4.1.16972.5.1.1.0
.1.3.6.1.4.1.16972.4.10.0
...etc (568 more)...

But I have currently no idea how can I pick one among them (specially afraid to test snmp-write on them!).

Some more info

Some other (walked) OID and values that might help:

.1.3.6.1.4.1.16972.1.3.0; Trendchip TC3162 T14F7_3.0
.1.3.6.1.4.1.16972.5.1.1.0; www.huawei.com
.1.3.6.1.4.1.16972.1.6.0; Ras Ver:2.10.4.0(UE0.C2C)3.6.0.0   DMT Ver:3.6.0.0

How can you help ?

  • Suggesting a way to script a restart via SNMP (Requires finding the OID first!?)
  • Suggesting a way to script a restart via HTTP
  • Suggesting a way to script a restart via telnet
  • Suggesting a way to script a restart (any other ways!)

FootNotes:

  • [1] hxxp://vwlowen.co.uk/internet/files.htm
  • [2] hxxp://www.skendric.com/nmgmt/device/Generic/reset-device
share|improve this question
    
Provide source code of web page where you see the restart button, so that anyone could help you with the script. –  John Dec 23 '12 at 12:47
    
@John: Image and source code of webpage added to the question text –  alfa Dec 24 '12 at 9:41
add comment

1 Answer

up vote 0 down vote accepted

Without a proper MIB file for SNMP your best bet will to either find some telnet command that does the restart and maybe use it with the help of the expect tool or to use something like curl to use the web interface.

Using curl might require multiple calls to it to first login and save a session cookies and then to do the actual restart.

I do wonder though - do you have an actual problem with the device you try to fix with a regular restart? If not, I can't see the reason to do so.

Edit:

Basic example for an expect script. Call it with scriptname hostname password or alter the variable assignments to contain the actual hostname and password:

#!/usr/bin/expect 

set timeout 15
set hostname [lindex $argv 0] 
set password [lindex $argv 1] 

spawn telnet $hostname 

expect "Password:" 
send "$password " 
expect "router>" 
send "set reboot "
share|improve this answer
    
The telnet section updated with showing the command to execute the reboot. Also the background section updated to show the reason behind doing this scheduled reboot. –  alfa Dec 24 '12 at 9:42
    
@AliFakoor: See my edit for an expect example. More infos via man expect and Google. –  SvW Dec 24 '12 at 10:09
    
This is exactly what I was looking for. I should have mentioned that it is a windows host connected to router, but thats fine, I will go do the rest (finding / compiling expect port for windows, etc). Tnx a lot –  alfa Dec 25 '12 at 5:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.