#! /usr/bin/python

# For this plugin you will need lm-sensors package. 
# For ubuntu - $sudo apt-get install lm-sensors hddtemp
# Use this plugin only if you have the above package otherwise it will not work

import sys
import commands
import re

def temp():
	cmd = 'sensors | grep -i temp1'
	(status, output) = commands.getstatusoutput(cmd)
	if status:
		sys.stderr.write(output)
		sys.exit(3)
	try:
		match = re.search('\d+.\d',output)
		ans = match.group()
	except:
		print 'item not found'
		exit(3)
	if ans < '70':
		print 'Normal temperature:', ans
		exit(0)
	elif ans > '70' and ans < '90':
		print 'Warning - Hot:', ans
		exit(1)
	elif ans >= '90':
		print 'Critical Temperature:', ans
		exit(2)
	else:
		print 'Unknown'
		exit(3)

def main():
	temp()
	

if __name__ == "__main__":
	main()
