#Look in daily syslog file and grab the #user, group, connection duration, bytes xmt and bytes rcv #Stick this data into a daily report in .csv format # #TIME & DATE STUFF $stime = localtime; @time1 = split(' ', $stime); $mon = $time1[1]; $day = $time1[2]; $year = $time1[4]; $filename = "dailyreport-$mon-$day-$year.csv"; #Open the log file for reading open (LOG, ">tmpfile.txt") || die "Couldn't open tmp file $!"; open (DREPORT, ">>/root/reports/$filename") || die "Couldn't open csv $!"; print DREPORT "DAILY LOG FOR $mon $day $year\n"; print DREPORT "\n"; print DREPORT "USERNAME,GROUP,DURATION,BYTES XMT,BYTES RCV,\n"; print DREPORT "\n"; #Pump data into array and parse for usefull data #Usefull data goes into tmpfile while( ) { @tmp = grep {/disconnected/} $_; print TMP "@tmp"; } #Close stuff we dont need close TMP; close LOG; #Open temp file and stuff into array by spaces print data we #want into the daily csv file open (TMP1, " ) { chomp $_; @tmpa = split(' ', $_); print DREPORT "$tmpa[15],$tmpa[17],$tmpa[20],$tmp[23],$tmp[26]\n"; $cnt++; } close TMP1; unlink ("tmpfile.txt");