Tag Archives: Solaris

Solaris utilization

Commands for checking various utilization on Solaris. Notes to self, based on this, this, and this. The sar command depends on regular collection of data by sa1 and sa2 commands. See bottom of post for how to set that up.

  • top (various)
  • vmstat (various)
  • mpstat (per CPU)
  • sar (see below)

Sar switches

-u  CPU utilization
-a  File access
-d  Disk activity
-b  Buffer activity
-c  System call statistics
-g  Page-out and memory
-r  Unused memory
-k  Kernel memory allocation
-m  Interprocess communication
-p  Page-in activity
-q  Queue activity
-v  System table activity
-w  Swapping activity
-y  Terminal activity
-A  Overall system performance

For what output means, see this page.

Real-time gathering

You can add interval and count to the vmstat, sar and mpstat commands to collect statistics real-time. For example

# Collect CPU usage in 10 second intervals, 60 times
$ sar -u 10 60
# Collect CPU usage in 10 second intervals indefinitely
$ sar -u 10

Setup of sar

Some sar commands depends on sa1 and sa2 collecting data regularly. If not setup, you’ll get the following error when running various sar commands (XX=todays date).

$ sar
sar: can't open /var/adm/sa/saXX

To set it up you need to edit the crontab of the sys user.

$ su
♯ su sys
♯ EDITOR=vi
♯ export EDITOR
♯ crontab -e

The sys crontab should already contain samples which you could just uncomment.

# System performance snapshot every hour
0 * * * 0-6 /usr/lib/sa/sa1
# System performance snapshot every 20 minutes, Monday through Friday between 8 and 17
20,40 8-17 * * 1-5 /usr/lib/sa/sa1
# ASCII report at 6:05, Monday through Friday
5 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A

Following is a more straight forward version.

# System performance snapshot every 15 minutes
0,15,30,45 * * * 0-6 /usr/lib/sa/sa1
# ASCII report every day at 23:55
55 23 * * 0-6 /usr/lib/sa/sa2 -A

After editing, save the file and data should start being collected.

Unix: Useful and pretty prompt

Some servers at work has varying degrees of useful prompts when I connect to them through SSH. Usually they are quite annoying and for example showing the shell type and version, which I frankly don’t care much about. Here’s how to make it show the current user, hostname and working directory. In addition the hostname is made more visible, which is a nice effect.

$ bold=$(tput bold)
$ reset=$(tput sgr0)
$ export PS1="\u@\[$bold\]\h\[$reset\]:\w\$ "

Stick it in your .profile, .bash_profile or whatever else you’ve got going on to make it more permanent.

How to install software on SunOS

Solaris is a major pain and unfortunately several servers I have to deal with runs on it. Why is it a pain? Because for some reason it seems all Solaris machines are set up differently. Different sets of installed binaries, different places things are configured, and so on. Probably all caused by lazy sysadmins and/or developers.

Anyways, today I found out that curl wasn’t installed in a server where i needed to test a SOAP request. After some hours of digging I finally managed to get a working curl installed, and figured I should document the procedure here in case I need it again, which I probably will…

Continue reading How to install software on SunOS