logMsgToConfigSysLog "ERROR""ERROR: $LOGS_01_HOST is not reachable. Please check your network and firewall settings. Continuing to configure Loggly on your system."
logMsgToConfigSysLog "ERROR""ERROR: $LOGS_01_HOST is not reachable. Please check your network and firewall settings."
exit 1
fi
echo"INFO: Checking if $LOGS_01_HOST is reachable via $LOGGLY_SYSLOG_PORT port. This may take some time."
if [ $(curl --connect-timeout 10 $LOGS_01_HOST:$LOGGLY_SYSLOG_PORT2>&1| grep "Empty reply from server"| wc -l)== 1 ];then
echo"INFO: $LOGS_01_HOST is reachable via $LOGGLY_SYSLOG_PORT port."
else
logMsgToConfigSysLog "ERROR""ERROR: $LOGS_01_HOST is not reachable via $LOGGLY_SYSLOG_PORT port. Please check your network and firewall settings. Continuing to configure Loggly on your system."
logMsgToConfigSysLog "ERROR""ERROR: $LOGS_01_HOST is not reachable via $LOGGLY_SYSLOG_PORT port. Please check your network and firewall settings."
exit 1
fi
@@ -401,22 +403,8 @@ write22LogglyConfFile()
{
echo"INFO: Checking if loggly sysconf file $LOGGLY_RSYSLOG_CONFFILE exist."
logMsgToConfigSysLog "INFO""INFO: Skipping Linux verification."
break;;
* ) echo"Please answer yes or no.";;
esac
done
else
LINUX_DO_VERIFICATION="false"
fi
}
#write the contents to 22-loggly.conf file
writeContents()
{
@@ -506,7 +536,7 @@ checkIfLogsMadeToLoggly()
let counter=$counter+1
if [ "$counter"-gt"$maxCounter" ];then
MANUAL_CONFIG_INSTRUCTION=$MANUAL_CONFIG_INSTRUCTION" Rsyslog troubleshooting instructions are available at https://www.loggly.com/docs/troubleshooting-rsyslog/"
logMsgToConfigSysLog "ERROR""ERROR: Verification logs did not make it to Loggly in time. Please check your token & network/firewall settings and retry."
logMsgToConfigSysLog "ERROR""ERROR: Logs did not make to Loggly in time. Please check network and firewall settings and retry."
#invoke file monitoring on each file after checking if it is a text file or not
invokeS3FileMonitoring
#install a cron job to sync the downloaded files after each 5 minutes
installCronToSyncS3BucketPeriodically
if [ "$IS_ANY_FILE_CONFIGURED"!="false" ];then
#check if s3 logs made it to loggly
checkIfS3LogsMadeToLoggly
else
logMsgToConfigSysLog "WARN""WARN: Did not find any files to configure. Nothing to do."
fi
#delete temporary directory
#deleteTempDir
}
@@ -95,9 +96,12 @@ removeLogglyConfForS3()
#remove file monitoring
removeS3FileMonitoring
#delete the s3 sync cron from the crontab
deleteS3CronFromCrontab
#delete temporary directory if exists
TEMP_DIR=/tmp/$LOGGLY_S3_ALIAS
TEMP_DIR=/tmp/s3monitoring/$LOGGLY_S3_ALIAS
deleteTempDir
#log success message
@@ -165,8 +169,8 @@ downloadS3cmd()
#configure s3cmd
configureS3cmd()
{
s3cmd --configure
IS_S3CMD_CONFIGURED_BY_SCRIPT="true"
sudo s3cmd --configure
IS_S3CMD_CONFIGURED_BY_SCRIPT="true"
#check if s3cmd configured successfully now
checkIfS3cmdConfigured
}
@@ -203,7 +207,7 @@ checkIfValidS3Bucket()
createTempDir()
{
TEMP_DIR=/tmp/$LOGGLY_S3_ALIAS
TEMP_DIR=/tmp/s3monitoring/$LOGGLY_S3_ALIAS
if [ -d"$TEMP_DIR" ];then
if [ "$(ls -A $TEMP_DIR)" ];then
logMsgToConfigSysLog "WARN""WARN: There are some files/folders already present in $TEMP_DIR. If you continue, the files currently inside the $TEMP_DIR will also be configured to send logs to loggly."
@@ -221,7 +225,12 @@ createTempDir()
done
fi
else
mkdir /tmp/$LOGGLY_S3_ALIAS
if [ -d"/tmp/s3monitoring" ];then
mkdir /tmp/s3monitoring/$LOGGLY_S3_ALIAS
else
mkdir /tmp/s3monitoring
mkdir /tmp/s3monitoring/$LOGGLY_S3_ALIAS
fi
fi
}
@@ -231,7 +240,7 @@ downloadS3Bucket()
#Files are downloaded in nested directory
cd$TEMP_DIR
echo"Downloading files, may take some time..."
s3cmd get -r -f $LOGGLY_S3_BUCKET_NAME> /dev/null 2>&1
sudo s3cmd get -r -f $LOGGLY_S3_BUCKET_NAME> /dev/null 2>&1
if [ $?-ne 0 ];then
logMsgToConfigSysLog "ERROR""ERROR: Error downloading files recursively from $LOGGLY_S3_BUCKET_NAME"
exit 1
@@ -242,7 +251,7 @@ downloadS3Bucket()
invokeS3FileMonitoring()
{
dir=/tmp/$LOGGLY_S3_ALIAS
dir=/tmp/s3monitoring/$LOGGLY_S3_ALIAS
#TODO: Not supporting multiple files with same name in different directories
#only supporting file with naming convention *.*
forfin$(find $dir -name '*')
@@ -260,6 +269,7 @@ invokeS3FileMonitoring()
LOGGLY_FILE_TAG="s3file"
CONF_FILE_FORMAT_NAME="LogglyFormatS3"
constructFileVariables
checkFileReadPermission
checkLogFileSize $LOGGLY_FILE_TO_MONITOR
write21ConfFileContents
IS_ANY_FILE_CONFIGURED="true"
@@ -274,6 +284,68 @@ invokeS3FileMonitoring()
fi
}
installCronToSyncS3BucketPeriodically()
{
whiletrue;do
read -p "Would you like install a Cron job to sync the files currently in your bucket every 5 minutes? (yes/no)" yn
case$ynin
[Yy]* )
#copying .s3cfg file to /root so that it can be used by crontab for sync
logMsgToConfigSysLog "ERROR""ERROR: Tomcat logs did not make to Loggly in time. Please check your token & network/firewall settings and retry."
logMsgToConfigSysLog "ERROR""ERROR: Tomcat logs did not make to Loggly in time. Please check network and firewall settings and retry."
exit 1
fi
done
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page.
For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they're used to log you in.
Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task.
Learn more
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added modular scripts - Tomcat, Apache2, File Monitorin, S3 File Monitoring and Nginx Server #69
Added modular scripts - Tomcat, Apache2, File Monitorin, S3 File Monitoring and Nginx Server #69
Changes from 1 commit
a24007e7d10190b12a1f14160bca8e46033040fcaf3f133cd1e00b42c6b391f1de793f318770bdc77925e6d46ebafb9a362868b89cb88b8fb0115f9dee3dc38e2117169324a4200fd934bfbbc06f4412fa1b62221ae7d6bfe0a4520cf4b301d22a45d63e96dc6197df9a98ed38bffdca35323ad5d6e6363752d2cc4bf09404891f114f566d138ef2faac29fab45d7e9be5085d2364a89e96a0304c2ffe6302c24385df450f9c864d8fee9382cac6726c54ab7c64f4b3e7a73283d44e13beccd2a9d522f8151b89ecc077959787d9529d982bbc505b9cfb1435dcab5502f3cf7eb8abcd07eac676a9436f9991e9fbc22bc309919125cda8b4bc7d1e727dbf18ab84686db7f7443a2d377e408af5520e0ef389892538b62c0fc716576fd0d7654e389371118c5ba05c43ab896a25d17eca27e7bc4cb0d9732b55c6803e0cb2603c5b2dac442f49cfdb4ccf1c248476a5efFile filter...
Jump to…
Merged script-dev changes