-
Notifications
You must be signed in to change notification settings - Fork 4
Home
bibiak1 edited this page Dec 28, 2018
·
5 revisions
Welcome to the python-orange-funbox wiki!
-
Let’s initialize package first:
import funbox funbox = funbox.FunBox("http://192.168.1.1", "admin")
-
Get some device informations
import json info = funbox.DeviceInfo() print json.dumps(info, indent=4)
-
Get some statistics
wan = funbox.NMC.getWANStatus() dsl_mibs = funbox.NeMo.Intf.data.getMIBs('dsl') dsl0_stats = funbox.NeMo.Intf.dsl0.getDSLStats() wifi_stats = funbox.NMC.Wifi.getStats() for key in ['DownstreamCurrRate', 'UpstreamCurrRate']: print("%20s: %s" % (key, str(dsl_mibs['result']['status']['dsl']['dsl0'][key]))) for key in ['TransmitBlocks', 'ReceiveBlocks']: print("%20s: %16s" % (key, str(dsl0_stats['result']['status'][key]))) for key in ['TxBytes', 'RxBytes']: print("%20s: %16s" % (key, str(wifi_stats['result']['data'][key])))
-
Show all hosts defined on Orange FunBox
hosts = funbox.Hosts.getDevices() for host in hosts['result']['status']: name = host['hostName'] physAddress = host['physAddress'] if 'IPAddress' in host: ipAddress = host['ipAddress'] else: ipAddress = "" print "\t%s [%s] :: %s :: %s" % (name, json.dumps(host['names'], sort_keys=True, separators=(',', ': ')), physAddress, ipAddress)
-
Show all devices and connected hosts
hosts = funbox.Devices.get() for type in hosts['result']['status']: print type + ' :::' for host in hosts['result']['status'][type]: name = host['Name'] DeviceType = host['DeviceType'] physAddress = host['PhysAddress'] Layer2Interface = host['Layer2Interface'] if 'IPAddress' in host: ipAddress = host['IPAddress'] else: ipAddress = "" print "\t%s (%s) [%s] :: %s :: %s (%s)" % (name, DeviceType, json.dumps(host['Names'], sort_keys=True, separators=(',', ': ')), physAddress, ipAddress, Layer2Interface)
-
Reconnect router
funbox.reconnect()
-
Restart router
funbox.restart()
-
Check for upgrades
funbox.NMC.checkForUpgrades()