本文整理汇总了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)