Find out who is login into your linux server, what process the user is running and send email notification to you.
Use the following Perl script (run as cron job every 5 minute) to monitor your server.
#!/usr/bin/perluse 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%


















































