1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__ = """CommandParser
15
16 CommandParser parses the output of a command to return a datamap
17
18 $Id: Uname_A.py,v 1.2 2003/10/01 23:40:51 edahl Exp $"""
19
20 __version__ = '$Revision: 1.2 $'[11:-2]
21
22 import re
23
24 from CommandParser import CommandParser
25
27
28 command = 'df -k'
29
33
34 - def parse(self, device, results, log):
35 log.info("collecting filesystems from device %s" % device.id)
36 rm = self.newRelationshipMap("filesystems")
37 rlines = results.split("\n")
38 for line in rlines:
39 aline = line.split()
40 if len(aline) != 6: continue
41 try:
42 om = self.newObjectMap("ZenModel.FileSystem")
43 om['storageDevice'] = aline[0]
44 om['totalBytes'] = long(aline[1]) * 1024
45 om['usedBytes'] = long(aline[2]) * 1024
46 om['availBytes'] = long(aline[3]) * 1024
47 cap = aline[4][-1] == "%" and aline[4][:-1] or aline[4]
48 om['capacity'] = cap
49 om['mount'] = aline[5]
50 om['id'] = self.prepId(om['mount'], '-')
51 om['title'] = om['mount']
52 rm.append(om)
53 except ValueError: pass
54 return rm
55
57 return "get df -k from server to build filesystems"
58