title: Unix CPU/Memory Monitoring
body: <p>I want to develop program that can monitor many Unix client's CPU/Memory share. <br />
  A Unix client program written in C runs the command popen to get CPU / memory information and send it to the server using sockets. <br/></p>
  
  <p>Example, On Solaris 11, use the following command to get CPU / Memory information.</p>
  
  <pre><code>CPU : top -n 1 |grep "CPU"|sed -n 1p|awk '{print $3}'|sed 's/[^0-9.0-9]//g'|awk '{print 100-$1}'
  Memory : top -n 1 |grep \"Mem\" |awk '{print $2, $5}'|sed 's/[^0-9]/ /g'|awk '{print $2/$1*100}'
  </code></pre>
  
  <p>There is a problem here. <br />
  Solaris 9, 10 have no top command. <br />
  HP-UX can not use grep because it can not execute commands once.<br />
  AIX's topas, too.</p>
  
  <p>If you have other command or way, please recommend to me.</p>