forked from Sysdeploy/idlers-agent
Compare commits
6 Commits
deac2cdee2
...
d6afa1c5eb
Author | SHA1 | Date | |
---|---|---|---|
d6afa1c5eb | |||
a07225a0eb | |||
bee43980da | |||
ca77ce4c45 | |||
9a9a98edf7 | |||
601bed9a34 |
|
@ -3,5 +3,5 @@
|
|||
Agent for my-idlers
|
||||
|
||||
```
|
||||
export API_KEY=<API_KEY> HOST=https://idlers.test2.sysdeploy.org/api/servers;python3 main.py
|
||||
```
|
||||
export AGENT_API=<API_KEY> HOST=https://idlers.test2.sysdeploy.org/api/servers;python3 agent.py
|
||||
```
|
||||
|
|
24
agent.py
24
agent.py
|
@ -124,7 +124,12 @@ class ServerData:
|
|||
|
||||
# Parse the output
|
||||
details = {}
|
||||
details['model_number'] = re.search(r'Model Number:\s*(.*)', output).group(1)
|
||||
model_number_match = re.search(r'Model Number:\s*(.*)', output)
|
||||
if model_number_match is None:
|
||||
logging.warning("Skipping device {} as it does not have a model number".format(device))
|
||||
continue
|
||||
|
||||
details['model_number'] = model_number_match.group(1)
|
||||
details['serial_number'] = re.search(r'Serial Number:\s*(.*)', output).group(1)
|
||||
details['firmware_revision'] = re.search(r'Firmware Revision:\s*(.*)', output).group(1)
|
||||
details['transport'] = re.search(r'Transport:\s*(.*)', output).group(1)
|
||||
|
@ -166,7 +171,7 @@ class ServerData:
|
|||
# Get the output of nvme id-ctrl command
|
||||
output = subprocess.check_output(['nvme', 'id-ctrl', device_path], stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Failed to get nvme id-ctrl output for {device_path}: {e}")
|
||||
print("Failed to get nvme id-ctrl output for {}: {}".format(device_path, e))
|
||||
continue
|
||||
|
||||
# Split the output into lines
|
||||
|
@ -212,7 +217,10 @@ class ServerData:
|
|||
if section['DMIType'] == 4: # 4 corresponds to processor
|
||||
core_count = int(section.get('Core Count', '0'))
|
||||
thread_count = int(section.get('Thread Count', '0'))
|
||||
cpu_count = core_count * thread_count
|
||||
if thread_count:
|
||||
cpu_count += thread_count
|
||||
else:
|
||||
cpu_count += core_count
|
||||
if cpu_count == 0:
|
||||
with open('/proc/cpuinfo', 'r') as f:
|
||||
cpuinfo = f.read()
|
||||
|
@ -351,8 +359,14 @@ class ServerData:
|
|||
size = ram.get('Size', 'Unknown')
|
||||
speed = ram.get('Speed', 'Unknown')
|
||||
configured_speed = ram.get('Configured Memory Speed', 'Unknown')
|
||||
total_width = int(ram.get('Total Width', "0").split()[0])
|
||||
data_width = int(ram.get('Data Width', "0").split()[0])
|
||||
try:
|
||||
total_width = int(ram.get('Total Width', "0").split()[0])
|
||||
except ValueError:
|
||||
total_width = 0
|
||||
try:
|
||||
data_width = int(ram.get('Data Width', "0").split()[0])
|
||||
except ValueError:
|
||||
data_width = 0
|
||||
ecc = 'Yes' if total_width > data_width else 'No'
|
||||
serial_number = ram.get('Serial Number', 'Unknown')
|
||||
ram_type = ram.get('Type', 'Unknown')
|
||||
|
|
Loading…
Reference in New Issue
Block a user