Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use MIME::Lite;
- ###########################################
- #This is a ILO in CS3000-1
- ###########################################
- open(FD, "/usr/local/bin/snmpwalk -v 1 -c communitynamehere 127.0.0.1 .1.3.6.1.4.1.232.6.2.6.8.1.4.0.1 |") || die "Failed: $!\n";
- while (<FD>)
- {
- chomp;
- $value = substr $_, 55, 2;
- $far = $value * 9 / 5 + 32;
- }
- ##########################################
- #This is the FAX Server ILO in CS3000-2
- ##########################################
- open(FF, "/usr/local/bin/snmpwalk -v 1 -c communitynamehere 127.0.0.1 .1.3.6.1.4.1.232.6.2.6.8.1.4.0.1 |") || die "Failed: $!\n";
- while (<FF>)
- {
- chomp;
- $dvalue = substr $_, 55, 2;
- $dfar = $dvalue * 9 / 5 + 32;
- }
- ##########################################
- #This is a CPRT03 in C3000-2 in the Server RooM
- ##########################################
- open(FS, "/usr/local/bin/snmpwalk -v 1 -c communitynamehere 127.0.0.1 .1.3.6.1.4.1.232.6.2.6.8.1.4.0.1 |") || die "Failed: $!\n";
- while (<FS>)
- {
- chomp;
- $svalue = substr $_, 55, 2;
- $sfar = $svalue * 9 / 5 + 32;
- }
- printf "Current Blade Inlet Ambient Air Temperatures\n\n";
- printf "Datacenter\n";
- printf "CS3000-1:$far\n";
- printf "CS3000-2:$dfar\n";
- printf "\n";
- printf "ServerRoom\n";
- printf "C3000-1:$sfar\n";
- if ($far > 74){
- &alertmail;
- }
- if ($dfar > 74){
- &alertmail;
- }
- if ($sfar > 82) {
- &alertmail;
- }
- if ($far > 80){
- &dcalert;
- }
- if ($dfar > 80){
- &dcalert;
- }
- if ($sfar > 85) {
- &fshalert;
- }
- sub alertmail {
- my $from = 'TempMon@foo.com';
- my $site = 'foo.com';
- my $smtp_host = '10.0.0.1';
- my $to = 'alert@foo.com';
- my $subject = 'Temperature Alert';
- my $message_body = "Datacenter Blade Inlet Ambient Temps \n\nCS3000-1: $far\nCS3000-2: $dfar\n\n\nServer Room Blade Inlet Ambient Temp \n\nC3000-1: $sfar\n";
- ### Create the multipart container
- $msg = MIME::Lite->gt;new (
- From => $from,
- To =>gt; $to,
- Subject => $subject,
- Type =>'multipart/mixed'
- ) or die "Error creating multipart container: $!\n";
- ### Add the text message part
- $msg->attach (
- Type => 'TEXT',
- Data => $message_body
- ) or die "Error adding the text message part: $!\n";
- ### Send the Message
- MIME::Lite->send('smtp', $smtp_host, Timeout=>60);
- $msg->send;
- }
- sub dcalert {
- my $from = 'alert@foo.com';
- my $site = 'foo.com';
- my $smtp_host = '10.0.0.1';
- my $to = 'alert@foo.com';
- my $subject = '!!!! DATA CENTER HIGH TEMPERATURE ALERT !!!!';
- my $message_body = "Datacenter Blade Inlet Ambient Temps \n\nCS3000-1: $far\nCS3000-2: $dfar\n\n\nServer Room Blade Inlet Ambient Temp \n\nC3000-1: $sfar\n";
- ### Create the multipart container
- $msg = MIME::Lite->new (
- From => $from,
- To => $to,
- Subject => $subject,
- Type =>'multipart/mixed'
- ) or die "Error creating multipart container: $!\n";
- ### Add the text message part
- $msg->attach (
- Type => 'TEXT',
- Data => $message_body
- ) or die "Error adding the text message part: $!\n";
- ### Send the Message
- MIME::Lite->send('smtp', $smtp_host, Timeout=>60);
- $msg->send;
- }
- sub fshalert {
- my $from = 'TempMon@foo.com';
- my $site = 'foo.com';
- my $smtp_host = '10.0.2.58';
- my $to = 'ITS@foo.com';
- my $subject = '!!!! FSH HIGH TEMPERATURE ALERT !!!!';
- my $message_body = "Datacenter Blade Inlet Ambient Temps \n\nFSCH-CS3000-1: $far\nFSCH-CS3000-2: $dfar\n\n\nServer Room Blade Inlet Ambient Temp \n\nFSH-C3000-1: $sfar\n";
- ### Create the multipart container
- $msg = MIME::Lite->new (
- From => $from,
- To => $to,
- Subject => $subject,
- Type =>'multipart/mixed'
- ) or die "Error creating multipart container: $!\n";
- ### Add the text message part
- $msg->attach (
- Type => 'TEXT',
- Data => $message_body
- ) or die "Error adding the text message part: $!\n";
- ### Send the Message
- MIME::Lite->send('smtp', $smtp_host, Timeout=>60);
- $msg->send;
- }
- close(FS);
- close(FF);
- close(FD);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement