|
|
@ -24,12 +24,14 @@ def main(argv): |
|
|
|
with open(tempfile, newline='') as csvfile: |
|
|
|
with open(tempfile, newline='') as csvfile: |
|
|
|
csvreader = csv.DictReader(csvfile, delimiter=';') |
|
|
|
csvreader = csv.DictReader(csvfile, delimiter=';') |
|
|
|
for row in csvreader: |
|
|
|
for row in csvreader: |
|
|
|
rowkeys = row.keys() |
|
|
|
rowkeys = iter(row.keys()) |
|
|
|
kbtotal = int(row.get('kbmemused')) + int(row.get('kbmemfree')) |
|
|
|
kbtotal = int(row.get('kbmemused')) + int(row.get('kbmemfree')) |
|
|
|
kbavail = int(row.get('kbavail')) |
|
|
|
kbavail = int(row.get('kbavail')) |
|
|
|
percavail = (kbavail/kbtotal) |
|
|
|
percavail = (kbavail/kbtotal) |
|
|
|
fmtpavail = str('{:.1%}'.format(percavail)) |
|
|
|
fmtpavail = str('{:.1%}'.format(percavail)) |
|
|
|
row.update({'%kbavail':fmtpavail}) |
|
|
|
row.update({'%kbavail':fmtpavail}) |
|
|
|
print(row['# hostname'],row['timestamp'],row['%kbavail']) |
|
|
|
for key,val in zip(row.keys(),row.values()): |
|
|
|
|
|
|
|
print(str(key)) |
|
|
|
|
|
|
|
print(str(val)) |
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
main(sys.argv[1:]) |
|
|
|
main(sys.argv[1:]) |
|
|
|