コード例 #1
0
    def __init__(self, server_profile, ctrl_be):
        mforms.Box.__init__(self, False)

        self.widgets = {}

        self.server_profile = server_profile
        self.set_managed()
        self.set_release_on_add()

        self.suspend_layout()

        self.ctrl_be = ctrl_be

        def bigLabel(text="---\n"):
            l = mforms.newLabel(text)
            l.set_style(mforms.VeryBigStyle)
            return l

        # Status icon
        self.box1 = mforms.newBox(True)
        self.box1.set_spacing(28)

        health_text = mforms.newBox(True)
        health_text.set_spacing(20)

        self.status_icon = mforms.newServerStatusWidget()
        self.status_icon.set_description("Server Status")
        self.status_icon.set_size(86, -1)
        self.box1.add(self.status_icon, False, True)

        self.status_label = bigLabel("Unknown\n")
        self.status_label.set_size(86, -1)
        health_text.add(self.status_label, False, True)

        # System.
        system_box = mforms.newBox(True)
        system_box.set_spacing(28)
        self.cpu_usage = newBarGraphWidget()
        if self.server_profile.target_is_windows:
            self.cpu_usage.set_description("CPU")
        else:
            self.cpu_usage.set_description("Load")
        self.cpu_usage.set_right_align(True)
        self.cpu_usage.set_size(31, -1)
        system_box.add(self.cpu_usage, False, True)

        label = bigLabel()
        label.set_size(47, -1)
        label.set_text_align(mforms.TopRight)
        health_text.add(label, False, True)
        if self.server_profile.target_is_windows:
            self.cpu_widget = (self.cpu_usage, label,
                               lambda x: str(int(x * 100)) + "%\n", None)
        else:
            self.cpu_usage.enable_auto_scale(True)
            self.cpu_widget = (self.cpu_usage, label, lambda x: str(x) + "\n",
                               None)

        sql = {}
        self.connection_usage = newLineDiagramWidget()
        self.connection_usage.set_description("Connections")
        self.connection_usage.enable_auto_scale(True)
        self.connection_usage.set_thresholds(
            [0.0], [10.0, 50.0, 100.0, 500.0, 1000.0])
        system_box.add(self.connection_usage, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_connections'] = (self.connection_usage, label,
                                           lambda x: "%s\n" % str(int(x)),
                                           None)
        sql['get_connections'] = {
            'query': ("Threads_connected", ),
            'min': 0,
            'max': 10,
            'calc': None
        }
        self.box1.add(system_box, True, True)

        self.add(self.box1, False, True)
        self.add(health_text, False, True)

        # Server health.
        health = mforms.newBox(True)
        health.set_spacing(28)
        health_text = mforms.newBox(True)
        health_text.set_homogeneous(True)
        health_text.set_spacing(
            24
        )  # 4px less as for the widgets (the labels have a bit leading space).

        self.traffic = newLineDiagramWidget()
        self.traffic.set_description("Traffic")
        self.traffic.enable_auto_scale(True)
        self.traffic.set_thresholds(
            [0.0], [100000.0, 1000000.0, 10000000.0, 100000000.0])
        health.add(self.traffic, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_traffic'] = (self.traffic, label,
                                       lambda x: "%s\n" % self.format_value(x),
                                       None)
        self.last_traffic = 0
        sql['get_traffic'] = {
            'query': ("Bytes_sent", ),
            'min': 0,
            'max': 100,
            'calc': self.calc_traffic
        }

        self.key_efficiency = newLineDiagramWidget()
        self.key_efficiency.set_description("Key Efficiency")
        health.add(self.key_efficiency, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_key_efficiency'] = (self.key_efficiency, label,
                                              lambda x: ("%.1f%%\n" % x), None)
        sql['get_key_efficiency'] = {
            'query': ("Key_reads", "Key_read_requests"),
            'min': 0,
            'max': 100,
            'calc': self.calc_key_efficiency
        }

        self.add(health, False, True)
        self.add(health_text, False, True)

        # Query
        health = mforms.newBox(True)
        health.set_spacing(28)
        health_text = mforms.newBox(True)
        health_text.set_homogeneous(True)
        health_text.set_spacing(24)

        self.qps = newLineDiagramWidget()
        self.qps.set_description("Selects per Second")
        self.qps.enable_auto_scale(True)
        self.qps.set_thresholds(
            [0.0], [50.0, 100.0, 200.0, 500.0, 1000.0, 5000.0, 10000.0])
        health.add(self.qps, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_qps'] = (self.qps, label, lambda x:
                                   ("%.0f\n" % x), None)
        self.last_qcount = 0
        sql['get_qps'] = {
            'query': ("Com_select", ),
            'min': 0,
            'max': 100,
            'calc': self.calc_qps
        }

        #        self.hitrate= newLineDiagramWidget()
        #        self.hitrate.set_description("Query Cache Hitrate")
        #        health.add(self.hitrate, True, True)
        #        label = bigLabel()
        #        health_text.add(label, True, True)
        #        self.widgets['get_hitrate'] = (self.hitrate, label, lambda x: ("%.1f%%\n" % x), None)
        #        sql['get_hitrate'] = {'query' : ("Qcache_hits", "Qcache_inserts", "Qcache_not_cached"), 'min' : 0, 'max' : 100, 'calc' : self.calc_hitrate}
        #
        #        self.add(health, False, True)
        #        self.add(health_text, False, True)
        #
        #        # Cache/buffer
        #        health = mforms.newBox(True)
        #        health.set_spacing(28)
        #        health_text = mforms.newBox(True)
        #        health_text.set_homogeneous(True)
        #        health_text.set_spacing(24)
        #
        #        self.qcache_usage = newLineDiagramWidget()
        #        self.qcache_usage.set_description("Query Cache Usage")
        #        health.add(self.qcache_usage, True, True)
        #        label = bigLabel()
        #        health_text.add(label, True, True)
        #        self.widgets['get_qcache_usage'] = (self.qcache_usage, label, lambda x: ("%.1f%%\n" % x), None)
        #        sql['get_qcache_usage'] = {'query' : ("Qcache_free_blocks", "Qcache_total_blocks"), 'min' : 0, 'max' : 100, 'calc' : self.calc_qcache_usage}

        self.ib_usage = newLineDiagramWidget()
        self.ib_usage.set_description("InnoDB Buffer Usage")
        health.add(self.ib_usage, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_ib_usage'] = (self.ib_usage, label, lambda x:
                                        ("%.1f%%\n" % x), None)
        sql['get_ib_usage'] = {
            'query': ("Innodb_buffer_pool_pages_free",
                      "Innodb_buffer_pool_pages_total"),
            'min':
            0,
            'max':
            100,
            'calc':
            self.calc_ib_usage
        }

        self.add(health, False, True)
        self.add(health_text, False, True)

        # InnoDB Reads/Writes per second:
        health = mforms.newBox(True)
        health.set_spacing(28)
        health_text = mforms.newBox(True)
        health_text.set_homogeneous(True)
        health_text.set_spacing(24)

        self.innodb_reads = newLineDiagramWidget()
        self.innodb_reads.set_description('InnoDB Reads per Second')
        self.innodb_reads.enable_auto_scale(True)
        self.innodb_reads.set_thresholds(
            [0.0], [50.0, 100.0, 200.0, 500.0, 1000.0, 5000.0, 10000.0])
        health.add(self.innodb_reads, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_innodb_reads'] = (self.innodb_reads, label, lambda x:
                                            ('%.0f\n' % x), None)
        self.last_ircount = 0
        sql['get_innodb_reads'] = {
            'query': ('Innodb_data_reads', ),
            'min': 0,
            'max': 100,
            'calc': self.calc_innodb_reads_per_second
        }

        self.innodb_writes = newLineDiagramWidget()
        self.innodb_writes.set_description('InnoDB Writes per Second')
        self.innodb_writes.enable_auto_scale(True)
        self.innodb_writes.set_thresholds(
            [0.0], [50.0, 100.0, 200.0, 500.0, 1000.0, 5000.0, 10000.0])
        health.add(self.innodb_writes, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_innodb_writes'] = (self.innodb_writes, label,
                                             lambda x: ('%.0f\n' % x), None)
        self.last_iwcount = 0
        sql['get_innodb_writes'] = {
            'query': ('Innodb_data_writes', ),
            'min': 0,
            'max': 100,
            'calc': self.calc_innodb_writes_per_second
        }

        self.add(health, False, True)
        self.add(health_text, False, True)

        self.resume_layout()

        self.mon_be = wba_monitor_be.WBAdminMonitorBE(UPDATE_INTERVAL,
                                                      server_profile, ctrl_be,
                                                      self.widgets,
                                                      self.cpu_widget, sql)
コード例 #2
0
ファイル: wb_admin_monitor.py プロジェクト: Arrjaan/Cliff
    def __init__(self, server_profile, ctrl_be):
        mforms.Box.__init__(self, True)
        
        self.widgets = {}
        
        self.server_profile = server_profile
        self.set_managed()

        self.suspend_layout()

        self.set_size(-1, 91)
        self.ctrl_be = ctrl_be

        # Info.
        info_box = newWidgetContainer("INFO")
        self.add(info_box, False, True)

        self.server_info = newServerInfoWidget()
        self.server_info.set_server_status(-1)
        host_name = None
        if server_profile.db_connection_params:
            if server_profile.db_connection_params.driver.name == "MysqlNativeSocket":
                host_name = "localhost"
            else:
                host_name = server_profile.db_connection_params.parameterValues["hostName"]
        if not host_name:
            host_name = u"Not Set"

        self.server_info.set_server_info(unicode(server_profile.name), host_name, self.ctrl_be.raw_version)

        info_box.add_widget(self.server_info, False)

        separator = newWidgetSeparator()
        separator.set_size(8, -1)
        self.add(separator, False, True)
        
        # System.
        system_box = newWidgetContainer("SYSTEM")
        self.cpu_usage = newBarGraphWidget()
        if self.server_profile.target_is_windows:
          self.ctrl_be.uitask(self.cpu_usage.set_description, "CPU: --")
        else:
          self.ctrl_be.uitask(self.cpu_usage.set_description, "Load: --")
        system_box.add_widget(self.cpu_usage, False)

        if self.server_profile.target_is_windows:
          self.widgets['get_cpu_info'] = (self.cpu_usage, lambda x: "CPU: " + str(int(x*100)) + "%", None)
        else:
          self.cpu_usage.enable_auto_scale(True)
          self.widgets['get_cpu_info'] = (self.cpu_usage, lambda x: "Load: " + str(x), None)

        self.memory = newBarGraphWidget()
        system_box.add_widget(self.memory, False)
        self.ctrl_be.uitask(self.memory.set_description, "Mem: --")

        def mem_label(x):
          up = self.memory.get_upper_range()
          x = int(x/up*100)
          s = "Mem: " + str(x) + "%"
          return s

        self.widgets['get_mem_info'] = (self.memory, lambda x: mem_label(x), lambda x: (self.memory.get_upper_range() - x))

        #self.heartbeat = newHeartbeatWidget()
        #self.heartbeat.set_size(142, -1)
        #system_box.add_widget(self.heartbeat, False)
        #self.heartbeat.set_description("Server Health: -")

        self.add(system_box, False, True);

        separator = newWidgetSeparator()
        separator.set_size(8, -1)
        self.add(separator, False, True)

        sql = {}
        # Server health.
        health= newWidgetContainer("SERVER HEALTH")
        self.connection_usage= newLineDiagramWidget()
        self.connection_usage.set_size(110, -1)
        self.ctrl_be.uitask(self.connection_usage.set_description, "Connection Usage: --")
        self.connection_usage.enable_auto_scale(True)
        self.connection_usage.set_thresholds([0.0], [10.0, 50.0, 100.0, 500.0, 1000.0])
        health.add_widget(self.connection_usage, True)
        self.widgets['get_connections'] = (self.connection_usage, lambda x: "Connection Usage: " + str(int(x)), None);
        sql['get_connections'] = {'query' : ("Threads_connected",), 'min' : 0, 'max' : 10, 'calc' : None}

        self.traffic= newLineDiagramWidget()
        self.traffic.set_size(110, -1)
        self.ctrl_be.uitask(self.traffic.set_description, "Traffic: --")
        self.traffic.enable_auto_scale(True)
        self.traffic.set_thresholds([0.0], [100000.0, 1000000.0, 10000000.0, 100000000.0])
        health.add_widget(self.traffic, True)
        self.widgets['get_traffic'] = (self.traffic, lambda x: "Traffic: " + self.format_value(x), None);

        self.last_traffic = 0
        sql['get_traffic'] = {'query' : ("Bytes_sent",), 'min' : 0, 'max' : 100, 'calc' : self.calc_traffic}

        self.hitrate= newLineDiagramWidget()
        self.hitrate.set_size(110, -1)
        self.ctrl_be.uitask(self.hitrate.set_description, "Query Cache Hitrate: --")
        health.add_widget(self.hitrate, True)
        self.widgets['get_hitrate'] = (self.hitrate, lambda x: "Query Cache Hitrate: " + ("%.2f" % x) + "%", None);
        sql['get_hitrate'] = {'query' : ("Qcache_hits", "Qcache_inserts", "Qcache_not_cached"), 'min' : 0, 'max' : 100, 'calc' : self.calc_hitrate}

        self.key_efficiency= newLineDiagramWidget()
        self.key_efficiency.set_size(110, -1)
        self.ctrl_be.uitask(self.key_efficiency.set_description, "Key Efficiency: --")
        health.add_widget(self.key_efficiency, True)
        self.widgets['get_key_efficiency'] = (self.key_efficiency, lambda x: "Key Efficiency: " + ("%.2f" % x) + "%", None);
        sql['get_key_efficiency'] = {'query' : ("Key_reads","Key_read_requests"), 'min' : 0, 'max' : 100, 'calc' : self.calc_key_efficiency}

        self.add(health, True, True)

        self.resume_layout()

        self.mon_be = wba_monitor_be.WBAdminMonitorBE(3, server_profile, ctrl_be, self.widgets, sql)
        if not self.server_profile.target_is_windows:
          mem = self.mon_be.run('get_mem_total')
          if mem is not None:
            mem = mem.strip(" \r\t\n.,:;")
        else:
          mem = 100

        if mem != "" and mem is not None:
          try:
              self.memory.set_value_range(0, float(mem))
          except ValueError, exc:
              print "Error parsing output of get_mem_total: '%s'"%mem
コード例 #3
0
    def __init__(self, server_profile, ctrl_be):
        mforms.Box.__init__(self, False)

        self.widgets = {}

        self.server_profile = server_profile
        self.set_managed()
        self.set_release_on_add()

        self.suspend_layout()

        self.ctrl_be = ctrl_be

        def bigLabel(text="---\n"):
            l = mforms.newLabel(text)
            l.set_style(mforms.VeryBigStyle)
            return l

        # Status icon
        self.box1 = mforms.newBox(True)
        self.box1.set_spacing(28)

        health_text = mforms.newBox(True)
        health_text.set_spacing(20)

        self.status_icon = mforms.newServerStatusWidget()
        self.status_icon.set_description("Server Status")
        self.status_icon.set_size(86, -1)
        self.box1.add(self.status_icon, False, True)

        self.status_label = bigLabel("Unknown\n")
        self.status_label.set_size(86, -1)
        health_text.add(self.status_label, False, True)

        # System.
        system_box = mforms.newBox(True)
        system_box.set_spacing(28)
        self.cpu_usage = newBarGraphWidget()
        if self.server_profile.target_is_windows:
            self.cpu_usage.set_description("CPU")
        else:
            self.cpu_usage.set_description("Load")
        self.cpu_usage.set_right_align(True)
        self.cpu_usage.set_size(31, -1);
        system_box.add(self.cpu_usage, False, True)

        label = bigLabel()
        label.set_size(47, -1)
        label.set_text_align(mforms.TopRight)
        health_text.add(label, False, True)
        if self.server_profile.target_is_windows:
            self.cpu_widget = (self.cpu_usage, label, lambda x: str(int(x*100)) + "%\n", None)
        else:
            self.cpu_usage.enable_auto_scale(True)
            self.cpu_widget = (self.cpu_usage, label, lambda x: str(x)+"\n", None)

        sql = {}
        self.connection_usage= newLineDiagramWidget()
        self.connection_usage.set_description("Connections")
        self.connection_usage.enable_auto_scale(True)
        self.connection_usage.set_thresholds([0.0], [10.0, 50.0, 100.0, 500.0, 1000.0])
        system_box.add(self.connection_usage, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_connections'] = (self.connection_usage, label, lambda x: "%s\n"%str(int(x)), None)
        sql['get_connections'] = {'query' : ("Threads_connected",), 'min' : 0, 'max' : 10, 'calc' : None}
        self.box1.add(system_box, True, True)

        self.add(self.box1, False, True)
        self.add(health_text, False, True)

        # Server health.
        health = mforms.newBox(True)
        health.set_spacing(28)
        health_text = mforms.newBox(True)
        health_text.set_homogeneous(True)
        health_text.set_spacing(24) # 4px less as for the widgets (the labels have a bit leading space).

        self.traffic = newLineDiagramWidget()
        self.traffic.set_description("Traffic")
        self.traffic.enable_auto_scale(True)
        self.traffic.set_thresholds([0.0], [100000.0, 1000000.0, 10000000.0, 100000000.0])
        health.add(self.traffic, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_traffic'] = (self.traffic, label, lambda x: "%s\n"%self.format_value(x), None)
        self.last_traffic = 0
        sql['get_traffic'] = {'query' : ("Bytes_sent",), 'min' : 0, 'max' : 100, 'calc' : self.calc_traffic}

        self.key_efficiency= newLineDiagramWidget()
        self.key_efficiency.set_description("Key Efficiency")
        health.add(self.key_efficiency, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_key_efficiency'] = (self.key_efficiency, label, lambda x: ("%.1f%%\n" % x), None)
        sql['get_key_efficiency'] = {'query' : ("Key_reads","Key_read_requests"), 'min' : 0, 'max' : 100, 'calc' : self.calc_key_efficiency}

        self.add(health, False, True)
        self.add(health_text, False, True)

        # Query
        health= mforms.newBox(True)
        health.set_spacing(28)
        health_text = mforms.newBox(True)
        health_text.set_homogeneous(True)
        health_text.set_spacing(24)

        self.qps= newLineDiagramWidget()
        self.qps.set_description("Selects per Second")
        self.qps.enable_auto_scale(True)
        self.qps.set_thresholds([0.0], [50.0, 100.0, 200.0, 500.0, 1000.0, 5000.0, 10000.0])
        health.add(self.qps, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_qps'] = (self.qps, label, lambda x: ("%.0f\n" % x), None)
        self.last_qcount = 0
        sql['get_qps'] = {'query' : ("Com_select",), 'min' : 0, 'max' : 100, 'calc' : self.calc_qps}

#        self.hitrate= newLineDiagramWidget()
#        self.hitrate.set_description("Query Cache Hitrate")
#        health.add(self.hitrate, True, True)
#        label = bigLabel()
#        health_text.add(label, True, True)
#        self.widgets['get_hitrate'] = (self.hitrate, label, lambda x: ("%.1f%%\n" % x), None)
#        sql['get_hitrate'] = {'query' : ("Qcache_hits", "Qcache_inserts", "Qcache_not_cached"), 'min' : 0, 'max' : 100, 'calc' : self.calc_hitrate}
#
#        self.add(health, False, True)
#        self.add(health_text, False, True)
#
#        # Cache/buffer
#        health = mforms.newBox(True)
#        health.set_spacing(28)
#        health_text = mforms.newBox(True)
#        health_text.set_homogeneous(True)
#        health_text.set_spacing(24)
#
#        self.qcache_usage = newLineDiagramWidget()
#        self.qcache_usage.set_description("Query Cache Usage")
#        health.add(self.qcache_usage, True, True)
#        label = bigLabel()
#        health_text.add(label, True, True)
#        self.widgets['get_qcache_usage'] = (self.qcache_usage, label, lambda x: ("%.1f%%\n" % x), None)
#        sql['get_qcache_usage'] = {'query' : ("Qcache_free_blocks", "Qcache_total_blocks"), 'min' : 0, 'max' : 100, 'calc' : self.calc_qcache_usage}

        self.ib_usage = newLineDiagramWidget()
        self.ib_usage.set_description("InnoDB Buffer Usage")
        health.add(self.ib_usage, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_ib_usage'] = (self.ib_usage, label, lambda x: ("%.1f%%\n" % x), None)
        sql['get_ib_usage'] = {'query' : ("Innodb_buffer_pool_pages_free", "Innodb_buffer_pool_pages_total"), 'min' : 0, 'max' : 100, 'calc' : self.calc_ib_usage}
        
        self.add(health, False, True)
        self.add(health_text, False, True)

        # InnoDB Reads/Writes per second:
        health= mforms.newBox(True)
        health.set_spacing(28)
        health_text = mforms.newBox(True)
        health_text.set_homogeneous(True)
        health_text.set_spacing(24)

        self.innodb_reads = newLineDiagramWidget()
        self.innodb_reads.set_description('InnoDB Reads per Second')
        self.innodb_reads.enable_auto_scale(True)
        self.innodb_reads.set_thresholds([0.0], [50.0, 100.0, 200.0, 500.0, 1000.0, 5000.0, 10000.0])
        health.add(self.innodb_reads, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_innodb_reads'] = (self.innodb_reads, label, lambda x: ('%.0f\n' % x), None)
        self.last_ircount = 0
        sql['get_innodb_reads'] = {'query' : ('Innodb_data_reads',), 'min' : 0, 'max' : 100, 'calc' : self.calc_innodb_reads_per_second}

        self.innodb_writes = newLineDiagramWidget()
        self.innodb_writes.set_description('InnoDB Writes per Second')
        self.innodb_writes.enable_auto_scale(True)
        self.innodb_writes.set_thresholds([0.0], [50.0, 100.0, 200.0, 500.0, 1000.0, 5000.0, 10000.0])
        health.add(self.innodb_writes, True, True)
        label = bigLabel()
        health_text.add(label, True, True)
        self.widgets['get_innodb_writes'] = (self.innodb_writes, label, lambda x: ('%.0f\n' % x), None)
        self.last_iwcount = 0
        sql['get_innodb_writes'] = {'query' : ('Innodb_data_writes',), 'min' : 0, 'max' : 100, 'calc' : self.calc_innodb_writes_per_second}
        
        self.add(health, False, True)
        self.add(health_text, False, True)

        self.resume_layout()

        self.mon_be = wba_monitor_be.WBAdminMonitorBE(UPDATE_INTERVAL, server_profile, ctrl_be, self.widgets, self.cpu_widget, sql)
コード例 #4
0
    def __init__(self, server_profile, ctrl_be):
        mforms.Box.__init__(self, True)

        self.widgets = {}

        self.server_profile = server_profile
        self.set_managed()

        self.suspend_layout()

        self.set_size(-1, 91)
        self.ctrl_be = ctrl_be

        # Info.
        info_box = newWidgetContainer("INFO")
        self.add(info_box, False, True)

        self.server_info = newServerInfoWidget()
        self.server_info.set_server_status(-1)
        host_name = None
        if server_profile.db_connection_params:
            if server_profile.db_connection_params.driver.name == "MysqlNativeSocket":
                host_name = "localhost"
            else:
                host_name = server_profile.db_connection_params.parameterValues[
                    "hostName"]
        if not host_name:
            host_name = u"Not Set"

        self.server_info.set_server_info(unicode(server_profile.name),
                                         host_name, self.ctrl_be.raw_version)

        info_box.add_widget(self.server_info, False)

        separator = newWidgetSeparator()
        separator.set_size(8, -1)
        self.add(separator, False, True)

        # System.
        system_box = newWidgetContainer("SYSTEM")
        self.cpu_usage = newBarGraphWidget()
        if self.server_profile.target_is_windows:
            self.ctrl_be.uitask(self.cpu_usage.set_description, "CPU: --")
        else:
            self.ctrl_be.uitask(self.cpu_usage.set_description, "Load: --")
        system_box.add_widget(self.cpu_usage, False)

        if self.server_profile.target_is_windows:
            self.widgets['get_cpu_info'] = (
                self.cpu_usage, lambda x: "CPU: " + str(int(x * 100)) + "%",
                None)
        else:
            self.cpu_usage.enable_auto_scale(True)
            self.widgets['get_cpu_info'] = (self.cpu_usage,
                                            lambda x: "Load: " + str(x), None)

        self.memory = newBarGraphWidget()
        system_box.add_widget(self.memory, False)
        self.ctrl_be.uitask(self.memory.set_description, "Mem: --")

        def mem_label(x):
            up = self.memory.get_upper_range()
            x = int(x / up * 100)
            s = "Mem: " + str(x) + "%"
            return s

        self.widgets['get_mem_info'] = (self.memory, lambda x: mem_label(x),
                                        lambda x:
                                        (self.memory.get_upper_range() - x))

        #self.heartbeat = newHeartbeatWidget()
        #self.heartbeat.set_size(142, -1)
        #system_box.add_widget(self.heartbeat, False)
        #self.heartbeat.set_description("Server Health: -")

        self.add(system_box, False, True)

        separator = newWidgetSeparator()
        separator.set_size(8, -1)
        self.add(separator, False, True)

        sql = {}
        # Server health.
        health = newWidgetContainer("SERVER HEALTH")
        self.connection_usage = newLineDiagramWidget()
        self.connection_usage.set_size(110, -1)
        self.ctrl_be.uitask(self.connection_usage.set_description,
                            "Connection Usage: --")
        self.connection_usage.enable_auto_scale(True)
        self.connection_usage.set_thresholds(
            [0.0], [10.0, 50.0, 100.0, 500.0, 1000.0])
        health.add_widget(self.connection_usage, True)
        self.widgets['get_connections'] = (
            self.connection_usage,
            lambda x: "Connection Usage: " + str(int(x)), None)
        sql['get_connections'] = {
            'query': ("Threads_connected", ),
            'min': 0,
            'max': 10,
            'calc': None
        }

        self.traffic = newLineDiagramWidget()
        self.traffic.set_size(110, -1)
        self.ctrl_be.uitask(self.traffic.set_description, "Traffic: --")
        self.traffic.enable_auto_scale(True)
        self.traffic.set_thresholds(
            [0.0], [100000.0, 1000000.0, 10000000.0, 100000000.0])
        health.add_widget(self.traffic, True)
        self.widgets['get_traffic'] = (
            self.traffic, lambda x: "Traffic: " + self.format_value(x), None)

        self.last_traffic = 0
        sql['get_traffic'] = {
            'query': ("Bytes_sent", ),
            'min': 0,
            'max': 100,
            'calc': self.calc_traffic
        }

        self.hitrate = newLineDiagramWidget()
        self.hitrate.set_size(110, -1)
        self.ctrl_be.uitask(self.hitrate.set_description,
                            "Query Cache Hitrate: --")
        health.add_widget(self.hitrate, True)
        self.widgets['get_hitrate'] = (self.hitrate,
                                       lambda x: "Query Cache Hitrate: " +
                                       ("%.2f" % x) + "%", None)
        sql['get_hitrate'] = {
            'query': ("Qcache_hits", "Qcache_inserts", "Qcache_not_cached"),
            'min': 0,
            'max': 100,
            'calc': self.calc_hitrate
        }

        self.key_efficiency = newLineDiagramWidget()
        self.key_efficiency.set_size(110, -1)
        self.ctrl_be.uitask(self.key_efficiency.set_description,
                            "Key Efficiency: --")
        health.add_widget(self.key_efficiency, True)
        self.widgets['get_key_efficiency'] = (self.key_efficiency,
                                              lambda x: "Key Efficiency: " +
                                              ("%.2f" % x) + "%", None)
        sql['get_key_efficiency'] = {
            'query': ("Key_reads", "Key_read_requests"),
            'min': 0,
            'max': 100,
            'calc': self.calc_key_efficiency
        }

        self.add(health, True, True)

        self.resume_layout()

        self.mon_be = wba_monitor_be.WBAdminMonitorBE(3, server_profile,
                                                      ctrl_be, self.widgets,
                                                      sql)
        if not self.server_profile.target_is_windows:
            mem = self.mon_be.run('get_mem_total')
            if mem is not None:
                mem = mem.strip(" \r\t\n.,:;")
        else:
            mem = 100

        if mem != "" and mem is not None:
            try:
                self.memory.set_value_range(0, float(mem))
            except ValueError, exc:
                print "Error parsing output of get_mem_total: '%s'" % mem