This simple script uses command driven templates and creates a snapshot of system information and outputs to a html file.
This project is maintained by jrosco
sysinfo.sh -c cmd_list -o output.html
-c cmd_list is the template to use (see template setup below) [required]
-o output.html is the html output file (default: sysinfo.html) [optional]
run with -h option to display help menu [optional]
source /$(pwd)/functions
heading_start "Example Heading"
Start with sub heading
sub_start "Example sub heading"
Now add the command to show
run_command "route -n"
Surround commands with double quotes.
Close sub heading
sub_end
Close heading
heading_end
End result would like something like this:
source /$(pwd)/functions
heading_start "Example Heading"
sub_start "Example sub heading"
run_command "route -n"
sub_end
heading_end
NB: indention is not required, just makes it look nicer
HTML output:
You can also create nested sub headings
source /$(pwd)/functions
heading_start "Example Heading"
sub_start "Example sub heading"
sub_start "Nested sub heading 1"
run_command "route -n"
sub_end
sub_start "Nested sub heading 2"
run_command "ifconfig -a"
sub_end
sub_end
heading_end
sub_start "Advanced Example 1"
run_command "[ -f /etc/hosts ] && echo 'File Exist' && grep 'local' /etc/hosts | wc -l"
sub_end
sub_start "Advanced example 2"
ifconfig | grep 'eth\|lo' | cut -c1-4 >interfaces.tmp
while read line
do
run_command "ethtool $line"
done <interfaces.tmp
rm -f interfaces.tmp
sub_end
sub_start "Loop Example"
for i in {1..5}
do
run_command echo "$i"
done
sub_end