• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++ Code Help, Create Array based on file input matching criteria

kg4dsx

Junior Member
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😱verwrote 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
 
Read in the line
Look for the string Authentication:
If string exists - continue parsing the data and use it.
Extract the time and turn it into a 24hour numeric value.
Truncate the time to only have an hour (ignore the minutes/seconds)
Use that as an index into the array of integers [24] witch then can be incremented

Otherwise - get next line of data
 
Back
Top