configure collectd
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user