configure collectd

This commit is contained in:
2025-01-03 09:42:20 +01:00
parent b8471944b0
commit d967b73db4
18 changed files with 314 additions and 1162 deletions

View File

@@ -1,23 +1,22 @@
#!/usr/bin/python -u
#!/usr/bin/python3
#
# Imports
#
import sys
import time
import commands
import argparse
import subprocess
#
# Methods
#
def get_temperature(disks):
command = "sudo smartctl -a /dev/%s | grep Temperature_Celsius | awk '{print $10}'" % disk
status, output = commands.getstatusoutput(command)
result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
try:
return int(output)
return int(result.stdout)
except Exception as e:
return None
@@ -25,9 +24,9 @@ def get_temperature(disks):
#
# Settings
#
hostname = 'server'
hostname = 'shuttle'
interval = 10
disks = ['sdd', 'sde', 'sdf']
disks = ['sda', 'sdb', 'sdc', 'sdd']
#
@@ -40,4 +39,3 @@ while True:
if temperature:
print('PUTVAL {}/exec-temperature/gauge-{}_total {}:{}'.format(hostname, disk, timestamp, temperature))
time.sleep(interval)