#!/usr/bin/python -u # # Imports # import sys import time import commands import argparse # # Methods # def get_temperature(disks): command = "sudo smartctl -a /dev/%s | grep Temperature_Celsius | awk '{print $10}'" % disk status, output = commands.getstatusoutput(command) try: return int(output) except Exception as e: return None # # Settings # hostname = 'server' interval = 10 disks = ['sdd', 'sde', 'sdf'] # # Main # while True: timestamp = int(time.time()) for disk in disks: temperature = get_temperature(disk) if temperature: print('PUTVAL {}/exec-temperature/gauge-{}_total {}:{}'.format(hostname, disk, timestamp, temperature)) time.sleep(interval)