本文整理匯總了Python中datalogger.DataLogger.tsastat_group_by方法的典型用法代碼示例。如果您正苦於以下問題:Python DataLogger.tsastat_group_by方法的具體用法?Python DataLogger.tsastat_group_by怎麽用?Python DataLogger.tsastat_group_by使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類datalogger.DataLogger
的用法示例。
在下文中一共展示了DataLogger.tsastat_group_by方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: sr_vicenter_unused_mem
# 需要導入模塊: from datalogger import DataLogger [as 別名]
# 或者: from datalogger.DataLogger import tsastat_group_by [as 別名]
def sr_vicenter_unused_mem(args):
"""
special resport to find virtual machine which are not used their ram entirely
on this machines there is a possibility to save some virtual memory
works only for VMware machine, in special virtualMachineMemoryStats
"""
datestring = args[0]
datalogger = DataLogger(basedir, "vicenter", "virtualMachineMemoryStats")
tsastat = datalogger.load_tsastats(datestring)
tsastat_g = datalogger.tsastat_group_by(tsastat, ("hostname", ))
data = []
data.append(("hostname", "avg_active_max", "avg_granted_min", "avg_notused_min"))
for key in tsastat_g.keys():
not_used = tsastat_g[key]["mem.granted.average"]["min"] - tsastat_g[key]["mem.active.average"]["max"]
data.append((key[0], "%0.2f" % tsastat_g[key]["mem.active.average"]["max"], "%0.3f" % tsastat_g[key]["mem.granted.average"]["min"], "%0.2f" % not_used))
return json.dumps(data)
示例2: sr_vicenter_unused_cpu_cores
# 需要導入模塊: from datalogger import DataLogger [as 別名]
# 或者: from datalogger.DataLogger import tsastat_group_by [as 別名]
def sr_vicenter_unused_cpu_cores(args):
"""
special report to find virtual machine which re not used their virtual core entirely
on this machine there is a possibility to save some virtual cores
works only for VMware machines, in special virtualMachineCpuStats
"""
datestring = args[0]
datalogger = DataLogger(basedir, "vicenter", "virtualMachineCpuStats")
tsastat = datalogger.load_tsastats(datestring)
tsastat_g = datalogger.tsastat_group_by(tsastat, ("hostname", ))
data = []
data.append(("hostname", "avg_idle_min", "avg_used_avg", "avg_used_max"))
for key in tsastat_g.keys():
num_cpu = sum([key[0] in index_key for index_key in tsastat.keys()])
if num_cpu < 3:
continue
data.append((key[0], "%0.2f" % tsastat_g[key]["cpu.idle.summation"]["min"], "%0.2f" % tsastat_g[key]["cpu.used.summation"]["avg"], "%0.2f" % tsastat_g[key]["cpu.used.summation"]["max"]))
return json.dumps(data)
示例3: sr_hrstorageram_unused
# 需要導入模塊: from datalogger import DataLogger [as 別名]
# 或者: from datalogger.DataLogger import tsastat_group_by [as 別名]
def sr_hrstorageram_unused(args):
"""
special report to find servers which are not using their ram entirely
specially on virtual machines are is a huge saving potential
works only for snmp data especially hrStorageTable
"""
datestring = args[0]
datalogger = DataLogger(basedir, "snmp", "hrStorageTable")
tsastat = datalogger.load_tsastats(datestring)
data = []
data.append(("hostname", "hrStorageSizeKb", "hrStorageUsedKb", "hrStorageNotUsedKbMin", "hrStorageNotUsedPct"))
for index_key in tsastat.keys():
# (u'srvcacdbp1.tilak.cc', u'Physical Memory',
# u'HOST-RESOURCES-TYPES::hrStorageRam')
if u'HOST-RESOURCES-TYPES::hrStorageRam' not in index_key:
del tsastat[index_key]
for key, tsstat in datalogger.tsastat_group_by(tsastat, ("hostname", )).items():
sizekb = tsstat["hrStorageSize"]["min"] * tsstat["hrStorageAllocationUnits"]["max"] / 1024
usedkb = tsstat["hrStorageUsed"]["max"] * tsstat["hrStorageAllocationUnits"]["max"] / 1024
notused = sizekb - usedkb
notused_pct = 100.0 * notused / sizekb
data.append((key[0], "%0.2f" % sizekb, "%0.2f" % usedkb, "%0.2f" % notused, "%0.2f" % notused_pct))
return json.dumps(data)