Exemplo n.º 1
0
    def save(self, connection: Connection) -> None:
        data = self.data()
        if data is None:
            print("ERROR: Could not read sensordata from /proc/diskstats!")
            return

        for item in data:
            for measurement in item.values():
                connection.insert('diskstats', measurement)
        self.raw_data = []
Exemplo n.º 2
0
    def save(self, connection: Connection) -> None:
        data = self.data()
        if data is None:
            print("ERROR: Could not read sensordata from smartctl!")
            return

        for item in data:
            connection.insert(item['type'], item['data'])

        self.raw_data = []
Exemplo n.º 3
0
    def save(self, connection: Connection) -> None:
        data = self.data()
        if data is None:
            print("ERROR: Could not read sensordata from ss!")
            return

        for item in data:
            connection.insert('netstat', item)

        self.raw_data = []
Exemplo n.º 4
0
    def create_datamodel(self, connection: Connection) -> None:
        connection.create_table(
            'cpu_usage_counter',
            [
                {"name": "core", "type": "INT", "null": "NOT NULL"},
                {"name": "user", "type": "BIGINT", "null": "NULL"},
                {"name": "nice", "type": "BIGINT", "null": "NULL"},
                {"name": "system", "type": "BIGINT", "null": "NULL"},
                {"name": "idle", "type": "BIGINT", "null": "NULL"},
                {"name": "iowait", "type": "BIGINT", "null": "NULL"},
                {"name": "irq", "type": "BIGINT", "null": "NULL"},
                {"name": "softirq", "type": "BIGINT", "null": "NULL"},
                {"name": "steal", "type": "BIGINT", "null": "NULL"},
                {"name": "guest", "type": "BIGINT", "null": "NULL"},
                {"name": "guest_nice", "type": "BIGINT", "null": "NULL"}
            ]
        )
        connection.create_index('cpu_usage_counter', ('time', 'core'))
        connection.create_index('cpu_usage_counter', 'core')

        connection.create_table(
            'kernel',
            [
                {"name": "interrupts", "type": "BIGINT", "null": "NULL"},
                {"name": "context_switches", "type": "BIGINT", "null": "NULL"},
                {"name": "processes_forked", "type": "BIGINT", "null": "NULL"},
                {"name": "processes_running", "type": "BIGINT", "null": "NULL"},
                {"name": "processes_blocked", "type": "BIGINT", "null": "NULL"},
                {"name": "soft_interrupts", "type": "BIGINT", "null": "NULL"}
            ]
        )
Exemplo n.º 5
0
 def create_datamodel(self, connection: Connection) -> None:
     connection.create_table('netstat', [{
         "name": "established",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "syn_sent",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "syn_recv",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "fin_wait1",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "fin_wait2",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "time_wait",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "close",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "close_wait",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "last_ack",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "listen",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "closing",
         "type": "INT",
         "null": "NULL"
     }, {
         "name": "unknown",
         "type": "INT",
         "null": "NULL"
     }])
Exemplo n.º 6
0
    def save(self, connection: Connection) -> None:
        data = self.data()
        if data is None:
            print("ERROR: Could not read sensordata from /proc/stat!")
            return
        
        for item in data:
            for table, measurement in item.items():
                if isinstance(measurement, list):
                    for item in measurement:
                        connection.insert(table, item)
                else:
                    connection.insert(table, measurement)

        self.raw_data = []
Exemplo n.º 7
0
    def save(self, connection: Connection) -> None:
        data = self.data()
        if data is None:
            print("ERROR: Could not read sensordata from ryzen power!")
            return

        for item in data:
            timestamp = item['time']
            for t, measurement in item.items():
                if t == 'time':
                    continue
                for sensor_name, value in measurement.items():
                    connection.insert(
                        'power', {
                            "time": timestamp,
                            "power_type": f"{t}.{sensor_name}",
                            "power": value
                        })

        self.raw_data = []
Exemplo n.º 8
0
    def create_datamodel(self, connection: Connection) -> None:
        connection.create_table(
            'diskstats',
            [
                {"name": "disk", "type": "TEXT", "null": "NOT NULL"},
                {"name": "reads_completed", "type": "BIGINT", "null": "NULL"},
                {"name": "reads_merged", "type": "BIGINT", "null": "NULL"},
                {"name": "sectors_read", "type": "BIGINT", "null": "NULL"},
                {"name": "millis_reading", "type": "BIGINT", "null": "NULL"},
                {"name": "writes_completed", "type": "BIGINT", "null": "NULL"},
                {"name": "writes_merged", "type": "BIGINT", "null": "NULL"},
                {"name": "sectors_written", "type": "BIGINT", "null": "NULL"},
                {"name": "millis_writing", "type": "BIGINT", "null": "NULL"},
                {"name": "io_in_progress", "type": "BIGINT", "null": "NULL"},
                {"name": "millis_io", "type": "BIGINT", "null": "NULL"},
                {"name": "weighted_millis_io", "type": "BIGINT", "null": "NULL"},
                {"name": "discards_completed", "type": "BIGINT", "null": "NULL"},
                {"name": "discards_merged", "type": "BIGINT", "null": "NULL"},
                {"name": "sectors_discarded", "type": "BIGINT", "null": "NULL"},
                {"name": "millis_discarding", "type": "BIGINT", "null": "NULL"}
            ]
        )

        connection.create_index('diskstats', 'disk')
Exemplo n.º 9
0
 def create_datamodel(self, connection: Connection) -> None:
     connection.create_table('power', [
         {
             "name": "power_type",
             "type": "TEXT",
             "null": "NOT NULL"
         },
         {
             "name": "power",
             "type": "FLOAT",
             "null": "NULL"
         },
     ])
     connection.create_index('power', ('time', 'power_type'))
     connection.create_index('power', 'power_type')
Exemplo n.º 10
0
    def create_datamodel(self, connection: Connection) -> None:
        connection.create_table('cpu_usage', [{
            "name": "core",
            "type": "INT",
            "null": "NOT NULL"
        }, {
            "name": "user",
            "type": "FLOAT",
            "null": "NULL"
        }, {
            "name": "nice",
            "type": "FLOAT",
            "null": "NULL"
        }, {
            "name": "system",
            "type": "FLOAT",
            "null": "NULL"
        }, {
            "name": "idle",
            "type": "FLOAT",
            "null": "NULL"
        }, {
            "name": "iowait",
            "type": "FLOAT",
            "null": "NULL"
        }, {
            "name": "irq",
            "type": "FLOAT",
            "null": "NULL"
        }, {
            "name": "softirq",
            "type": "FLOAT",
            "null": "NULL"
        }, {
            "name": "steal",
            "type": "FLOAT",
            "null": "NULL"
        }, {
            "name": "guest",
            "type": "FLOAT",
            "null": "NULL"
        }, {
            "name": "guest_nice",
            "type": "FLOAT",
            "null": "NULL"
        }])
        connection.create_index('cpu_usage', ('time', 'core'))
        connection.create_index('cpu_usage', 'core')

        connection.create_table('cpu_freq', [{
            "name": "core",
            "type": "INT",
            "null": "NOT NULL"
        }, {
            "name": "frequency",
            "type": "FLOAT",
            "null": "NULL"
        }])
        connection.create_index('cpu_freq', ('time', 'core'))
        connection.create_index('cpu_freq', 'core')

        connection.create_table('load_avg', [{
            "name": "load_avg",
            "type": "FLOAT",
            "null": "NULL"
        }])

        connection.create_table('processes', [{
            "name": "num_processes",
            "type": "INT",
            "null": "NULL"
        }])

        connection.create_table('virtual_memory', [{
            "name": "total",
            "type": "BIGINT",
            "null": "NOT NULL"
        }, {
            "name": "available",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "used",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "free",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "active",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "inactive",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "buffers",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "cached",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "shared",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "slab",
            "type": "BIGINT",
            "null": "NULL"
        }])

        connection.create_table('swap_memory', [{
            "name": "total",
            "type": "BIGINT",
            "null": "NOT NULL"
        }, {
            "name": "used",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "free",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "sin",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "sout",
            "type": "BIGINT",
            "null": "NULL"
        }])

        connection.create_table('disk_usage', [
            {
                "name": "disk",
                "type": "TEXT",
                "null": "NOT NULL"
            },
            {
                "name": "total",
                "type": "BIGINT",
                "null": "NULL"
            },
            {
                "name": "used",
                "type": "BIGINT",
                "null": "NULL"
            },
            {
                "name": "free",
                "type": "BIGINT",
                "null": "NULL"
            },
        ])
        connection.create_index('disk_usage', ('time', 'disk'))
        connection.create_index('disk_usage', 'disk')

        connection.create_table('net_io_counters', [{
            "name": "interface",
            "type": "TEXT",
            "null": "NOT NULL"
        }, {
            "name": "bytes_sent",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "bytes_recv",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "packets_sent",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "packets_recv",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "errin",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "errout",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "dropin",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "dropout",
            "type": "BIGINT",
            "null": "NULL"
        }])
        connection.create_index('net_io_counters', ('time', 'interface'))
        connection.create_index('net_io_counters', 'interface')

        connection.create_table('disk_io_counters', [{
            "name": "disk",
            "type": "TEXT",
            "null": "NOT NULL"
        }, {
            "name": "read_count",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "write_count",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "read_bytes",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "write_bytes",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "read_time",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "write_time",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "read_merged_count",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "write_merged_count",
            "type": "BIGINT",
            "null": "NULL"
        }, {
            "name": "busy_time",
            "type": "BIGINT",
            "null": "NULL"
        }])
        connection.create_index('disk_io_counters', ('time', 'disk'))
        connection.create_index('disk_io_counters', 'disk')
Exemplo n.º 11
0
 def insert_power(self, time: datetime, chip:str, sensor_name: str, value: float, connection:Connection) -> None:
     connection.insert('power', {"time": time, "power_type": f"{chip}.{sensor_name}", "power": value})
Exemplo n.º 12
0
 def insert_current(self, time: datetime, chip:str, sensor_name: str, value: float, connection:Connection) -> None:
     connection.insert('current', {"time": time, "current_type": f"{chip}.{sensor_name}", "current": value})
Exemplo n.º 13
0
 def insert_fan(self, time: datetime, chip:str, sensor_name: str, value: float, connection:Connection) -> None:
     connection.insert('fans', {"time": time, "fan_type": f"{chip}.{sensor_name}", "speed": value})
Exemplo n.º 14
0
 def insert_temp(self, time: datetime, chip:str, sensor_name: str, value: float, connection:Connection) -> None:
     connection.insert('temps', {"time": time, "temp_type": f"{chip}.{sensor_name}", "temp": value})
Exemplo n.º 15
0
    def create_datamodel(self, connection: Connection) -> None:
        connection.create_table(
            'temps',
            [
                {"name": "temp_type", "type": "TEXT", "null": "NOT NULL"},
                {"name": "temp", "type": "FLOAT", "null": "NULL"},
            ]
        )
        connection.create_index('temps', ('time', 'temp_type'))
        connection.create_index('temps', 'temp_type')

        connection.create_table(
            'voltage',
            [
                {"name": "voltage_type", "type": "TEXT", "null": "NOT NULL"},
                {"name": "voltage", "type": "FLOAT", "null": "NULL"},
            ]
        )
        connection.create_index('voltage', ('time', 'voltage_type'))
        connection.create_index('voltage', 'voltage_type')

        connection.create_table(
            'fans',
            [
                {"name": "fan_type", "type": "TEXT", "null": "NOT NULL"},
                {"name": "speed", "type": "FLOAT", "null": "NULL"},
            ]
        )
        connection.create_index('fans', ('time', 'fan_type'))
        connection.create_index('fans', 'fan_type')

        connection.create_table(
            'current',
            [
                {"name": "current_type", "type": "TEXT", "null": "NOT NULL"},
                {"name": "current", "type": "FLOAT", "null": "NULL"},
            ]
        )
        connection.create_index('current', ('time', 'current_type'))
        connection.create_index('current', 'current_type')

        connection.create_table(
            'power',
            [
                {"name": "power_type", "type": "TEXT", "null": "NOT NULL"},
                {"name": "power", "type": "FLOAT", "null": "NULL"},
            ]
        )
        connection.create_index('power', ('time', 'power_type'))
        connection.create_index('power', 'power_type')
Exemplo n.º 16
0
 def insert_voltage(self, time: datetime, chip:str, sensor_name: str, value: float, connection:Connection) -> None:
     connection.insert('voltage', {"time": time, "voltage_type": f"{chip}.{sensor_name}", "voltage": value})
Exemplo n.º 17
0
    def create_datamodel(self, connection: Connection) -> None:
        connection.create_table('sata_smart', self.fields('sata'))
        connection.create_index('sata_smart', ('time', 'disk'))
        connection.create_index('sata_smart', 'disk')

        connection.create_table('nvme_smart', self.fields('nvme'))
        connection.create_index('nvme_smart', ('time', 'disk'))
        connection.create_index('nvme_smart', 'disk')