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