#!/usr/bin/env bash # # System Report Script, Version 1.05 # # The purpose of this script is to use shell commands to build a set of html files in a # folder in the user's folder called home/username/SysReport where username is replaced with # the username of the logged on user. This set of files will load # via home/username/SysReport/index.html a frame set with navigation in the left frame, # and individual reports about different parts of the system in the right frame of the document. # # #First we create the folder if it doesn't already exist echo "Creating SysReport Folder" if [ -e ~/SysReport ] && [ -d ~/SysReport ] then : # if it exists and is a folder do nothing else mkdir ~/SysReport fi # Next we want to create the index.html file whether it exists or not to allow for updating it # with new versions of the script echo "Creating index.html" cat > ~/SysReport/index.html << EOF System Report <BODY> <P> </BODY> EOF # echo "Creating Introduction.html" # Here I create the introduction page. cat > ~/SysReport/Introduction.html << EOF Introduction to System Report

Welcome, you are logged in as: $USER

Welcome to the script generated System Report for Ubuntu systems. This set of web pages is generated from many accessible files and commands on your system by the SystemReport.sh file. This set of pages was generated by Version 1.05 of SystemReport.sh

Each report is listed in the navigation frame on the left and will load in this frame. Each section includes an explanation of what command or file was accessed to generate that section of the report.

As I learn more about Ubuntu and Linux and scripting the SystemReport.sh file will grow and so will the number of html files it generates. Look for it at System Report Script to see if there are new versions of it.

The SystemReport.sh file is open source and so I encourage you to add to it yourself as long as you don't hold me responsible for any damages your changes cause. 8-)

If you do add a section to one of the pages, or even a whole page to the set, please email me your changes or additions only. Please don't send me the whole script to look through for your changes.

SystemReport.sh may be ran multiple times so that it may update these pages when you make changes to your system and so you can replace it with a newer version of the script and generate a new set of these web pages.



EOF # # Now it's time to create navigate.html which will expand as new parts of the script are created echo "Creating navigate.html" cat > ~/SysReport/navigate.html << EOF Sysytem Report Navigation EOF # # Here we create cpuinfo.html echo "Creating cpuinfo.html" cat > ~/SysReport/cpuinfo.html << EOF CPU Information

The command that generates the following out put is:

cat /proc/cpuinfo >> ~/SysReport/cpuinfo.html
cat /proc/cpuinfo
EOF
# generate the out put from system file
cat /proc/cpuinfo >> ~/SysReport/cpuinfo.html
# add the end of the file
cat >> ~/SysReport/cpuinfo.html << EOF

To get the out put of this command in terminal use the following form:

cat /proc/cpuinfo

This will output the information to the terminal screen. You can't open the file cpuinfo in Gedit but the cat command gives you access to the contents of it. It is actually a place in memory, not an actual file on your hard drive and that is why you cannot open it in a text editor. EOF # # Here we create drive.html echo "Creating drive.html" cat > ~/SysReport/drive.html << EOF Drive Information
The command that generates the following out put is:
cat /proc/diskstats >> ~/SysReport/drive.html
cat /proc/diskstats
EOF
# generate the out put from system file
cat /proc/diskstats >> ~/SysReport/drive.html
# add the end of the file
cat >> ~/SysReport/drive.html << EOF

To get the out put of this command in terminal use the following form:

cat /proc/diskstats

This will output the information to the terminal screen. I'm not sure who this information might be useful to, it's greek to me.

The following output is generated with this command:

df -h >> ~/SysReport/drive.html

The -h switch makes it generate human readable output grouped in G, M, and K bytes 8-) You can get the out put in bytes only by using the -b switch instead of -h
df -h
EOF
# generate the out put from system file
df -h >> ~/SysReport/drive.html
# try to prompt user to hit enter
cat >> ~/SysReport/drive.html << EOF

There is another command you can use to get your partition information but this script cannot run it as it doesn't have super user permission. To have your partition information included in this document, run the following command in terminal, then re-run SystemReport.sh to have that information added in here.

sudo fdisk -l > ~/SysReport/fdisk.txt

You will be prompted for your password, type it in and hit enter. You won't see any characters echoed by terminal when you type your password, but just keep typing, it's getting them.

This will create a text file of the fdisk command output which when you re-run SystemReport.sh will be detected and added into this file. Don't forget to update fdisk.txt if you change your partitions around. EOF # If the user has ran the ""sudo fdisk -l > ~/SysReport/fdisk.txt" command, add the content # of fdisk.txt into drive.html if [ -e ~/SysReport/fdisk.txt ] then cat >> ~/SysReport/drive.html << EOF

I see you've created fdisk.txt so here is the information from it below.
sudo fdisk - l
EOF
		cat ~/SysReport/fdisk.txt >> ~/SysReport/drive.html
		cat >> ~/SysReport/drive.html << EOF

Of course you can get your partition information at any time by opening a terminal window and running the following command. You will be prompted for your password, then the output will go to the terminal window.

sudo fdisk -l EOF fi # Create the PCIBus.html file with the lspci command # first write the top of the file to disk echo "Creating PCIBus.html" cat > ~/SysReport/PCIBus.html << EOF PCI Bus Information

This file has information about your PCI bus and the things connected to it. It gives you a good list of the hardware in your computer.

This first command that generates the following out put is:

lspci -t -vv >> ~/SysReport/PCIBus.html

The -t makes the output in tree form and -vv means very verbose
lspci -t -vv
EOF
# generate the out put into the PCIBus.html file
lspci -t -vv >> ~/SysReport/PCIBus.html
# Now add the next section of the file
cat >> ~/SysReport/PCIBus.html << EOF

This next section uses a different set of switches to generate a bit more detailed output.

The command to generate this section of the file is:

lspci -b -v >> ~/SysReport/PCIBus.html

The -b means bus centric and -v is just verbose

For a reference to the lspci command and it's other switches see lspci(8) - Linux man page

lspci -b -v
EOF
# out put the next command to disk
lspci -b -v >> ~/SysReport/PCIBus.html
# now write then end of the file
cat >> ~/SysReport/drive.html << EOF
EOF # generate a memory report file # first write the top of the file to disk echo "Creating memory.html" cat > ~/SysReport/memory.html << EOF Memory Information

This file has some information about your memory.

This first command that generates the following out put is:

free -m >> ~/SysReport/memory.html

The -m makes the output in Megabytes. -b will give the results in bytes and running just free with no switches defaults to output in Kilobytes.
free -m
EOF
# out put the next command to disk
free -m >> ~/SysReport/memory.html
# now write the next part of the file
cat >> ~/SysReport/memory.html << EOF

Swappiness is a measure of how aggressively Ubuntu swaps memory out to the swap file or partition. This next command checks the value of swappiness.

cat /proc/sys/vm/swappiness

Swappiness can be set from 0 to 100 with 100 being the most aggressively paged out. A low number like 10 is recommended for desktops, while 60 is the default in Ubuntu. 60 is also recommended for servers.
cat /proc/sys/vm/swappiness
EOF
# 
# out put the next command to disk
cat /proc/sys/vm/swappiness >> ~/SysReport/memory.html
# now write the end of the file
cat >> ~/SysReport/memory.html << EOF

Here is the Ubuntu Swap Partition FAQ so you can get up to speed on swap files. Among other things it talks about, the article tells how to adjust swappiness. EOF # generate a network report file # first write the top of the file to disk echo "Creating network.html" cat > ~/SysReport/network.html << EOF Network Information

This file has some information about your network.

This first command that generates the following out put is:

ifconfig -a >> ~/SysReport/network.html

The -a makes ifconfig output all network connections.
ifconfig -a
EOF
# out put the next command to disk
ifconfig -a >> ~/SysReport/network.html
# now write then end of the file
cat >> ~/SysReport/network.html << EOF

This next command checks to see if you are connected to a network currently.

cat /sys/class/net/eth0/carrier

This location returns a 0 if you are not connected, and a 1 if you are connected to a network.
cat /sys/class/net/eth0/carrier
EOF
# 
# out put the next command to disk
cat /sys/class/net/eth0/carrier >> ~/SysReport/network.html
# now write the end of the file
cat >> ~/SysReport/network.html << EOF
EOF # # create the opsys.html file # write the head of the file echo "Creating opsys.html" cat > ~/SysReport/opsys.html << EOF Operating System Information

This first command checks a place on your file system which is a location in memory to get the version of Ubuntu you are using. The command is in the top of the following table.
cat /etc/issue
EOF
cat /etc/issue >> ~/SysReport/opsys.html
cat >> ~/SysReport/opsys.html << EOF

This command generates the contents of your Grub menu.lst file if you are on a dual booting system.

cat /boot/grub/menu.lst >> ~/SysReport/opsys.html

If there is no menu.lst file on your computer the following output will say so.

The file menu.lst can be edited with Gedit if you start it with gksu in terminal with the following command.

gksu gedit

You will be prompted for your password after you hit enter.

It is much easier to make changes to the grub menu with a grub menu editor than editing it with Gedit. To do so open Synaptic Package Manager and install the package qgrubeditor or kgrubeditor, I prefer the qgrubeditor myself.
cat /boot/grub/menu.lst
EOF
# test for existence of menu.lst file and do output accordingly
if [ -e /boot/grub/menu.lst ]
	then cat /boot/grub/menu.lst >> ~/SysReport/opsys.html
	else echo "No menu.lst file found" >> ~/SysReport/opsys.html
fi
# now write the next part of the file
cat >> ~/SysReport/opsys.html << EOF

If the menu.lst file exists, we can check to see wbere grub is installed with the following command.

cat /boot/grub/device.map >> ~/SysReport/opsysy.html
cat /boot/grub/device.map
EOF
# get the device.map info
if [ -e /boot/grub/menu.lst ]
	then cat /boot/grub/device.map >> ~/SysReport/opsys.html
	else echo "no menu.lst file found" >> ~/SysReport/opsys.html
fi
# write the end of the file
cat >> ~/SysReport/opsys.html << EOF

To learn more about grub go to the grub page

Now we check the version of your Linux kernel.
uname -a

EOF
uname -a >> ~/SysReport/opsys.html
cat >> ~/SysReport/opsys.html << EOF

This next command generates a bit more information about your version of Ubuntu.
lsb_release -a
EOF
lsb_release -a 2> /dev/null >> ~/SysReport/opsys.html
cat >> ~/SysReport/opsys.html << EOF
EOF # create logfiles.html # module added 9/22/08 by C Ray Parrish echo "Creating logfiles.html" cat > ~/SysReport/logfiles.html << EOF Log Files

This file is the syslog.conf file which determines what messages from the system get sent to which log file. You can look up what log files are available for inspection in this file.

The command that generates the following out put is:

cat /etc/syslog.conf >> ~/SysReport/logfiles.html
cat /etc/syslog.conf
EOF
# out put the next command to disk
cat /etc/syslog.conf >> ~/SysReport/logfiles.html
# now write the next part of the file
cat >> ~/SysReport/logfiles.html << EOF

The syslog.conf file can be edited with a text editor but may need to be started with gksu priveleges to write to file any changes you make. Use the following command -

gksu gedit /etc/syslog.conf

You will be prompted for your password when you run the above command. EOF # create software.html # module added 9/22/08 by C Ray Parrish echo "Creating software.html" cat > ~/SysReport/software.html << EOF Log Files

The following is a list of all packages installed on this system. It is in reality a list of all of the subfolders in your /usr/share/doc folder. Each subfolder there corresponds to a package with the same name which is installed on your system.

For this out put we have to be in the right folder first so we cd

cd /usr/share/doc

Then we run the ls command to get a list of the folders

ls -a --group-directories-first >> ~/SysReport/software.html

Jump down to Software Version Information
cd /usr/share/doc
ls -a --group-directories-first
EOF
echo "     inventory of /usr/share/doc"
# out put the next command to disk
# first change to the right folder
cd /usr/share/doc
# and put a list of it's folders into software.html
ls -a --group-directories-first >> ~/SysReport/software.html
# now write the next part of the file
cat >> ~/SysReport/software.html << EOF
Jump to updateable packages

There is another command which you can install on your system which will give you the current version of all installed software along with whether or not it is up to date. To install this package issue the following command in terminal -

sudo apt-get install apt-show-versions

You will be prompted for your password and then the package will be installed.

Now re-run the SystemReport.sh script to add the software version information into this document below.
apt-show-versions
EOF
if [ -e "/usr/bin/apt-show-versions" ]; then
  echo "     generating version list"
  touch ~/SysReport/versions.txt
  chmod 777 ~/SysReport/versions.txt
  apt-show-versions > ~/SysReport/versions.txt
  echo "     Sorting version list"
  sort ~/SysReport/versions.txt >> ~/SysReport/software.html
else
  echo "apt-show-versions not found, follow directions above to get this output" >> ~/SysReport/software.html
fi
cat >> ~/SysReport/software.html << EOF

In this next output section we are looking to see which packages on our system need updating.

To do this we add a -u switch to the command from the last section as you can see at the top of the table below.

If there is no out put in the following section, all software on your system is up to date.
apt-show-versions -u
EOF
# now we add the output of packages which need updating if any
echo "     generating list of updates"
# first be sure they have the command installed
if [ -e /usr/bin/apt-show-versions ]
	# check to see if output of command is empty
	then texttest=$(apt-show-versions -u 2> /dev/null)
	     if [ "$texttest" == "" ]
		# if it's empty, all software is up to date
		then echo "Your software is all up to date." >> ~/SysReport/software.html
		# otherwise add list of packages which need updating
		else apt-show-versions -u 2> /dev/null >> ~/SysReport/software.html
		fi
	# if they don't have the command installed tell them
	else echo "you must install apt-show-versions to get this output" >> ~/SysReport/software.html
fi
cat >> ~/SysReport/software.html << EOF

This next section isn't the result of a command, it is merely a link to a file on your system which keeps a lot of information about installed software in it. It includes the version, what packages it depends on to operate, which packages they conflict with, and a description of the packages function.

Note that even if you are viewing the sample System Report online the following link is to a file on your system and is not part of the sample report.

You can open the following file with your text editor.

The reason I don't cat this file into the web page report is that on my system it is 1.4 megabytes large so it isn't practical to import it.
/var/lib/dpkg/status
Software Information File
EOF # create environment.html # module added 9/22/08 by C Ray Parrish echo "Creating environment.html" cat > ~/SysReport/environment.html << EOF Environment Variables

This page is all about your environment variables. They are used by programs to look up global settings for your system. One of these settings is the PATH variable which stores the paths where the system looks for a command when you type in just it's name in terminal.

The following command prints out all environment variables

printenv

to get only one variables value there are two ways as follows, both work

printenv PATH

You can also use "echo \$variablename" to return the value of any variable.
printenv
EOF
# out put the next command to disk
printenv >> ~/SysReport/environment.html
# now write the next part of the file
cat >> ~/SysReport/environment.html << EOF

To learn more about environment variables and how to set them have a look at Environment Variables - Ubuntu Community documentation EOF # create modules.html # module added 9/29/08 by C Ray Parrish echo "Creating modules.html" cat > ~/SysReport/modules.html << EOF Environment Variables

This page lists the modules you have loaded in memory and how large they are. To generate this out put I have used the lsmod command which pretties up the information also available at /proc/modules via the cat command.
lsmod
EOF
# out put the next command to disk
lsmod >> ~/SysReport/modules.html
# now write the next part of the file
cat >> ~/SysReport/modules.html << EOF
EOF # create usb.html # module added 9/29/08 by C Ray Parrish echo "Creating usb.html" cat > ~/SysReport/usb.html << EOF USB Devices

This page lists the USB devices attached to your system. The -v switch on the following command means verbose out put.
lsusb -v
EOF
# out put the next command to disk
lsusb -v 2>/dev/null >> ~/SysReport/usb.html
# now write the next part of the file
cat >> ~/SysReport/usb.html << EOF
EOF echo "Loading System Report in browser" # call the web browser with the System Report loaded # get thwe command for the users default browser BROWSER=`gconftool-2 --get '/desktop/gnome/url-handlers/http/command' | cut -f1 -d' ' ` # call that browser with the report url ${BROWSER} ~/SysReport/index.html & exit