文件操作 - DellAlert.pl
返回文件管理
返回主菜单
删除本文件
文件: /opt/dell/srvadmin/alert/DellAlert.pl
编辑文件内容
#!/usr/bin/perl ######## # # Alter these setting to suit your system $alert_script='/opt/dell/srvadmin/alert/DellAlert.pl'; $argument = 0; $argument = $ARGV[0]; $omreport = '/opt/dell/srvadmin/bin/omreport'; $omconfig = '/opt/dell/srvadmin/bin/omconfig'; $sendemail = '/opt/dell/srvadmin/alert/sendEmail'; $toname = 'rossano@planetline.it'; $bccname = 'webfarm@staff.aruba.it'; $fromname = 'controllo-raid-sd@staff.aruba.it'; $smtpwd = 'cNrD112012'; $tmp_path = '/tmp'; $mail_gateway = 'smtp.staff.aruba.it'; $unix2dos = '/usr/bin/unix2dos'; $admin_number = 'admin97720376'; $ipaddr = '5.249.157.183'; if("$argument" eq "setup"){ set_available_alerts(); exit; } if("$argument" eq "show"){ display_set_alerts(); exit; } if("$argument" eq "help"){ print "If you need some help read the code\n"; exit; } unless($argument){ $desc=`$omreport system alertlog 2>/dev/null | grep "Description" | head -1 | cut -f2-9 -d: | sed 's/ //'`; chomp($desc); $date=`$omreport system alertlog 2>/dev/null | grep "Date and Time" | head -1 | cut -f2-9 -d: | sed 's/ //g' | sed 's/://g'`; chomp($date); $host=`$omreport system summary 2>/dev/null | grep "Host Name" | head -1 | cut -f2-9 -d: | sed 's/ //'`; chomp($host); $tag=`$omreport system summary 2>/dev/null | grep "Chassis Service Tag" | head -1 | cut -f2-9 -d: | sed 's/ //'`; chomp($tag); $attach="$tmp_path/omreport.log"; `$omreport system alertlog > "$attach"`; sleep(5); if( -f "$unix2dos"){ `$unix2dos "$attach" 2>/dev/null`; } $send=`$sendemail -f "$fromname" -t "$toname" -u "System Error on $admin_number ($ipaddr) Service Tag: $tag: $desc" -m "Verificare lo stato del server in oggetto attrverso l'apposito strumento Dell OpenManage Server Administrator, se necessario contattare l'assistenza attraverso il portale ticket.aruba.it(Non rispondere alla presente mail, proviene da un indirizzo non presidiato)" -a "$attach" -bcc "$bccname" -s "$mail_gateway" -xu "$fromname" -xp "$smtpwd"`; }else{ print "If you need some help read the code\n"; exit; } sub set_available_alerts { @alert_to_config = qw/storagesyswarn storagesysfail storagectrlwarn storagectrlfail pdiskwarn pdiskfail vdiskwarn vdiskfail/; foreach my $alert (@alert_to_config){ $set_result = `$omconfig system alertaction event=$alert execappath="$alert_script" 2>/dev/null | head -1`; chomp($set_result); if("$set_result" eq "Alert action(s) configured successfully."){ print "Set Action:\t$alert\n"; }else{ print "ERROR Set didnt return expected value ($set_result)\n"; } } } sub display_set_alerts { $currently_set = `$omreport system alertaction`; print "$currently_set\n"; } exit;
修改文件时间
将文件时间修改为当前时间的前一年
删除文件