How can I monitor
Memory Usage: 33/512MB (6%)
Disk usage: 4.2/20GB (23%)
CPU Load: 0.01
on a Solaris 11 System? I want to make a script to monitor my desktop resources.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityHow can I monitor
Memory Usage: 33/512MB (6%)
Disk usage: 4.2/20GB (23%)
CPU Load: 0.01
on a Solaris 11 System? I want to make a script to monitor my desktop resources.
If you have one system then SAR is the a good alternative out of the box. If you have multiple system you might want to evaluate other choices as well besides SAR.
Xymon and dimSTAT are two of them that I use and recommend. dimSTAT is specially good for Solaris as it was developed with Solaris in mind by a Sun Engineer. Xymon is multipurpose and highly customizable.
Now if you want to use your own scripting then there are several possibilites and you should use the one that suits you best. examples inline: echo "::memstat"|mdb -k
root@solsrv01:~# echo "::memstat" |mdb -k
Page Summary Pages Bytes %Tot
----------------- ---------------- ---------------- ----
Kernel 114567 447.5M 11%
ZFS Metadata 7312 28.5M 1%
ZFS File Data 72180 281.9M 7%
Anon 36257 141.6M 3%
Exec and libs 1559 6.0M 0%
Page cache 6286 24.5M 1%
Free (cachelist) 8973 35.0M 1%
Free (freelist) 784053 2.9G 75%
Total 1048463 3.9G
you will need to look at the right line and get the desired values. for cpu load you can use uptime, prstat or even kstat.
root@solsrv01:~# uptime
11:35pm up 12 min(s), 1 user, load average: 0.02, 0.29, 0.30
root@solsrv01:~# prstat -c 1 1
Please wait...
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
5 root 0K 0K sleep 99 -20 0:00:01 0.1% zpool-rpool/147
996 root 11M 3064K cpu0 49 0 0:00:00 0.1% prstat/1
957 root 21M 7064K sleep 59 0 0:00:01 0.1% sshd/1
958 root 11M 3188K sleep 49 0 0:00:00 0.0% bash/1
489 root 3964K 2116K sleep 59 0 0:00:00 0.0% hald-addon-acpi/1
480 root 8204K 6312K sleep 59 0 0:00:00 0.0% hald/4
68 netadm 5320K 3360K sleep 59 0 0:00:00 0.0% ipmgmtd/6
86 root 4044K 2284K sleep 59 0 0:00:00 0.0% svc.periodicd/4
547 root 15M 3040K sleep 59 0 0:01:03 0.0% ldap_cachemgr/8
360 root 10M 2464K sleep 59 0 0:00:00 0.0% picld/4
45 netadm 11M 2288K sleep 59 0 0:00:00 0.0% ibmgmtd/4
42 netcfg 3748K 2588K sleep 59 0 0:00:00 0.0% netcfgd/4
15 root 20M 19M sleep 59 0 0:00:46 0.0% svc.configd/31
13 root 53M 33M sleep 59 0 0:00:13 0.0% svc.startd/15
185 root 18M 3740K sleep 59 0 0:00:00 0.0% rad/4
Total: 62 processes, 397 lwps, load averages: 0.02, 0.25, 0.29
root@solsrv01:~# kstat -p 'unix:0:system_misc:avenrun*'|awk '{print $1"\t"$2/256}'
unix:0:system_misc:avenrun_15min 0.269531
unix:0:system_misc:avenrun_1min 0.0195312
unix:0:system_misc:avenrun_5min 0.203125
For disk usage:
root@solsrv01:~# df -h
Filesystem Size Used Available Capacity Mounted on
rpool/ROOT/solaris 19G 2.8G 13G 18% /
/devices 0K 0K 0K 0% /devices
/dev 0K 0K 0K 0% /dev
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 3.9G 1.6M 3.9G 1% /system/volatile
objfs 0K 0K 0K 0% /system/object
sharefs 0K 0K 0K 0% /etc/dfs/sharetab
/usr/lib/libc/libc_hwcap1.so.1
16G 2.8G 13G 18% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
rpool/ROOT/solaris/var
19G 221M 13G 2% /var
swap 3.9G 4K 3.9G 1% /tmp
rpool/VARSHARE 19G 2.4M 13G 1% /var/share
rpool/export 19G 32K 13G 1% /export
rpool/export/home 19G 38K 13G 1% /export/home
rpool 19G 4.5M 13G 1% /rpool
rpool/VARSHARE/zones 19G 31K 13G 1% /system/zones
rpool/VARSHARE/pkg 19G 32K 13G 1% /var/share/pkg
rpool/VARSHARE/pkg/repositories
19G 31K 13G 1% /var/share/pkg/repositories
root@solsrv01:~# zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
rpool 19.6G 6.08G 13.5G 30% 1.00x ONLINE -
Use sar
.
sar
- system activity reporter
Also, read this link
Monitoring System Activities (sar)
Use the sar command to perform the following tasks:
Organize and view data about system activity.
Access system activity data on a special request basis.
Generate automatic reports to measure and monitor system performance, as well as special request reports to pinpoint specific performance problems. For information about how to set up the sar command to run on your system, as well as a description of these tools, see Collecting System Activity Data Automatically (sar).
For a detailed description of this command, see the sar(1) man page.
and this link.
Collecting System Activity Data Automatically (sar)
Three commands are involved in the automatic collection of system activity data: sadc, sa1, and sa2.
...