Find out who is login into your linux server, what process the user is running and send email notification to you.

No GoodNeed ImprovementOKGoodExcellent (1 votes, average: 5 out of 5)
Loading ... Loading ...

Use the following Perl script (run as cron job every 5 minute) to monitor your server.

#!/usr/bin/perl

use strict;

my $who =`who`;

if (length($who)>10)
{
my $content =`w`;
my $sendmail = “/usr/sbin/sendmail -t”;
my $send_to=”To: xxx\@gmail.com\n”;
my $subject=”Subject: Users in Linux Server\n”;
my $reply_to = “Reply-to: yyy\@hotmail.com\n”;

if (length($content)>100)
{
$content = $who.”\n”. $content;
open(SENDMAIL, “|$sendmail”) or die “Cannot open $sendmail: $!”;
print SENDMAIL $reply_to;
print SENDMAIL $subject;
print SENDMAIL $send_to;
print SENDMAIL “Content-type: text/plain\n\n”;
print SENDMAIL $content;
close(SENDMAIL);
#print $content .”\n”;
}
}

Popularity: 1%

Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word