c0d3
c0d3

Reputation: 117

how to efficiently monitor system stat using vmstat?

Am getting the real-time memory stats from vmstat command. I did this using following steps:

$nohup vmstat 60 > vmstatrecord.app &

the command executes in background and writes the log to the file vmstatrecord.app. When i see use the command

$ps -A | grep stat

I could see the vmstat running in the background and i could also access the log using tail command as:

$tail -f vmstatrecord.app

the file updates every 60sec interval.

Now my question is
1. process continues to write to the file so what will happen if i leave for days ?

Assumption:
If the process writes the file forever am afraid that the file size might grow too large

  1. If my assumption is correct and my steps are inefficient. Is there any alternatives to achieve what am trying to achieve from my above steps ?

Upvotes: 1

Views: 1610

Answers (1)

Guntram Blohm
Guntram Blohm

Reputation: 9819

This question should better be asked on superuser.com or maybe serverfault.com, as it's not about programming.

Yes, your file will keep growing. That's what the 2nd parameter of vmstat is for - run vmstat 60 1440 to stop after a day (note 1440 = 60 minutes * 24 hours). Once when i had this problem, i made a crontab entry:

0 0 * * * vmstat 60 1440  > /some/where/vmstat.out

to restart the output every day.

Upvotes: 1

Related Questions