#!/bin/bash -e ################################################################## # john meister - april 2016 - http://LinuxMeister # script to gather system info on linux systems for spreadsheet ################################################################## # # field 1: TOPIC # field 2: DATA # field 3: COMMAND used # # PROCESS: # 1) run script sh./collect-sys-info.sh # 2) vi the output file (hostname.date.csv); edit in vi, # join each set of 3 lines into 1 # 3) then open the csv into excel/openoffice/libre office # 4) save as xls - 97-2003 format and use to manage system, adding fields as neeed. ################################################################# LOG=`hostname`.`date +'%Y_%m_%d_%H%M'`.csv HOST=`hostname` ################################################################## # ################################################################## # header line for CSV file import into excel/openoffice/libreoffice # best for interoperability to save as office 97-2003 .xls format ################################################################## ### NOTE the following line starts the file contents ##### echo "#### TOPIC ####" > $LOG echo "#### VALUE ####" >> $LOG echo "#### COMMAND USED ####" >> $LOG # echo "hostname; " >> $LOG # hostname echo "`hostname` ;" >> $LOG # hostname echo "hostname; " >> $LOG # hostname # echo "make; ">> $LOG # make echo "`sudo dmesg | grep DMI`; " >> $LOG # make echo "sudo dmesg | grep DMI ;" >> $LOG # make # echo "kernel; " >> $LOG # kernel echo "`uname -r` ;" >> $LOG # kernel echo "uname -r ;" >> $LOG # kernel # echo "cpu; " >> $LOG # cpu echo "`sudo cat /proc/cpuinfo | grep "model name" | uniq `;" >> $LOG # cpu echo "sudo cat /proc/cpuinfo | grep model name | uniq ;" >> $LOG # cpu # echo "MemTotal;" >> $LOG # total_memory echo "`sudo cat /proc/meminfo | grep MemTotal` ;" >> $LOG # total_memory echo "sudo cat /proc/meminfo | grep MemTotal ;" >> $LOG # total_memory # echo "SwapTotal; " >> $LOG # total_swap echo "`sudo cat /proc/meminfo | grep SwapTotal` ;" >> $LOG # total_swap echo "sudo cat /proc/meminfo | grep SwapTotal ;" >> $LOG # total_swap # echo "rootfs; " >> $LOG # root_filesystem echo "`cat /proc/mounts | grep " / " | grep -v rootfs` ;" >> $LOG # root_filesystem echo "cat /proc/mounts | grep " / " | grep -v rootfs ;" >> $LOG # root_filesystem # echo "root_size; " >> $LOG # root_size echo "`df -h / | awk '{print $2}' | grep -v Size`;" >> $LOG # root_size echo "df -h / | awk '{print \$2}' | grep -v Size ;" >> $LOG # root_size # echo "root_avail; " >> $LOG # root_avail echo "`df -h / | awk '{print $4}' | grep -v Avail`;" >> $LOG # root_avail echo "df -h / | awk '{print \$4}' | grep -v Size ;" >> $LOG # root_avail # echo "ip_addr; " >> $LOG # ip_address echo "`ping -c 1 $HOST | grep PING | awk '{print $3}'`;" >> $LOG # ip_address echo "ping -c 1 'hostname' | grep PING | awk '{print \$3}' ;" >> $LOG # ip_address # echo "route; " >> $LOG # gateway echo "`route | grep default | awk '{print $2}'`;" >> $LOG # gateway echo "route | grep default | awk '{print \$2}' ;" >> $LOG # gateway # echo "HWaddr; " >> $LOG # mac echo "`ifconfig -a | grep -C 2 Bcast | grep HWaddr | awk '{print $5}'`;" >> $LOG # mac echo "ifconfig -a | grep -C 2 Bcast | grep HWaddr | awk '{print \$5}' ;" >> $LOG # mac # echo "netmask; " >> $LOG # netmask echo "`ifconfig -a | grep Bcast | awk '{print $4}'`;" >> $LOG # netmask echo "ifconfig -a | grep Bcast | awk '{print \$4}' ;" >> $LOG # netmask # echo "gateway " >> $LOG # gateway echo "`route | grep default | awk '{print $2}'`" >> $LOG # gateway echo "route | grep default | awk '{print \$2}' " >> $LOG # gateway # results of script------------------------------------------------ --> more server-info.2017_04_26_1457.csv #### TOPIC #### #### VALUE #### #### COMMAND USED #### hostname; server; hostname; make; [ 0.000000] DMI: Dell Inc. Precision WorkStation T4500 /0D893F, BIOS A11 10/30/2011; sudo dmesg | grep DMI ; kernel; 3.10.0-514.el7.x86_64 ; uname -r ; cpu; model name : Intel(R) Xeon(R) CPU X5550 @ 2.67GHz; sudo cat /proc/cpuinfo | grep model name | uniq ; MemTotal; MemTotal: 18321720 kB ; sudo cat /proc/meminfo | grep MemTotal ; SwapTotal; SwapTotal: 9306108 kB ; sudo cat /proc/meminfo | grep SwapTotal ; rootfs; /dev/mapper/cl-root / xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0 ; cat /proc/mounts | grep / | grep -v rootfs ; root_size; 50G; df -h / | awk '{print $2}' | grep -v Size ; root_avail; 46G; df -h / | awk '{print $4}' | grep -v Size ; ip_addr; (10.10.10.95); ping -c 1 'hostname' | grep PING | awk '{print $3}' ; route; 10.10.10.1; route | grep default | awk '{print $2}' ; HWaddr; ; ifconfig -a | grep -C 2 Bcast | grep HWaddr | awk '{print $5}' ; netmask; ; ifconfig -a | grep Bcast | awk '{print $4}' ; gateway 10.10.10.1; route | grep default | awk '{print $2}' ------------------------------------------------ |
The Art of Linux System Administration published by O'Reilly Media Study Guide for the LPIC-2 Certification Exams |
Wagoneers FULL SIZE JEEPS JeepMeister "Jeep is America's -Enzo Ferrari MeisterTech Diesels + |
One Page Overview of Linux Commands click for an image of the 5 essential Linux commands An Intro to Linux |
at Midway Auto on SR9 in Snohomish, or at Northland Diesel in Bellingham, WA |