1

I am trying to write shell script to calculate memory and cpu utilization on solaris box.

For CPU utilization, I tried below command but I want to append date, time and host name in same command but on solaris I am unable to append

sar -u 1 | awk '{print $5}' | tail -1 | awk '{sub=100 - $1} {print "Total CPU Utilization = " sub "%"}'

For memory utilization I tried below commands

TOP="/opt/sfw/bin/top"

$TOP | grep Memory | awk '{print $2" "$4}'| sed -e 's/M//g' | awk '{sub=$1 - $2} {print "Total Memory Utilization = " (sub/$1)* 100"%"}'

I want to remove TOP variable and in the single command I want to return total memory utilization count, because I am unable to access top dir/file, so wanted to implement different approach.

can any one suggest changes for above two scripts ?

Thanks,

2
  • What version of Solaris? Though I think between 8-10 it shouldn't matter. Oct 23, 2020 at 11:40
  • 1
    @MarkScheck solaris version is SunOS 5.10 Oct 23, 2020 at 12:01

1 Answer 1

1

Here's some good documentation here, https://docs.oracle.com/cd/E53394_01/html/E54798/gmaem.html

It's been years since I used Solaris. But I think I would assign the hostname and date to variables, then use echo or printf to output them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .