From 6e1fdd0c2bb99c59c5ac008ed837798be8902667 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Thu, 15 Jan 2009 20:52:15 +0000 Subject: [PATCH] -Reformat temperatures coming from a BladeCenter to conform to the look of the IPMI plugin git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2616 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/blade.pm | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index a6b875e27..96bf19ea3 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -668,6 +668,20 @@ sub bootseq { } } +sub cleantemp { +#Taken a bladecenter string, reformat/convert to be consistent with ipmi presentation choices + my $temp = shift; + my $tnum; + $temp =~ /(\d+\.\d+) Centigrade/; + $tnum=$1; + $temp =~ s/ = /:/; + $temp =~ s/\+(\d+)/$1/; #remove + sign from temperature readings if put in + $temp =~ s/Centigrade/C/; #remove controversial use of Centigrade + if ($tnum) { + $temp .= " (".sprintf("%.2f",$tnum*(9/5)+32)." F)"; + } + return $temp; +} my %chassiswidevitals; sub vitals { @@ -750,7 +764,7 @@ sub vitals { $session->get($bindobj); #[".1.3.6.1.4.1.2.3.51.2.22.1.5.5.1.$idx.$slot"]); for my $tmp (@$bindobj) { if ($tmp and defined $tmp->[2] and $tmp->[2] !~ /Not Readable/ and $tmp->[2] ne "") { - $tmp =~ s/ = /:/; + $tmp->[2] =~ s/ = /:/; push @output,$tmp->[2]; } } @@ -766,10 +780,10 @@ sub vitals { } $bindobj= new SNMP::VarList(@bindlist); $session->get($bindobj); + my $tnum; for my $tmp (@$bindobj) { if ($tmp and defined $tmp->[2] and $tmp->[2] !~ /Not Readable/ and $tmp->[2] ne "") { - $tmp =~ s/ = /:/; - push @output,$tmp->[2]; + push @output,cleantemp($tmp->[2]); } } unless (defined $chassiswidevitals{ambient}) { @@ -780,10 +794,11 @@ sub vitals { $session->get($targ); for my $result (@$targ) { if ($result->[2] eq "NOSUCHINSTANCE") { next; } - push @{$chassiswidevitals{ambient}},"Ambient ".$tempidx++." :".$result->[2]; + push @{$chassiswidevitals{ambient}},"Ambient ".$tempidx++." :".cleantemp($result->[2]); } } foreach (@{$chassiswidevitals{ambient}}) { + push @output,$_; } }