错误 <bound method Node.getCpuPowerUsage of <__main__.Node instance at 0x7f6f60c6b8c0>>

Error <bound method Node.getCpuPowerUsage of <__main__.Node instance at 0x7f6f60c6b8c0>>

我只想在 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 ' == \"Current\" {print }'").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 ' == \"Current\" {print }'").read().replace("\n", "") 看起来像这样

$sudo ipmi-oem intelnm get-node-manager-statistics mode=globalpower | awk ' == \"Current\" {print }'").read().replace("\n", "")
 185


只需将 print(node1.getPowerUsage) 替换为 print(node1.getPowerUsage()),就像 gmds 所说的那样