added ipmi support

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@644 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2008-03-01 22:08:04 +00:00
parent 6cefc17de9
commit e66af64ba9
4 changed files with 86 additions and 31 deletions

View File

@ -8,6 +8,7 @@ BEGIN
use lib "$::XCATROOT/lib/perl";
use IO::File;
print "xCAT_monitoring::snmpmon loaded\n";
1;
@ -36,6 +37,7 @@ print "xCAT_monitoring::snmpmon loaded\n";
#--------------------------------------------------------------------------------
sub start {
print "snmpmon::start called\n";
$noderef=shift;
if ($noderef =~ /xCAT_monitoring::snmpmon/) {

View File

@ -98,7 +98,7 @@ sub supportNodeStatusMon {
#--------------------------------------------------------------------------------
sub startNodeStatusMon {
my $temp=shift;
if ($temp =~ /xCAT_plugin::xcatmon/) {
if ($temp =~ /xCAT_monitoring::xcatmon/) {
$temp=shift;
}
my $setting=shift;
@ -244,7 +244,7 @@ sub getMonNodesStatus {
#--------------------------------------------------------------------------------
sub processNodeStatusChanges {
my $temp=shift;
if ($temp =~ /xCAT_plugin::xcatmon/) {
if ($temp =~ /xCAT_monitoring::xcatmon/) {
$temp=shift;
}
return xCAT_monitoring::monitorctrl->processNodeStatusChanges($temp);

View File

@ -62,7 +62,6 @@ my $passwd;
my $timeout;
my $port;
my $debug;
my $ndebug = 0;
my $sock;
my @user;
my @pass;
@ -108,7 +107,7 @@ my %codes = (
);
my %units = (
0 => "", #"unspecified",
0 => "unspecified",
1 => "C",
2 => "F",
3 => "K",
@ -2067,14 +2066,18 @@ sub fruwrite {
sub decodealert {
my $trap = shift;
if ($trap =~ /xCAT_plugin::ipmi/) {
$trap=shift;
}
my $node = shift;
my $pet = shift;
my $rc;
my $text;
($rc,$text) = initsdr();
($rc,$text) = initsdr();
if($rc != 0) {
return($rc,$text);
return($rc,$text);
}
my $type;
@ -2152,6 +2155,7 @@ sub decodealert {
$sev = "UNKNOWN-SEVERITY:$sev";
}
$text = "$sev:";
#print "sev=$sev\n";
($rc,$type,$desc) = getsensorevent($sensor_type,$offset,"ipmisensorevents");
if($rc == 1) {
@ -2160,6 +2164,8 @@ sub decodealert {
$rc = 0;
}
#print "type=$type, desc=$desc\n";
if($event_type <= 0x0c) {
my $gtype;
my $gdesc;
@ -2183,6 +2189,7 @@ sub decodealert {
if($type eq $desc) {
$desc = "";
}
#print "type=$type, desc=$desc\n";
my $extra_info = getaddsensorevent($sensor_type,$offset,$event_data_1,$event_data_2,$event_data_3);
if($extra_info) {
@ -2197,6 +2204,8 @@ sub decodealert {
$text = "$text $type,";
$text = "$text $desc";
#print "type=$type, desc=$desc\n";
my $key;
my $sensor_desc = sprintf("Sensor 0x%02x",$sensor_num);
foreach $key (keys %sdr_hash) {
@ -2210,6 +2219,7 @@ sub decodealert {
}
$text = "$text ($sensor_desc)";
#print "sensor_sedc=$sensor_desc\n";
if($event_dir) {
$text = "$text - Recovered";
@ -2917,7 +2927,7 @@ sub checkleds {
if ($returnd[38-$authoffset] != 0) {
#It's on...
if ($returnd[42-$authoffset] == 4) {
push(@output,sprintf("BIOS or admininstrator has %s lit",getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds")));
push(@output,sprintf("LED 0x%02x%02x (%s) active to indicate BIOS detected error (or user requested LED activity)",$led_id_ms,$led_id_ls,getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds")));
}
elsif ($returnd[42-$authoffset] == 3) {
push(@output,sprintf("A user has manually requested LED 0x%04x (%s) be active",$sdr->led_id,getsensorname($mfg_id,$prod_id,$sdr->led_id,"ibmleds")));
@ -2968,13 +2978,10 @@ sub vitals {
my $value;
my $format = "%-30s%8s %-20s";
my $per = " ";
my $doall;
$doall=0;
$rc=0;
if($subcommand eq "all") {
@sensor_filters=(0x01); #,0x02,0x03,0x04);
$doall=1;
@sensor_filters=(0x01,0x02,0x03,0x04);
}
elsif($subcommand =~ /temp/) {
@sensor_filters=(0x01);
@ -3014,7 +3021,7 @@ sub vitals {
foreach $key (sort {$sdr_hash{$a}->id_string cmp $sdr_hash{$b}->id_string} keys %sdr_hash) {
my $sdr = $sdr_hash{$key};
if(($doall and not $sdr->sensor_type==0xed) or ($sdr->sensor_type == $filter && $sdr->rec_type == 0x01)) {
if($sdr->sensor_type == $filter && $sdr->rec_type == 0x01) {
my $lformat = $format;
($rc,$reading) = readsensor($sdr->sensor_number);
@ -3062,7 +3069,6 @@ sub vitals {
$unitdesc = "F (" . int($c + .5) . " C)";
}
}
#$unitdesc.= sprintf(" %x",$sdr->sensor_type);
$text = sprintf($lformat,$sdr->id_string . ":",$reading,$per.$unitdesc);
push(@output,$text);
}
@ -3428,11 +3434,9 @@ sub getsensorname
if ($file eq "ibmleds") {
if ($xCAT::data::ibmleds::leds{"$mfgid,$prodid"}->{$sensor}) {
return $xCAT::data::ibmleds::leds{"$mfgid,$prodid"}->{$sensor}. " LED";
} elsif ($ndebug) {
return "Unknown $sensor/$mfgid/$prodid";
return $xCAT::data::ibmleds::leds{"$mfgid,$prodid"}->{$sensor};
} else {
return sprintf ("LED 0x%x",$sensor);
return "";
}
} else {
return "";

View File

@ -7,6 +7,7 @@ BEGIN
use lib "$::XCATROOT/lib/perl";
use Sys::Syslog;
use xCAT::Table;
use xCAT_plugin::ipmi;
# admin needs to create a mail aliase called alerts
# put "alerts: emailadd,emailaddr.." to /etc/aliases file
@ -21,16 +22,41 @@ my $info;
my $severity_type;
my $severity;
# read host name
my $host=<STDIN>;
chomp($host);
# read the host ip
my $ip=<STDIN>;
chomp($ip);
# read uptime
my $uptimeline=<STDIN>;
chomp($uptimeline);
my @a=split(/ /, $uptimeline);
my $oid=shift @a;
my $value=join(' ', @a);
$message .= " $oid=$value\n";
# read trapid
my $trapidline=<STDIN>;
chomp($trapidline);
@a=split(/ /, $trapidline);
$oid=shift @a;
$value=join(' ', @a);
$message .= " $oid=$value\n";
#for ipmi traps, the values is: SNMPv2-SMI::enterprises.3183.1.1.0.x, x is the ipmi trap id.
$value =~ s/(SNMPv2-SMI::enterprises\.3183\.1\.1\.0\.)//g;
my $trapid=$value;
#print "trapid=$trapid\n";
my $holder;
my $begin=1;
my $pair;
while ($temp=<STDIN>) {
chomp($temp);
my $temp1=$temp; #save the one with quotes
@ -88,29 +114,52 @@ while ($temp=<STDIN>) {
elsif ($oid =~ /BLADESPPALT-MIB::spTrapPriority|RSASPPALT-MIB::ibmSpTrapPriority/) {
# Critical Alert(0), Major(1), Non-Critical Alert(2), System Alert(4),
# Recovery Alert(8), Informational Only Alert(255)
$severity_type="Warning";
if ($value==0) {
$severity="Critical Alert";
$severity_type="Critical";
} elsif ($value==1) {
$severity="Major Alert";
$severity_type="Critical";
} elsif ($value==2) {
$severity="Non-Critical Alert";
$severity_type="Warning";
} elsif ($value==4) {
$severity="System Alert";
$severity_type="Warning";
} elsif ($value==8) {
$severity="Recovery Alert";
$severity_type="Warning";
} elsif ($value==255) {
$severity="Informational Alert";
$severity_type="Informational";
}
}
#elsif ($oid =~ /enterprises\.3183\.1\.1\.1/) { #IPMI starts here
# ;
# }
elsif ($oid =~ /enterprises\.3183\.1\.1\.1/) { #IPMI PRTs (traps)
$node1=$host;
$node1 =~ s/(-(eth|man)\d+)?(\..*)?$//;
$value =~ s/\"//g;
my @varray=split(/ /, $value);
#print "\n\n\ntrapid=$trapid\nhost=$host\npet=$value\n";
my $error = xCAT_plugin::ipmi->decodealert($trapid, $host, \@varray);
$briefmsg .= $error;
#print "error=$error\n";
#severity value from decodealert are:
#LOG,INFORMATION,OK,CRITICAL,NON-RECOVERABLE,MONITOR and UNKNOWN-SEVERITY
$severity_type="Warning";
if ($error) {
@tempArray=split(/\:/, $error);
$severity=$tempArray[0];
if ($severity eq "LOG") {
$severity_type="Informational";
}
elsif($severity eq "INFORMATION") {
$severity_type="Informational";
}
elsif($severity eq "OK") {
$severity_type="Informational";
}
elsif($severity eq "CRITICAL") {
$severity_type="Critical";
}
elsif($severity eq "NON-RECOVERABLE") {
$severity_type="Critical";
}
}
}
}
if ($node1) {$info= getMoreInfo($node1);}