Advertisement
theKillerx

Get CPU/Memory from UNIX servers

Apr 1st, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.69 KB | None | 0 0
  1. #!/bin/ksh
  2.  
  3. USER='username'
  4. SERVER='lists of servers go here'
  5. LOG=CPUMemlog.txt
  6.  
  7. for i in $SERVER; do
  8.   echo -n ".";
  9.   CHK=`ssh -q -o "BatchMode yes" -o "ConnectTimeout 5" \
  10.             -l $USER $i "echo success"`;
  11.   if [ "success" = $CHK ] >/dev/null 2>&1
  12.   then
  13.     A=`ssh -q -o "BatchMode yes" -o "ConnectTimeout 5" -l $USER $i "machinfo | grep CPUs | awk '{print $5}'"`
  14.     B=`ssh -q -o "BatchMode yes" -o "ConnectTimeout 5" -l $USER $i "machinfo | grep Memory | awk '{print $3}'"`
  15.     echo "$i CPU: $A MEMORY: $B" >> scp $LOG
  16.   else
  17.     printf "${i}\tUnable to connect to host\n" >> $LOG;
  18.   fi
  19. done
  20. echo ""
  21. echo "Done!"
  22. echo "Check the list 'checkssh_failure' for errors."
  23. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement