2024-11-28 00:04:57 -05:00
|
|
|
#! /bin/python3
|
|
|
|
|
2024-12-02 23:32:33 -05:00
|
|
|
# Why does this program continuously print instead of accumulating the results
|
|
|
|
# and printing them at the end? Because of indefinite program runtime!
|
|
|
|
|
2024-11-28 00:04:57 -05:00
|
|
|
# For the sake of simplicity, this script will only return the power info
|
|
|
|
# for the first socket of Ampere Altra nodes.
|
|
|
|
|
|
|
|
import argparse, subprocess
|
2024-12-02 23:32:33 -05:00
|
|
|
import sys
|
2024-11-28 00:04:57 -05:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('-s', '--seconds', type=int)
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
arch = subprocess.run(['uname', '-m'], stdout=subprocess.PIPE, text=True).stdout.strip()
|
|
|
|
if arch == "aarch64":
|
|
|
|
import time
|
|
|
|
upper_bound = args.seconds if args.seconds is not None else -1
|
|
|
|
i = 0
|
|
|
|
while i != upper_bound:
|
|
|
|
proc = subprocess.Popen(['sensors'], stdout=subprocess.PIPE)
|
|
|
|
proc = subprocess.Popen(['awk', '/CPU power:/ {print $3}'], stdin=proc.stdout, stdout=subprocess.PIPE, text=True)
|
|
|
|
power = proc.communicate()[0].strip().split('\n')[0]
|
|
|
|
print(power)
|
|
|
|
|
|
|
|
i += 1
|
|
|
|
time.sleep(1)
|
|
|
|
elif arch == "x86_64":
|
|
|
|
pass
|