Hello All!
I am very new to perl.
I want to write a script that reads a log file and outputs the result
A snippet of log file is as shown below. 333.333.333.333 is the ip address. ip addresses are always preceded by the word AAD@.
----------------------------------------
10:54:11 [crelay_child-106762-0]: Reading local IPC message...
10:54:11 [crelay_child-106762-0]: Writing 220 bytes : LOGIN_MSG_RSP[-726510107](1)
secu_server-0@222.222.22.22->AAD@333.333.333.33
10:54:12 [crelay_child-106762-0]: Scheduled send message to client on sfd 5
11:54:01 [crelay_child-312350-0]: Read 173 bytes : LOGIN_MSG[-934384907](1)
AAD@333.333.333.33->secu_server@222.222.222.22
11:54:01 [crelay_child-312350-0]: Writing 213 bytes : LOGOUT_MSG[-726510107](1)
secu_server-0@222.222.222.22->AAD@333.333.333.33
------------------
We need to track the ip addresses on the lines that precede by a line that has the LOGIN_MSG (for logins) and LOGOUT_MSG (for logouts). Each ip address represents a user and LOGIN_MSG says that a user has logged in and LOGOUT_MSG says that a user has logged out.
The script has to track ip addresses. If a new ip address is found and if the line above it has LOGIN_MSG, then the user is logged in. And if the same ip address is found again (with LOGIN_MSG at top), that would make no difference. (Here, multiple LOGIN_MSGs exist). Similarly, when an ip address is found with LOGOUT_MSG on it's above line, then that user is no longer logged in. It's like deleting the user from the list.
Finally we just need to print the logged in ip addresses (distinct) and the count.
Thank you very much in anticipation.
I am very new to perl.
I want to write a script that reads a log file and outputs the result
A snippet of log file is as shown below. 333.333.333.333 is the ip address. ip addresses are always preceded by the word AAD@.
----------------------------------------
10:54:11 [crelay_child-106762-0]: Reading local IPC message...
10:54:11 [crelay_child-106762-0]: Writing 220 bytes : LOGIN_MSG_RSP[-726510107](1)
secu_server-0@222.222.22.22->AAD@333.333.333.33
10:54:12 [crelay_child-106762-0]: Scheduled send message to client on sfd 5
11:54:01 [crelay_child-312350-0]: Read 173 bytes : LOGIN_MSG[-934384907](1)
AAD@333.333.333.33->secu_server@222.222.222.22
11:54:01 [crelay_child-312350-0]: Writing 213 bytes : LOGOUT_MSG[-726510107](1)
secu_server-0@222.222.222.22->AAD@333.333.333.33
------------------
We need to track the ip addresses on the lines that precede by a line that has the LOGIN_MSG (for logins) and LOGOUT_MSG (for logouts). Each ip address represents a user and LOGIN_MSG says that a user has logged in and LOGOUT_MSG says that a user has logged out.
The script has to track ip addresses. If a new ip address is found and if the line above it has LOGIN_MSG, then the user is logged in. And if the same ip address is found again (with LOGIN_MSG at top), that would make no difference. (Here, multiple LOGIN_MSGs exist). Similarly, when an ip address is found with LOGOUT_MSG on it's above line, then that user is no longer logged in. It's like deleting the user from the list.
Finally we just need to print the logged in ip addresses (distinct) and the count.
Thank you very much in anticipation.