Showing posts with label tools. Show all posts
Showing posts with label tools. Show all posts

Monday 19 January 2015

Monitoring page faults (page out)

Page-outs can be a sign of trouble. When the kernel detects that memory is running low, it attempts to free up memory by paging out. Though this may happen briefly from time to time, if page-outs are plentiful and constant, the kernel can reach a point where it's actually spending more time managing paging activity than running the applications, and system performance suffers. To monitor page-outs in the system, we can use vmstat. Below script display the amount of free memory for page-out. Ideally it should be zero.
#!/bin/bash
/usr/bin/vmstat | head -3 | tail -n +3 | awk {'print $8'}

[root@fc21 ~]# pageout
0

Monitoring swap space

To monitor the swap space available in the system, we can use free command. Below script display the swap space available in the system.
[root@fc21 ~]# cat /usr/local/sbin/swap
#!/bin/bash
/usr/bin/free | head -3 | tail -n +3 | awk {'print $3'}

[root@fc21 ~]# swap
1648

Monitoring ram

To monitor the free ram available in the system, we can use free command. Below script display the available ram.
#!/bin/bash
/usr/bin/free | head -2 | tail -n +2 | awk {'print $4'}

[root@fc21 ~]# ram
135720

Monitoring active tcp connections

Active tcp connections number brings us light on whether the system can serve the request fast. A high number indicate queuing/processing of requests. This number can be retrieved from netstat.
#!/bin/bash
tcp=$(/bin/netstat -nt | tail -n +3 | grep ESTABLISHED | wc -l)
printf "%s \n" "$tcp"

[root@fc21 ~]# tcp
5

Monitoring diskspace

To monitor the amount of hdd space used in the system, we can use df. Below script display the percentage the disk is used.
[root@fc21 ~]# cat /usr/local/sbin/disk
#!/bin/bash
/bin/df -t ext4 -m | awk {'print $5'} | tail -1

[root@fc21 ~]# disk
10%

Monitoring system load

System load can be obtained from Uptime command. Below script is used to display the last min system load number.
[root@fc21 ~]# cat load
#!/bin/bash
uptime | awk '{print $10}' | awk -F, '{print $1}'

[root@fc21 ~]# load
1.43

search iomeweekly