Skip to content

Commit be9b764

Browse files
authored
added curl on apache server and rsyslog restart (#124)
added curl on apache server and rsyslog restart
1 parent c33efef commit be9b764

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

Modular Scripts/Apache2/configure-apache.sh

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ write21ApacheConfFile() {
220220
write21ApacheFileContents
221221
break
222222
;;
223-
[Nn]*) break ;;
223+
[Nn]*)
224+
restartRsyslog
225+
break ;;
224226
*) echo "Please answer yes or no." ;;
225227
esac
226228
done
@@ -348,6 +350,40 @@ checkIfApacheLogsMadeToLoggly() {
348350
fi
349351
done
350352

353+
read -p "In order to check if Apache logs are successfully sent to Loggly, apache needs to produce logs. Do you want to create a log record by accessing server? (yes/no)" yn
354+
case $yn in
355+
[Yy]*)
356+
#access a page on apache server in order to create a log record in access log file
357+
WEB_ADDRESS=127.0.0.1
358+
while true; do
359+
read -p "Default check is performed on a localhost address 127.0.0.1 . Are you running an apache server with a different address? (yes/no)" yesno
360+
case $yesno in
361+
[Yy]*)
362+
logMsgToConfigSysLog "INFO" "INFO: Using specific apache server address."
363+
read -p "Please enter Apache server address " -r WEB_ADDRESS
364+
;;
365+
[Nn]*)
366+
logMsgToConfigSysLog "INFO" "INFO: Using default apache server address."
367+
;;
368+
*) echo "Please answer yes or no." ;;
369+
esac
370+
371+
RESPONSE_CODE=$(curl --max-time 10 -s -o /dev/null -i -w "%{http_code}" $WEB_ADDRESS)
372+
#curl return 000 response on reaching max-time
373+
if [ ${RESPONSE_CODE} != "000" ]; then
374+
logMsgToConfigSysLog "INFO" "INFO: Curl on server $WEB_ADDRESS has succeeded"
375+
break;
376+
else
377+
logMsgToConfigSysLog "INFO" "INFO: Curl on server $WEB_ADDRESS has failed."
378+
fi
379+
done
380+
;;
381+
[Nn]*)
382+
logMsgToConfigSysLog "INFO" "INFO: Creating a sample log record has been skipped."
383+
;;
384+
*) echo "Please answer yes or no." ;;
385+
esac
386+
351387
queryParam="$TAGS&from=-15m&until=now&size=1"
352388
queryUrl="$LOGGLY_ACCOUNT_URL/apiv2/search?q=$queryParam"
353389
logMsgToConfigSysLog "INFO" "INFO: Search URL: $queryUrl"

0 commit comments

Comments
 (0)