def writeRootSummary(self): ''' This method updates the RRD summary files.''' ds = DataStore() rootNode = ds.rootElement # If there isn't a root node then there is not need to continue. if rootNode is None: return # Get a lock on the data store. ds.acquireLock(self) try: gmetadConfig = getConfig() # Create the summary RRD base path and validate it rootPath = '%s/__SummaryInfo__' % self.cfg[RRDPlugin.RRD_ROOTDIR] self._checkDir(rootPath) # Update metrics for each grid node (there should only be one.) for gridNode in rootNode: # If there isn't any summary data, then no need to continue. if not hasattr(gridNode, 'summaryData'): continue # Update metrics RRDs for each cluster summary in the grid for metricNode in gridNode.summaryData['summary'].itervalues(): # Create the summary RRD final path and validate it. rrdPath = '%s/%s.rrd' % (rootPath, metricNode.getAttr('name')) # if the RRD file doesn't exist then create it if not os.path.isfile(rrdPath): self._createRRD(rootNode, metricNode, rrdPath, 15, True) #need to do some error checking here if the createRRD failed # Update the RRD file. self._updateRRD(rootNode, metricNode, rrdPath, True) except Exception, e: logging.error('Error writing to summary RRD %s' % str(e))
def writeRootSummary(self): ''' This method updates the RRD summary files.''' ds = DataStore() rootNode = ds.rootElement # If there isn't a root node then there is not need to continue. if rootNode is None: return # Get a lock on the data store. ds.acquireLock(self) try: gmetadConfig = getConfig() # Create the summary RRD base path and validate it rootPath = '%s/__SummaryInfo__'%self.cfg[RRDPlugin.RRD_ROOTDIR] self._checkDir(rootPath) # Update metrics for each grid node (there should only be one.) for gridNode in rootNode: # If there isn't any summary data, then no need to continue. if not hasattr(gridNode, 'summaryData'): continue # Update metrics RRDs for each cluster summary in the grid for metricNode in gridNode.summaryData['summary'].itervalues(): # Create the summary RRD final path and validate it. rrdPath = '%s/%s.rrd'%(rootPath,metricNode.getAttr('name')) # if the RRD file doesn't exist then create it if not os.path.isfile(rrdPath): self._createRRD(rootNode, metricNode, rrdPath, 15, True) #need to do some error checking here if the createRRD failed # Update the RRD file. self._updateRRD(rootNode, metricNode, rrdPath, True) except Exception, e: logging.error('Error writing to summary RRD %s'%str(e))
try: pffd = open(gmetadConfig[GmetadConfig.PIDFILE], 'w') pffd.write('%d\n' % os.getpid()) logging.debug('Wrote pid %d to pidfile %s' % (os.getpid(), gmetadConfig[GmetadConfig.PIDFILE])) pffd.close() pffd = open(gmetadConfig[GmetadConfig.PIDFILE], 'r') except Exception as e: logging.error('Unable to write PID %d to %s (%s)' % (os.getpid(), gmetadConfig[GmetadConfig.PIDFILE], e)) sys.exit() # Switch to non-priviledged user if running as root if not os.getuid(): setuid() # Initialize the data store with the notifier and summery threads and plugins dataStore = DataStore() readers = [] xmlSocket = XmlSocket() interactiveSocket = InteractiveSocket() try: try: # Create the gmond data source reader threads. for ds in gmetadConfig[GmetadConfig.DATA_SOURCE]: readers.append(GmondReader(ds)) gr = readers[len(readers)-1] gr.start() # Open the XML ports xmlSocket.open(port=int(gmetadConfig[GmetadConfig.XML_PORT])) interactiveSocket.open(port=int(gmetadConfig[GmetadConfig.INTERACTIVE_PORT])) # Use asyncore to handle all of the network socket traffic
try: pffd = open(gmetadConfig[GmetadConfig.PIDFILE], 'w') pffd.write('%d\n' % os.getpid()) logging.debug('Wrote pid %d to pidfile %s' % (os.getpid(), gmetadConfig[GmetadConfig.PIDFILE])) pffd.close() pffd = open(gmetadConfig[GmetadConfig.PIDFILE], 'r') except Exception, e: logging.error('Unable to write PID %d to %s (%s)' % (os.getpid(), gmetadConfig[GmetadConfig.PIDFILE], e)) sys.exit() # Switch to non-priviledged user if running as root if not os.getuid(): setuid() # Initialize the data store with the notifier and summery threads and plugins dataStore = DataStore() readers = [] xmlSocket = XmlSocket() interactiveSocket = InteractiveSocket() try: try: # Create the gmond data source reader threads. for ds in gmetadConfig[GmetadConfig.DATA_SOURCE]: readers.append(GmondReader(ds)) gr = readers[len(readers)-1] gr.start() # Open the XML ports xmlSocket.open(port=int(gmetadConfig[GmetadConfig.XML_PORT])) interactiveSocket.open(port=int(gmetadConfig[GmetadConfig.INTERACTIVE_PORT])) # Use asyncore to handle all of the network socket traffic