-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Huamin Chen <[email protected]>
- Loading branch information
Showing
8 changed files
with
144 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
[ | ||
"abs((rate(kepler_{level}_package_joules_total{{{query}, job='metal', mode='dynamic'}}[{interval}]) - on() rate(kepler_node_platform_joules_total{{{vm_query}}}[{interval}])) / on() rate(kepler_{level}_package_joules_total{{{query}, job='metal', mode='dynamic'}}[{interval}]))", | ||
"abs((rate(kepler_{level}_platform_joules_total{{{query}, job='metal', mode='dynamic'}}[{interval}]) - on() rate(kepler_node_platform_joules_total{{{vm_query}}}[{interval}])) / on() rate(kepler_{level}_platform_joules_total{{{query}, job='metal', mode='dynamic'}}[{interval}]))" | ||
|
||
"abs((rate(kepler_{level}_package_joules_total{{{query}, job='{metal_job_name}', mode='dynamic'}}[{interval}]) - on() rate(kepler_node_platform_joules_total{{{vm_query}}}[{interval}])) / on() rate(kepler_{level}_package_joules_total{{{query}, job='{metal_job_name}', mode='dynamic'}}[{interval}]))", | ||
"abs((rate(kepler_{level}_platform_joules_total{{{query}, job='{metal_job_name}', mode='dynamic'}}[{interval}]) - on() rate(kepler_node_platform_joules_total{{{vm_query}}}[{interval}])) / on() rate(kepler_{level}_platform_joules_total{{{query}, job='{metal_job_name}', mode='dynamic'}}[{interval}]))" | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# SPDX-FileCopyrightText: 2024-present Sunil Thaha <[email protected]> | ||
# | ||
# SPDX-License-Identifier: APACHE-2.0 | ||
|
||
# a python program to get host and VM cpu spec, dram size, number of cpu cores, and return a json output | ||
import json | ||
import os | ||
import subprocess | ||
import sys | ||
import re | ||
|
||
def parse_lscpu_output(output: str): | ||
cpu_spec = {} | ||
cpu_spec["cpu"] = {} | ||
cpu_spec["cpu"]["model"] = "" | ||
cpu_spec["cpu"]["cores"] = "" | ||
cpu_spec["cpu"]["threads"] = "" | ||
cpu_spec["cpu"]["sockets"] = "" | ||
cpu_spec["cpu"]["flags"] = "" | ||
|
||
for line in output.split("\n"): | ||
if line: | ||
key, value = line.split(":", 1) | ||
if key == "Model name": | ||
cpu_spec["cpu"]["model"] = value.strip() | ||
elif key == "CPU(s)": | ||
cpu_spec["cpu"]["cores"] = value.strip() | ||
elif key == "Thread(s) per core": | ||
cpu_spec["cpu"]["threads"] = value.strip() | ||
elif key == "Socket(s)": | ||
cpu_spec["cpu"]["sockets"] = value.strip() | ||
elif key == "Flags": | ||
cpu_spec["cpu"]["flags"] = value.strip() | ||
return cpu_spec | ||
|
||
def get_host_cpu_spec(): | ||
# get host cpu spec | ||
host_cpu_spec = {} | ||
lscpu = subprocess.run(["lscpu"], stdout=subprocess.PIPE) | ||
if lscpu.stdout: | ||
host_cpu_spec = parse_lscpu_output(lscpu.stdout.decode()) | ||
return host_cpu_spec | ||
|
||
def get_vm_cpu_spec(login: str = "root", vm_addr: str = "my-vm", key_path: str = "/tmp/vm_ssh_key"): | ||
vm_cpu_spec = {} | ||
# run ssh command to get the cpu spec of the VM | ||
ssh = subprocess.run(["ssh", "-i", key_path, login + "@" + vm_addr, "lscpu"], stdout=subprocess.PIPE) | ||
if ssh.stdout: | ||
vm_cpu_spec = parse_lscpu_output(ssh.stdout.decode()) | ||
return vm_cpu_spec | ||
|
||
def get_host_dram_size(): | ||
# get host dram size | ||
dram_size = "" | ||
meminfo = open("/proc/meminfo", "r") | ||
for line in meminfo: | ||
if "MemTotal" in line: | ||
dram_size = line.split(":")[1].strip() | ||
return dram_size | ||
|
||
def get_vm_dram_size(login: str = "root", vm_addr: str = "my-vm", key_path: str = "/tmp/vm_ssh_key"): | ||
# get vm dram size | ||
vm_dram_size = "" | ||
ssh = subprocess.run(["ssh", "-i", key_path, login + "@" + vm_addr, "cat /proc/meminfo"], stdout=subprocess.PIPE) | ||
if ssh.stdout: | ||
for line in ssh.stdout.decode().split("\n"): | ||
if "MemTotal" in line: | ||
vm_dram_size = line.split(":")[1].strip() | ||
return vm_dram_size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ remote: | |
# pkey: ~/.ssh/id_rsa | ||
|
||
metal: | ||
metal_job_name: metal | ||
vm_job_name: vm | ||
vm: | ||
pid: 2093543 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters