build an array based on data from file matching criteria

S

shaun.pille

I am trying to get data from a tab delimited file(example of a few
lines below). I want to count the number of authentications per hour.
The first and fourth line is an example of a line I would want to
count, the middle two are examples of other lines in the file that I
want to ignore. The approach I am looking at is reading the first
section and using the hour field as the address in the array.

int count = 0;
If (string contains "Successfully")
AuthCount[HourValue] = count ++

So the data below would result in
AuthCount[14]=1
AuthCount[15]=1

Any suggestions on how to write this?

2006-07-20 14:31:52 User.Info ServerIP Perfigo: Authentication:[User
MAC ## User IP] username - Successfully logged in, Provider:
authservername, L2 MAC address: User MAC

2006-07-20 14:31:52 User.Info ServerIP Perfigo: Administration:User MAC
added to certified device list

2006-07-20 15:12:49 User.Info ServerIP Perfigo: Miscellaneous:Overwrote
1 logs in the past 10 minutes to keep the event log limit.

2006-07-20 15:31:52 User.Info ServerIP Perfigo: Authentication:[User
MAC ## User IP] username - Successfully logged in, Provider:
authservername, L2 MAC address: User MAC
 
M

mlimber

I am trying to get data from a tab delimited file(example of a few
lines below). I want to count the number of authentications per hour.
The first and fourth line is an example of a line I would want to
count, the middle two are examples of other lines in the file that I
want to ignore. The approach I am looking at is reading the first
section and using the hour field as the address in the array.

int count = 0;
If (string contains "Successfully")
AuthCount[HourValue] = count ++

So the data below would result in
AuthCount[14]=1
AuthCount[15]=1

Any suggestions on how to write this?

2006-07-20 14:31:52 User.Info ServerIP Perfigo: Authentication:[User
MAC ## User IP] username - Successfully logged in, Provider:
authservername, L2 MAC address: User MAC

2006-07-20 14:31:52 User.Info ServerIP Perfigo: Administration:User MAC
added to certified device list

2006-07-20 15:12:49 User.Info ServerIP Perfigo: Miscellaneous:Overwrote
1 logs in the past 10 minutes to keep the event log limit.

2006-07-20 15:31:52 User.Info ServerIP Perfigo: Authentication:[User
MAC ## User IP] username - Successfully logged in, Provider:
authservername, L2 MAC address: User MAC

Use a std::map<unsigned int,unsigned int>.

Cheers! --M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top