Package ZenHub :: Package services :: Module ProcessConfig
[hide private]
[frames] | no frames]

Source Code for Module ZenHub.services.ProcessConfig

 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  #! /usr/bin/env python  
14   
15  from PerformanceConfig import PerformanceConfig 
16  from ZODB.POSException import POSError 
17   
18 -class ProcessConfig(PerformanceConfig):
19
20 - def getProcessStatus(self, device=None):
21 "Get the known process status from the Event Manager" 22 from Products.ZenEvents.ZenEventClasses import Status_OSProcess 23 down = {} 24 conn = self.zem.connect() 25 try: 26 curs = conn.cursor() 27 query = ("SELECT device, component, count" 28 " FROM status" 29 " WHERE eventClass = '%s'" % Status_OSProcess) 30 if device: 31 query += " AND device = '%s'" % device 32 curs.execute(query) 33 for device, component, count in curs.fetchall(): 34 down[device] = (component, count) 35 finally: 36 self.zem.close(conn) 37 result = [] 38 for dev in self.config.devices(): 39 try: 40 component, count = down[dev.id] 41 result.append( (dev.id, component, count) ) 42 except KeyError: 43 pass 44 return result
45 46
47 - def getOSProcessConf(self, devices = None):
48 'Get the OS Process configuration for all devices.' 49 result = [] 50 for dev in self.config.devices(): 51 if devices and dev.id not in devices: 52 continue 53 dev = dev.primaryAq() 54 try: 55 procinfo = dev.getOSProcessConf() 56 if procinfo: 57 result.append(procinfo) 58 except POSError: raise 59 except: 60 self.log.exception("device %s", dev.id) 61 return result
62 63
64 - def remote_getOSProcessConf(self, devices=None):
65 return self.getOSProcessConf(devices)
66 67
68 - def remote_getProcessStatus(self, devices=None):
69 return self.getProcessStatus(devices)
70 71
72 - def getDeviceConfig(self, device):
74 75
76 - def sendDeviceConfig(self, listener, config):
77 return listener.callRemote('updateDevice', config)
78