delete=0
awstats=0
reload=0
+content=0
config_dir=/etc/nagios3/conf.d
config_file_web=$config_dir/web_services.cfg
export params=''
function help() {
- echo $0': [-s|-W|-A|-r] <[-D] -w website> [-h hostname] [-c cname1,cname2,etc...]'
+ echo $0': [-s|-W|-A|-r] <[-D] -w website> [-h hostname] [-c cname1,cname2,etc...] [-C /path!string]'
echo -e "\t-s Add SSL monitoring"
echo -e "\t-W Also add a monitor for the WWW record"
echo -e "\t-D Delete the monitor(s) for the hostname/website provided"
echo -e "\t-h Provide a hostname, useful for VHOSTs"
echo -e "\t-c A comma seperated list of cnames to add monitors for"
echo -e "\t-A Adds an AWSTATS monitor for this host"
+ echo -e "\t-C Adds a Content check for string matching"
echo -e "\t-r Reloads nagios after config files are updated"
}
set-params 'check-termite' "AWSTATS: $1" "termite.fsf.org" "check_termite!$1"
}
+function set-content-params() {
+ set-params 'http-vhost' "URL Content: $1" $2 "check_http_string!$2!$3"
+}
+
function write-config-header() {
echo "# AUTOGENERATED CONFIG FOR HOST: $host:$website"
echo "# User: $USER"
function write-config-footer() {
echo "# END $host:$website"
- echo
}
function write-config-body() {
}
# Process our args
-while getopts "rADWw:h:sc:" opt; do
+while getopts "rADWw:h:sc:C:" opt; do
case "${opt}" in
s)
ssl=1
r)
reload=1
;;
+ C)
+ content_data=${OPTARG}
+ content=1
*)
help
exit 1
write-config-body >> $config_file_web
fi
+ if [ $content -eq 1 ]; then
+ set-content-params $website $host $content_data
+ write-config-body >> $config_file_web
+ fi
+
# AWSTATS check, if requested
if [ $awstats -eq 1 ]; then
if [ $www -eq 1 ]; then