我只想用python脚本打印系统的PowerUsage。我的脚本是监视脚本的一部分。
我收到错误<bound method Node.getCpuPowerUsage of <__main__.Node instance at 0x7f6f60c6b8c0>>
def getPowerUsage(self):
self.powerUsage = os.popen("sudo ipmi-oem intelnm get-node-manager-statistics mode=globalpower | awk '$1 == \"Current\" {print $4}'").read().replace("\n", "")
return self.powerUsage
node1 = Node(0, 0, 0)
node1.getPowerUsage()
node1.getGpuPowerUsage()
node1.getCpuPowerUsage()
print(node1.getPowerUsage)
命令的输出
sudo ipmi-oem intelnm get-node-manager-statistics mode=globalpower | awk '$1 == \"Current\" {print $4}'").read().replace("\n", "")
看起来像这样
$sudo ipmi-oem intelnm get-node-manager-statistics mode=globalpower | awk '$1 == \"Current\" {print $4}'").read().replace("\n", "")
185
答案 0 :(得分:1)
就像gmds所说的那样,将print(node1.getPowerUsage)
替换为print(node1.getPowerUsage())