Skip to content

Instantly share code, notes, and snippets.

@felipepodesta
Forked from chrisfu/linux-explorer.sh
Created March 19, 2022 03:03
Show Gist options
  • Select an option

  • Save felipepodesta/b02c032159b6c4dd2ed90852d0d22dd7 to your computer and use it in GitHub Desktop.

Select an option

Save felipepodesta/b02c032159b6c4dd2ed90852d0d22dd7 to your computer and use it in GitHub Desktop.

Revisions

  1. @chrisfu chrisfu revised this gist Jan 15, 2018. 1 changed file with 40 additions and 47 deletions.
    87 changes: 40 additions & 47 deletions linux-explorer.sh
    Original file line number Diff line number Diff line change
    @@ -3,20 +3,20 @@
    #
    #
    # FILE : linux-explorer.sh
    # Last Change Date : 30-03-2015
    # Last Change Date : 04-07-2016
    # Author(s) : Joe Santoro
    # Date Started : 15th April, 2004
    # Email : linuxexplo [ at ] unix-consultants.com
    # Web : http://www.unix-consultants.com/examples/scripts/linux/linux-explorer
    #
    # Usage : ./linux-explorer.sh [option]
    # -d Target directory for explorer files
    # -k Do not delete files created by this script
    # -t [hardware] [software] [configs] [cluster] [disks] [network] [all]
    # -v Verbose output
    # -s Verify Package Installation
    # -h This help message
    # -V Version Number of LINUXEXPLO
    # -d Target directory for explorer files
    # -k Do not delete files created by this script
    # -t [hardware] [software] [configs] [cluster] [disks] [network] [all]
    # -v Verbose output
    # -s Verify Package Installation
    # -h This help message
    # -V Version Number of LINUXEXPLO
    #
    ##############################################################################
    #
    @@ -28,19 +28,10 @@
    # This script is a general purpose script for ALL linux
    # systems and therefore NOT tied into any one distro.
    #
    ##############################################################################
    #
    # J.S UNIX CONSULTANTS LTD MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
    # SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
    # LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
    # PARTICULAR PURPOSE, OR NON-INFRINGEMENT. J.S UNIX CONSULTANTS LTD SHALL
    # NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
    # MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
    #
    ##############################################################################

    COPYRIGHT="Copyright (c) J.S Unix Consultants Ltd"
    MYVERSION="0.206"
    MYVERSION="0.210"
    LICENSE="GLPv2"
    MYDATE="$(/bin/date +'%Y.%m.%d.%m.%H.%M')" # Date and time now
    MYNAME=$(basename $0)
    WHOAMI=$(/usr/bin/whoami) # The user running the script
    @@ -666,7 +657,6 @@ SYSTEMDLOGINCTL=$(mywhich systemd-loginctl)
    DMIDECODE=$(mywhich dmidecode )
    FDISK=$(mywhich fdisk )
    BLKID=$(mywhich blkid )
    HDPARM=$(mywhich hdparm )
    HOSTNAME=$(mywhich hostname )
    HWINFO=$(mywhich hwinfo )
    HWCLOCK=$(mywhich hwclock )
    @@ -683,7 +673,7 @@ SYSTEMDLOGINCTL=$(mywhich systemd-loginctl)
    MDADM=$(mywhich mdadm )
    PROCINFO=$(mywhich procinfo )
    POWERMT=$(mywhich powermt )
    SMARTCTL=$(mywhich smartclt )
    SMARTCTL=$(mywhich smartctl )
    SFDISK=$(mywhich sfdisk )
    HWPARM=$(mywhich hwparm )
    SCSI_ID=$(mywhich scsi_id )
    @@ -935,8 +925,8 @@ function hardware_checks
    MakeDir ${LOGDIR}/hardware/lspci

    if [ -x $LSPCI ] ; then
    $LSPCI > ${LOGDIR}/hardware/lspci/lspci.out 2>&1
    $LSPCI -n > ${LOGDIR}/hardware/lspci/lspci-n.out 2>&1
    $LSPCI > ${LOGDIR}/hardware/lspci/lspci.out 2>&1
    $LSPCI -n > ${LOGDIR}/hardware/lspci/lspci-n.out 2>&1
    $LSPCI -knn > ${LOGDIR}/hardware/lspci/lspci-knn.out 2>&1

    $LSPCI | while read line
    @@ -952,7 +942,7 @@ function hardware_checks
    do
    if [ -f $i ] ; then
    name=$( echo $i | sed 's/\//_/g' | sed 's/^_//g')
    echo "Port Name : $(cat $i )" >> ${LOGDIR}/hardware/lspci/cat_${name}.out
    echo "Port Name : $(cat $i )" >> ${LOGDIR}/hardware/lspci/cat_${name}.out 2>&1
    fi
    done

    @@ -1246,7 +1236,6 @@ function disk_info
    Echo "Section - Disk Section Checks"
    local Dirname


    MakeDir ${LOGDIR}/hardware/disks

    # Check to see what is mounted
    @@ -1264,11 +1253,12 @@ function disk_info
    $MOUNT > ${LOGDIR}/hardware/disks/mount.out 2>&1
    $MOUNT -l > ${LOGDIR}/hardware/disks/mount_-l.out 2>&1

    $CAT /proc/mounts > ${LOGDIR}/hardware/disks/mounts.out 2>&1

    $CAT /proc/mounts > ${LOGDIR}/hardware/disks/cat_proc-mounts.out 2>&1

    # Display any quotas that my have been set
    $REPQUOTA -av > ${LOGDIR}/hardware/disks/repquota_-av 2>&1
    if [ -x $REPQUOTA ] ; then
    $REPQUOTA -av > ${LOGDIR}/hardware/disks/repquota_-av 2>&1
    fi


    ##############################################################################
    @@ -1291,7 +1281,12 @@ function disk_info
    fi

    if [ -x $LSBLK ] ; then
    $LSBLK -f > ${LOGDIR}/hardware/disks/lsblk_-f.out 2>&1
    $LSBLK -f > ${LOGDIR}/hardware/disks/lsblk_-f.out 2>&1
    $LSBLK -a > ${LOGDIR}/hardware/disks/lsblk_-a.out 2>&1
    $LSBLK -p > ${LOGDIR}/hardware/disks/lsblk_-p.out 2>&1
    $LSBLK -t > ${LOGDIR}/hardware/disks/lsblk_-t.out 2>&1
    $LSBLK -S > ${LOGDIR}/hardware/disks/lsblk_-S.out 2>&1
    $LSBLK --list > ${LOGDIR}/hardware/disks/lsblk_--list.out 2>&1
    fi

    if [ -x $LSSCSI ] ; then
    @@ -1304,32 +1299,29 @@ function disk_info

    Dirname=$(dirname $DISK)

    if [ "$Dirname" = "/dev/mapper" ] ; then
    if [ "$Dirname" == "/dev/mapper" ] ; then

    if [ ! -L $DISK ] ; then
    continue
    fi
    fi

    NEWDISK=$(/bin/echo $DISK | sed s'/\/dev\///g' )

    MakeDir ${LOGDIR}/hardware/disks/${NEWDISK}
    NEWDISK=$(/bin/echo $DISK | sed 's/\//-/g' | sed 's/^-//'g )

    if [ -x $HDPARM ] ; then
    $HDPARM -vIi $DISK > ${LOGDIR}/hardware/disks/${NEWDISK}/hdparm_-vIi_${NEWDISK}.out 2>&1
    $HDPARM -vIi $DISK > ${LOGDIR}/hardware/disks/hdparm_-vIi_${NEWDISK}.out 2>&1
    fi

    if [ -x $SFDISK ] ; then
    $SFDISK -l $DISK > ${LOGDIR}/hardware/disks/${NEWDISK}/sfdisk_-l_${NEWDISK}.out 2>&1
    $SFDISK -l $DISK > ${LOGDIR}/hardware/disks/sfdisk_-l_${NEWDISK}.out 2>&1
    fi

    if [ -x $FDISK ] ; then
    $FDISK -l $DISK > ${LOGDIR}/hardware/disks/${NEWDISK}/fdisk_-l_${NEWDISK}.out 2>&1
    $FDISK -l $DISK > ${LOGDIR}/hardware/disks/fdisk_-l_${NEWDISK}.out 2>&1
    fi

    done


    if [ -x "$DUMPE2FS" ] ; then

    MakeDir ${LOGDIR}/hardware/disks/dumpe2fs
    @@ -1635,15 +1627,15 @@ function raid_info
    for i in $( $LS /dev/md[0-9]* 2>/dev/null )
    do
    name=$(/bin/echo $i | sed 's/\//_/g')
    $LSRAID -a $i > ${LOGDIR}/hardware/disks/raid/lsraid_-a_${name}.out > /dev/null 2>&1
    $LSRAID -a $i > ${LOGDIR}/hardware/disks/raid/lsraid_-a_${name}.out 2>&1
    done
    fi

    if [ -x "$MDADM" ] ; then
    for i in $( $LS /dev/md[0-9]* 2>/dev/null )
    do
    name=$( echo $i | sed 's/\//_/g' )
    $MDADM --detail $i > ${LOGDIR}/hardware/disks/raid/mdadm_--detail_${name}.out > /dev/null 2>&1
    $MDADM --detail $i > ${LOGDIR}/hardware/disks/raid/mdadm_--detail_${name}.out 2>&1

    if [ ! -s ${LOGDIR}/hardware/disks/raid/mdadm--detail_${name}.out ] ; then
    $RM -f ${LOGDIR}/hardware/disks/raid/mdadm--detail_${name}.out
    @@ -1671,7 +1663,7 @@ function brtfs_info

    # Scan all devices
    if [ -x $BTRFS ] ; then
    ${BRTFS} filesystem show > ${LOGDIR}/hardware/disks/btrfs/btrfs_filesystem_show.out > /dev/null 2>&1
    ${BRTFS} filesystem show > ${LOGDIR}/hardware/disks/btrfs/btrfs_filesystem_show.out 2>&1

    $DF -h -t btrfs 2>/dev/null | grep -v Filesystem | while read line
    do
    @@ -2326,17 +2318,19 @@ function docker_info
    $DOCKER images > $DockerDir/images.out 2>&1
    # $DOCKER events > $DockerDir/images.out 2>&1

    for containerID in $($DOCKER ps -l | grep -v STATUS | awk '{print $1}' )
    for containerID in $($DOCKER ps -l | grep -v STATUS | awk '{print $2}' )
    do

    $DOCKER inspect $containerID > $DockerDir/docker_inspect_${containerID}.out 2>&1
    $DOCKER port $containerID > $DockerDir/docker_port_${containerID}.out 2>&1
    $DOCKER logs $containerID > $DockerDir/docker_logs_${containerID}.out 2>&1
    containerIDName=$( echo $containerID | sed 's/\//_/g')
    $DOCKER inspect $containerID > $DockerDir/docker_inspect_${containerIDName}.out 2>&1
    $DOCKER port $containerID > $DockerDir/docker_port_${containerIDName}.out 2>&1
    $DOCKER logs $containerID > $DockerDir/docker_logs_${containerIDName}.out 2>&1
    done

    for imageID in $($DOCKER ps -l | grep -v STATUS | awk '{print $1}' )
    for imageID in $($DOCKER ps -l | grep -v STATUS | awk '{print $2}' )
    do
    $DOCKER history $imageID > $DockerDir/docker_history_${imageID}.out 2>&1
    imageIDName=$( echo $imageID | sed 's/\//_/g')
    $DOCKER history $imageID > $DockerDir/docker_history_${imageIDName}.out 2>&1
    done

    fi
    @@ -3359,7 +3353,6 @@ if [ ! -d $LOGDIR ] ; then

    fi


    if [ -f /tmp/README ] ; then
    mv /tmp/README ${LOGDIR}/README
    fi
  2. @chrisfu chrisfu created this gist Jan 27, 2016.
    3,383 changes: 3,383 additions & 0 deletions linux-explorer.sh
    3,383 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.