Hello All!
I am very new to shell scripting.
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
------------------
The log file has many such entries as shown above. The script needs to read only secu_server entries. The line with LOGIN_MSG
represents a login and the line with LOGOUT_MSG represents a logout.
And after everything, Count(Logins) - Count(Logouts) should give the
number of current users.
It would be great if it can also print the login ip addresses and logout ip addresses.
I feel this is a tough question. Your help will be greatly appreciated.
Thanks a lot in anticipation!!!
chatguy2020.
I am very new to shell scripting.
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
------------------
The log file has many such entries as shown above. The script needs to read only secu_server entries. The line with LOGIN_MSG
represents a login and the line with LOGOUT_MSG represents a logout.
And after everything, Count(Logins) - Count(Logouts) should give the
number of current users.
It would be great if it can also print the login ip addresses and logout ip addresses.
I feel this is a tough question. Your help will be greatly appreciated.
Thanks a lot in anticipation!!!
chatguy2020.