Thursday, December 11, 2008

Executing command on remote host, remote monitoring unix/Linux flavour

I was given some exercise on remote monitoring. Here is how I cracked the same. I have splited the task into 2 parts. 1) Executing a command on remote host 2) Run vmstat in remote host and collect performance statistics.

Steps for Executing the command on remote host

  1. Create/update .netrc file in user home directory and add credentials of all the machines that we need to be accessed remotely. Format should be as follows: machine  login  password 
  2. Execute “chmod 600 .netrc” so that only owner will have read/write access.
  3. To execute the command on remote host use the following command:rexec   

Few examples for remote monitoring
HP Unix:
rexec remote_hp_ux_host vmstat 1 2 | tail -1 | awk '{print "Load Average : "$1"\nFree Mem :"$5"\nUser CPU : "$16"\nSystem CPU : "$17"\nIdle : "$18}'
Rexec remote_aix_host vmstat 1 2 | awk -v  psize="`pagesize`" '{if (NR ==2) print "Total "$4"\nPage Size : " psize}{if (NR == 8) print "Free list sz: "$4"\nUser CPU   : "$14"\nSystem CPU : "$15"\nIdle       : "$16"\nIO Wait    : "$17}'

Rest of Flavours:
Give a try and send me a feed back.

No comments: