Warning: imagecreatefromstring() [function.imagecreatefromstring]: Empty string or invalid image in /var/www/vhosts/tachytelic.net/httpdocs/wp-includes/media.php on line 258

Archive for E-Mail

Earlier this year I posted a script which sends email alerts from Dell servers using the alerting system built into Dell Openmanage. However, that script will only work on Windows systems.

A visitor to the blog called Steve has kindly posted some code on that post which enables the same functionality in Linux and I think it is worthy of its own post.

Before attempting to use the script you will need to download this perl script called sendEmail and that you have unix2dos installed.

The script accepts two arguments, which are setup or show.

“setup” will set the alerts action to the value of $alert_script which should be the full path to the script itself.
“show” will print the current alert settings for the system to the screen.

The code of the script is as follows, or you can download from here:


#!/usr/bin/perl
########
#
# Alter these setting to suit your system
$alert_script='/opt/asx_scripts/send_alert.pl';
$argument = 0;
$argument = $ARGV[0];
$omreport = '/opt/dell/srvadmin/bin/omreport';
$omconfig = '/opt/dell/srvadmin/bin/omconfig';
$sendemail = '/opt/asx_scripts/sendEmail';
$toname = 'name';
$fromname = 'name';
$domain = 'domain.com';
$tmp_path = '/tmp';
$mail_gateway = 'ip or name of mailgate';
$unix2dos = '/usr/bin/unix2dos';
#
#

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/$date.log";
`$omreport system alertlog > "$attach"`;
if( -f "$unix2dos"){
`$unix2dos "$attach" 2>/dev/null`;
}
$send=`$sendemail -f "$fromname\@$domain" -t "$toname\@$domain" -u "System Error: $host SvcTag: $tag Time: $date" -m "$host SvcTag: $tag Error: $desc Time: $date" -a "$attach" -s "$mail_gateway"`;
}else{
print "If you need some help read the code\n";
exit;
}

sub set_available_alerts {
$alert_list = `$omconfig system alertaction 2>/dev/null | cut -f2 -d"<" | cut -f1 -d">"`;
chomp($alert_list);
chomp($alert_list);
@split_alert_list = split(/\|/, $alert_list);
foreach my $alert (@split_alert_list){
$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;

A good way to test the script is to temporarily set the “Temperature Maximum” to something low like 12 to trigger an alert.

Unfortunately all of my Linux machines are virtual machines so I cannot test or modify this script, so if anyone wants to give me SSH access to a server running OMSA, be my guest. :)

Again, big thanks to Steve for posting this and I am sure it will be useful to lots of people. This has also inspired me to make some improvements to my original Windows version.

Comments (24)

I am always forgetting the syntax for the New-ExchangeCertificate cmdlet when I need to do a new certificate request so I decided to write a little bit of javascript to build up the command automatically. Its much easier to copy and paste it from here than work with in it the Exchange 2007 Command Shell.

So just fill in the fields below and the command will be built automatically in the box below. Then just copy into command shell. If required, seperate the “Subject Alternative Names” with commas.

Common Name:

Subject Alternative Names:
Organisation:
Organisational Unit:
Town/City:
County/State:
Country:

CSR Command:

I am thinking of duplicating this code and writing another post which will generate the commands for the import of the newly generated certificate.

Comments (1)

Dell Openmanage Server Administrator is a really useful tool for configuring and monitoring server hardware but it lacks built in E-Mail alerting or notifications.

The software is capable of calling external programs or scripts when a server alert is triggered so I have written a simple script that provides E-Mail alert functionality.

There are a couple of scripts out there that do similar, but I wanted something self contained and capable of using SMTP Authentication with an external relay.

The other problem with OMSA is that you need to go into each individual alert to configure the settings which can be very time consuming, I wanted a way to add them all automatically as I am going to install the script on a number of servers.

Once you have downloaded and extracted the zip file you will need to edit the variables at the top of the script to make them appropriate for your environment:

The variables at the top define the e-mail settings and are hopefully self explanatory. If a remote SMTP server is not specified the local machine will be used to send the E-Mail.

Below these you can to decide what events you want to be notified of, just comment out any that you aren’t interested in, e.g:

AlertConfig(0)="powersupply|Power supply failure"
AlertConfig(1)="powersupplywarn|Power supply warning"
'AlertConfig(2)="tempwarn|Temperature warning"
'AlertConfig(3)="tempfail|Temperature failure"

I have included every alert available in OMSA 6.2 on a PE T710, some of these alerts won’t be available on older versions or machines.

After you have configured the script, I suggest you test that the E-Mail options by running:

cscript dellalert.vbs testemail

You should receive a test e-mail, if not something isn’t working properly.

When you have successfully tested e-mail, configure OMSA to send alerts by running:

cscript dellalert.vbs setup

You will then see the script go through and setup all the appropriate alerts as per your settings. This process can take a couple of minutes as the “omconfig” command takes a while. This step will not work if you do not have OMSA installed.

Once this is done you should be able to see that the script has been added into OMSA:

Now you need to generate some real alerts to test the script properly. How you do this will depend on the capabilities of your server, I was able to disconnect the redundant power supply and have an alert generated almost immediately. I think opening the case will also generate an event, but I am not sure as I didn’t test. Hopefully you should get something like this in your Inbox:

Update: There is a new version of this script which is written entirely in Powershell and will work with Windows Server Core etc.  Please visit :

http://www.tachytelic.net/2011/09/dell-openmanage-server-administrator-e-mail-alerts-updated-powershell-script/

Download both versions by following the PayPal link.

GBP 2.95 / Download

 

I have had several incidents this week of customer systems being infected by executables attached to e-mails appearing to be from UPS.

Looking around the blogs, these e-mails seem to be having a higher than normal infection rate. It is time consuming to get rid of and makes the infected machines unusable and creates a huge number of network connections.

The exact subject line of the email’s that have been received is:

UPS Tracking Number 5440074870

Attached to the e-mail is a zip file containing an executable which when executed installs "XP Security Center".

XPSecurity1 

Much more information about the detail of the actual email can be found on the Trend Malware Blog.  The worrying thing about this e-mail is that both of the machines that it infected have their e-mail filtered by very well known external 3rd party mail systems, then have virus scanning on their own Exchange servers and finally on their desktop machines.  At the moment this e-mail is still slipping through the net.

This virus does a LOT of clever things to prevent you getting rid of it.  I noticed that when trying to run Autoruns from Sysinternals that it just would not work.  Renaming the autoruns executable allows it to run.  It also stops you being able to install/download Windows Defender, disables system restore, removes the system tools program group amongst other things.

Not a very sophisticated solution but for now I have edited the Exchange IMF custom weighting file on customer systems to ensure that messages with "UPS Tracking" in the subject line are never delivered to the recipients and definitely classed as spam. 

I had written a separate post on how to remove the virus manually, but at the moment I am still monitoring the infected machines to ensure they are completely clean.

Categories : Technical Posts
Comments (2)