Skip to main content

Memory usage by process

The Solaris pmap command will provide the total memory usage of each process.

The following shell script prints the memory usage of each process, sorted by ascending memory usage.

#!/bin/sh

/usr/bin/printf "%-6s %-9s %s\n" "PID" "Total" "Command"
/usr/bin/printf "%-6s %-9s %s\n" "---" "-----" "-------"

for PID in `/usr/bin/ps -e | /usr/bin/awk '$1 ~ /[0-9]+/ { print $1 }'`
do
   CMD=`/usr/bin/ps -o comm -p $PID | /usr/bin/tail -1`
   # Avoid "pmap: cannot examine 0: system process"-type errors
   # by redirecting STDERR to /dev/null
   TOTAL=`/usr/bin/pmap $PID 2>/dev/null | /usr/bin/tail -1 | \
/usr/bin/awk '{ print $2 }'`
   [ -n "$TOTAL" ] && /usr/bin/printf "%-6s %-9s %s\n" "$PID" "$TOTAL" "$CMD"
done | /usr/bin/sort -n -k2


Example output:

PID    Total     Command
---    -----     -------
21245  336K      sh
25291  336K      sh
25385  336K      sh
1      888K      /etc/init
1341   1056K     /usr/lib/efcode/sparcv9/efdaemon
1201   1080K     /usr/lib/utmpd
26675  1096K     /bin/sh
26679  1096K     /bin/sh
25327  1656K     csh
1323   1752K     /usr/sadm/lib/smc/bin/smcboot
1324   1752K     /usr/sadm/lib/smc/bin/smcboot
1365   1888K     /usr/lib/saf/ttymon
1270   1912K     /usr/lib/osa/bin/sparcv9/rdaemon
1299   1912K     /usr/lib/osa/bin/sparcv9/rdaemon
1135   2000K     /usr/sbin/cron
19828  2208K     sh
59     2264K     /usr/lib/sysevent/syseventd
1254   2496K     /usr/lib/osa/bin/arraymon
25042  2624K     -bash
19748  2648K     -bash
21123  2648K     -bash
21852  2648K     -bash
65     2832K     devfsadmd
1351   3600K     /usr/local/sbin/sshd
1026   3864K     /usr/lib/picl/picld
1118   4416K     /usr/local/bin/ntpd
19742  6200K     /usr/local/sbin/sshd
21106  6320K     /usr/local/sbin/sshd
21838  6320K     /usr/local/sbin/sshd
25033  6416K     /usr/local/sbin/sshd
17876  6432K     /usr/lib/sendmail
19702  6600K     /usr/local/sbin/sshd
21071  6600K     /usr/local/sbin/sshd
21806  6600K     /usr/local/sbin/sshd
24807  6600K     /usr/local/sbin/sshd
2790   6712K     /usr/lib/sendmail
14201  6720K     /usr/lib/sendmail
1488   6720K     /usr/lib/sendmail
14936  6720K     /usr/lib/sendmail
17210  6720K     /usr/lib/sendmail
19949  6720K     /usr/lib/sendmail
2859   6720K     /usr/lib/sendmail
2998   6720K     /usr/lib/sendmail
5621   6720K     /usr/lib/sendmail
942    6720K     /usr/lib/sendmail
3886   6728K     /usr/lib/sendmail
5646   6728K     /usr/lib/sendmail
1127   9808K     /usr/sbin/syslogd
26678  17568K    /usr/bin/sort
29484  83624K    /usr/local/sbin/named
27831  90464K    /usr/local/sbin/rbldnsd
26741  2206432K  /usr/local/sbin/clamd

Comments

Popular posts from this blog

Solaris. remove unusable scsi lun

Solaris remove unusable or failing scsi lun 1. The removed devices show up as drive not available in the output of the format command: # format Searching for disks...done ................      255. c1t50000974082CCD5Cd249 <drive not available>           /pci@3,700000/SUNW,qlc@0/fp@0,0/ssd@w50000974082ccd5c,f9 ................      529. c3t50000974082CCD58d249 <drive not available>           /pci@7,700000/SUNW,qlc@0/fp@0,0/ssd@w50000974082ccd58,f9 2. After the LUNs are unmapped Solaris displays the devices as either unusable or failing. # cfgadm -al -o show_SCSI_LUN | grep -i unusable # # cfgadm -al -o show_SCSI_LUN | grep -i failing c1::50000974082ccd5c,249       disk         connected    configured   failing c3::50000974082ccd58,249 ...

memory error detect XSCF uboot

If you see something like this when you poweron you server: memory error detect 80000008, address 000002d0 data 55555555 -> fbefaaaa capture_data hi fbefaaaa lo deadbeef ecc 1b1b capture_attributes 01113001 address 000002d0 memory error detect 80000008, address 000002d4 data aaaaaaaa -> deadbeef capture_data hi fbefaaaa lo deadbeef ecc 1b1b capture_attributes 01113001 address 000002d4 memXSCF uboot  01070000  (Feb  8 2008 - 11:12:19) XSCF uboot  01070000  (Feb  8 2008 - 11:12:19) SCF board boot factor = 7180     DDR Real size: 256 MB     DDR: 224 MB Than your XSCF card is broked. Replace it with new one. After that it will ask you for enter chassis number - located at front of the server XSCF promt to enter your chasses number ( is a S/N of your server ): Please input the chassis serial number : XXXXXXX 1:PANEL Please select the number : 1 Restoring data from PANEL to XSCF#0. Please wait for se...

SPARC OBP cheatsheet

Boot PROM Basics Boot PROM(programmable read only memory): It is a firmware (also known as the monitor program) provides: 1. basic hardware testing & initialization before booting. 2. contains a user interface that provide access to many important functions. 3. enables the system to boot from wide range of devices. It controls the system operation before the kernel becomes available. It provides a user interface and firmware utility commands known as FORTH command set. These commands include the boot commands, the diagnostic commands & the commands for modifying the default configuration. Command to determine the version of the Open Boot PROM on the system: # /usr/platform/'uname -m'/sbin/prtdiag -v (output omitted) System PROM revisions: ---------------------- OBP 4.16.4 2004/12/18 05:21 Sun Blade 1500 (Silver) OBDIAG 4.16.4.2004/12/18 05:21 # prtconf -v OBP 4.16.4 2004/12/18 05:21 Open Boot Architectures Standards: It is based on IEEE standard #1275, accord...