# Aug 5 11:50:50 ev-cis-cons2 142682254: 2004 Aug 05 11:50:50.040 EDT -4:00 %AUTH-5-28: RPT=88653: 10.1.1.1: User [user0] Group [group0] disconnected: Duration: 1:16:40 Bytes xmt: 1441872 Bytes rcv: 563776 Reason: User Requested # Aug 5 11:51:52 ev-cis-cons2 142683959: 2004 Aug 05 11:51:52.760 EDT -4:00 %AUTH-5-28: RPT=88654: 10.1.1.2: User [user1] Group [group1] disconnected: Duration: 3:55:38 Bytes xmt: 21588288 Bytes rcv: 2879544 Reason: Lost Service # Aug 5 11:52:22 ev-cis-cons2 142685133: 2004 Aug 05 11:52:22.650 EDT -4:00 %AUTH-5-28: RPT=88655: 10.1.1.3: User [user2] Group [group2] disconnected: Duration: 1:35:37 Bytes xmt: 1424368 Bytes rcv: 314304 Reason: User Requested #### #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");