#!/bin/bash get_adapter () { megaraid -showadapter } get_config () { megaraid -showconfig } get_devices () { megaraid -showdevices } ############################## ############################## extract_adapter () { get_adapter | tail -4 } extract_config () { get_config | sed -n '8p' | awk '{print $5}' } extract_devices () { get_devices | sed -n '8,11p' | tr -s ' ' } ############################## ############################## make_html_adapter () { extract_adapter > tmp_adapter cat tmp_adapter | sed 's/$/
/' > tmp_adapter } make_html_devices () { extract_devices > tmp_devices cat tmp_devices | sed -n "s/^ //gp" > tmp_devices cat tmp_devices | sed -n "s/ /<\/td>/pg" > tmp_devices cat tmp_devices | sed -e "s/ONLINE/ONLINE<\/font><\/b><\/td><\/tr>/" > tmp_devices cat tmp_devices | sed -e "s/OFFLINE/OFFLINE<\/font><\/b><\/td><\/tr>/" > tmp_devices echo "" `cat tmp_devices` "
" > tmp_devices } make_html_config () { extract_config > tmp_config cat tmp_config | sed -e "s/OPTIMAL/OPTIMAL<\/font><\/b>/" > tmp_config cat tmp_config | sed -e "s/DEGRADED/DEGRADED<\/font><\/b>/" > tmp_config } make_html_header () { echo "" echo " " echo " " echo " " echo " " } make_html_footer () { echo " " echo "" } make_html_contenu () { make_html_adapter make_html_config make_html_devices for i in `ls | grep "^tmp_"`; do echo `cat $i` "

" >> tmp_html_contenu done echo `cat tmp_html_contenu` } ############################# ############################# clear () { [ -f tmp_adapter ] && rm tmp_adapter [ -f tmp_devices ] && rm tmp_devices [ -f tmp_config ] && rm tmp_config [ -f tmp_html_contenu ] && rm tmp_html_contenu [ -f html_megaraid.html ] && rm html_megaraid.html } ############################ ############################ main () { clear make_html_header >> html_megaraid.html make_html_contenu >> html_megaraid.html make_html_footer >> html_megaraid.html } main