I will be running a custom daemon that could potentially spike the server's cpu? Is there a way to log those spikes with their start and running time?
4 Answers
If youre running linux or other unix variant, there is sar
which is installed by default in many distributions. Many times it runs from cron on a defined interval, however you can also run it manually with a specified polling interval
For example:
sar -u 1 0
This will run sar once a second forever. The -u
tells it to output the CPU usage info, the 1
is how many seconds between polls, and the 0
is how many times to poll (0 for forever).
It can also watch a specific process with the -x
parameter. It can also log its data to a file for later viewing. Sar can do a lot, so consult the man page if you want to do more.
-
This is typically what we do too, because it is really quite easy to get it running. The one point is that it takes a snapshot of that point in time. So as long as you are doing them pretty frequently, it isn't a problem. If you bump the interval up to 5 or 10 minutes, you may miss the time when the app is actually spiking.– AlexJan 31, 2011 at 18:50
Use any monitoring system(Cacti,Zabbix,Munin,...) for monitoring daemon memory usage.
I would say if you have a bunch of servers to monitor, get a "utility server" and take the time and setup munin (what I use), or cacti or zenoss or ganglia or whatever you like.
But if it's a one-off server, go with sar, which is part of the sysstat suite. Usually it's run from cron. In Debian systems, you'll have to enable it in /etc/defaults/sysstat. You can graph the results with ksar.