diff --git a/chkhosts-sample.d/conf/gen-webstat.sh b/chkhosts-sample.d/conf/gen-webstat.sh index e1d41b9..1d833f2 100755 --- a/chkhosts-sample.d/conf/gen-webstat.sh +++ b/chkhosts-sample.d/conf/gen-webstat.sh @@ -1,9 +1,20 @@ #!/bin/bash # -# Script to generate host status php web page. +# Script to generate host status php web page and +# the comment update form page. # # usage: gen-webstat.sh chkhosts_directory + +# Variables to customize the output page +_CHKHOSTS_TITLE_="Chkhosts System Status" +_CHKHOSTS_FORMTITLE_="Chkhosts System Comment Update" +_CHKHOSTS_HOSTNAME_="chkhost.somwhere.com" +_CHKHOSTS_POLL_INTERVAL_="5 minute" +_CHKHOSTS_CONTACTNAME_="John Doe" +_CHKHOSTS_CONTACTEMAIL_="john.doe@somewhere.com" +_CHKHOSTS_TABLE_COLS_="3" + # Announce ourselves. echo "Gen-webstat.sh MY_VERSION_STRING" @@ -26,7 +37,124 @@ DOWNHOSTSTATUSDIR=$WORKDIR/status-down CHKHOSTLOGDIR=$WORKDIR/log CHKHOSTLOG=$CHKHOSTLOGDIR/chkhosts.log WEBSTATDIR=$WORKDIR/webstat +WEBDESCRIPTIONDIR=$WEBSTATDIR/system-description +WEBCOMMENTDIR=$WEBSTATDIR/system-comment WEBPAGE=$WEBSTATDIR/status.php +FORMPAGE=$WEBSTATDIR/update-comment.php + +# Calculate the number of hosts we're monitoring +NUMSYSTEMS=$(grep -v -e '^#' $HOSTLISTFILE | wc -l) + + +# +# Create the Comment Form page first +#################################### + +echo '' >$FORMPAGE +echo '' >>$FORMPAGE +echo '
' >>$FORMPAGE +echo ' ' >>$FORMPAGE +echo ' ' >>$FORMPAGE +echo ' ' \ + >>$FORMPAGE +echo ' ' >>$FORMPAGE +echo "+To help coordinate access to the systems, you can change the comment +to a host's status cell by using the following form: +
+ +COMMENT_SECTION_2 + +# +# Close out FORMPAGE document +############################# + +echo '' >>$FORMPAGE +echo '' >>$FORMPAGE + +# now customize the Comment Form page... +sed -i "s/_CHKHOSTS_FORMTITLE_/${_CHKHOSTS_FORMTITLE_}/g" $FORMPAGE +sed -i "s/_CHKHOSTS_HOSTNAME_/${_CHKHOSTS_HOSTNAME_}/g" $FORMPAGE +sed -i "s/_CHKHOSTS_POLL_INTERVAL_/${_CHKHOSTS_POLL_INTERVAL_}/g" $FORMPAGE +sed -i "s/_CHKHOSTS_CONTACTNAME_/${_CHKHOSTS_CONTACTNAME_}/g" $FORMPAGE +sed -i "s/_CHKHOSTS_CONTACTEMAIL_/${_CHKHOSTS_CONTACTEMAIL_}/g" $FORMPAGE + + # # Generate the HTML header @@ -40,7 +168,7 @@ echo ' ' >>$WEBPAGE echo ' ' \ >>$WEBPAGE echo ' ' >>$WEBPAGE -echo '