#!/usr/bin/perl -w

use strict;
use Sys::Hostname;

my $h = hostname;
my $disk = shift;

POZOR: smartctl zda se shazuje driver 3ware - jeste prozkoumat!
open SC, "/usr/sbin/smartctl -A -d 3ware,$disk /home/stats/dev/twe0|";
my $temp;
# The line we want to know looks like this:
# 194 Temperature_Celsius     0x0002   177   177   000    Old_age   Always       -       31 (Lifetime Min/Max 23/47)

my $t;
while (<SC>) {
	next unless /Temperature/i;
	my @list = split /\s+/;
	$t = $list[9];
	last;
}
close SC;

die "Drive does not support temperature"
	unless defined $t;

print <<EOF;
0
$t

$h
EOF

1;

	
