Beispiel #1
0
 def init(self):
     self.sensor = Sensor.find('power')
     self.append(self.ui.inflate('power:widget'))
     self.find('ac').visible = self.sensor.value() == 'ac'
     self.find('battery').visible = self.sensor.value() == 'battery'
     charge = Sensor.find('battery').value()
     self.find('charge').value = charge[0] * 1.0 / charge[1]
Beispiel #2
0
 def init(self):
     self.sensor = Sensor.find('power')
     self.append(self.ui.inflate('power:widget'))
     self.find('ac').visible = self.sensor.value() == 'ac'
     self.find('battery').visible = self.sensor.value() == 'battery'
     charge = Sensor.find('battery').value()
     self.find('charge').value = charge[0] * 1.0 / charge[1]
Beispiel #3
0
    def init(self):
        self.sensor = Sensor.find('power')
        self.append(self.ui.inflate('power:widget'))
        self.find('ac').visible = self.sensor.value() == 'ac'
        self.find('battery').visible = self.sensor.value() == 'battery'
        charge = Sensor.find('battery').value()
        self.find('charge').value = charge[0] * 1.0 / charge[1]

        self.powerctl = PowerController.get()
        caps = self.powerctl.capabilities()
        for cap in ('shutdown', 'suspend', 'hibernate', 'reboot'):
            self.find(cap).visible = cap in caps
Beispiel #4
0
    def init(self):
        self.sensor = Sensor.find('power')
        self.append(self.ui.inflate('power:widget'))
        self.find('ac').visible = self.sensor.value() == 'ac'
        self.find('battery').visible = self.sensor.value() == 'battery'
        charge = Sensor.find('battery').value()
        self.find('charge').value = charge[0] * 1.0 / charge[1]

        self.powerctl = PowerController.get()
        caps = self.powerctl.capabilities()
        for cap in ('shutdown', 'suspend', 'hibernate', 'reboot'):
            self.find(cap).visible = cap in caps
Beispiel #5
0
 def init(self):
     self.sensor = Sensor.find('power')
     self.append(self.ui.inflate('power:widget'))
     self.find('ac').visible = self.sensor.value() == 'ac'
     self.find('battery').visible = self.sensor.value() == 'battery'
     charge = Sensor.find('battery').value()
     self.find('charge').value = charge[0] * 1.0 / charge[1]
     try:
         subprocess.call(['which', 'pm-suspend'])
     except:
         self.find('suspend').visible = False
     try:
         subprocess.call(['which', 'pm-hibernate'])
     except:
         self.find('hibernate').visible = False
Beispiel #6
0
    def worker(self):
        if not ENDPOINT:
            return
        while True:
            datapack = {'sensors': {}}

            for sensor in Sensor.get_all():
                data = {}
                for variant in sensor.get_variants():
                    data[variant] = sensor.value(variant)
                datapack['sensors'][sensor.id] = data

            gevent.sleep(10)
            url = ENDPOINT % ajenti.config.tree.installation_id

            if not self.get_key():
                continue

            try:
                requests.post(url, data={
                    'data': json.dumps(datapack),
                    'key': self.get_key()
                })
                self.last_report = datetime.now()
                self.last_error = None
            except Exception, e:
                self.last_error = e
Beispiel #7
0
    def refresh(self):
        self.find('header').hostname = Sensor.find('hostname').value()

        self.dash.empty()
        for widget in self.classconfig['widgets']:
            for cls in DashboardWidget.get_classes():
                if cls.classname == widget['class']:
                    if not UserManager.get().has_permission(self.context, WidgetPermissions.name_for(cls)):
                        continue
                    try:
                        instance = cls.new(
                            self.ui,
                            container=widget['container'],
                            index=widget['index'],
                            config=widget['config'],
                        )
                    except Exception, e:
                        traceback.print_exc()
                        instance = CrashedWidget.new(
                            self.ui,
                            container=widget['container'],
                            index=widget['index'],
                            config=widget['config'],
                        )
                        instance.classname = cls.classname
                        instance.set(e)
                    instance.on('save-config', self.on_widget_config, widget, instance)
                    self.dash.append(instance)
Beispiel #8
0
    def init(self):
        self.sensor = Sensor.find('uptime')
        self.append(self.ui.inflate('sensors:value-widget'))

        self.find('icon').text = 'off'
        self.find('name').text = 'Uptime'
        self.find('value').text = str_timedelta(self.sensor.value())
Beispiel #9
0
    def worker(self):
        if not ENDPOINT:
            return
        while True:
            datapack = {'sensors': {}}

            for sensor in Sensor.get_all():
                data = {}
                for variant in sensor.get_variants():
                    data[variant] = sensor.value(variant)
                datapack['sensors'][sensor.id] = data

            gevent.sleep(3)
            url = ENDPOINT % ajenti.config.tree.installation_id

            if not self.get_key():
                continue

            try:
                requests.post(url, data={
                    'data': json.dumps(datapack),
                    'key': self.get_key()
                })
                self.last_report = datetime.now()
                self.last_error = None
            except Exception, e:
                self.last_error = e
Beispiel #10
0
    def refresh(self):
        self.find('header').hostname = Sensor.find('hostname').value()

        self.dash.empty()
        for widget in self.classconfig['widgets']:
            for cls in DashboardWidget.get_classes():
                if cls.classname == widget['class']:
                    if not UserManager.get().has_permission(
                            self.context, WidgetPermissions.name_for(cls)):
                        continue
                    try:
                        instance = cls.new(
                            self.ui,
                            container=widget['container'],
                            index=widget['index'],
                            config=widget['config'],
                        )
                    except Exception, e:
                        traceback.print_exc()
                        instance = CrashedWidget.new(
                            self.ui,
                            container=widget['container'],
                            index=widget['index'],
                            config=widget['config'],
                        )
                        instance.classname = cls.classname
                        instance.set(e)
                    instance.on('save-config', self.on_widget_config, widget,
                                instance)
                    self.dash.append(instance)
Beispiel #11
0
    def init(self):
        self.sensor = Sensor.find("uptime")
        self.append(self.ui.inflate("sensors:value-widget"))

        self.find("icon").text = "off"
        self.find("name").text = "Uptime"
        self.find("value").text = str_timedelta(self.sensor.value())
Beispiel #12
0
 def send_init(self):
     data = {
         'version': ajenti.version,
         'platform': ajenti.platform,
         'hostname': Sensor.find('hostname').value(),
     }
     self.emit('init', json.dumps(data))
Beispiel #13
0
 def send_init(self):
     data = {
         'version': ajenti.version,
         'platform': ajenti.platform,
         'hostname': Sensor.find('hostname').value(),
     }
     self.emit('init', json.dumps(data))
Beispiel #14
0
    def init(self):
        self.sensor = Sensor.find('uptime')
        self.append(self.ui.inflate('sensors:value-widget'))

        self.find('icon').text = 'off'
        self.find('name').text = 'Uptime'
        self.find('value').text = str_timedelta(self.sensor.value())
Beispiel #15
0
    def init( self ):
        self.sensor = Sensor.find( 'lvm' )
        self.append(self.ui.inflate( 'lvm:lvm-widget' ) )
        self.find( 'icon' ).icon = 'hdd'
        self.find( 'name' ).text = _( 'LVM status' )

        lvm = self.sensor.value()
        for group in lvm.Groups:
            group_box   = self.ui.inflate( 'lvm:lvm-widget-gline' )
            group_box.find( 'group' ).text  = group.name
            group_box.find( 'lines' ).append( line )
            for volume in group.Volumes:
                line    = self.ui.inflate( 'lvm:lvm-widget-vline' )
                line.find( 'volume' ).text  = volume.name
                progress            = line.find( 'progress' )
                progress.value      = volume.Size
                status              = line.find( 'status' )
                status.text         = device.stateText

                group_box.find( 'lines' ).append( line )

            # next
            self.find( 'lines' ).append( group_box )
        # next
    # end def
# end class
Beispiel #16
0
 def init(self):
     self.sensor = Sensor.find('load')
     self.append(self.ui.inflate('sensors:value-widget'))
     self.find('icon').icon = 'signal'
     self.find('name').text = _('Load average')
     self.find('value').text = ' / '.join(
         str(self.sensor.value(x)) for x in self.sensor.get_variants())
Beispiel #17
0
 def init(self):
     self.sensor = Sensor.find("memory")
     self.append(self.ui.inflate("sensors:progressbar-widget"))
     self.find("icon").icon = "tasks"
     self.find("name").text = "Memory usage"
     value = self.sensor.value()
     self.find("value").text = str_fsize(value[0])
     self.find("progress").value = 1.0 * value[0] / value[1]
Beispiel #18
0
 def init(self):
     self.sensor = Sensor.find('memory')
     self.append(self.ui.inflate('sensors:progressbar-widget'))
     self.find('icon').icon = 'tasks'
     self.find('name').text = _('Memory usage')
     value = self.sensor.value()
     self.find('value').text = str_fsize(value[0])
     self.find('progress').value = 1.0 * value[0] / value[1]
Beispiel #19
0
 def send_init(self):
     data = {
         'version': ajenti.version,
         'platform': ajenti.platform,
         'hostname': Sensor.find('hostname').value(),
         'session': self.context.session.id,
         'feedback': ajenti.config.tree.enable_feedback,
         'edition': ajenti.edition,
     }
     self.emit('init', json.dumps(data))
Beispiel #20
0
 def send_init(self):
     data = {
         'version': ajenti.version,
         'platform': ajenti.platform,
         'hostname': Sensor.find('hostname').value(),
         'session': self.context.session.id,
         'feedback': ajenti.config.tree.enable_feedback,
         'edition': ajenti.edition,
     }
     self.emit('init', json.dumps(data))
Beispiel #21
0
 def send_init(self):
     data = {
         "version": ajenti.version,
         "platform": ajenti.platform,
         "hostname": Sensor.find("hostname").value(),
         "session": self.context.session.id,
         "feedback": ajenti.config.tree.enable_feedback,
         "edition": ajenti.edition,
     }
     self.emit("init", json.dumps(data))
Beispiel #22
0
 def init(self):
     self.sensor = Sensor.find('cpu')
     self.append(self.ui.inflate('sensors:cpu-widget'))
     self.find('icon').icon = 'signal'
     self.find('name').text = _('CPU usage')
     for value in self.sensor.value():
         l = self.ui.inflate('sensors:cpu-line')
         l.find('progress').value = value
         l.find('value').text = '%i%%' % int(value * 100)
         self.find('lines').append(l)
Beispiel #23
0
 def init(self):
     self.sensor = Sensor.find("cpu")
     self.append(self.ui.inflate("sensors:cpu-widget"))
     self.find("icon").icon = "signal"
     self.find("name").text = "CPU usage"
     for value in self.sensor.value():
         l = self.ui.inflate("sensors:cpu-line")
         l.find("progress").value = value
         l.find("value").text = "%i%%" % int(value * 100)
         self.find("lines").append(l)
Beispiel #24
0
 def init(self):
     self.sensor = Sensor.find("swap")
     self.append(self.ui.inflate("sensors:progressbar-widget"))
     self.find("icon").icon = "hdd"
     self.find("name").text = "Swap usage"
     value = self.sensor.value()
     self.find("value").text = str_fsize(value[0])
     if value[1] > 0:
         frac = 1.0 * value[0] / value[1]
     else:
         frac = 0
     self.find("progress").value = frac
Beispiel #25
0
 def init(self):
     self.sensor = Sensor.find('swap')
     self.append(self.ui.inflate('sensors:progressbar-widget'))
     self.find('icon').icon = 'hdd'
     self.find('name').text = _('Swap usage')
     value = self.sensor.value()
     self.find('value').text = str_fsize(value[0])
     if value[1] > 0:
         frac = 1.0 * value[0] / value[1]
     else:
         frac = 0
     self.find('progress').value = frac
Beispiel #26
0
    def refresh(self):
        self.find('header').hostname = Sensor.find('hostname').value()

        self.dash.empty()
        for widget in self.classconfig['widgets']:
            for cls in DashboardWidget.get_classes():
                if cls.classname == widget['class']:
                    instance = cls.new(
                        self.ui,
                        container=widget['container'],
                        index=widget['index'],
                        config=widget['config'],
                    )
                    instance.on('save-config', self.on_widget_config, widget, instance)
                    self.dash.append(instance)
Beispiel #27
0
    def refresh(self):
        self.find('header').hostname = Sensor.find('hostname').value()

        self.dash.empty()
        for widget in self.classconfig['widgets']:
            for cls in DashboardWidget.get_classes():
                if cls.classname == widget['class']:
                    instance = cls.new(
                        self.ui,
                        container=widget['container'],
                        index=widget['index'],
                        config=widget['config'],
                    )
                    instance.on('save-config', self.on_widget_config, widget, instance)
                    self.dash.append(instance)
Beispiel #28
0
    def init(self):
        self.sensor = Sensor.find('mdadm')
        self.append(self.ui.inflate('mdadm:mdadm-widget'))
        self.find('icon').icon = 'hdd'
        self.find('name').text = _('MDADM status')

        mdadm = self.sensor.value()

        for device in mdadm.Devices:
            line = self.ui.inflate('mdadm:mdadm-widget-line')
            line.find('device').text = device.name
            status = line.find('status')
            progress = line.find('progress')
            progress.visible = ( device.showRecovery )
            if progress.visible:
                log.debug("progress.value: '%s' = '%s'" % ( device.progress, device.progress / 100 ))
                progress.value = float(device.progress / 100)
                log.debug("progress.value: '%f'" % ( progress.value ))
            # end if
            status.text = device.stateText
            self.find('lines').append(line)
Beispiel #29
0
    def refresh(self):
        self.find("header").hostname = Sensor.find("hostname").value()

        self.dash.empty()
        for widget in self.classconfig["widgets"]:
            for cls in DashboardWidget.get_classes():
                if cls.classname == widget["class"]:
                    if not UserManager.get().has_permission(WidgetPermissions.name_for(cls)):
                        continue
                    try:
                        instance = cls.new(
                            self.ui, container=widget["container"], index=widget["index"], config=widget["config"]
                        )
                    except Exception, e:
                        traceback.print_exc()
                        instance = CrashedWidget.new(
                            self.ui, container=widget["container"], index=widget["index"], config=widget["config"]
                        )
                        instance.classname = cls.classname
                        instance.set(e)
                    instance.on("save-config", self.on_widget_config, widget, instance)
                    self.dash.append(instance)
Beispiel #30
0
    def init(self):
        self.sensor = Sensor.find("lvm")
        self.append(self.ui.inflate("lvm:lvm-widget"))
        self.find("icon").icon = "hdd"
        self.find("name").text = _("LVM status")

        lvm = self.sensor.value()
        for group in lvm.Groups:
            group_box = self.ui.inflate("lvm:lvm-widget-gline")
            group_box.find("group").text = group.name
            group_box.find("lines").append(line)
            for volume in group.Volumes:
                line = self.ui.inflate("lvm:lvm-widget-vline")
                line.find("volume").text = volume.name
                progress = line.find("progress")
                progress.value = volume.Size
                status = line.find("status")
                status.text = device.stateText

                group_box.find("lines").append(line)

            # next
            self.find("lines").append(group_box)
Beispiel #31
0
 def on_prepare(self):
     self.sensor = Sensor.find('lm-sensors')
     self.append(self.ui.inflate('lm_sensors:widget'))
Beispiel #32
0
 def on_prepare(self):
     self.sensor = Sensor.find('hdparm_state')
     self.append(self.ui.inflate('hdparm:widget'))
Beispiel #33
0
 def on_prepare(self):
     self.sensor = Sensor.find('disk-usage')
     self.append(self.ui.inflate('fstab:free-widget'))
Beispiel #34
0
 def on_prepare(self):
     self.sensor = Sensor.find("hdd-temp")
     self.append(self.ui.inflate("hddtemp:widget"))
Beispiel #35
0
 def on_prepare(self):
     self.sensor = Sensor.find('smart')
     self.append(self.ui.inflate('smartctl:widget'))
Beispiel #36
0
 def on_prepare(self):
     self.sensor_write = Sensor.find('immediate-write')
     self.sensor_read = Sensor.find('immediate-read')
     self.append(self.ui.inflate('fstab:iio-widget'))
Beispiel #37
0
 def init(self):
     self.sensor = Sensor.find('load')
     self.append(self.ui.inflate('sensors:value-widget'))
     self.find('icon').icon = 'signal'
     self.find('name').text = _('Load average')
     self.find('value').text = ' / '.join(str(self.sensor.value(x)) for x in self.sensor.get_variants())
Beispiel #38
0
 def on_prepare(self):
     self.sensor = Sensor.find('hdd-temp')
     self.append(self.ui.inflate('hddtemp:widget'))
Beispiel #39
0
 def init(self):
     self.append(self.ui.inflate('mpd:widget'))
     Binder(Sensor.find('mpd').value(),
         self.find('mpd')).populate()
Beispiel #40
0
 def on_prepare(self):
     self.sensor = Sensor.find('traffic')
     self.append(self.ui.inflate('network:widget'))
Beispiel #41
0
 def on_prepare(self):
     self.sensor = Sensor.find('disk-usage')
     self.append(self.ui.inflate('fstab:free-widget'))
Beispiel #42
0
 def on_prepare(self):
     self.sensor = Sensor.find('hdparm_state')
     self.append(self.ui.inflate('hdparm:widget'))
Beispiel #43
0
 def on_prepare(self):
     self.sensor = Sensor.find('lm-sensors')
     self.append(self.ui.inflate('lm_sensors:widget'))
Beispiel #44
0
 def on_prepare(self):
     self.sensor = Sensor.find('ipmi')
     self.append(self.ui.inflate('ipmi:widget'))
Beispiel #45
0
 def on_prepare(self):
     self.sensor = Sensor.find('traffic')
     self.sensor_tx = Sensor.find('immediate-tx')
     self.sensor_rx = Sensor.find('immediate-rx')
     self.append(self.ui.inflate('network:widget'))
Beispiel #46
0
 def init(self):
     self.sensor = Sensor.find('memcache')
     self.append(self.ui.inflate('memcache:widget'))
     value = self.sensor.value()
     self.find('value').text = str_fsize(value[0])
     self.find('progress').value = 1.0 * value[0] / value[1]
Beispiel #47
0
 def init(self):
     self.sensor = Sensor.find('ups')
     self.append(self.ui.inflate('apcups:widget'))
     value = self.sensor.value()
     self.find('charge').value = value[0]
     self.find('time').text = value[1]
Beispiel #48
0
 def on_prepare(self):
     self.sensor = Sensor.find('traffic')
     self.append(self.ui.inflate('network:widget'))
Beispiel #49
0
 def on_prepare(self):
     self.sensor = Sensor.find('traffic')
     self.sensor_tx = Sensor.find('immediate-tx')
     self.sensor_rx = Sensor.find('immediate-rx')
     self.append(self.ui.inflate('network:widget'))
Beispiel #50
0
 def on_prepare(self):
     self.sensor_write = Sensor.find('immediate-write')
     self.sensor_read = Sensor.find('immediate-read')
     self.append(self.ui.inflate('fstab:iio-widget'))
Beispiel #51
0
 def send_init(self):
     data = {"version": ajenti.version, "platform": ajenti.platform, "hostname": Sensor.find("hostname").value()}
     self.emit("init", json.dumps(data))
Beispiel #52
0
 def on_prepare(self):
     self.sensor = Sensor.find('smart')
     self.append(self.ui.inflate('smartctl:widget'))