Search This Blog

Showing posts with label sun script. Show all posts
Showing posts with label sun script. Show all posts

Monday, 9 August 2010

How to write your own Ganglia gmetric monitors

 
To define a new metric to monitor below is a an example
This metric could read and monitor the number of users currently logged in to the system and display the graph in ganglia front end.
Path for gmetric command:
Soaris: /usr/local/bin/gmetric
Aix: /opt/freeware/bin/gmetric
Linux: /usr/bin/gmetric
This command is available for all users.

Below is the command to monitoring number of users and display corresponding graph in Ganglia front end
/usr/local/bin/gmetric --name Current_Users --value `who |wc -l` --type int32 –unit current_users
Here:
/usr/local/bin/gmetric -> is the ganglia client command
--name Current_Users  -> this will be the name of graph
--value `who |wc -l` -> this is the value(this command should return a single number)
--type int32 -> type of value(since it’s a number its int32)
 
Now you can either crontab this command or  just loop it as below.
#while true; do /usr/local/bin/gmetric --name Current_Users --value `who |wc -l` --type int32 --unit current_users; sleep 10; done
Now this graph is visible on ganglia portal.
image


The Art of Capacity Planning: Scaling Web Resources

Sunday, 22 November 2009

Script for Continuous monitoring of percentage of page file usage in solaris

#script for monitoring page file usage in %. written by latheefp@gmail.com
while true
do
used=`swap -s|awk {'print $9'}|cut -dk -f1`
#echo "Used is :`expr $used / 1024`MB"
avail=`swap -s|awk {'print $11'}|cut -dk -f1`
#echo "Available is :`expr $avail / 1024`MB"
total=`expr $used + $avail`
#echo "Total is :`expr $total / 1024`MB"
percused=`expr $used \* 100`
percent=`expr $percused / $total`
#echo "Percentage of page file usage is :$percent% "
clear
echo "Used Available Total %Used"
echo "`expr $used / 1024`MB `expr $avail / 1024`MB `expr $total / 1024`MB $percent%"
sleep 5
done