gatherinfo: Get Useful Information About UNIX/Linux System

I recently came across HP Universal Discovery software but it's very complicated, requires a separate server and database and is far from complete when it comes to gathering data from the UNIX and Linux systems.

So I sat one day and thought what information about a system you need to tell that you know enough about it and that you can take responsibility for its uptime... and of course how to gather that information fast end efficiently from a running system.

After several hours I already had a prototype that gathers information about UNIX and Linux systems, without an idea for a better name I end up with gatherinfo. It's a simple script gatherinfo.sh with dependency on POSIX sh(1) and echo/cat/sed, all other commands are used to gather information from the running system. The result of the script is a report-like HTML file named gatherinfo.sh.$( hostname ).htm with outputs of the desired commands.

As the script is running it shows which command is now being processed, so you know why it may take that much time, usually its work is done in less than a minute. And yes, it does need to run as root.

Code:
# [color="Blue"]gatherinfo.sh[/color]
top -d 1
sockstat
ps ax
ps aux
ps auxwww
ps auxefw
pstree -A
pstree -A -a
lsof
cat /etc/hostid
cat /etc/freebsd-update.conf
grep enable /etc/rc.conf
kldstat
kldstat -v
jls
vmstat 1 5
(...)

And the end result looks like that one below. You can expand/collapse each command so its not several kilometers long ;)

gatherinfo-02.png


Of course it's far from complete after two days of messing with it, but I will add more and more useful commands.

Currently it gathers information from FreeBSD and Linux but my personal TODO contains operating systems like AIX, Solaris, HP-UX and of course other BSDs. On the other side I will also add cluster and/or HA software like FreeBSD's HAST/CARP, Linux RHCS, Oracle Clusterware, Sun Cluster, HP Serviceguard and AIX PowerHA. Also various Veritas storage and HA solutions are on my TODO list.

I have created the https://github.com/vermaden/gatherinfo repository for the development.

Feel free to submit your favorite commands ;)
 
Last edited by a moderator:
This looks really nice and simple. I do seem to be missing something here. I copied gatherinfo from GitHub, saved and made executable. The output for each field comes out as
Code:
./gatherinfo.sh: s/>/\>/g: not found
I am running PC-BSD 10.1 RC3. What am I doing wrong?
 
Last edited by a moderator:
This looks really nice and simple. I do seem to be missing something here. I copied gatherinfo from GitHub, saved and made executable. The output for each field comes out as "./gatherinfo.sh: s/>/\>/g: not found". I am running PC-BSD 10.1 RC3. What am I doing wrong?
Hi, could you execute it like that and give me the output?

% sh -x ./gatherinfo.sh

Thanks.
 
I was not aware of your script until today. I was personally interested in writing a script which will enumerate unknown servers for me. I have to carefully go through your script. It might not be 100% what I want but it is definitely a great start.

Thank you for this!
 
% sh -x ./gatherinfo.sh gives "too many arguments". sh -x ./gatherinfo.sh gives the same
Code:
./gatherinfo.sh: s/>/\>/g: not found
for each item.

Output is attached. Also, thanks for writing the script and taking the time to review my results.
 

Attachments

  • gatherinfooutput.txt
    30 KB · Views: 164
% sh -x ./gatherinfo.sh gives "too many arguments". sh -x ./gatherinfo.sh gives same "./gatherinfo.sh: s/>/\>/g: not found" for each item.

Output is attached. Also, Thanks for writing the script and taking the time to review my results.


The only isntance of sed in gatherinfo.sh is here, and it's valid:
# grep sed gatherinfo.sh
Code:
  echo "${OUT}" | sed -e s/'&'/'\&amp;'/g -e s/'<'/'\&lt;'/g -e s/'>'/'\&gt;'/g >> ${OUTFILE} 2>&1

Here is a quick test (no errors): # dmesg | sed -e s/'>'/'\&gt;'/g 1> /dev/null

You should try to download the RAW script again this way and test again please:
# fetch -o gatherinfo.sh
Code:
https://raw.githubusercontent.com/vermaden/gatherinfo/master/gatherinfo.sh

Regards,
vermaden
 
Just installed it on my Freebsd FreeBSD 10.1, and found these problems

1. iostat(8) - looks like iostat -c 1 5 will run forever, while the intention seems to be to run 5 times with 1 second delay. The command then should be iostat -w 1 -c 5. Applies also to the next invocation with -x.

2. Currently script is still running, and I presume it will run for very long time on these finds. My server is with 10TB filled of various files, so time to do this is not worthy.....I killed it and limit the search just in /var so it perform faster. Now is ok for me.

Code:
"find / -type f -iname dsmserv.err | xargs tail -n 99999" \
  "find / -type f -iname dsmserv.opt | xargs tail -n 99999" \
  "find / -type f -iname volhist.dat | xargs tail -n 99999" \
  "find / -type f -iname devconf.dat | xargs tail -n 99999" \
  "find / -type f -iname logattr.chk | xargs tail -n 99999" \
  "find / -type f -iname dsm.sys | xargs tail -n 99999" \
  "find / -type f -iname dsm.opt | xargs tail -n 99999" \
  "find / -type f -iname Tivoli_Storage_Manager_InstallLog.log

3. Very good report, it will be useful. Thanks.
 
  • Thanks
Reactions: Oko
In addition pkg audit returns >0 when there are vulnerabilities found, but __command skips any command that returns non-zero exit code, so nothing will be displayed in case of vulnerabilities.

Code:
if [ ${?} -ne 0 ]
then
   return
fi
 
Just installed it on my Freebsd FreeBSD 10.1, and found these problems

1. iostat(8) - looks like iostat -c 1 5 will run forever, while the intention seems to be to run 5 times with 1 second delay. The command then should be iostat -w 1 -c 5. Applies also to the next invocation with -x.

Fixed, now as iostat 1 5.

The 'idea' of gatherinfo.sh is to be as much cross platform with the same code as possible, iostat command was one of the commands that worked on HP-UX or AIX but not on FreeBSD.

2. Currently script is still running, and I presume it will run for very long time on these finds. My server is with 10TB filled of various files, so time to do this is not worthy.....I killed it and limit the search just in /var so it perform faster. Now is ok for me.

Code:
"find / -type f -iname dsmserv.err | xargs tail -n 99999" \
  "find / -type f -iname dsmserv.opt | xargs tail -n 99999" \
  "find / -type f -iname volhist.dat | xargs tail -n 99999" \
  "find / -type f -iname devconf.dat | xargs tail -n 99999" \
  "find / -type f -iname logattr.chk | xargs tail -n 99999" \
  "find / -type f -iname dsm.sys | xargs tail -n 99999" \
  "find / -type f -iname dsm.opt | xargs tail -n 99999" \
  "find / -type f -iname Tivoli_Storage_Manager_InstallLog.log

Limited to 1024 or 10240 in latest version.


3. Very good report, it will be useful. Thanks.
Welcome. Thanks for your input about its usage.

In addition pkg audit returns >0 when there are vulnerabilities found, but __command skips any command that returns non-zero exit code, so nothing will be displayed in case of vulnerabilities.

Code:
if [ ${?} -ne 0 ]
then
   return
fi
Added 'dirty' workaround as pkg audit | tee /dev/null.

Its created that way because if some command is not available on one system, it will work on another, HP-UX vs. FreeBSD vs. Linux vs. AIX ...
 
vermaden Thank you for your script, it is useful and very instructive.

I was wondering how could it be used to inspect a system being repaired using a live CD?

After mounting that system as readonly under /mnt, how can I have gatherinfo.sh pick it up?

Is this something that would work?
Code:
zpool import -o altroot=/mnt -o readonly=on -f tank1
env ROOT=/mnt
/home/gsl/gatherinfo.sh
 
Last edited by a moderator:
Back
Top