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

Source Code for Module DataCollector.CommandParsers.Unix_df_k

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
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   
24 -class Unix_df_k(CommandParser):
25 26 command = 'df -k' 27
28 - def condition(self, device, log):
29 pp = device.getPrimaryPath() 30 return "Linux" in pp or "Darwin" in pp
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
54 - def description(self):
55 return "get df -k from server to build filesystems"
56