Script for system performance

I need to prepare script which will run as background process ever 30 mins to collect the following information

  1. Memory usage.
  2. CPU usage.
  3. Number processors running.
  4. System resource (CPU and Memory) used by each process.
  5. Number of sessions logged

PLEASE HELP ME OUT FROM THIS

Thanks in advance
-----------
VASTARE

I think you can use the output of the following commands

echo "q" | top 35 1
ps -ef
who

Use sar. It has everything you need