Operating System - HP-UX
1833189 Members
2856 Online
110051 Solutions
New Discussion

Script for Memory and CPU utilization

 
M.sureshkumar
Regular Advisor

Script for Memory and CPU utilization

Hi All,

We need script for Continuously monitoring the CPU utilization and Memory utilization on our HP unix 11.11 server.

Note:Glance command is not availble in our hp server.Pls guide me,how to install glance in our server.

Thanks&Regards,
Suresh.
7 REPLIES 7
Rajeev  Shukla
Honored Contributor

Re: Script for Memory and CPU utilization

You can write a shell script to run from cron which will have entries like

hour=`date +'%H'`
min=`date +'%M'`
uptime=`uptime`
load=`echo $uptime | cut -f2 -dl |cut -f2 -d: | cut -f1 -d, |awk '{print $1}'`
mem=`swapinfo -t |grep ^total | awk '{print $5}' | cut -f1 -d%`

echo "$load-$hour:$min" >> cpu_utilization.txt
echo "$mem-$hour:$min" >> memory_utz.txt
M.sureshkumar
Regular Advisor

Re: Script for Memory and CPU utilization

Hi Rajeev,

Thanks for your quick reply.

Our requirment is %of CPU utilzation and free memory at the same time i.e free memory in GB only.We need %of CPU utilzation and total and free memory in GB.

Pls modify the old script and provide new script for our requirment.

Regards,
Suresh.
spex
Honored Contributor

Re: Script for Memory and CPU utilization

#!/usr/bin/sh

DATE=$(date +'%D @ %T')
CPU=$(uptime | awk '{print $10}' | tr -d ',')
RAM=$(swapinfo -t | awk '/^total/ {printf "%2.2f GiB Avail\t%2.2f GiB Free\n",$2/1048576,$4/1048576}')
echo "$DATE\t$CPU\t$RAM" >> monitor.text

exit
Sean Dale
Trusted Contributor

Re: Script for Memory and CPU utilization

You can install Glance from the Applications CDs or get the trial version here-> http://www.managementsoftware.hp.com/products/gplus/download.html
Live life everyday
Steven E. Protter
Exalted Contributor

Re: Script for Memory and CPU utilization

Shalom,

I thought I posted to this thread.

Here is a freebie with production time all over the world.

http://www.hpux.ws/system.perf.sh

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Rajeev  Shukla
Honored Contributor

Re: Script for Memory and CPU utilization

Here you go

hour=`date +'%H'`
min=`date +'%M'`
uptime=`uptime`
load=`echo $uptime | cut -f2 -dl |cut -f2 -d: | cut -f1 -d, |awk '{print $1}'`
mem=`swapinfo -tm |grep ^memory | awk '{print $4/1024}'`

echo "$load-$hour:$min" >> cpu_utilization.txt
echo "$mem-$hour:$min" >> memory_utz.txt

You'll have free memory in GB but with CPU load i have never come accross it displaying in %. Only values you can get in % format are system utilization (%SYS), user utilization (%USR), system idle (%IDLE)
M.sureshkumar
Regular Advisor

Re: Script for Memory and CPU utilization

Hi All,

Thanks,

We need small modification on that Script.

1.% of cpu --> Pls use the Glance command output
2.Available memory and Free memory ---> Pls use swapinf command output.

Pls modify the script for the above requirement in single script.

Regards,
Suresh.