Best way to monitor memory usage and swap usage?
Whats the best way to see if I am using to much memory or to its resulting in swap usage? I pasted a few things below… I noticed when checking the vmstat there is some swap usage, but why would there be when there seemed to be some free memory (in cache), this is what gets dumped first if there is need for memory correct?
Is there anything else I should be monitoring to see if I'm using swap? (If you have time, based on what you see below, do I have enough free memory to allow mysql a bit more memory room ?)
Thanks for the help in advance, just need some better clarification on what exactly I should be watching.
free -m
total used free shared buffers cached
Mem: 497 487 9 0 7 254
-/+ buffers/cache: 226 270
Swap: 1023 86 937
vmstat 1 20
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 84616 36668 7272 254396 3 2 8 7 12 10 2 1 97 0
0 0 84616 36668 7276 254420 0 0 8 0 382 116 0 0 99 0
0 0 84600 40896 7276 254424 0 0 0 0 219 50 0 0 100 0
0 0 84600 41392 7280 254420 0 0 16 48 639 168 1 0 98 1
0 0 84600 41384 7288 254432 0 0 0 152 647 211 0 1 92 6
2 0 84536 35208 7288 254452 112 0 192 0 1836 885 5 2 91 2
1 1 84456 32960 7336 255260 108 0 744 180 1746 655 4 2 89 5
0 0 84448 33332 7336 255364 12 0 144 0 1024 558 1 1 97 1
0 0 84448 33580 7344 255304 32 0 40 356 588 211 1 0 99 0
0 0 84392 38060 7344 255336 4 0 4 20 530 171 0 0 99 0
0 0 84328 37952 7344 255448 64 0 112 0 1210 523 3 1 95 0
0 0 84328 37952 7344 255448 0 0 0 0 84 23 0 0 100 0
0 0 84328 44780 7344 255448 0 0 0 0 111 23 0 0 100 0
1 0 84328 50484 7348 255444 0 0 0 428 166 45 0 0 100 0
1 0 84264 45340 7348 255480 36 0 36 40 1252 481 2 1 96 0
1 0 84264 47448 7348 255516 0 0 0 0 607 250 2 0 98 0
0 0 84264 47448 7348 255520 0 0 0 0 345 157 0 0 99 0
0 0 84264 47324 7348 255520 0 0 0 0 654 274 3 1 97 0
1 0 84264 42364 7348 255544 0 0 28 20 744 249 3 1 96 0
0 0 84264 47936 7356 255584 0 0 32 132 1111 239 1 1 94 4
top
top - 12:02:05 up 2 days, 14:09, 1 user, load average: 0.03, 0.12, 0.13
Tasks: 136 total, 1 running, 135 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.7%us, 0.6%sy, 0.0%ni, 97.2%id, 0.4%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 509084k total, 452264k used, 56820k free, 7544k buffers
Swap: 1048572k total, 83292k used, 965280k free, 258640k cached
3 Replies
Regarding swap, swap is good, swapping is bad. Swap takes things that aren't used a lot out of memory freeing it up for something useful. Swapping is when things go in and out of swap, this is bade since it's slow and if you're swapping a lot your server will crawl and die. Munin can show your swap in/out per day,week and month if you see it starting to spike then you need to look into why.
I understand that swapping is bad. I'll check out munin as well. Is there anything else I should monitor to see if things are using swap?