D
D
Dmitriy Loginov2020-04-16 21:21:08
bash
Dmitriy Loginov, 2020-04-16 21:21:08

How to parse the log?

Hello. Help parse the log
There is a status log from openVPN like this.

ivanov.as,IP_addres,56924339,46404603,Thu Apr 16 07:20:32
2020
16 08:08:04 2020

Bash or regular expressions need to read the presence of a user for example ivanov.as every minute and write to another log like ivanov.as 1, after a minute read the log again and if the user is there, increase the counter by one

PS I understand that the solution can be a crutch, I don’t know how else to take into account the connection time of users to the OpenVPN server.

Thanks in advance to everyone who replied.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-04-17
@caramingo

cut -d, -f2 111.txt
where the -dseparator is a ","
-fcolumn it remains for you to cut it as you need here you will receive online all the lines about this comrade, then you can count them
tail -f /var/log/syslog | grep -o "ivanov.as"

tail -f /var/log/syslog  |  grep -o "ivanov.as" | wc -l > ivanov.sa

but here it's better to take the whole file
cat  /var/log/syslog  |  grep -o "ivanov.as" | wc -l > ivanov.sa

well, if you need to compile a list of users and their number of mentions, then it’s different here.
But it was not in TK;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question