1N/A# errinfo - report on syscall failures and print errno error messages. 1N/A# Written using Perl and DTrace (Solaris 10 03/05) 1N/A# When system calls fail, an errno variable is set to convay a meaningful 1N/A# message to the end user - so long as the program does something with it 1N/A# (eg, "ls" printing "No such file or directory"). This program fetches 1N/A# and prints details for all syscall failures along with their message, 1N/A# whether the failing program is already printing this info or not. 1N/A# $Id: errinfo 3 2007-08-01 10:50:08Z brendan $ 1N/A# USAGE: errinfo [-ch] [-p PID] [-n name] 1N/A# -c # counts - aggregate style 1N/A# -p PID # examine this PID only 1N/A# -n name # examine processes with this name only 1N/A# errinfo # default output - snoop event style 1N/A# errinfo -n ssh # examine "ssh" processes only 1N/A# errinfo -cn ssh # examine "ssh" using counts 1N/A# EXEC Program name (truncated) 1N/A# SYSCALL System call name 1N/A# DESC Description of errno message 1N/A# COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg. 1N/A# The contents of this file are subject to the terms of the 1N/A# Common Development and Distribution License, Version 1.0 only 1N/A# (the "License"). You may not use this file except in compliance 1N/A# See the License for the specific language governing permissions 1N/A# and limitations under the License. 1N/A# Author: Brendan Gregg [Sydney, Australia] 1N/A# 18-Apr-2005 Brendan Gregg Created this. 1N/A# 20-Apr-2006 " " Last update. 1N/A# Command line arguments 1N/A# Load errno descriptions 1N/A# Declare DTrace script 1N/A/usr/sbin/dtrace -n ' 1N/A #pragma D option quiet 1N/A /errno != 0 && pid != \$pid $FILTER/ 1N/A \@Errs[execname, probefunc, errno] = count(); 1N/A printa("%s %s %d %\@d\\n", \@Errs); 1N/A } else { # snoop style 1N/A/usr/sbin/dtrace -n ' 1N/A #pragma D option quiet 1N/A #pragma D option switchrate=5hz 1N/A /errno != 0 && pid != \$pid $FILTER/ 1N/A printf("%s %s %d\\n", execname, probefunc, errno); 1N/A# Run DTrace, process output 1N/A print STDERR "Tracing... Hit Ctrl-C to end.\n"; 1N/A printf("%16s %16s %4s %s\n","EXEC","SYSCALL","ERR","DESC"); 1N/A### Process DTrace output 1N/A ### Print count header 1N/A "EXEC","SYSCALL","ERR","COUNT","DESC"); 1N/A ### Fetch errno description 1N/A ### Print output line 1N/A# Triggered by signals 1N/A print STDERR "USAGE: errinfo [-ch] [-p PID] [-n name]\n"; 1N/A errinfo # default output - snoop event style 1N/A -c # counts - aggregate style 1N/A -p 871 # examine PID 871 only 1N/A -n ssh # examine processes with the name "ssh" only 1N/A -cn ssh # examine "ssh" using counts