How can I actively monitor drive usage
-
Using this on Xen,
df | grep "/$" | head -n 1
How could I actively monitor the free/used space. I've excluded -h on purpose
-
I think you should be able to use monit for that.
-
In what way do you want to monitor it?
-
I want to see how much free space my partition has, as it applies updates to Xen.
I could simply keep tapping up, and hitting enter, and watch the sizes change, but I'd prefer to simply, run the command, and hit Ctlr+C to stop it when I'm satisfied.
-
@DustinB3403 said:
I could simply keep tapping up, and hitting enter, and watch the sizes change, but I'd prefer to simply, run the command, and hit Ctlr+C to stop it when I'm satisfied.
Oh, okay, that's super easy. Just find the command that you like (which you did) and add the word watch in front of it. Ta da, done. UNIX, the easy way.
-
So:
watch "df | grep "/$" | head -n 1"
But this doesn't seem to output any information, I'm at the classic stuck console to Ctrl+C out of
Edited to reflect that quotes are needed.
-
Edit, putting it in quotes works.
-
Next one for you is there anyway to actively dump the changes to the session screen, rather than just an updated single line?
The above code outputs
Every 2.0s: df | grep / | head -n 1 Thu Sep 24 13:01:05 2015 /dev/sda1 4127440 2593592 1324184 67% /
And just that results line.
What I'd prefer would be:
/dev/sda1 4127440 2593592 1324184 67% / /dev/sda1 4127440 2593592 1324184 67% / /dev/sda1 4127440 2593592 1324384 67% / /dev/sda1 4127440 2593592 1324184 67% /
-
Oh that's completely different. Try this....
for i in {1..1000}; do echo $(df | grep / | head -n 1); sleep 5; done
-
Wonderful!
-
Obviously, adjust the "1000" if you want it to do it a different number of times. And adjust the "5" if you want it to update at a different interval than every five seconds.