Introduction –

One of my friend was looking for script to parse FTP server log after every 10mins and send mail for every file uploaded by user
with Username, Uploaded File Name, Date and Size.  Please prefer the follow perl script to this task….

Download ftp file from here –

1] Script –

arunb@mylaptop:~$ cat perl-prog/


use strict;
use warnings;

no warnings 'uninitialized';

my $argument = $#ARGV + 1 ;
my $mylog_file = $ARGV[0];

if ( -f $mylog_file ) {
  print "\nChecking FTP log file for Upload files ~ $mylog_file";
  open(FILE, "<$mylog_file") or die("\nFile not found : $! ");

  print "\nContent of file is....\n";
  while() {
	## Fri Jul  6 14:15:25 2012 [pid 27841] [vivek] OK UPLOAD: Client ""," /squid-2 7-Template-v23.docx", 594488 bytes
	#print "\nLine=> $_";
	if ($_ !~ /^\s*$/) {
	  #print "\nLine=> $_";
	  if ($_ =~ m/(.*)\s+\[pid.*\]\s+\[(.*)\]\s+OK\s+UPLOAD:\s+Client\s+"(\d+.\d+.\d+.\d+)","(.*)",\s+(\d+)\sbytes.*/) {
	     my ($mydate, $myser,$ipaddr, $file_upload, $file_size) = ($1,$2,$3,$4,$5);
	     print "\n'$mydate' - '$myser' - '$ipaddr' - '$file_upload' - '$file_size'";
	     ## send mail
	     my $CONTACTEMAIL = "abc\";
	     open(MAIL, "|/usr/sbin/sendmail -t");
	     print MAIL "To: $CONTACTEMAIL\n";
	     print MAIL "From: ftp\\n";
	     print MAIL "Subject: File Uploaded- $file_upload";
	     #print MAIL "\nContent-type: text/html\n\n";
	     print MAIL "\nContent-type: text/plain\n\n";
	     print MAIL "\nFile Name: $file_upload";
	     print MAIL "\nFile Size: $file_size bytes";
	     print MAIL "\nUser: $myser";
	     print MAIL "\nIPaddr: $ipaddr";
	     print MAIL "\nDate: $mydate";

  print "\nDone";
} else {
   print "\n * Usage: $0  \n";

print "\n";

2] How to Use –

arunb@mylaptop:~$ ./perl-prog/

* Usage: ./perl-prog/

arunb@mylaptop:~$ ./perl-prog/ /var/log/ftp.log

Thank you,
Arun Bagul

(0) Comments   
Posted on 03-07-2012
Filed Under (NFS and NIS) by Arun Bagul

If you are using NFS (mount) volume/drive for Database, Then following mount options are recommended for databases on NetApp NFS:

Common mount options are = rw,bg,hard,rsize=32768,wsize=32768,vers=3

OS Mount Options for Binaires Mount Options for Oracle Datafiles
Solaris noac,nointr, proto=tcp, suid forcedirectio, noac,nointr, proto=tcp,suid
AIX nointr,timeo=600, proto=tcp cio,noac, nointr,timeo=600, proto=tcp
HPU noac,nointr, timeo=600, proto=tcp,suid forcedirectio, noac,nointr, timeo=600, proto=tcp, suid
Linux actimeo=0, nointr, suid, timeo=600, tcp actimeo=0, nointr, suid, timeo=600, tcp

Example –
root@myhost:~# cat /etc/fstab
arun_netapp07:/vol/db_vol /mydata nfs actimeo=0,nointr,suid,timeo=600,tcp,rw,bg,hard,rsize=32768,wsize=32768,vers=3 0 0

Thank you,
Arun Bagul

(0) Comments    Read More
arunbagul's photos More of arunbagul's photos
Get Adobe Flash player