On Mon, 11 Mar 2002, David Douthitt wrote:

> On 3/11/02 at 1:46 AM, Matt Schalit <[EMAIL PROTECTED]> wrote:
> 
> > guitarlynn wrote:
> 
> > The section below needs a little more work.  The syntax shown
> > will overwrite forward.txt.
> > 
> > cp /var/log/messages /mnt/messages.txt
> > ip addr show > /mnt/address.txt
> > ipchains -nvL > /mnt/filter.txt
> > /usr/sbin/ipmasqadm mfw -nL > /mnt/forward.txt
> > /usr/sbin/ipmasqadm portfw -nl > /mnt/forward.txt
> > cat /proc/net/ip_masq/autofw > /mnt/forward.txt
> > 
> > And I request again that you add in
> > 
> >      ip route show > /mnt/routes.txt
> > 
> > and remove the netstat -rn, only because ip route show
> > is on every distro (correct?)
> 
> Not really....  May I recommend:

If you _are_ going to make a script, all sorts of options are available.
As I said before, the problem is that it will have to be made easy to
install... packaged, I guess.  Not insurmountable, but I still like
instructions that encourage people to examine their own diagnostics.

> ( echo "Messages log\n"

echo doesn't process escapes unless told to.

> cat /var/log/messages
> echo
> 
> if which ip 2> /dev/null ; then
>    ip addr show
>    echo
>    ip route show
> else
>    ifconfig -a
>    echo
>    netstat -rn
> fi

The idea of using tests to distinguish which set of diagnostic
utilities to use is slick.

I did notice that this fails to inform the reader which commands were in
fact executed, and sequence can't really be relied on unless everyone
agrees what it should be.

[...]

> 
> ) > /tmp/sysdata.txt

See attached for further development of this concept...

> This has several advantages:
> 
> 1. Single file at the end for details - /tmp/sysdata.txt - just attach
> and mail.  If you use "matt" (new package to attach files to mail!)
> you can even mail it right from the box.

I prefer to be able to specify output destination.  This may be
undesirable from the point of view of teaching the uninitiated how to use
it, but I think the trade is worth it.

> 2. Testing for existance of programs allows clean execution in even
> the most spartan (or odd) environments.  No ip?  No problem.  No
> ipchains?  No problem....

Of course, you are stuck if your system doesn't have "which" :)

> 3. Using a single file saves some space (constant redirections and
> filenames).  Of course, with all the testing (using which) the end
> result is more bytes - but it's worth it, I think.

But functions can reduce this a bit.

Disclaimers:
My modifications have been tested on a frankenstein 2.2.19 LRP 2.9.8.

I have not really reviewed the set of diagnostics for completeness yet.  
For example, lsmod probably ought to be included.  Perhaps "cat
/etc/issue" ought to be included as well.

Diagnostics from multiple participating machines are often needed to
troubleshoot actual networking problems, and the choices encoded in a
script like this one may have to be manually applied by the user to other
operating systems before a meaningful solution can be found.

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<[EMAIL PROTECTED]>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k
---------------------------------------------------------------------------
#!/bin/sh
# file : leafinfo
# by   : David Douthitt (DD)
#        Jeff Newmiller (JDN)

myw() {
    unalias -a
    # unset may not work right for filenames beginning with "-", but
    # ash does not have the "--" option terminator.
    unset "$@" &> /dev/null
    # ash has no "enable" command... take chances with builtins
    # enable -n -- "$@" &> /dev/null
    # ash has no "-p" option for "type" builtin command
    type "$@" | sed "/not found/d;s/.*\( \)\([^ ]*\)$/\2/"
}

docmd() {
    echo "###BEGIN################################################################"
    echo "## \"$@\" ##"
    eval "$@"
    echo -e 
"###END##################################################################\n"
}

(
echo "## BEGIN REPORT ##"
echo -e "Generated by: leafinfo v0.1\n"
docmd "uname -a"
docmd "cat /var/log/messages"

if [ `myw ip` ]; then
    docmd "ip addr show"
    docmd "ip route show"
else
    docmd "ifconfig -a"
    docmd "netstat -rn"
fi

if [ `myw ipchains` ]; then
   docmd "ipchains -L -v -n"
else
   docmd "iptables -L -v -n"
fi

if [ `myw ipmasqadm` ]; then
   docmd "ipmasqadm mfw -L -n"
   docmd "ipmasqadm portfw -n -l"
   docmd "cat /proc/net/ip_masq/autofw"
fi

echo
echo "## END REPORT ##"

) 2>&1

Reply via email to