错误<bound method =“” node.getcpupowerusage =“” of =“” <__ main __。node =“” instance =“” at =“” 0x7f6f60c6b8c0 =“” >>

时间:2019-04-24 08:38:19

标签: python python-3.x ipmi

我只想用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


1 个答案:

答案 0 :(得分:1)

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