Example #1
0
    def _index(self):
        tpl_vars = {}
        tpl_vars['host_eui64'] = self._bridge.host_eui64_hex
        tpl_vars['system_version'] = self._ver.version_string
        tpl_vars['system_ember_firmware'] = self._ver.firmware_version
        tpl_vars['system_mac_address'] = self._ver.mac_address
        tpl_vars['system_ncp_version'] = self._ver.ncp_stack_version
        if self._wdm.watchdog_enabled:
            tpl_vars['watchdog_status'] = 'enabled'
        else:
            tpl_vars['watchdog_status'] = 'disabled'
        monitored_keys = self._wdm.watchdog_keys
        watchdog_key_table = ''
        for k in monitored_keys:
            if time.time() - monitored_keys[
                    k] < watchdog_monitor.WatchdogMonitor.WATCHDOG_MAX_INTERVAL:
                watchdog_key_table = watchdog_key_table + '<tr><td>%s</td><td><span class="label label-success">%1d</span></td></tr>' % (
                    k, time.time() - monitored_keys[k])
            else:
                watchdog_key_table = watchdog_key_table + '<tr><td>%s</td><td><span class="label label-important">%1d</span></td></tr>' % (
                    k, time.time() - monitored_keys[k])

        tpl_vars['watchdog_key_table'] = watchdog_key_table
        (
            eth_speed,
            eth_duplex,
            eth_auto,
            eth_up,
        ) = linux_hub.get_eth_speed()
        tpl_vars['eth_speed'] = eth_speed
        tpl_vars['eth_duplex'] = eth_duplex
        tpl_vars['eth_auto'] = eth_auto
        tpl_vars['eth_up'] = eth_up
        if eth_speed == 10:
            tpl_vars['next_eth_speed'] = 100
        elif eth_speed == 100:
            tpl_vars['next_eth_speed'] = 10
        tpl_vars['command_transferring'] = self._sm.commandTransferring
        tpl_vars[
            'command_destination_eui64'] = self._sm.commandDestinationEui64
        tpl_vars['command_tx_speed'] = self._sm.commandTransferSpeed()
        tpl_vars['command_packet_errors'] = self._sm.packetFailedCount
        tpl_vars['packet_telemetry'] = {}
        tpl_vars['device_radio_stats'] = {}
        for sourceEui64 in self._sm.loggedPacketsStatistics.keys():
            if len(self._sm.loggedPacketsStatistics[sourceEui64]) > 0:
                agg_stats = self._sm.rssiStatsForEui64(sourceEui64)
                if agg_stats != None:
                    tpl_vars['device_radio_stats'][sourceEui64] = agg_stats
                packets = [
                    x.to_list() for x in list(
                        reversed(
                            self._sm.loggedPacketsStatistics[sourceEui64]))
                ]
                tpl_vars['packet_telemetry'][sourceEui64] = packets

        tpl_vars['log_statements'] = self._htmlLogLines
        tpl_out = bottle.template(
            '/usr/local/bergcloud-bridge/webassets/debug.tpl', **tpl_vars)
        return tpl_out
Example #2
0
    def _metrics(self):
        metrics = {}
        (
            eth_speed,
            eth_duplex,
            eth_auto,
            eth_up,
        ) = linux_hub.get_eth_speed()
        metrics['eth_speed'] = eth_speed
        metrics['eth_duplex'] = int(eth_duplex)
        metrics['eth_auto'] = int(eth_auto)
        metrics['eth_up'] = int(eth_up)
        metrics['cloud_connected'] = int(
            self._bridge.berg_cloud_api.isConnected())

        for device in self._sm.loggedPacketsStatistics.keys():
            if len(self._sm.loggedPacketsStatistics[device]) > 0:
                stats = self._sm.loggedPacketsStatistics[device][-1]
                metrics['device_last_timestamp_seconds{device="%s"}' %
                        device] = stats.timestamp
                metrics['device_last_rssi{device="%s"}' % device] = stats.rssi
                metrics['device_last_lqi{device="%s"}' % device] = stats.lqi

        t = uptime()
        metrics['system_uptime_seconds'] = t
        metrics['process_uptime_seconds'] = t - START_TIME

        bottle.response.content_type = "text/plain"
        return bottle.template(
            '/usr/local/bergcloud-bridge/webassets/metrics.tpl',
            metrics=metrics)
    def _index(self):
        tpl_vars = {}
        tpl_vars['host_eui64'] = self._bridge.host_eui64_hex
        tpl_vars['system_version'] = self._ver.version_string
        tpl_vars['system_ember_firmware'] = self._ver.firmware_version
        tpl_vars['system_mac_address'] = self._ver.mac_address
        tpl_vars['system_ncp_version'] = self._ver.ncp_stack_version
        if self._wdm.watchdog_enabled:
            tpl_vars['watchdog_status'] = 'enabled'
        else:
            tpl_vars['watchdog_status'] = 'disabled'
        monitored_keys = self._wdm.watchdog_keys
        watchdog_key_table = ''
        for k in monitored_keys:
            if time.time() - monitored_keys[k] < watchdog_monitor.WatchdogMonitor.WATCHDOG_MAX_INTERVAL:
                watchdog_key_table = watchdog_key_table + '<tr><td>%s</td><td><span class="label label-success">%1d</span></td></tr>' % (k, time.time() - monitored_keys[k])
            else:
                watchdog_key_table = watchdog_key_table + '<tr><td>%s</td><td><span class="label label-important">%1d</span></td></tr>' % (k, time.time() - monitored_keys[k])

        tpl_vars['watchdog_key_table'] = watchdog_key_table
        (eth_speed, eth_duplex, eth_auto, eth_up,) = linux_hub.get_eth_speed()
        tpl_vars['eth_speed'] = eth_speed
        tpl_vars['eth_duplex'] = eth_duplex
        tpl_vars['eth_auto'] = eth_auto
        tpl_vars['eth_up'] = eth_up
        if eth_speed == 10:
            tpl_vars['next_eth_speed'] = 100
        elif eth_speed == 100:
            tpl_vars['next_eth_speed'] = 10
        tpl_vars['command_transferring'] = self._sm.commandTransferring
        tpl_vars['command_destination_eui64'] = self._sm.commandDestinationEui64
        tpl_vars['command_tx_speed'] = self._sm.commandTransferSpeed()
        tpl_vars['command_packet_errors'] = self._sm.packetFailedCount
        tpl_vars['packet_telemetry'] = {}
        tpl_vars['device_radio_stats'] = {}
        for sourceEui64 in self._sm.loggedPacketsStatistics.keys():
            if len(self._sm.loggedPacketsStatistics[sourceEui64]) > 0:
                agg_stats = self._sm.rssiStatsForEui64(sourceEui64)
                if agg_stats != None:
                    tpl_vars['device_radio_stats'][sourceEui64] = agg_stats
                packets = [ x.to_list() for x in list(reversed(self._sm.loggedPacketsStatistics[sourceEui64])) ]
                tpl_vars['packet_telemetry'][sourceEui64] = packets

        tpl_vars['log_statements'] = self._htmlLogLines
        tpl_out = bottle.template('/usr/local/bergcloud-bridge/webassets/debug.tpl', **tpl_vars)
        return tpl_out
Example #4
0
# 2016.01.27 00:42:52 MSK
import linux_hub
linux_hub.set_eth_speed(10)
(eth_speed, eth_duplex, eth_auto, eth_up,) = linux_hub.get_eth_speed()
if eth_duplex:
    print 'Ethernet speed set to %dBase-T full-duplex' % eth_speed
else:
    print 'Ethernet speed set to %dBase-T half-duplex' % eth_speed

+++ okay decompyling ./set_ethernet_speed.pyc 
# decompiled 1 files: 1 okay, 0 failed, 0 verify failed
# 2016.01.27 00:42:52 MSK
Example #5
0
# 2016.01.27 00:42:52 MSK
import linux_hub
linux_hub.set_eth_speed(10)
(
    eth_speed,
    eth_duplex,
    eth_auto,
    eth_up,
) = linux_hub.get_eth_speed()
if eth_duplex:
    print 'Ethernet speed set to %dBase-T full-duplex' % eth_speed
else:
    print 'Ethernet speed set to %dBase-T half-duplex' % eth_speed

# +++ okay decompyling ./set_ethernet_speed.pyc
# decompiled 1 files: 1 okay, 0 failed, 0 verify failed
# 2016.01.27 00:42:52 MSK