Permalink
Browse files

Merge pull request #38 from pschaff/master

getinfo: Update to version 1.1
  • Loading branch information...
2 parents 5d85527 + f634aa4 commit 030f173b1417375c50bfc072213b59f1bb8cfeb1 Phil Schaffner committed Apr 23, 2012
Showing with 97 additions and 46 deletions.
  1. +41 −21 getinfo/el5/getinfo.sh
  2. +8 −2 getinfo/el5/getinfo.spec
  3. +41 −21 getinfo/el6/getinfo.sh
  4. +7 −2 getinfo/el6/getinfo.spec
View
@@ -6,6 +6,7 @@
# the GNU General Public License, version 2 or later (GPL).
# It should work on most Enterprise Linux or Fedora distributions.
# Version 1.0 4/5/2011
+# Version 1.1 4/23/2012
# Set locale to English
export LC_ALL=en_US.UTF-8
@@ -26,71 +27,90 @@ PRGPKGS=$PRGPKGS:"yum repolist all:egrep 'include|exclude' /etc/yum.repos.d/*.re
PRGPKGS=$PRGPKGS:'sed -n -e "/^\[/h; /priority *=/{ G; s/\n/ /; s/ity=/ity = /; p }" /etc/yum.repos.d/*.repo | sort -k3n'
PRGKRNL="rpm -qa kernel\\* | sort"
PRGHARD="lspci -nn:lsusb:rpm -qa kmod\* kmdl\*"
-PRGSNET="ifconfig -a:brctl show:route -n:cat /etc/resolv.conf:grep net /etc/nsswitch.conf:chkconfig --list | grep -Ei 'network|wpa'"
+PRGSNET="ifconfig -a:brctl show:route -n"
+PRGSNET=$PRGSNET:"sysctl -a | grep "\.rp_filter":ip rule show:ip route show"
+PRGSNET=$PRGSNET:"cat /etc/resolv.conf:grep net /etc/nsswitch.conf"
+PRGSNET=$PRGSNET:"chkconfig --list | grep -Ei 'network|wpa'"
if [ $# -lt 1 ]; then
echo "No option provided. Default to all information."
CASE="all"
else
- CASE="$1"
+ CASE=$(echo "$1" | tr '[:upper:]' '[:lower:]')
fi
-# If not running as root then no fdisk, parted, or lvdisplay
+# If not running as root then no fdisk, parted, blkid, or lvdisplay
if [[ $EUID -eq 0 ]]; then
PRGDISK="cat /etc/fstab:df -h:fdisk -l:parted -l:blkid:cat /proc/mdstat:pvs:vgs:lvs"
else
- PRGDISK="cat /etc/fstab:df -h:blkid:cat /proc/mdstat"
+ PRGDISK="cat /etc/fstab:df -h:cat /proc/mdstat"
echo ""
echo "WARNING!!!"
- echo "Not running as root. No fdisk, parted, or LVM information will be provided!"
+ echo "Not running as root. No fdisk, parted, blkid, or LVM information will be provided!"
echo ""
- if [ "$CASE" = "disk" ]; then
- echo "Not running as root. No fdisk, parted, or LVM information will be provided!!!" >> $TMPFILE 2>&1
- fi
fi
case "$CASE" in
- basic)
+ bas*)
PRGS="$PRGBASE"
echo "Basic system information." >> $TMPFILE 2>&1
+ CAS="Basic"
;;
- disk)
+ dis*)
PRGS="$PRGBASE:$PRGDISK"
echo "Information for disk problems." >> $TMPFILE 2>&1
- ;;
- driver)
+ CAS="Disk"
+ if [[ $EUID -ne 0 ]]; then
+ echo "Not running as root. No fdisk, parted, blkid, or LVM information provided!!!" >> $TMPFILE 2>&1
+ fi
+ ;;
+ dri*)
PRGS="$PRGBASE:$PRGKRNL:$PRGHARD"
echo "Information for driver problems." >> $TMPFILE 2>&1
- ;;
- network)
+ CAS="Driver"
+ ;;
+ net*)
PRGS="$PRGBASE:$PRGHARD:$PRGSNET"
- echo "Information for network problems." >> $TMPFILE 2>&1
+ echo "Information for networking problems." >> $TMPFILE 2>&1
+ CAS="Networking"
;;
- package)
+ pac*)
PRGS="$PRGBASE:$PRGPKGS:$PRGKRNL"
- echo "Information for package problems." >> $TMPFILE 2>&1
+ echo "Information for package management problems." >> $TMPFILE 2>&1
+ CAS="Packaging"
;;
all)
PRGS="$PRGBASE:$PRGPKGS:$PRGDISK:$PRGKRNL:$PRGHARD:$PRGSNET"
echo "Information for general problems." >> $TMPFILE 2>&1
+ CAS="General"
;;
*)
echo "Usage: `basename $0` {all|basic|disk|driver|network|package}"
echo "Option $CASE not recognized."
exit 1
esac
-echo "Collecting system information for $CASE questions."
+
+echo "Collecting system information for $CAS questions."
echo "[code]" >> $TMPFILE 2>&1
for program in $PRGS
do
- echo "== BEGIN $program ==" >> $TMPFILE 2>&1
- eval $program >> $TMPFILE 2>&1
- echo "== END $program ==" >> $TMPFILE 2>&1
+ PRG=$(type -p $(echo $program | cut -d ' ' -f 1) 2>/dev/null | cut -d ' ' -f 3)
+ if [ -n "$PRG" -a -x "$PRG" ]; then
+ echo "== BEGIN $program ==" >> $TMPFILE 2>&1
+ eval $program >> $TMPFILE 2>&1
+ echo "== END $program ==" >> $TMPFILE 2>&1
+ else
+ PRG=$(echo $program | cut -d ' ' -f 1)
+ echo "== Warning: $PRG is not installed ==" >> $TMPFILE 2>&1
+ echo "***"
+ echo "*** Warning: $PRG is not installed."
+ fi
echo >> $TMPFILE 2>&1
done
+echo "***"
echo "[/code]" >> $TMPFILE 2>&1
chmod a+r $TMPFILE
View
@@ -1,7 +1,7 @@
Summary: Packaged 'getinfo.sh' script for RPM based distros
Name: getinfo
-Version: 1.0
-Release: 2%{?dist}
+Version: 1.1
+Release: 1%{?dist}
License: GPLv2
Group: Applications/System
URL: https://github.com/elrepo/packages/tree/master/getinfo/el5
@@ -35,8 +35,14 @@ Bash script to supply system information for use on support fora.
%doc %{_usr}/local/share/doc/%{name}-%{version}/ReadMe.txt
%changelog
+* Mon Apr 23 2012 Phil Schaffner <pschaff2@verizon.net> - 1.1-1
+- Enhancements to network information
+- Add error checking for missing commands
+- Arguments now require only 3 characters and are case-insensitive
+
* Sat Apr 7 2012 Phil Schaffner <pschaff2@verizon.net> - 1.0-1
- Package for ELRepo for el5
* Thu Apr 05 2012 Trevor Hemsley <trevor.hemsley@ntlworld.com> - 1.0-0
- Initial spec.
+
View
@@ -6,6 +6,7 @@
# the GNU General Public License, version 2 or later (GPL).
# It should work on most Enterprise Linux or Fedora distributions.
# Version 1.0 4/5/2011
+# Version 1.1 4/23/2012
# Set locale to English
export LC_ALL=en_US.UTF-8
@@ -26,71 +27,90 @@ PRGPKGS=$PRGPKGS:"yum repolist all:egrep 'include|exclude' /etc/yum.repos.d/*.re
PRGPKGS=$PRGPKGS:'sed -n -e "/^\[/h; /priority *=/{ G; s/\n/ /; s/ity=/ity = /; p }" /etc/yum.repos.d/*.repo | sort -k3n'
PRGKRNL="rpm -qa kernel\\* | sort"
PRGHARD="lspci -nn:lsusb:rpm -qa kmod\* kmdl\*"
-PRGSNET="ifconfig -a:brctl show:route -n:cat /etc/resolv.conf:grep net /etc/nsswitch.conf:chkconfig --list | grep -Ei 'network|wpa'"
+PRGSNET="ifconfig -a:brctl show:route -n"
+PRGSNET=$PRGSNET:"sysctl -a | grep "\.rp_filter":ip rule show:ip route show"
+PRGSNET=$PRGSNET:"cat /etc/resolv.conf:grep net /etc/nsswitch.conf"
+PRGSNET=$PRGSNET:"chkconfig --list | grep -Ei 'network|wpa'"
if [ $# -lt 1 ]; then
echo "No option provided. Default to all information."
CASE="all"
else
- CASE="$1"
+ CASE=$(echo "$1" | tr '[:upper:]' '[:lower:]')
fi
-# If not running as root then no fdisk, parted, or lvdisplay
+# If not running as root then no fdisk, parted, blkid, or lvdisplay
if [[ $EUID -eq 0 ]]; then
PRGDISK="cat /etc/fstab:df -h:fdisk -l:parted -l:blkid:cat /proc/mdstat:pvs:vgs:lvs"
else
- PRGDISK="cat /etc/fstab:df -h:blkid:cat /proc/mdstat"
+ PRGDISK="cat /etc/fstab:df -h:cat /proc/mdstat"
echo ""
echo "WARNING!!!"
- echo "Not running as root. No fdisk, parted, or LVM information will be provided!"
+ echo "Not running as root. No fdisk, parted, blkid, or LVM information will be provided!"
echo ""
- if [ "$CASE" = "disk" ]; then
- echo "Not running as root. No fdisk, parted, or LVM information will be provided!!!" >> $TMPFILE 2>&1
- fi
fi
case "$CASE" in
- basic)
+ bas*)
PRGS="$PRGBASE"
echo "Basic system information." >> $TMPFILE 2>&1
+ CAS="Basic"
;;
- disk)
+ dis*)
PRGS="$PRGBASE:$PRGDISK"
echo "Information for disk problems." >> $TMPFILE 2>&1
- ;;
- driver)
+ CAS="Disk"
+ if [[ $EUID -ne 0 ]]; then
+ echo "Not running as root. No fdisk, parted, blkid, or LVM information provided!!!" >> $TMPFILE 2>&1
+ fi
+ ;;
+ dri*)
PRGS="$PRGBASE:$PRGKRNL:$PRGHARD"
echo "Information for driver problems." >> $TMPFILE 2>&1
- ;;
- network)
+ CAS="Driver"
+ ;;
+ net*)
PRGS="$PRGBASE:$PRGHARD:$PRGSNET"
- echo "Information for network problems." >> $TMPFILE 2>&1
+ echo "Information for networking problems." >> $TMPFILE 2>&1
+ CAS="Networking"
;;
- package)
+ pac*)
PRGS="$PRGBASE:$PRGPKGS:$PRGKRNL"
- echo "Information for package problems." >> $TMPFILE 2>&1
+ echo "Information for package management problems." >> $TMPFILE 2>&1
+ CAS="Packaging"
;;
all)
PRGS="$PRGBASE:$PRGPKGS:$PRGDISK:$PRGKRNL:$PRGHARD:$PRGSNET"
echo "Information for general problems." >> $TMPFILE 2>&1
+ CAS="General"
;;
*)
echo "Usage: `basename $0` {all|basic|disk|driver|network|package}"
echo "Option $CASE not recognized."
exit 1
esac
-echo "Collecting system information for $CASE questions."
+
+echo "Collecting system information for $CAS questions."
echo "[code]" >> $TMPFILE 2>&1
for program in $PRGS
do
- echo "== BEGIN $program ==" >> $TMPFILE 2>&1
- eval $program >> $TMPFILE 2>&1
- echo "== END $program ==" >> $TMPFILE 2>&1
+ PRG=$(type -p $(echo $program | cut -d ' ' -f 1) 2>/dev/null | cut -d ' ' -f 3)
+ if [ -n "$PRG" -a -x "$PRG" ]; then
+ echo "== BEGIN $program ==" >> $TMPFILE 2>&1
+ eval $program >> $TMPFILE 2>&1
+ echo "== END $program ==" >> $TMPFILE 2>&1
+ else
+ PRG=$(echo $program | cut -d ' ' -f 1)
+ echo "== Warning: $PRG is not installed ==" >> $TMPFILE 2>&1
+ echo "***"
+ echo "*** Warning: $PRG is not installed."
+ fi
echo >> $TMPFILE 2>&1
done
+echo "***"
echo "[/code]" >> $TMPFILE 2>&1
chmod a+r $TMPFILE
View
@@ -1,7 +1,7 @@
Summary: Packaged 'getinfo.sh' script for RPM based distros
Name: getinfo
-Version: 1.0
-Release: 2%{?dist}
+Version: 1.1
+Release: 1%{?dist}
License: GPLv2
Group: Applications/System
URL: https://github.com/elrepo/packages/tree/master/getinfo/el6
@@ -35,6 +35,11 @@ Bash script to supply system information for use on support fora.
%doc %{_usr}/local/share/doc/%{name}-%{version}/ReadMe.txt
%changelog
+* Mon Apr 23 2012 Phil Schaffner <pschaff2@verizon.net> - 1.1-1
+- Enhancements to network information
+- Add error checking for missing commands
+- Arguments now require only 3 characters and are case-insensitive
+
* Sat Apr 7 2012 Phil Schaffner <pschaff2@verizon.net> - 1.0-1
- Package for ELRepo for el6

0 comments on commit 030f173

Please sign in to comment.