Package Products :: Package DataCollector :: Package CommandParsers :: Module Unix_df_k
[hide private]
[frames] | no frames]

Source Code for Module Products.DataCollector.CommandParsers.Unix_df_k

 1  ############################################################################## 
 2  #  
 3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved. 
 4  #  
 5  # This content is made available according to terms specified in 
 6  # License.zenoss under the directory where your Zenoss product is installed. 
 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   
21 -class Unix_df_k(CommandParser):
22 23 command = 'df -k' 24
25 - def condition(self, device, log):
26 pp = device.getPrimaryPath() 27 return "Linux" in pp or "Darwin" in pp
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
51 - def description(self):
52 return "get df -k from server to build filesystems"
53