Exemple #1
0
	def __elapse(self):
		if self.__timer == 0:
			for m in self.__env.HOSTS:
				self.__scr.writeFooter(_("Loading ..."))
				self.__scr.refresh()
				try:
					self.__cpu_num[m] = Utils.safeInt(Data.getRRD("%s/%s/cpu_num.rrd" % (self.__env.DATADIR, m))[-1][1])
					self.__cpu_speed[m] = Utils.safeFloat(Data.getRRD("%s/%s/cpu_speed.rrd" % (self.__env.DATADIR, m))[-1][1])
					self.__cpu_user[m] = Data.getRRD("%s/%s/cpu_user.rrd" % (self.__env.DATADIR, m))
					self.__cpu_system[m] = Data.getRRD("%s/%s/cpu_system.rrd" % (self.__env.DATADIR, m))

					self.__mem_buffers[m] = Data.getRRD("%s/%s/mem_buffers.rrd" % (self.__env.DATADIR, m))
					self.__mem_cached[m] = Data.getRRD("%s/%s/mem_cached.rrd" % (self.__env.DATADIR, m))
					self.__mem_free[m] = Data.getRRD("%s/%s/mem_free.rrd" % (self.__env.DATADIR, m))
					self.__mem_total[m] = Data.getRRD("%s/%s/mem_total.rrd" % (self.__env.DATADIR, m))

					self.__cpu_topuser[m] = Data.getProcData("%s/%s/cpu_topuser" % (self.__env.DATADIR, m))
					self.__mem_topuser[m] = Data.getProcData("%s/%s/mem_topuser" % (self.__env.DATADIR, m))
				except ElementTree.ParseError:
					return False
				except IOError:
					return False

			self.__redraw = True

		# go ahead
		self.__timer += 1
		if self.__timer >= self.__options.interval * 1000 // Screen.timeout():
			self.__timer = 0

		return True
Exemple #2
0
	def getRRD(filename):
		if "://" in filename:
			tree = ElementTree.parse(urlopen(filename))
		else:
			tree = ElementTree.parse(filename)
		elem = tree.getroot()
		rootstep = int(elem.find(".//step").text)
		lastupdate = int(elem.find(".//lastupdate").text)
		dataset = {}
		for e in elem.findall(".//rra"):
			second_val = Utils.safeFloat(e.find(".//secondary_value").text)
			prim_val = Utils.safeFloat(e.find(".//primary_value").text, second_val)
			step = int(e.find(".//pdp_per_row").text) * rootstep
			dataset.update({
				lastupdate - i * step: Utils.safeFloat(val.text, prim_val)
				for i, val in enumerate(reversed(e.findall(".//v")))})
		return sorted(dataset.items(), key=lambda x: x[0])
Exemple #3
0
    def __elapse(self):
        if self.__timer == 0:
            for m in self.__env.HOSTS:
                self.__scr.writeFooter(_("Loading ..."))
                self.__scr.refresh()
                try:
                    self.__cpu_num[m] = Utils.safeInt(
                        Data.getRRD("%s/%s/cpu_num.rrd" %
                                    (self.__env.DATADIR, m))[-1][1])
                    self.__cpu_speed[m] = Utils.safeFloat(
                        Data.getRRD("%s/%s/cpu_speed.rrd" %
                                    (self.__env.DATADIR, m))[-1][1])
                    self.__cpu_user[m] = Data.getRRD("%s/%s/cpu_user.rrd" %
                                                     (self.__env.DATADIR, m))
                    self.__cpu_system[m] = Data.getRRD("%s/%s/cpu_system.rrd" %
                                                       (self.__env.DATADIR, m))

                    self.__mem_buffers[m] = Data.getRRD(
                        "%s/%s/mem_buffers.rrd" % (self.__env.DATADIR, m))
                    self.__mem_cached[m] = Data.getRRD("%s/%s/mem_cached.rrd" %
                                                       (self.__env.DATADIR, m))
                    self.__mem_free[m] = Data.getRRD("%s/%s/mem_free.rrd" %
                                                     (self.__env.DATADIR, m))
                    self.__mem_total[m] = Data.getRRD("%s/%s/mem_total.rrd" %
                                                      (self.__env.DATADIR, m))

                    self.__cpu_topuser[m] = Data.getProcData(
                        "%s/%s/cpu_topuser" % (self.__env.DATADIR, m))
                    self.__mem_topuser[m] = Data.getProcData(
                        "%s/%s/mem_topuser" % (self.__env.DATADIR, m))
                except ElementTree.ParseError:
                    return False
                except IOError:
                    return False

            self.__redraw = True

        # go ahead
        self.__timer += 1
        if self.__timer >= self.__options.interval * 1000 // Screen.timeout():
            self.__timer = 0

        return True