-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add metrics ipmi_dcmi_power_consumption_rate
Add new ipmi-dcmi metrics Rate = power consumption / maximum power consumption
- Loading branch information
Showing
3 changed files
with
99 additions
and
4 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
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,32 @@ | ||
"""Lshw metrics collector.""" | ||
import json | ||
from logging import getLogger | ||
from typing import Dict, List | ||
|
||
from ..utils import Command | ||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
class LSHW(Command): | ||
"""Command line tool for lshw.""" | ||
|
||
prefix = "" | ||
command = "lshw" | ||
|
||
def get_powers(self) -> List[Dict[str, str]]: | ||
"""Get power class data.""" | ||
result = self("-c power -json") | ||
if result.error: | ||
logger.error(result.error) | ||
return [] | ||
data = json.loads(result.data) | ||
return data | ||
|
||
def get_power_capacities(self) -> List[int]: | ||
"""Get list of power capacities.""" | ||
powers = self.get_powers() | ||
capacities = [] | ||
for power in powers: | ||
capacities.append(int(power.get("capacity", 0))) | ||
return capacities |