Commit 638c36f8 authored by Mike Hibler's avatar Mike Hibler

Alright, alright, I will report temps in Celsius (-c).

parent d13277d5
...@@ -63,6 +63,7 @@ sub dostatus(@); ...@@ -63,6 +63,7 @@ sub dostatus(@);
sub usage() { sub usage() {
print << "END"; print << "END";
Usage: $0 [-rw] [-TPC] [ <type> ... ] Usage: $0 [-rw] [-TPC] [ <type> ... ]
-c print out temps in Celsius
-r print out raw values, no syslog-style format -r print out raw values, no syslog-style format
-w whiner flag, send mail to $TBOPS about errors -w whiner flag, send mail to $TBOPS about errors
-T turn on temperature (in degrees F) monitoring -T turn on temperature (in degrees F) monitoring
...@@ -77,7 +78,8 @@ Usage: $0 [-rw] [-TPC] [ <type> ... ] ...@@ -77,7 +78,8 @@ Usage: $0 [-rw] [-TPC] [ <type> ... ]
END END
} }
my $optlist = "rwANTPC"; my $optlist = "crwANTPC";
my $docelsius = 0;
my $doraw = 0; my $doraw = 0;
my $dotemps = 1; my $dotemps = 1;
my $dopower = 0; my $dopower = 0;
...@@ -100,6 +102,9 @@ my %options = (); ...@@ -100,6 +102,9 @@ my %options = ();
if (! getopts($optlist, \%options)) { if (! getopts($optlist, \%options)) {
usage(); usage();
} }
if (defined($options{"c"})) {
$docelsius = 1;
}
if (defined($options{"r"})) { if (defined($options{"r"})) {
$doraw = 1; $doraw = 1;
} }
...@@ -260,16 +265,25 @@ sub dostatus(@) { ...@@ -260,16 +265,25 @@ sub dostatus(@) {
} }
my $msg = ""; my $msg = "";
my $temp;
if ($doraw) { if ($doraw) {
$msg .= $status{current} . " " $msg .= $status{current} . " "
if ($docurrent && defined($status{current})); if ($docurrent && defined($status{current}));
$msg .= $status{power} . " " $msg .= $status{power} . " "
if ($dopower && defined($status{power})); if ($dopower && defined($status{power}));
if ($dotemps && if ($dotemps &&
defined($status{tempF}) || defined($status{tempC})) { (defined($status{tempF}) || defined($status{tempC}))) {
my $temp = $status{tempF}; if ($docelsius) {
if (!defined($temp)) { $temp = $status{tempC};
$temp = sprintf "%.2f", $status{tempC} * 9 / 5 + 32; if (!defined($temp)) {
$temp = sprintf "%.2f", ($status{tempF} - 32) * 5 / 9;
}
} else {
$temp = $status{tempF};
if (!defined($temp)) {
$temp = sprintf "%.2f", $status{tempC} * 9 / 5 + 32;
}
} }
$msg .= "$temp "; $msg .= "$temp ";
} }
...@@ -280,12 +294,20 @@ sub dostatus(@) { ...@@ -280,12 +294,20 @@ sub dostatus(@) {
$msg .= $status{power} . "W, " $msg .= $status{power} . "W, "
if ($dopower && defined($status{power})); if ($dopower && defined($status{power}));
if ($dotemps && if ($dotemps &&
defined($status{tempF}) || defined($status{tempC})) { (defined($status{tempF}) || defined($status{tempC}))) {
my $temp = $status{tempF}; if ($docelsius) {
if (!defined($temp)) { $temp = $status{tempC};
$temp = sprintf "%.2f", $status{tempC} * 9 / 5 + 32; if (!defined($temp)) {
$temp = sprintf "%.2f", ($status{tempF} - 32) * 5 / 9;
}
$msg .= ${temp} . "C";
} else {
$temp = $status{tempF};
if (!defined($temp)) {
$temp = sprintf "%.2f", $status{tempC} * 9 / 5 + 32;
}
$msg .= ${temp} . "F";
} }
$msg .= ${temp} . "F";
} }
} }
logit($msg); logit($msg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment