Esempio n. 1
0
    def read_data(self):
        """
        Read the data from sensors.

        """
        drives = list(sorted(self.datasource_names))
        command = ["hddtemp", "-q", "-n"] + drives
        result = call(*command).split("\n")
        values = {}
        for i in range(len(drives)):
            values[drives[i]] = float(result[i])
        return values
Esempio n. 2
0
    def read_data(self):
        """
        Read the data from sensors.

        """
        values = {}
        result = call("who", "-q").split("\n")[0].split(" ")
        if len(result[0]) == 0:
            result = []
        values["logins"] = len(result)
        values["users"] = len(set(result))
        return values
Esempio n. 3
0
 def _get_temps(cls):
     values = {}
     command = ["nvidia-smi", "-q", "-d", "TEMPERATURE"]
     result = call(*command).split("\n")
     # Find temperature section
     for i in range(len(result)):
         if re.match("\s*Temperature\s*", result[i]) is not None:
             break
     for j in range(i+1, len(result)):
         match = re.match("\s*([^:]+?)\s*:\s*([0-9]+) C", result[j], re.I)
         if match is None:
             break
         name = match.group(1)
         values[name] = float(match.group(2))
     return values
Esempio n. 4
0
    def read_data(self):
        """
        Read the data from sensors.

        """
        columns = list(self.datasource_names)
        values = {}
        for row in call("smartctl", "-A", self._drive).split("\n"):
            match = re.match("\s*[0-9]+\s+(\S+)\s*\S+\s*\S+\s*\S+\s*\S+\s*\S+\s*\S+\s*\S+\s*([0-9]+)", row)
            if match is None:
                continue
            name = match.group(1)
            if name not in columns:
                continue
            values[name] = int(match.group(2))
        return values
Esempio n. 5
0
    def read_data(self):
        """
        Read the data from sensors.

        """
        temperatures = self.datasource_names
        values = {}
        for row in call("sensors", "-A").split("\n"):
            match = re.match("([^: ][^:]*):\s+\+([0-9.]+) C\s+", row)
            if match is None:
                continue
            name = "temp_{}".format(match.group(1))
            if name not in temperatures:
                continue
            values[name] = float(match.group(2))
        return values