def add_maps(self, result, ds): """ Return a list of ObjectMaps with config properties updates for this regionserver and all it's regions. """ oms = [] conf = ConfWrapper(result) oms.append(ObjectMap({ "compname": "hbase_servers/{}".format(self.component), "modname": "Region Server conf", 'handler_count': conf.handler_count, 'memstore_upper_limit': conf.memstore_upper_limit, 'memstore_lower_limit': conf.memstore_lower_limit, 'logflush_interval': conf.logflush_interval })) # All the regions within the region server will have the same # configuration as set in the region server's conf file. for region in ds.region_ids: oms.append(ObjectMap({ "compname": "hbase_servers/{}/regions/{}{}{}".format( ds.component, ds.component, NAME_SPLITTER, prepId(region)), "modname": "Region conf", 'memstore_flush_size': convToUnits(conf.memestore_flush_size), 'max_file_size': convToUnits(conf.max_file_size) })) return oms
def utilDisk(self): usage = self._object.getIntForValue('usageDisk') quota = self._object.getIntForValue('quotaDisk') return "{0} of {1} ({2:.0%})".format( convToUnits(usage, 1024, 'B'), convToUnits(quota, 1024, 'B'), float(usage) / quota)
def add_maps(self, result, ds): """ Return a list of ObjectMaps with config properties updates for this regionserver and all it's regions. """ oms = [] conf = ConfWrapper(result) oms.append( ObjectMap({ "compname": "hbase_servers/{}".format(self.component), "modname": "Region Server conf", 'handler_count': conf.handler_count, 'memstore_upper_limit': conf.memstore_upper_limit, 'memstore_lower_limit': conf.memstore_lower_limit, 'logflush_interval': conf.logflush_interval })) # All the regions within the region server will have the same # configuration as set in the region server's conf file. for region in ds.region_ids: oms.append( ObjectMap({ "compname": "hbase_servers/{}/regions/{}{}{}".format( ds.component, ds.component, NAME_SPLITTER, prepId(region)), "modname": "Region conf", 'memstore_flush_size': convToUnits(conf.memestore_flush_size), 'max_file_size': convToUnits(conf.max_file_size) })) return oms
def processMemcacheInfo(memcacheinfo): memccheck = ['limit_maxbytes', 'bytes', 'curr_connections', 'evictions'] memclist = {} memcacheinfo.pop(0) for memcline in memcacheinfo: memcline.strip() fieldname, value = memcline.split() fieldname = fieldname.strip() fieldname = fieldname.strip('\t') if fieldname == 'limit_maxbytes': temp_value = int(value) final_value = convToUnits(temp_value, 1024, "B") memclist['Maximum Size'] = final_value if fieldname == 'bytes': temp_value = int(value) final_value = convToUnits(temp_value, 1024, "B") memclist['Current Size'] = final_value if fieldname == 'curr_connections': final_value = int(value) memclist['Current Connections'] = final_value if fieldname == 'evictions': final_value = int(value) memclist['Evictions'] = final_value # if memclist.has_key('Maximum Size') and memclist.has_key('Current Size'): # memclist['Utilization'] = memclist['Current Size'] / memclist['Maximum Size'] * 100 return memclist
def processCpuInfo(cpuinfo): cpucheck = ['processor', 'model name', 'cpu MHz', 'cache size'] cpulist = {} cpusummary = {} cpusummary['sockets'] = 0 cpusummary['cores'] = 0 cpusummary['hyperthreadcores'] = 0 cpusummary['socketlist'] = {} cpusummary['corelist'] = {} for cpuline in cpuinfo: if cpuline.count(':'): fieldname, value = cpuline.split(':') fieldname = fieldname.strip() fieldname = fieldname.strip('\t') if fieldname == 'virtualization platform': cpusummary['virtualization platform'] = value.strip() if fieldname == 'cpu cores': cpusummary['cores'] = int(value.strip()) if fieldname == 'siblings': cpusummary['hyperthreadcores'] = int(value.strip()) if fieldname == 'physical id': socket = int(value.strip()) if not socket in cpusummary['socketlist']: cpusummary['socketlist'][socket] = 1 if cpucheck.count(fieldname): if fieldname == 'processor': proc_num = int(value.strip()) cpulist[proc_num] = {} cpusummary['corelist'][proc_num] = 1 else: cpulist[proc_num][fieldname] = value.strip() if fieldname == 'cpu MHz': temp_value = float(value.strip()) * 1000 * 1000 final_value = convToUnits(temp_value, 1000, 'Hz') cpulist[proc_num][fieldname] = final_value if fieldname == 'cache size': temp_value = int(value.strip('KB')) * 1024 final_value = convToUnits(temp_value, 1024, "B") cpulist[proc_num][fieldname] = final_value cpusummary['sockets'] = len(cpusummary['socketlist']) del cpusummary['socketlist'] if cpusummary['cores'] == 0: cpusummary['cores'] = len(cpusummary['corelist']) del cpusummary['corelist'] if cpusummary['hyperthreadcores'] == cpusummary['cores']: cpusummary[ 'hyperthreadcores'] = 'No hyperthreading (note: may not be accurate for virtual guests)' cpusummary['model name'] = cpulist[0]['model name'] cpusummary['cpu speed'] = cpulist[0]['cpu MHz'] cpusummary['cache size'] = cpulist[0]['cache size'] if cpusummary['sockets'] == 0: del cpusummary['sockets'] if cpusummary['hyperthreadcores'] == 0: del cpusummary['hyperthreadcores'] if not (cpusummary['virtualization platform'].lower().count("virtual") or cpusummary['virtualization platform'].lower().count("kvm")): cpusummary['virtualization platform'] = 'Unable to detect' return cpusummary
def process(self, device, results, log): """collect CIM information from this device""" log.info('processing %s for device %s', self.name(), device.id) rm = self.relMap() for instance in results.get("CIM_PhysicalMemory", []): om = self.objectMap(instance) try: if om._slot: om.slot = "%s_0" % om._slot om.slot, board = MODULENAME.search(om.slot).groups() om.id = self.prepId( "Board%s %s%s" % (board, self.slottypes.get(om._slottype, 'Slot'), om.slot)) if om.size > 0: model = [] if not om._manufacturer: om._manufacturer = '' model.append(getattr(om, '_manufacturer', '')) if self.technologies.get(om._technology, '') != '': model.append(self.technologies.get(om._technology, '')) if self.slottypes.get(om._slottype, '') != '' and om._slottype > 1: model.append(self.slottypes.get(om._slottype, '')) model.append(convToUnits(om.size)) if getattr(om, '_frequency', 0) > 0: model.append("%sMHz" % getattr(om, '_frequency', 0)) if getattr(om, '_speed', 0) > 0: model.append("%sns" % getattr(om, '_speed', 0)) om.setProductKey = "%s" % " ".join(model) except AttributeError: continue rm.append(om) return rm
def process(self, device, results, log): """collect snmp information from this device""" log.info('processing %s for device %s', self.name(), device.id) getdata, tabledata = results rm = self.relMap() for oid, card in tabledata.get('memoryModulesTable', {}).iteritems(): try: om = self.objectMap(card) om.snmpindex = oid.strip('.') om.slot = om.slot.split()[-1] om.id = self.prepId('%s %s' % (getattr(om,'_banck','0'), getattr(om, 'id', om.slot))) om.size = getattr(om, 'size', 0) if om.size > 0: model = [] if getattr(om, '_manufacturer', 'null') != 'null': model.append(getattr(om, '_manufacturer', '')) manuf = getattr(om, '_manufacturer', '') else: manuf = 'Unknown' if self.technologies.get(om._technology, '') != '': model.append(self.technologies.get(om._technology, '')) if 2 < int(getattr(om, '_slottype', 0)) < 24: model.append(self.slottypes[int(om._slottype)]) model.append(convToUnits(om.size)) if getattr(om, '_frequency', 0) > 0: model.append("%sMHz" % getattr(om, '_frequency', 0)) if getattr(om, '_speed', 'null') != 'null': model.append("%sns" % getattr(om, '_speed', 0)) om.setProductKey = MultiArgs(" ".join(model), manuf) if getattr(om, '_active', 0) == 0: om.monitor = False om.status = 0 except AttributeError: continue rm.append(om) return rm
def process(self, device, results, log): """collect CIM information from this device""" log.info('processing %s for device %s', self.name(), device.id) rm = self.relMap() for instance in results.get("CIM_PhysicalMemory", []): om = self.objectMap(instance) try: if om._slot: om.slot = "%s_0" % om._slot om.slot, board = MODULENAME.search(om.slot).groups() om.id = self.prepId("Board%s %s%s" % (board, self.slottypes.get(om._slottype,'Slot'), om.slot)) if om.size > 0: model = [] if not om._manufacturer: om._manufacturer = '' model.append(getattr(om, '_manufacturer', '')) if self.technologies.get(om._technology, '') != '': model.append(self.technologies.get(om._technology, '')) if self.slottypes.get(om._slottype, '') != '' and om._slottype > 1: model.append(self.slottypes.get(om._slottype, '')) model.append(convToUnits(om.size)) if getattr(om, '_frequency', 0) > 0: model.append("%sMHz" % getattr(om, '_frequency', 0)) if getattr(om, '_speed', 0) > 0: model.append("%sns" % getattr(om, '_speed', 0)) om.setProductKey = "%s" % " ".join(model) except AttributeError: continue rm.append(om) return rm
def usedBlocksString(self): """ Return the number of used blocks in human readable form ie 10MB """ __pychecker__='no-constCond' ub = self.usedBlocks() return ub is None and "unknown" or convToUnits(ub)
def availBytesString(self): """ Return the number of availible bytes in human readable form ie 10MB """ __pychecker__='no-constCond' ab = self.availBytes() return ab is None and "unknown" or convToUnits(ab)
def process(self, device, results, log): """collect snmp information from this device""" log.info('processing %s for device %s', self.name(), device.id) getdata, tabledata = results cardtable = tabledata.get('memoryDeviceTable') rm = self.relMap() for oid, card in cardtable.iteritems(): try: om = self.objectMap(card) om.snmpindex = oid.strip('.') om.id = self.prepId( getattr(om, '_location', 'Unknown').strip()) if hasattr(om, 'size'): om.size = om.size * 1024 om.moduletype = self.moduletypes.get( getattr(om, 'moduletype', 1), '%s (%d)' % (self.moduletypes[1], om.moduletype)) if om.size > 0: model = [] om._manuf = getattr(om, '_manuf', 'Unknown').split('(')[0].strip() if not om._manuf: om._manuf = 'Unknown' model.append(om._manuf) model.append(om.moduletype) model.append(convToUnits(om.size)) if getattr(om, 'frequency', 0) > 0: model.append("%sMHz" % getattr(om, 'frequency', 0)) om.setProductKey = MultiArgs("%s" % " ".join(model), om._manuf) else: om.monitor = False except AttributeError: continue rm.append(om) return rm
def niceSpeed(self): """ Return a string that expresses self.speed in reasonable units. """ if not self.speed: return 'Unknown' return convToUnits(self.speed, divby=1000, unitstr='bps')
def availString(self): """ Return the Available bytes in human readable form ie 10MB """ sa = long(self.totalBytes()) - long(self.usedBytes()) if 0 > sa: sa = 0 return convToUnits(sa)
def process(self, device, results, log): """collect snmp information from this device""" log.info("processing %s for device %s", self.name(), device.id) getdata, tabledata = results cardtable = tabledata.get("memoryDeviceTable") rm = self.relMap() for oid, card in cardtable.iteritems(): try: om = self.objectMap(card) om.snmpindex = oid.strip(".") om.id = self.prepId(getattr(om, "_location", "Unknown").strip()) if hasattr(om, "size"): om.size = om.size * 1024 om.moduletype = self.moduletypes.get( getattr(om, "moduletype", 1), "%s (%d)" % (self.moduletypes[1], om.moduletype) ) if om.size > 0: model = [] om._manuf = getattr(om, "_manuf", "Unknown").split("(")[0].strip() if not om._manuf: om._manuf = "Unknown" model.append(om._manuf) model.append(om.moduletype) model.append(convToUnits(om.size)) if getattr(om, "frequency", 0) > 0: model.append("%sMHz" % getattr(om, "frequency", 0)) om.setProductKey = MultiArgs("%s" % " ".join(model), om._manuf) else: om.monitor = False except AttributeError: continue rm.append(om) return rm
def process(self, device, results, log): """collect snmp information from this device""" log.info('processing %s for device %s', self.name(), device.id) getdata, tabledata = results rm = self.relMap() for oid, card in tabledata.get('memoryDeviceTable', {}).iteritems(): try: om = self.objectMap(card) om.snmpindex = oid.strip('.') om.id = self.prepId(getattr(om, '_location', 'Unknown').strip()) om.size = int(getattr(om, 'size', 0)) * 1024 if om.size > 0: model = [] om._manuf=getattr(om,'_manuf','Unknown').split('(')[0].strip() if not om._manuf: om._manuf = 'Unknown' model.append(om._manuf) model.append(self.moduletypes.get(getattr(om, '_mtype', 1), 'Other (%s)'%om._mtype)) model.append(convToUnits(om.size)) if getattr(om, 'frequency', 0) > 0: model.append("%sMHz" % getattr(om, 'frequency', 0)) om.setProductKey = MultiArgs(" ".join(model), om._manuf) else: om.monitor = False except AttributeError: continue rm.append(om) return rm
def usedBlocksString(self): """ Return the number of used blocks in human readable form ie 10MB """ __pychecker__ = 'no-constCond' ub = self.usedBlocks() return ub is None and "unknown" or convToUnits(ub)
def availBytesString(self): """ Return the number of availible bytes in human readable form ie 10MB """ __pychecker__ = 'no-constCond' ab = self.availBytes() return ab is None and "unknown" or convToUnits(ab)
def sizeString(self): """ Return the number of total bytes in human readable form ie 10MB """ if self.size > 0: return convToUnits(self.size) else: return ''
def main_loop(self): """Execute once-per-cycletime tasks.""" if self.options.worker: node_paths = self.get_paths_and_uuids(uuids=False)[0] else: node_paths, node_uuids = self.get_paths_and_uuids(uuids=True) self.log.info("pruning non-existent nodes") connections.compact(node_uuids) if connections.should_optimize(self.options.optimize_interval): self.log.info("optimizing database") connections.optimize() self.log.info("finished optimizing database") # Paths must be sorted for workers to get the right chunks. node_paths.sort() # Start workers if configured, but only if cycling. if self.options.workers > 0 and self.options.cycle: chunk_size = int( math.ceil(len(node_paths) / float(self.options.workers))) self.log.info( "starting %s workers (%s nodes each)", self.options.workers, chunk_size) for i in xrange(self.options.workers): self.start_worker(i, chunk_size) return if self.options.worker: start = self.options.offset * self.options.chunk node_paths = node_paths[start:start + self.options.chunk] self.log.info("checking %s nodes", len(node_paths)) start_time = datetime.datetime.now() start_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss updated = self.update_nodes(node_paths) end_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss end_time = datetime.datetime.now() duration = end_time - start_time growth = (end_rss - start_rss) * 1024 self.log.info( "updated %s of %s nodes (%s in %s)", updated, len(node_paths), convToUnits(growth, 1024.0, "B"), duration)
def processMemInfo(meminfo): memcheck = ['MemTotal', 'MemFree', 'SwapTotal', 'SwapFree'] memlist = {} for memline in meminfo: if memline.count(':') == 1: fieldname, value = memline.split(':') fieldname = fieldname.strip() fieldname = fieldname.strip('\t') if memcheck.count(fieldname): temp_value = int(value.strip('kB')) * 1024 final_value = convToUnits(temp_value, 1024, "B") memlist[fieldname] = final_value return memlist
def _block_size(column_families): """ Return the value for column family block size property. @param column_families: list of table's column families @type column_families: list @return: string value """ result = [ '{}: {}; '.format( family.get('name'), convToUnits(family.get('BLOCKSIZE')) ) for family in column_families ] return ''.join(result).rstrip("; ")
def update_nodes(self, paths): """Update nodes given paths.""" updated = 0 progress = ProgressLogger(self.log, total=len(paths), interval=60) for node in nodes_from_paths(self.dmd.Devices, paths): progress.increment() if not node.getZ("zL2UpdateInBackground", True): self.log.debug("%s: zL2UpdateInBackground = False", node.id) continue start_time = datetime.datetime.now() start_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss try: added = connections.update_node(node, force=self.options.force) except Exception: self.log.exception("%s: unexpected exception while updating", node.id) continue if added: end_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss end_time = datetime.datetime.now() duration = end_time - start_time growth = (end_rss - start_rss) * 1024 long_time = duration.total_seconds() > LONG_TIME high_memory = growth > HIGH_MEMORY if long_time and high_memory: log_level = logging.INFO else: log_level = logging.DEBUG self.log.log( log_level, "%s: updated (%s in %s)", node.id, convToUnits(growth, 1024.0, "B"), duration) updated += 1 else: self.log.debug("%s: already up to date", node.id) return updated
def process(self, device, results, log): """collect snmp information from this device""" log.info('processing %s for device %s', self.name(), device.id) getdata, tabledata = results cardtable = tabledata.get('cpqHeResMem2ModuleTable', {}) if not cardtable: mmstt = tabledata.get('cpqHeResMemModuleTable', {}) cardtable = tabledata.get('cpqSiMemModuleTable', {}) for oid in cardtable.keys(): cardtable[oid]['status'] = mmstt.get(oid, {}).get('status', 1) self.maptype = "cpqSiMemModule" self.modname = "ZenPacks.community.HPMon.cpqSiMemModule" rm = self.relMap() for oid, card in cardtable.iteritems(): try: om = self.objectMap(card) om.snmpindex = oid.strip('.') om.id = self.prepId( "Board%d %s%d" % (om._boardindex, self.slottypes.get(om._slottype, 'Slot'), om.slot)) om.size = getattr(om, 'size', 0) * 1024 if om.size > 0: model = [] if getattr(om, '_manufacturer', '') != '': model.append(getattr(om, '_manufacturer', '')) manuf = getattr(om, '_manufacturer', '') else: manuf = 'Unknown' if self.technologies.get(om._technology, '') != '': model.append(self.technologies.get(om._technology, '')) if 2 < int(getattr(om, '_slottype', 0)) < 19: model.append(self.slottypes[int(om._slottype)]) model.append(convToUnits(om.size)) if getattr(om, '_frequency', 0) > 0: model.append("%sMHz" % getattr(om, '_frequency', 0)) if getattr(om, '_speed', 0) > 0: model.append("%sns" % getattr(om, '_speed', 0)) om.setProductKey = MultiArgs(" ".join(model), manuf) else: om.monitor = False rm.append(om) except AttributeError: continue return rm
def _getProductKey(self, results, inst): model = [] manuf = inst.get("_manuf") or "Unknown" model = inst.get("setProductKey") or [] if model: return MultiArgs(model, manuf) model.append(manuf) try: if int((inst.get("_technology") or 0)) in self.technologies: model.append(self.technologies[int(inst["_technology"])]) if int((inst.get("_slottype") or 0)) in self.slottypes: model.append(self.slottypes[int(inst["_slottype"])]) model.append(convToUnits(int((inst.get("size") or 0)))) except: pass if int((inst.get("_frequency") or 0)) > 0: model.append("%sMHz"%inst["_frequency"]) if int((inst.get("_speed") or 0)) > 0: model.append("%sns"%inst["_speed"]) return MultiArgs(" ".join(model), manuf)
def process(self, device, results, log): """collect snmp information from this device""" log.info('processing %s for device %s', self.name(), device.id) getdata, tabledata = results cardtable = tabledata.get('cpqHeResMem2ModuleTable', {}) if not cardtable: mmstt = tabledata.get('cpqHeResMemModuleTable', {}) cardtable = tabledata.get('cpqSiMemModuleTable', {}) for oid in cardtable.keys(): cardtable[oid]['status'] = mmstt.get(oid, {}).get('status', 1) self.maptype = "cpqSiMemModule" self.modname = "ZenPacks.community.HPMon.cpqSiMemModule" rm = self.relMap() for oid, card in cardtable.iteritems(): try: om = self.objectMap(card) om.snmpindex = oid.strip('.') om.id = self.prepId("Board%d %s%d" % (om._boardindex, self.slottypes.get(om._slottype,'Slot'), om.slot)) om.size = getattr(om, 'size', 0) * 1024 if om.size > 0: model = [] if getattr(om, '_manufacturer', '') != '': model.append(getattr(om, '_manufacturer', '')) manuf = getattr(om, '_manufacturer', '') else: manuf = 'Unknown' if self.technologies.get(om._technology, '') != '': model.append(self.technologies.get(om._technology, '')) if 2 < int(getattr(om, '_slottype', 0)) < 19: model.append(self.slottypes[int(om._slottype)]) model.append(convToUnits(om.size)) if getattr(om, '_frequency', 0) > 0: model.append("%sMHz" % getattr(om, '_frequency', 0)) if getattr(om, '_speed', 0) > 0: model.append("%sns" % getattr(om, '_speed', 0)) om.setProductKey = MultiArgs(" ".join(model), manuf) else: om.monitor = False rm.append(om) except AttributeError: continue return rm
def process(self, device, results, log): """collect snmp information from this device""" log.info('processing %s for device %s', self.name(), device.id) getdata, tabledata = results mmstatustable = tabledata.get('cpqHeResMemModuleTable') cardtable = tabledata.get('cpqSiMemModuleTable') statusmap ={} rm = self.relMap() for oid, card in mmstatustable.iteritems(): statusmap[oid.strip('.')] = int(card['status']) for oid, card in cardtable.iteritems(): try: om = self.objectMap(card) om.snmpindex = '%s.%s'%(om._boardindex, om.slot) om.id = self.prepId("Board%d %s%d" % (om._boardindex, self.slottypes.get(om._slottype,'Slot'), om.slot)) om.status = statusmap.get(om.snmpindex, None) if not om.status: om.status = 1 om.monitor = False if hasattr(om, 'size'): om.size = om.size * 1024 if om.size > 0: model = [] if getattr(om, '_manufacturer', '') != '': model.append(getattr(om, '_manufacturer', '')) if self.technologies.get(om._technology, '') != '': model.append(self.technologies.get(om._technology, '')) if self.slottypes.get(om._slottype, '') != '' and om._slottype > 1: model.append(self.slottypes.get(om._slottype, '')) model.append(convToUnits(om.size)) if getattr(om, '_frequency', 0) > 0: model.append("%sMHz" % getattr(om, '_frequency', 0)) if getattr(om, '_speed', 0) > 0: model.append("%sns" % getattr(om, '_speed', 0)) om.setProductKey = "%s" % " ".join(model) else: om.monitor = False except AttributeError: continue rm.append(om) return rm
def get_graph(self, entity): """Return full networkx.Graph starting at entity. This behaves as a read-through cache to connections.networkx_graph(). Cached entries expire after a certain amount of time. See gateways_cache in the clear_caches method for how long. """ # Maybe a graph is already cached for entity. cached_graph = self.graphs_cache.get(entity) if cached_graph: return cached_graph # Maybe entity exists in a graph cached for a different entity. for g in self.graphs_cache.values(): if g and entity in g: return g # I don't know how big these graphs can get. So it's important to # log when we're building graphs, how long it takes, and how much # memory caching them is going to consume. start = datetime.datetime.now() g = connections.networkx_graph(entity, ["layer2"]) elapsed = datetime.datetime.now() - start if g is None: nodes = 0 size = 0 else: nodes = len(g) size = sys.getsizeof(g.node) + sys.getsizeof(g.edge) LOG.info( "cached network graph for %s (%s nodes: %s in %s)", entity, nodes, convToUnits(number=size, divby=1024.0, unitstr="B"), elapsed) self.graphs_cache.set(entity, g) return g
def tableSizeString(self): return convToUnits(self._object.getIntForValue('size'), 1024, 'B')
def availBytesString(self): return convToUnits((self.totalBytes() - self.usedBytes()), divby=1024)
def totalBytesString(self): return convToUnits(self.totalBytes(), divby=1024)
def getLogDiskReservedCapacity(self): return convToUnits( self.cacheRRDValue('LogDiskReservedCapacity', 0) * 512)
def sizeString(self): """ Return the number of total bytes in human readable form ie 10MB """ return convToUnits(self.size,divby=1000)
def cacheSizeString(self): return convToUnits(self.cacheSize)
def size(self): return convToUnits(self._object.size)
def utilMemory(self): return "{0} of {1} ({2:.0%})".format( convToUnits(self.usageMemory, 1024, 'B'), convToUnits(self.limitMemory, 1024, 'B'), float(self.usageMemory) / self.limitMemory)
def humanBits(self, value, scale=1, unitstr="b"): if value is None: return UNAVAILABLE return convToUnits(value * scale, 1000, unitstr=unitstr)
def usageDisk(self): return convToUnits( self._object.getIntForValue('usageDisk'), 1024, 'B')
def flavorDiskString(self): return convToUnits(self._object.flavorDisk, 1024, 'B')
def cacheSizeString(self): """ Return the cache size in human readable form ie 10MB """ return convToUnits(self.cacheSize)
def sizeString(self): """ Return the number of total bytes in human readable form ie 10MB """ return convToUnits(self.size, divby=1000)
def speedString(self): """ Return the speed in human readable form ie 10MB """ return convToUnits(self.speed, divby=1024)
def resourcesMemory(self): return convToUnits( self._object.getIntForValue('resourcesMemory'), 1024, 'B')
def totalSwapString(self): return self.totalSwap and convToUnits(self.totalSwap) or 'Unknown'
def resourcesDisk(self): return convToUnits( self._object.getIntForValue('resourcesDisk'), 1024, 'B')
def totalMemoryString(self): return self.totalMemory and convToUnits(self.totalMemory) or 'Unknown'
def flavorRAMString(self): return convToUnits(self._object.flavorRAM, 1024, 'B')
def size(self): return convToUnits(self._object.size, divby=1000.00)
def sizeString(self): return convToUnits(self.size, divby=1000)
def totalBytesString(self): """ Return the number of total bytes in human readable form ie 10MB """ return convToUnits(self.totalBytes(), divby=1024)
def usedBytesString(self): return convToUnits(self.usedBytes(), divby=1024)
def memoryString(self): return convToUnits(self.memory * 1024 * 1024)
def totalBytesString(self): """ Return the number of total bytes in human readable from ie 10MB """ return convToUnits(self.totalBytes())
def stripesizeString(self): """ Return the Stripes Size in human readable form ie 64Kb """ return convToUnits(self.stripesize)
if master_hostname.count(db_params['host'].lower()): out.write("* ZODB on Master\n\n\n") master_info['database']['zodb']['host'] = 'master' else: out.write("* ZODB on " + db_params['host'] + "\n\n\n") master_info['database']['zodb']['host'] = db_params['host'] dbsizes, stderr = executeDbSql( zep_db, "SELECT table_schema,round(SUM(data_length+index_length)/1024/1024,1) AS size_mb FROM information_schema.tables WHERE table_schema IN ('zodb','zodb_session','zenoss_zep') GROUP BY table_schema;" ) out.write("* Database sizes\n\n") master_info['database']['sizes'] = {} for dbsize in dbsizes.splitlines(): dbname, dbsizeval = dbsize.split('\t') dbsizeval = int(float(dbsizeval) * 1024 * 1024) out.write(" * " + dbname + ": " + convToUnits(dbsizeval, 1000, "B") + "\n") master_info['database']['sizes'][dbname] = convToUnits( dbsizeval, 1000, "B") except Exception as ex: out.write(" Unable to retrieve information for this section: %s\n" % ex.message) out.write("\n\n") #Try to get version information (currently only works on 4.2.x) out.write("Version information\n") out.write( "=============================================================================================================================================================\n" ) out.write("\n") try: