Blog O' Matty


Is that an alias or a command?

This article was posted by Matty on 2005-10-07 13:05:00 -0400 -0400

When executing shell commands, I occassionally find that my alias definitions collide with actual commands. This periodically causes unexpected side effects, and munges the command output when additional options and pipelines are present. Since I use the Korn shell as my primary shell, I frequently use the whence(1) shell built-in to resolve these issues:

$ whence -v ls
ls is a tracked alias for /bin/ls

$ whence -v awk
awk is /bin/awk

whence(1) will provide a summary of the command passed as an argument, which can be helpful for determining if the command is an alias, function or an actual command. If you want to view all aliases, you can use the alias(1m) command without any options:

$ alias

autoload='typeset -fu'
cat=/bin/cat
command='command '
functions='typeset -f'
history='fc -l'
integer='typeset -i'
local=typeset
ls=/bin/ls
nohup='nohup '
r='fc -e -'
stop='kill -STOP'
suspend='kill -STOP $$'

UNIX shells contain lots of obscure commands and functionality, and are one of the coolest things to learn about!!

Viewing shared library search order

This article was posted by Matty on 2005-10-06 00:41:00 -0400 -0400

When debugging library search path problems, it is often useful to see which libraries are used, and the order in which they are accessed. This is easily accomplished with the Solaris ldd(1m) utilities “-s” option:

$ ldd -ss /usr/sfw/bin/wget |more

find object=libsocket.so.1; required by /usr/sfw/bin/wget
search path=/usr/local/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libsocket.so.1
search path=/usr/lib (default)
trying path=/usr/lib/libsocket.so.1
libsocket.so.1 => /usr/lib/libsocket.so.1

find object=libnsl.so.1; required by /usr/sfw/bin/wget
search path=/usr/local/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libnsl.so.1
search path=/usr/lib (default)
trying path=/usr/lib/libnsl.so.1
libnsl.so.1 => /usr/lib/libnsl.so.1

find object=libc.so.1; required by /usr/sfw/bin/wget
search path=/usr/local/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libc.so.1
search path=/usr/lib (default)
trying path=/usr/lib/libc.so.1
libc.so.1 => /usr/lib/libc.so.1

find object=libnsl.so.1; required by /usr/lib/libsocket.so.1
search path=/usr/local/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libnsl.so.1
search path=/usr/lib (default)
trying path=/usr/lib/libnsl.so.1

find object=libc.so.1; required by /usr/lib/libsocket.so.1
search path=/usr/local/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libc.so.1
search path=/usr/lib (default)
trying path=/usr/lib/libc.so.1

find object=libdl.so.1; required by /usr/lib/libnsl.so.1
search path=/usr/local/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libdl.so.1
search path=/usr/lib (default)
trying path=/usr/lib/libdl.so.1
libdl.so.1 => /usr/lib/libdl.so.1

find object=libc.so.1; required by /usr/lib/libnsl.so.1
search path=/usr/local/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libc.so.1
search path=/usr/lib (default)
trying path=/usr/lib/libc.so.1

find object=libmp.so.2; required by /usr/lib/libnsl.so.1
search path=/usr/local/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libmp.so.2
search path=/usr/lib (default)
trying path=/usr/lib/libmp.so.2
libmp.so.2 => /usr/lib/libmp.so.2

find object=libdl.so.1; required by /usr/lib/libc.so.1
search path=/usr/local/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libdl.so.1
search path=/usr/lib (default)
trying path=/usr/lib/libdl.so.1

find object=libc.so.1; required by /usr/lib/libmp.so.2
search path=/usr/local/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libc.so.1
search path=/usr/lib (default)
trying path=/usr/lib/libc.so.1

object=/usr/lib/libc.so.1; filter for /usr/platform/$PLATFORM/lib/libc_psr.so.1

find object=/usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1; required by /usr/lib/libc.so.1
/usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1

object=/usr/lib/libdl.so.1; filter for /usr/lib/ld.so.1

I find this useful for finding references to outdated libraries, and libraries that are not located in standard locations (e.g., /usr/lib).

Solaris fault manager overview

This article was posted by Matty on 2005-09-29 14:06:00 -0400 -0400

One of the coolest features in Solaris 10 in the fault management service. Fault management allows system software to send telemetry data to the fmd(1m) daemon, which then diagnoses the problem, and takes action (e.g., offlining a faulty components and logging an error with FMRI/UUID information to syslog) based on the type of event received. The diagnosis phase is controlled by a set of diagnosis engines, which can be viewed with the fmadm(1m) utilities “config” option:

$ fmadm config

MODULE VERSION STATUS DESCRIPTION
USII-io-diagnosis 1.0 active UltraSPARC-II I/O Diagnosis
cpumem-retire 1.0 active CPU/Memory Retire Agent
eft 1.12 active eft diagnosis engine
fmd-self-diagnosis 1.0 active Fault Manager Self-Diagnosis
io-retire 1.0 active I/O Retire Agent
syslog-msgs 1.0 active Syslog Messaging Agent

If the fault manager daemon (fmd) detects a fault, it will log a detailed message to syslog, and update the fault manager error and fault logs. The contents of these logfiles can be viewed with the fmdump(1m) utility:

$ fmdump -v

TIME UUID SUNW-MSG-ID
fmdump: /var/fm/fmd/fltlog is empty

$ fmdump -e -v

TIME CLASS ENA
fmdump: /var/fm/fmd/errlog is empty

If a device is diagnosed as faulty, this will be indicated in the fmadm(1m) “faulty” output:

$ fmadm faulty

STATE RESOURCE / UUID
-------- ----------------------------------------------------------------------

The fault management daemon (fmd) keeps track of service events and numerous pieces of key statistical data. This information can be accessed and printed with the fmstat(1m) utility:

$ fmstat

module ev_recv ev_acpt wait svc_t %w %b open solve memsz bufsz
USII-io-diagnosis 0 0 0.0 0.0 0 0 0 0 0 0
cpumem-retire 0 0 0.0 0.0 0 0 0 0 0 0
eft 0 0 0.0 0.0 0 0 0 0 552K 0
fmd-self-diagnosis 0 0 0.0 0.0 0 0 0 0 0 0
io-retire 0 0 0.0 0.0 0 0 0 0 0 0
syslog-msgs 0 0 0.0 0.0 0 0 0 0 32b 0

If you are interested in learning more about this amazingly cool technology, you can check out the following resources:

Mike Shapiro’s ACM Fault Management Article

Mike Shapiro’s Fault Management Presentation

Debugging lease problems with Sun DHCP Servers

This article was posted by Matty on 2005-09-29 02:33:00 -0400 -0400

While debugging some PXE boot problems a few weeks back, I needed to see who DHCP leases were being issued to. Since the box was running Solaris 9, I was able to take advantage of the Sun DHCP server’s “-d” (debug) and “-v” (verbose) options:

$ /usr/lib/inet/in.dhcpd -d -v -i ge0 -b manual

42a07602: Daemon Version: 3.5
42a07602: Maximum relay hops: 4
42a07602: Run mode is: DHCP Server Mode.
42a07602: Datastore resource: SUNWfiles
42a07602: Location: /var/dhcp
42a07602: DHCP offer TTL: 10
42a07602: BOOTP compatibility enabled.
42a07602: ICMP validation timeout: 1000 milliseconds, Attempts: 1.
42a07602: Maximum concurrent clients: 1024
42a07602: Maximum threads: 256
42a07602: Read 4 entries from DHCP macro database on Fri Jun 3 11:23:46 2005
42a07602: Monitor (0003/ge0) started...
42a07602: Thread Id: 0003 - Monitoring Interface: ge0 
42a07602: MTU: 1500 Type: SOCKET
42a07602: Broadcast: 10.10.10.255
42a07602: Netmask: 255.255.255.0
42a07602: Address: 10.10.10.122
42a07632: Datagram received on network device: ge0(limited broadcast)
42a07632: (Error 0) No more IP addresses on 10.10.10.0 network
42a07637: Datagram received on network device: ge0(limited broadcast)
42a07637: (Error 0) No more IP addresses on 10.10.10.0 network
42a0763f: Datagram received on network device: ge0(limited broadcast)
42a0763f: (Error 0) No more IP addresses on 10.10.10.0 network
42a0764f: Datagram received on network device: ge0(limited broadcast)
42a0764f: (Error 0) No more IP addresses on 10.10.10.0 network
42a07663: Datagram received on network device: ge0(limited broadcast)
42a07664: Sending datagram to broadcast address.
42a07664: (Added offer: 10.10.10.112
42a0766b: Datagram received on network device: ge0(limited broadcast)
42a0766b: Client: 01000D609C8889 maps to IP: 10.10.10.112
42a0766b: Sending datagram to broadcast address.
42a0766e: Datagram received on network device: ge0(limited broadcast)
42a0766e: Unicasting datagram to 10.10.10.112 address.
42a0766e: Adding ARP entry: 10.10.10.112 == 000D609C8889
42a0766e: Updated offer: 10.10.10.112
42a0766e: Datagram received on network device: ge0(limited broadcast)
42a0766e: Reserved offer: 10.10.10.112
42a0766e: Database write unnecessary for DHCP client: 01000D609C8889, 10.10.10.112
42a0766e: Client: 01000D609C8889 maps to IP: 10.10.10.112
42a0766e: Unicasting datagram to 10.10.10.112 address.
42a0766e: Adding ARP entry: 10.10.10.112 == 000D609C8889

The debug option will place the DHCP server into the foreground, causing the server to print a slew of information to the terminal screen. The debug options helped me solve my problem, and assisted with identifying several devices that shouldn’t be using DHCP.

S.M.A.R.T Article update

This article was posted by Matty on 2005-09-29 00:02:00 -0400 -0400

I revamped my article Out S.M.A.R.T Your Hard Drive this week. The new version contains several new examples, better explanations, and several additional references. I am hoping to BLOG about smartd(1m) in the near future.