"Fossies" - the Fresh Open Source Software Archive

Member "systeminfo/systeminfo.bash" (4 Feb 2005, 7273 Bytes) of package /linux/privat/old/systeminfov12.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 
    3 ################################################################################
    4 #                                                                              #
    5 # Systeninfo - A System Information Generator                                  #
    6 # ===========================================                                  #
    7 #                                                                              #
    8 #    Version : systeminfo v1.2                                                 #
    9 # Created by : Muthukumar Kandasamy                                            #
   10 #         on : Wednesday, Feb 04, 2005                                         #
   11 #    License : GPL (The GNU General Public License)                            #
   12 #                                                                              #
   13 ################################################################################
   14 #                                                                              #
   15 # INSTALL                                                                      #
   16 #                                                                              #
   17 #     1. Copy this script into /usr/bin/systeminfo file.                       #
   18 #        wget                                                                  #
   19 #        cp systeminfo.bash /usr/bin/systeminfo                                #
   20 #                                                                              #
   21 #     2. Change permission into executable.                                    #
   22 #        chmod 755 /usr/bin/systeminfo                                         #
   23 #                                                                              #
   24 #     3. Change User Permission into bin:bin.                                  #
   25 #        chown bin:bin /usr/bin/systeminfo                                     #
   26 #                                                                              #
   27 #     4. Execution.                                                            #
   28 #        systeminfo -h                                                         #
   29 #                                                                              #
   30 ################################################################################
   31 
   32 # Path variable
   33 PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:.
   34 
   35 # System General Informations
   36 geninfo() {
   37 
   38 printf "\nSysteminfo v1.2  - Muthukumar Kandasamy\n"
   39 printf "\nYour system's general information\n"
   40 printf "=================================\n"
   41 
   42 printf "       Hostname : `hostname`\n"
   43 printf "     IP-Address : $(ping `hostname` -c 1 | awk '/^PING/ { print $3 }' | tr -d '()')\n"
   44 printf "  Linux Version : `tr -d '()' < /proc/version | awk '{ print $1" "$2" "$3 }'`\n"
   45 printf "    GCC Version : `tr -d '()' < /proc/version | awk '{ print $5" "$6" "$7" "$8" "$9" "$10" "$11" "$12 }'`\n"
   46 printf "     Build Date : `tr -d '()' < /proc/version |  awk '{ for (i=13;i<=NF;i++) printf $i" " }END { printf "\n";}'`\n"
   47 printf "       Platform : `uname -a | awk '{ print $11" "$12" "$13" "$14 }'`\n"
   48 printf "        Release : `cat /etc/redhat-release`\n\n\n"
   49 
   50 }
   51 # End geninfo
   52 
   53 # Systeminfo usage
   54 usage()
   55 {
   56 printf "USAGE : systeminfo [options]\n\n"
   57 printf "\t-b\tRPM Packages available\n"
   58 printf "\t-c\tSystem Routing Table\n"
   59 printf "\t-d\tDisk Information\n"
   60 printf "\t-D\tDevices (Block/Character) Information\n"
   61 printf "\t-f\tFile System Information\n"
   62 printf "\t-g\tSystem General Information\n"
   63 printf "\t-h\tPrint help message\n"
   64 printf "\t-i\tNetwork Interface information and configuration\n"
   65 printf "\t-I\tInput / Output Port Information\n";
   66 printf "\t-k\tKernel Tunable Parameters\n"
   67 printf "\t-l\tSystem Resource limitation for current user\n"
   68 printf "\t-m\tMemory Information\n"
   69 printf "\t-M\tModules available in the Linux Kernel\n"
   70 printf "\t-N\tAll Sockets Listening on Network\n"
   71 printf "\t-o\tNetwork Statistics\n"
   72 printf "\t-p\tProcessor Information\n"
   73 printf "\t-r\tRAM Size Available\n"
   74 printf "\t-s\tService Running now\n"
   75 printf "\t-t\tRunning Process status\n"
   76 printf "\t-u\tSystem UP-TIME and Users logged now\n"
   77 printf "\t-v\tSystem Information Generator Version\n"
   78 printf "\t-V\tVirtual Memory Statistics\n\n"
   79 }
   80 # End usage
   81 
   82 # Main Script start
   83 option="`getopt -n systeminfo bcdDfghiIklmMoNprstuvV $*`"
   84 if [ $? -ne 0 ]; then
   85     printf "\nUse systeminfo -h for help message\n\n";
   86     exit 1
   87 fi
   88 
   89 set -- `echo $option`
   90 
   91 printf "\nSystem Information Generator - systeminfo v1.2\n"
   92 printf "===============================================\n"
   93 
   94 if [[ $# -eq 1 ]]
   95 then
   96     usage
   97     exit 1
   98 fi
   99 
  100 while [ $# -gt 0 ]; do
  101 case $1 in
  102 -b)
  103     printf "\nRPM Packages Available :\n\n"
  104     rpm -qa
  105     printf "\n"
  106     shift;
  107     ;;
  108 -c)
  109     printf "System Routing Table Information :\n\n"
  110     netstat -rn
  111     printf "\n"
  112     shift;
  113     ;;
  114 -d)
  115     printf "\nDisk Information :\n\n";
  116     fdisk -l
  117     printf "\nDisk Usage :\n\n";
  118     df -h
  119     printf "\n";
  120     shift;
  121     ;;
  122 -D)
  123     printf "\nDevices (Block/Character) Information :\n\n";
  124     cat /proc/devices;
  125     printf "\n";
  126     shift;
  127     ;;
  128 -f)
  129     printf "\nFile System Information :\n\n";
  130     cat /etc/fstab
  131     printf "\n";
  132     shift;
  133     ;;
  134 -g)
  135     geninfo
  136     shift;
  137     ;;
  138 -i)
  139     printf "\nNetwork Interface Information and Configuration :\n\n";
  140     ip link show
  141     printf "\n";
  142     ifconfig -a
  143     printf "\n";
  144     shift;
  145     ;;
  146 -I)
  147     printf "\nInput / Output Port Information :\n\n";
  148     printf "PortStart - PortEnd - PortName\n"
  149     awk '{ split($1,a,"-"); print "0x"a[1]" 0x"a[2]"  "$3 }' /proc/ioports | while read start end name
  150     do 
  151         printf "$(($start))-$(($end)) $name\n"
  152     done
  153     printf "\n";
  154     shift;
  155     ;;
  156 -k)
  157     printf "\nKernel Tunable Parameters :\n\n";
  158     sysctl -a;
  159     printf "\n";
  160     shift;
  161     ;;
  162 -l)
  163     printf "\nSystem Resource limitation for <$USER>:\n\n";
  164     ulimit -a;
  165     printf "\n";
  166     shift;
  167     ;;
  168 -m)
  169     printf "\nMemory Information :\n\n";
  170     cat /proc/meminfo
  171     printf "\n";
  172     shift;
  173     ;;
  174 -M)
  175     printf "\nModules available in the Linux Kernel `uname -r` :\n\n";
  176     lsmod;
  177     printf "\n";
  178     shift;
  179     ;;
  180 -o)
  181     printf "\nNetwork Statistics :\n\n";
  182     netstat -sv;
  183     printf "\n";
  184     shift;
  185     ;;
  186 -N)
  187     printf "\nAll sockets connected and listening in Network :\n\n";
  188     netstat -apen;
  189     printf "\n";
  190     shift;
  191     ;;
  192 -p)
  193     printf "\nProcessor Information :\n\n";
  194     cat /proc/cpuinfo
  195     printf "\n";
  196     shift;
  197     ;;
  198 -r)
  199     printf "\nAvailable RAM size : `awk '/^MemTotal/ { print $2/1024 }' /proc/meminfo` MB\n\n";
  200     shift;
  201     ;;
  202 -s)
  203     printf "\nINIT Level : `awk -F : '/^id/ { print $2 }' /etc/inittab`\n"
  204     printf "\nServices Running now :\n\n";
  205     service --status-all
  206     printf "\n";
  207     shift;
  208     ;;
  209 -t)
  210     printf "\nProcess Information :\n\n";
  211     top -n 1;
  212     printf "\n";
  213     shift;
  214     ;;
  215 -u)
  216     printf "\nSystem UP-TIME and Users logged now :\n\n";
  217     w -l
  218     printf "\n";
  219     shift;
  220     ;;
  221 -v)
  222     printf "Version: systeminfo v1.2\n\n"
  223     break;
  224     ;;
  225 -V)
  226     printf "\nSystem Virtual Memory Statistics :\n\n";
  227     vmstat 1,2 5
  228     printf "\n";
  229     shift;
  230     ;;
  231 -h)
  232     usage;
  233     shift;
  234     break;
  235     ;;
  236 --)
  237     shift;
  238     break;
  239     ;;
  240 esac
  241 done
  242 
  243 # Normal exit
  244 exit 0
  245 
  246 # End
  247