PS7a
Home Assignments Lecture Blog Resources Discussion Group
Kronos Time Clock: Introduction to Regular Expression Parsing
In this assignment, we begin the analysis of the Kronos InTouch time clock log by using regular expressions to parse the file.
Details
Here is a summary of the whole assignment:
- Verify device boot up timing.
- Verify device startup services.
- Verify device software upgrades.
In this portion of the assignment, we will only be doing (1) – boot up timing.
Your job is to read in an entire InTouch log and report:
- each startup
- whether it completed
- if so, how much time it required
- whether it failed
Your output should begin with the line number of the startup message “(log.c.166) server started
”, the timestamp of the startup, and either: success
followed by elapsed time, or failure
.
- Success is determined by a line containing the string “
oejs.AbstractConnector:Started SelectChannelConnector
” that follows the startup message. - Failure is determined by another startup message before the success message, or end of file.
Each of these output reports should be on a single line.
The whole assignment may be viewed here: Attach:Intouch Startup Log Parsing_03.pdf
Here is sample code to get you started: Attach:stdin_boost.cpp
The code will read a regex from stdin, and then let you type input strings which are matched against the regex.
Notes
- While it's possible to do the assignment without the use of regular expressions, the point of this assignment is to learn about regular expressions.
- This assignment must be done in the Unix environment. You may either use your own Unix installation or the one on the CS cluster at
cs.uml.edu
. If you have any trouble with set-up, I suggest using the CS cluster because everything is already configured. - The built-in regex library provided with gcc is incomplete and should not be used. Instead, we will use the Boost regex library: http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/index.html
- To install the Boost regex library on your own machine, run this command:
sudo apt-get install libboost-regex-dev
- To use the Boost regex library in your source code, use the following:
- header include directive
#include <boost/regex.hpp>
- convenience directive
using namespace boost;
- header include directive
- To link to the Boost regex library, use this compiler flag:
-lboost_regex
- To install the Boost regex library on your own machine, run this command:
- The Kronos log files are large. If you are working on the CS cluster, you don't need to copy them over to your account; you may simply pipe them into your binaries as needed when you're running your code.
/usr/web/ecg/uploads/Comp4spr14/kronos/
- Here is info about the
regex_match
API and simple working sample code: http://www.cplusplus.com/reference/regex/regex_match/ - Boost defaults to the Perl syntax for regular expressions. We will use this. Docs are here: http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
- Use the Boost time and date functions for figuring out elapsed time between server boot and boot completion. See:
- Main docs: http://www.boost.org/doc/libs/1_55_0/doc/html/date_time.html
- Time examples: http://www.boost.org/doc/libs/1_55_0/doc/html/date_time/examples.html#date_time.examples.time_math
- Using the Gregorian features: http://www.boost.org/doc/libs/1_55_0/doc/html/date_time/gregorian.html#date_time.gregorian.date_class
Submit
Submit the following:
- Your source code
.cpp
file and any header file. - A Makefile for building the code. Only a Unix Makefile will be accepted—not instructions.
- Output from running your code on each of the five InTouch log files. Your output files must be named
device[1-5]_intouch.log.out
. - A filled-out copy of the
Attach:ps7a-readme.txt
file.
submit fredm 204-ps7a files
Grading Rubric
Feature | Value | Comment |
core implementation | 4 | full & correct implementation=4 pts; nearly complete=3pts; part way=2 pts; started=1 pt |
use of Boost time methods | 2 | please use them |
output files included | 2 | full & correct = 2 pts; partial = 1 pt; absent = 0 pt |
Makefile | 2 | Makefile included |
Readme | 4 | 2 pts for describing regexs in readme; 2 pts for discussion |
Total | 14 |