I want to develop program that can monitor many Unix client's CPU/Memory share.
A Unix client program written in C runs the command popen to get CPU / memory information and send it to the server using sockets.
Example, On Solaris 11, use the following command to get CPU / Memory information.
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}'
There is a problem here.
Solaris 9, 10 have no top command.
HP-UX can not use grep because it can not execute commands once.
AIX's topas, too.
If you have other command or way, please recommend to me.