psutil_logger.py
The main point of interest in psutil_logger.py is the write function, The index row is prepared before then fetching CPU, Memory, and Disk usage information and building the row structure and then writing it to the database
def write(self): now = datetime.datetime.utcnow() idx = [self.cnid, self.hostname, self.ipAddress, now] scputimes = psutil.cpu_times_percent() loadavg = os.getloadavg() cpu = [ now, 100.0-scputimes.idle, scputimes.user, scputimes.nice, scputimes.system, scputimes.idle, scputimes.iowait, loadavg[0], loadavg[1], loadavg[2] ] svmem = psutil.virtual_memory() mem = [ now, svmem.percent, svmem.total, svmem.available, svmem.used, svmem.free, svmem.buffers, svmem.cached ] mounts = [] mounts_used = [] mounts_total = [] sdiskusage = psutil.disk_usage("/") mounts.append([now, "/", sdiskusage.percent, sdiskusage.total, sdiskusage.used]) self.cpuTs.put(cpu) self.cpuTs.commit() self.memTs.put(mem) self.memTs.commit() self.diskTs.multi_put(mounts) self.diskTs.commit() self.idxCl.put(idx) self.idxCl.commit() return