3 # Copyright (c) University of Cambridge, 1995 - 2007
4 # See the file NOTICE for conditions of use and distribution.
6 # Except when they appear in comments, the following placeholders in this
7 # source are replaced when it is turned into a runnable script:
9 # CONFIGURE_FILE_USE_NODE
16 # EXIWHAT_MULTIKILL_CMD
17 # EXIWHAT_MULTIKILL_ARG
21 # Shell script for seeing what the exim processes are doing. It gets rid
22 # of the old process log, then sends SIGUSR1 to all exim processes to get
23 # them to write their state to the log. Then it displays the contents of
26 # The following lines are generated from Exim's configuration file when
27 # this source is built into a script, but you can subsequently edit them
28 # without rebuilding things, as long are you are careful not to overwrite
29 # the script in the next Exim rebuild/install. However, it's best to
30 # arrange your build-time configuration file to get the correct values.
32 # Some operating systems have a command that finds processes that match
33 # certain conditions (by default usually those running specific commands)
34 # and sends them signals. If such a command is defined for your OS, the
35 # following variables are set and used.
37 multikill_cmd=EXIWHAT_MULTIKILL_CMD
38 multikill_arg=EXIWHAT_MULTIKILL_ARG
40 # In other operating systems, Exim has to use "ps" and "egrep" to find the
41 # processes itself. In those cases, the next three variables are used:
45 egrep_arg=EXIWHAT_EGREP_ARG
47 # In both cases, kill_arg is the argument for the (multi)kill command to send
48 # SIGUSR1 (at least one OS requires a numeric value).
50 signal=EXIWHAT_KILL_SIGNAL
52 # See if this installation is using the esoteric "USE_NODE" feature of Exim,
53 # in which it uses the host's name as a suffix for the configuration file name.
55 if [ "CONFIGURE_FILE_USE_NODE" = "yes" ]; then
56 hostsuffix=.`uname -n`
59 # Now find the configuration file name. This has got complicated because
60 # CONFIGURE_FILE may now be a list of files. The one that is used is the first
61 # one that exists. Mimic the code in readconf.c by testing first for the
62 # suffixed file in each case.
64 set `awk -F: '{ for (i = 1; i <= NF; i++) print $i }' <<End
68 while [ "$config" = "" -a $# -gt 0 ] ; do
69 if [ -f "$1$hostsuffix" ] ; then
70 config="$1$hostsuffix"
71 elif [ -f "$1" ] ; then
77 # check we have a config file
78 if [ "$config" = "" -o ! -f "$config" ]; then
79 echo Config file not found.
83 # Determine where the spool directory is. Search for an exim_path setting
84 # in the configure file; otherwise use the bin directory. Call that version of
85 # Exim to find the spool directory. BEWARE: a tab character is needed in the
86 # first command below. It has had a nasty tendency to get lost in the past. Use
87 # a variable to hold a space and a tab. This is less likely to be touched.
90 exim_path=`grep "^[$st]*exim_path" $config | sed "s/.*=[$st]*//"`
91 if test "$exim_path" = ""; then exim_path=BIN_DIRECTORY/exim; fi
92 spool_directory=`$exim_path -C $config -bP spool_directory | sed "s/.*=[ ]*//"`
93 process_log_path=`$exim_path -C $config -bP process_log_path | sed "s/.*=[ ]*//"`
95 # The file that Exim writes when sent the SIGUSR1 signal is specified by
96 # the process_log_path option. If that is not defined, Exim uses the file
97 # called "exim-process.info" in the spool directory.
100 if [ "$log" = "" ] ; then
101 log=$spool_directory/exim-process.info
107 if [ -f ${log} ]; then
108 echo "** Failed to remove ${log}"
112 # If there is a multikill command, use it. On some OS this command is called
113 # "killall" (Linux, FreeBSD). On Solaris it is called "pkill". Note that on
114 # Solaris, "killall" kills ALL processes - this is the System V version of this
115 # command, and not what we want!
117 if [ "$multikill_cmd" != "" ] && type "$multikill_cmd" >/dev/null 2>&1; then
118 $multikill_cmd $signal "$multikill_arg"
120 # No multikill command; do it the hard way
124 egrep "$egrep_arg" | \
125 awk "{print \"kill $signal \"\$1}" | \
131 if [ ! -s ${log} ] ; then echo "No exim process data" ;
132 else sort -nu ${log} ; fi