Tuesday, 15 January 2013
manohar viswanatha
Well to start with , We come across various daily needs where in which we find different paths to reach or bring the desired output , this post is one of them .
If you also came across kind of requirement in this post , this is for you ….Well Well , What is that requirement ?????…..Ya I’m coming to that !!
If you want to automate some of you db tasks depending on the server load , If your DB server load crosses 50 …..set this flag to ‘Y’ , if above 80 , set this flag to ‘N’ , if below 80 set the flag again to ‘Y’……………………………..
For doing that we need to primarily catch up the server load which we do with a familiar command top
We have 2 options
Using Top in batch mode (OR)
Using Uptime command
Use this if you want to go with `top` batch mode
If you also came across kind of requirement in this post , this is for you ….Well Well , What is that requirement ?????…..Ya I’m coming to that !!
If you want to automate some of you db tasks depending on the server load , If your DB server load crosses 50 …..set this flag to ‘Y’ , if above 80 , set this flag to ‘N’ , if below 80 set the flag again to ‘Y’……………………………..
For doing that we need to primarily catch up the server load which we do with a familiar command top
We have 2 options
Using Top in batch mode (OR)
Using Uptime command
Use this if you want to go with `top` batch mode
top -b -n 1|awk -F: '/load average/ {print $5}'|awk -F, '{print $1}'Or this if you want to go with `uptime` command
uptime|awk -F: '{print $4;}'|awk -F, '{print $1}'Here i’m giving you a sample script to complete the task
#! /bin/sh value=`top -b -n 1|awk -F: '/load average/ {print $5}'|awk -F, '{print $1}'` #or use this #value=`uptime|awk -F: '{print $4;}'|awk -F, '{print $1}'` if [ $value -ge 50 ] ; then #these are sample stmts i have given to show for understading purpose , replace them with your custom command /home/db2inst1/sqllib/bin/db2 "connect to sample" /home/db2inst1/sqllib/bin/db2 "list tables for schema DB2INST1" else exit; fi
No comments:
Post a Comment