Info-script om hdds

Dette forum bruges på EGET ANSVAR til at lege med scripts og andre ting med risiko for at beskadige sit eget og andres systemer.
Brugeravatar
NickyThomassen
Admin
Indlæg: 3650
Tilmeldt: 5. mar 2010, 19:58
IRC nickname: nicky
Geografisk sted: 192.168.20.42

Info-script om hdds

Indlægaf NickyThomassen » 29. dec 2011, 17:23

Se hvad jeg fandt hos vores venner ovre ved Cent-OS

Kode: Vælg alt

#!/bin/bash
# getinfo.sh
# This script collects system hardware and software information.
# Exact information collected depends on how it is called.
# It was developed by CentOS Forum members and is released under
#   the GNU General Public License, version 2 or later (GPL).

# Set locale to English
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US:en_GB:en

PATH=/sbin:/bin:/usr/sbin:/usr/bin

# Separator for commands.
IFS=:

# Temporary file for output.
TMPFILE="`mktemp -t basedata.XXXXXX`" || exit 1

# Command list:
PRGBASE="uname -rmi:rpm -qa \*-release\*:cat /etc/redhat-release:getenforce:free -m"
PRGPKGS="rpm -qa yum\* rpm-\* python | sort:ls /etc/yum.repos.d:cat /etc/yum.conf"
PRGPKGS=$PRGPKGS:"yum repolist all:egrep 'include|exclude' /etc/yum.repos.d/*.repo"
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"
PRGSNET="ifconfig -a:route -n:cat /etc/resolv.conf:grep net /etc/nsswitch.conf:chkconfig --list | grep -Ei 'network|wpa'"

if [ $# -lt 1 ]; then
    echo "No option provided.  Default to all information."
    CASE="all"
else
    CASE="$1"
fi

# If not running as root then no fdisk or lvdisplay
if [[ $EUID -eq 0 ]]; then
    PRGDISK="cat /etc/fstab:df -h:fdisk -l:blkid:cat /proc/mdstat:pvs:vgs:lvs"
else
    PRGDISK="cat /etc/fstab:df -h:blkid:cat /proc/mdstat"
    echo ""
    echo "WARNING!!!"
    echo "Not running as root. No fdisk or LVM information will be provided!"
    echo ""
    if [ "$CASE" = "disk" ]; then
        echo "Not running as root. No fdisk information will be provided!!!" >> $TMPFILE 2>&1
    fi
fi

case "$CASE" in
  basic)
        PRGS="$PRGBASE"
        echo "Basic system information." >> $TMPFILE 2>&1
   ;;
  disk)
        PRGS="$PRGBASE:$PRGDISK"
        echo "Information for disk problems." >> $TMPFILE 2>&1
        ;;
  driver)
        PRGS="$PRGBASE:$PRGKRNL:$PRGHARD"
        echo "Information for driver problems." >> $TMPFILE 2>&1
        ;;
  network)
        PRGS="$PRGBASE:$PRGHARD:$PRGSNET"
        echo "Information for network problems." >> $TMPFILE 2>&1
   ;;
  package)
   PRGS="$PRGBASE:$PRGPKGS:$PRGKRNL"
        echo "Information for package problems." >> $TMPFILE 2>&1
   ;;
  all)
   PRGS="$PRGBASE:$PRGPKGS:$PRGDISK:$PRGKRNL:$PRGHARD:$PRGSNET"
        echo "Information for general problems." >> $TMPFILE 2>&1
   ;;
  *)
        echo "Usage: `basename $0` {all|basic|disk|driver|network|package}"
   echo "Option $CASE not recognized."
        exit 1
esac
echo "Collecting CentOS system information for $CASE 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
   echo >> $TMPFILE 2>&1
done

echo "[/code]" >> $TMPFILE 2>&1

chmod a+r $TMPFILE

echo -e "\n########################"
echo -e "Results are in the file:\n* $TMPFILE *"
echo -e "########################\n"

echo    "To provide this information in support of a question on the CentOS fora,"
echo -e "mailing list, or IRC channel please post its contents to\n"
echo    "      http://pastebin.centos.org/"
echo -e "\nor another similar public site of your choice."
echo    "Select a retention time longer than the default of 'a day'"
echo -e "and provide a link to the information in your post.\n"

echo    "Alternatively, post in-line, trimming to remove any unnecessary information"
echo    "for your topic.  For forum posts, please leave in the"
echo -e "[code] ... [/code] tags to preserve formatting.\n"

echo    "WARNING - Check the contents of the $TMPFILE file to ensure it does"
echo    "not contain any sensitive information such as public IP addresses or hostnames."
echo    "If necessary obfuscate such information before posting. For example:"
echo    "   146.xxx.xxx.41 or myhost.mydomain.net"


Jeg ved godt at vi har noget i den retning, men resultatet er rigtig lækkert, og fortæller alt omkring harddiske på systemet (indlæg #3):
https://www.centos.org/modules/newbb/viewtopic.php?topic_id=27649&forum=39

Det skal dog nok modificeres lidt hvis vi skal kunne bruge det, for det ser ud til at pille ved LOCALE (men jeg ved ikke om det betyder noget).

Edit, det kan åbenbart mere end bare harddisk-info, alt efter hvordan det kaldes:
http://www.centos.org/modules/newbb/viewtopic.php?topic_id=28723&forum=54

Tilbage til "Sandkassen"

Hvem er online

Brugere der læser dette forum: [Bot] og 0 gæster