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 from CommandParser import CommandParser
23
25
26 command = 'df -k'
27
31
32 - def parse(self, device, results, log):
33 log.info("collecting filesystems from device %s" % device.id)
34 rm = self.newRelationshipMap("filesystems")
35 rlines = results.split("\n")
36 for line in rlines:
37 aline = line.split()
38 if len(aline) != 6: continue
39 try:
40 om = self.newObjectMap("ZenModel.FileSystem")
41 om['storageDevice'] = aline[0]
42 om['totalBytes'] = long(aline[1]) * 1024
43 om['usedBytes'] = long(aline[2]) * 1024
44 om['availBytes'] = long(aline[3]) * 1024
45 cap = aline[4][-1] == "%" and aline[4][:-1] or aline[4]
46 om['capacity'] = cap
47 om['mount'] = aline[5]
48 om['id'] = self.prepId(om['mount'], '-')
49 om['title'] = om['mount']
50 rm.append(om)
51 except ValueError: pass
52 return rm
53
55 return "get df -k from server to build filesystems"
56