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.

  • 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

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.

| improve this answer | |

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

| improve this answer | |

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.

| improve this answer | |

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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