Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to develop a system statistics tool for Ubuntu that will store data about resource utilization of processes/users. I am storing these data in my own log files like /var/log/<process>.log. I want to know if there is any API (like procfs for collecting data about processes) for parsing my own log files using C programming language. These log files will contain simply username, process id, CPU%, MEM%, I/O etc.

share|improve this question
    
I cannot make out what you are trying to ask here. Perhaps you could try rewriting your question to expound on your situation a little bit. –  Caleb Apr 27 '11 at 8:23
    
this probably rather depends on the log files...Apache logs are quite different from Exim logs, or even Iptables logging, please clarify what logs you need to parse. –  xenoterracide Apr 27 '11 at 13:10
    
Thanks to all for their consideration, I have edited my question. So please reconsider it. –  Sushant Jain Apr 28 '11 at 3:47
add comment

4 Answers

What API would you want or need? Log files are text, use any text parsing utility, script or language that you might find useful.

Personally my language of choice tends to be awk, but that's because I am familiar with it. Though sometimes simple grep or sedsuffices.

But really it is all up to what you want to do with your logs. Possibilities are endless.

share|improve this answer
add comment

When you are creating your own log files, I think you should create your own API too.

share|improve this answer
add comment

You might consider integrating rrdtool ) into your workflow, since it seems to be doing a good deal of the things your looking for by itself already. There are a number of well documented examples on the net, so getting started shouldn't be too hard.

share|improve this answer
add comment

You have many choices you can choose from depending on your needs and skills.

Perl - A scripting language that is very good with text manipulation. Perl uses SED and AWK often

Awk - You can easily use this in a shell script. Awk uses some syntax that is more complicated than sed (but still easy). Awk is much faster than sed.

Sed - Just like awk, sed can be used in a shell script. Sed is easy for most people to learn.

Python - If you want to have an intricate logging system and you want a fast audit system, try Python. However, if you do not know Python, it will take some time to learn.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.