Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #
- # FreeNAS CPU and drive temperatures
- # based on a shell script by @Bidule0hm
- import subprocess
- ncpu = int(subprocess.check_output(['sysctl', '-n', 'hw.ncpu']))
- for cpu in range(ncpu):
- temperature = subprocess.check_output(
- ['sysctl', '-n', 'dev.cpu.'+str(cpu)+'.temperature']
- )
- print 'CPU {0}: {1}'.format(cpu, temperature),
- drives = subprocess.check_output(['sysctl', '-n', 'kern.disks']).split()
- drives.sort()
- for drive in drives:
- # get SMART data if available
- try:
- smart = subprocess.check_output(['smartctl', '-a', '/dev/'+drive]).splitlines()
- serial = filter(
- lambda line: 'umber' in line,
- smart
- )[0]
- serial = serial.split()[-1]+':'
- temperature = filter(
- lambda line: 'Temperature_Celsius' in line,
- smart
- )[0]
- temperature = temperature.split(None, 9)[9]
- # SMART not supported, or error?
- except subprocess.CalledProcessError as result:
- serial = 'N/A'
- temperature = ''
- print drive, serial, temperature
Add Comment
Please, Sign In to add comment