Esempio n. 1
0
    def tracker(self, device, interval=10):
        command = ["iostat -d -x", str(interval), device]

        def parser(line):
            line = line.strip()
            if line.startswith(device):
                vector = line.replace(",", ".").split()[1:]
                self.dump(self.probe(vector))

        run_command(command, callback=parser)
Esempio n. 2
0
 def run_ifconfig(self, iface):
     output = run_command(['ifconfig', iface])[0]
     m = re.search('RX bytes:([0-9]+)', output)
     rxbytes = int(m.group(1))
     m = re.search('TX bytes:([0-9]+)', output)
     txbytes = int(m.group(1))
     return [rxbytes, txbytes]
Esempio n. 3
0
 def check(self, mount):
     command = ['df -i', mount]
     output = run_command(command)[0].split("\n")[1].split()
     return {
         'total': output[1],
         'used':  output[2],
         'avail': output[3]
     }
Esempio n. 4
0
 def check(self):
     command = ['top -b -n 1']
     lines = run_command(command)[0].split("\n")
     for line in lines:
         line = line.replace(', ', ' ').replace(',', '.')
         m = re.search('load average\: ([0-9\.]+) ([0-9\.]+) ([0-9\.]+)', line)
         if m:
             return {
                 'avg1':  float(m.group(1)),
                 'avg5':  float(m.group(2)),
                 'avg15': float(m.group(3))
             }
Esempio n. 5
0
 def check(self):
     command = ["top -b -n 1"]
     lines = run_command(command)[0].split("\n")
     for line in lines:
         if line.startswith("KiB Mem:"):
             vector = line.split()
             return {
                 "total": int(vector[2]),
                 "used": int(vector[4]),
                 "free": int(vector[6]),
                 "buffers": int(vector[8]),
             }
Esempio n. 6
0
 def check(self):
     command = ['top -b -n 1']
     lines = run_command(command)[0].split("\n")
     for line in lines:
         if line.startswith('KiB Swap:'):
             vector = line.split()
             return {
                 'total':  int(vector[2]),
                 'used':   int(vector[4]),
                 'free':   int(vector[6]),
                 'cached': int(vector[8])
             }
Esempio n. 7
0
 def check(self):
     command = ['top -b -n 1']
     lines = run_command(command)[0].split("\n")
     for line in lines:
         if line.startswith('Tasks:'):
             vector = line.split()
             return {
                 'total':    int(vector[1]),
                 'running':  int(vector[3]),
                 'sleeping': int(vector[5]),
                 'stopped':  int(vector[7]),
                 'zombie':   int(vector[9])
             }
Esempio n. 8
0
 def tracker(self, interval=10):
     command = ["top -b -d", str(interval)]
     run_command(command, callback=self.parser)
Esempio n. 9
0
 def check(self, dir):
     command = ['find', dir, '-type f', '|', 'wc -l']
     return { 'files': int(run_command(command)[0]) }
Esempio n. 10
0
 def run(self):
     while True:
         command = ['tail -f', self.logpath]
         run_command(command, callback=self.parser)