Changeset 1077


Ignore:
Timestamp:
11/03/06 12:40:18 (7 years ago)
Author:
mglb1
Message:

Added a routine which regularly (every minute at the moment) checks the status
of the upstream connection and tries to re-establish it if there is a problem.

Fixes #87

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccsd/private/modules/ccs_monitor_rurallink.py

    r1074 r1077  
    8080# How often (seconds) to phone home  
    8181PHONE_HOME_INTERVAL = 60 * 30 
     82 
     83# How often to check that our upstream connection is working 
     84UPSTREAM_CHECK_INTERVAL = 60 
    8285 
    8386# Default XMLRPC server to phone home to 
     
    29682971    except: 
    29692972        log_error("Exception while trying to phone home!", sys.exc_info()) 
     2973 
     2974@registerRecurring(UPSTREAM_CHECK_INTERVAL) 
     2975def checkUpstream(): 
     2976    global int_ifname, backhaul_ifname, ext_ifname, backhaul_vbase 
     2977    global rl_isptype 
     2978 
     2979    if not isMasterNode(): 
     2980        # Check that the backhaul is up 
     2981        ifaces = {} 
     2982        for i in getInterfaces(True): ifaces[i["name"]] = i 
     2983        if backhaul_ifname not in ifaces.keys(): 
     2984            if checkClientInterfaces(): 
     2985                needsUp = True 
     2986        else: 
     2987            if not ifaces[backhaul_ifname]["up"]: 
     2988                needsUp = True 
     2989        if needsUp: 
     2990            log_info("Attempting to bring backhaul interface up") 
     2991            log_command("/sbin/ifdown %s 2>&1" % backhaul_ifname) 
     2992            log_command("/sbin/ifup %s 2>&1" % backhaul_ifname) 
     2993        return 
     2994 
     2995    # Check the various internet connection options are connected 
     2996    gwstatus, gwtext, ispstatus, isptext, ispaction = getISPStatus() 
     2997    if ispstatus != "ok" or gwstatus == "critical": 
     2998        # Attempt to reconnect the ISP 
     2999        log_info("Attempting to reconnect to the ISP") 
     3000        ISPDisconnect() 
     3001        ISPConnect() 
    29703002 
    29713003############################################################################## 
Note: See TracChangeset for help on using the changeset viewer.