Skip to content
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

Merged
merged 96 commits into from Oct 21, 2014
Merged
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
a24007e
Added customer token to configsyslog
Jun 24, 2014
7d10190
Validated Tomcat installation before Linux
Jun 24, 2014
b12a1f1
Added support to check Loggly port reachabilty
Jun 26, 2014
4160bca
Support for Tomcat downloaded as a package
Jun 26, 2014
8e46033
Added Apache2 Configuration Script
Jun 30, 2014
040fcaf
Download Linux script inside it
Jul 1, 2014
3f133cd
Downloads Linux script inside it
Jul 1, 2014
1e00b42
Logging OS name to Loggly if unsupported
Jul 3, 2014
c6b391f
Updated Red Hat to RedHat
Jul 3, 2014
1de793f
Updated RedhHat/ CentOS log file name
Jul 3, 2014
318770b
Stop of the user do not want to restart tomcat
Jul 3, 2014
dc77925
No verification if already configured
Jul 4, 2014
e6d46eb
No verification if already configured
Jul 4, 2014
afb9a36
Updated typos and link
Jul 4, 2014
2868b89
Removed duplicate variables and updated message
Jul 9, 2014
cb88b8f
Removed duplicate variables
Jul 9, 2014
b0115f9
Added file monitoring script
Jul 9, 2014
dee3dc3
Updated Manual link and Logging file name also
Jul 10, 2014
8e21171
Updated warning text
Jul 11, 2014
69324a4
Updated message text
Jul 11, 2014
200fd93
Made token optional
Jul 11, 2014
4bfbbc0
Made token optional
Jul 11, 2014
6f4412f
Made token optional
Jul 11, 2014
a1b6222
Check if the file name/ path contains spaces
Jul 14, 2014
1ae7d6b
Removed Extra characters
Jul 14, 2014
fe0a452
Updated version 1.0 to 1.01
Jul 14, 2014
0cf4b30
Updated message
Jul 15, 2014
1d22a45
Removed extra break
Jul 15, 2014
d63e96d
Updated text message
Jul 15, 2014
c6197df
Configure script if log file size is 0
Jul 16, 2014
9a98ed3
Configure Script if log file size is 0
Jul 16, 2014
8bffdca
Added README.md for the Linux Script
Jul 18, 2014
35323ad
Updated README
Jul 18, 2014
5d6e636
Create README.md
Jul 18, 2014
3752d2c
Create README.md
Jul 18, 2014
c4bf094
Update README.md
Jul 18, 2014
04891f1
Update README.md
Jul 18, 2014
14f566d
Create README.md
Jul 18, 2014
138ef2f
Incorporated Manoj's Feedback
Jul 21, 2014
aac29fa
Incorporated Manoj's Feedback
Jul 21, 2014
b45d7e9
Update README.md
Jul 21, 2014
be5085d
Update README.md
Jul 21, 2014
2364a89
Update README.md
Jul 21, 2014
e96a030
Update README.md
Jul 21, 2014
4c2ffe6
Updated script to support any Linux OS
Jul 23, 2014
302c243
Merge branch 'master' of https://github.com/psquickitjayant/install-s…
Jul 23, 2014
85df450
Added s3 monitoring scripts
Jul 25, 2014
f9c864d
Add support to Amazon AMI OS
Jul 27, 2014
8fee938
Removed extra variable
Jul 28, 2014
2cac672
Updated command
Jul 28, 2014
6c54ab7
Updated version number
Jul 28, 2014
c64f4b3
Updated version number
Jul 28, 2014
e7a7328
Updated version number
Jul 28, 2014
3d44e13
Updated Scripts (Under development)
Jul 28, 2014
beccd2a
Added check for sub domain
Jul 29, 2014
9d522f8
Changed message if Mac OSX found
Jul 30, 2014
151b89e
Revert "Changed message if Mac OSX found"
Jul 30, 2014
cc07795
Changed message if "Darwin OS"
Jul 30, 2014
9787d95
Updated s3 Script. Under Developement
Jul 30, 2014
29d982b
Added comments
Jul 30, 2014
bc505b9
Add support to download bucket/ file using -s3b
Jul 31, 2014
cfb1435
Minor Bug Fix
Jul 31, 2014
dcab550
Updated s3b to s3url and Minor bug fixes
Aug 1, 2014
2f3cf7e
Added more checks for the bucket name validation
Aug 4, 2014
b8abcd0
Removed extra quotes
Aug 5, 2014
7eac676
Updated script to support s3 file monitoring
Aug 5, 2014
a9436f9
Added check for the directory
Aug 5, 2014
991e9fb
Delete Temp Folder after Rollback
Aug 6, 2014
c22bc30
Added dynamic tag to modify from other scripts
Aug 7, 2014
9919125
Fixed a bug
Aug 7, 2014
cda8b4b
Revert "Fixed a bug"
Aug 7, 2014
c7d1e72
S3 Script: Added "s3file" tag
Aug 7, 2014
7dbf18a
Updated script to support multiple Linux machines
Aug 18, 2014
b84686d
File-Monitoring-
Aug 19, 2014
b7f7443
Revert "File-Monitoring-"
Aug 19, 2014
a2d377e
File-monitoring: Added support to set Format name
Aug 19, 2014
408af55
S3 Script: Setting New Format name
Aug 19, 2014
20e0ef3
Updated Path for configure-file-monitoring.sh
Aug 21, 2014
8989253
Updated Path for configure-linux.sh
Aug 21, 2014
8b62c0f
Updated Path for configure-file-monitoring.sh
Aug 21, 2014
c716576
Updated Path for configure-linux.sh
Aug 21, 2014
fd0d765
Merged script-dev changes
Sep 26, 2014
4e38937
Create README.md
Sep 26, 2014
1118c5b
Update README.md
Sep 26, 2014
a05c43a
Update README.md
Sep 26, 2014
b896a25
Update README.md
Sep 26, 2014
d17eca2
Update README.md
Sep 26, 2014
7e7bc4c
Updated ReadMes
Sep 26, 2014
b0d9732
Skipping permissions check on RedHat and CentOS
Sep 26, 2014
b55c680
Minor modifications
Sep 30, 2014
3e0cb26
Nginx Script: Initial Commit
Sep 30, 2014
03c5b2d
Update README.md
Sep 30, 2014
ac442f4
Create README.md
Sep 30, 2014
9cfdb4c
Update README.md
Sep 30, 2014
cf1c248
Nginx Script: Updated manual configuration link
Oct 3, 2014
476a5ef
File Monitoring: Added tag as parameter
Oct 7, 2014
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Updated Scripts (Under development)

  • Loading branch information
psquickitjayant
psquickitjayant committed Jul 28, 2014
commit 3d44e13951b17eed269a3c2132c4eebd77be6a72
@@ -1,7 +1,7 @@
#!/bin/bash

#downloads configure-linux.sh
echo "INFO: Downloading dependencies - configure-linux.sh"
#echo "INFO: Downloading dependencies - configure-linux.sh"
#curl -s -o configure-linux.sh https://raw.githubusercontent.com/psquickitjayant/install-script/master/Linux%20Script/configure-linux.sh
source configure-linux.sh "being-invoked"

@@ -278,10 +278,12 @@ checkIfConfFileExist()
#remove 21<filemonitoring>.conf file
remove21ConfFile()
{
echo "INFO: Deleting the loggly file syslog conf file."
echo "INFO: Deleting the loggly syslog conf file $FILE_SYSLOG_CONFFILE."
if [ -f "$FILE_SYSLOG_CONFFILE" ]; then
sudo rm -rf "$FILE_SYSLOG_CONFFILE"
echo "INFO: Removed all the modified files."
if [ "$IS_FILE_MONITOR_SCRIPT_INVOKED" = "false" ]; then
echo "INFO: Removed all the modified files."
fi
else
logMsgToConfigSysLog "WARN" "WARN: $FILE_SYSLOG_CONFFILE file was not found."
fi
@@ -203,6 +203,9 @@ checkIfSupportedOS()
*"centos"* )
echo "INFO: Operating system is CentOS."
;;
*"amazon"* )
echo "INFO: Operating system is Amazon AMI."
;;
*"darwin"* )
#if the OS is mac then exit
logMsgToConfigSysLog "ERROR" "ERROR: '$LINUX_DIST' operating system is not supported by the script."
@@ -234,6 +237,9 @@ getOs()
# If available, use LSB to identify distribution
if [ -f /etc/lsb-release -o -d /etc/lsb-release.d ]; then
LINUX_DIST=$(lsb_release -i | cut -d: -f2 | sed s/'^\t'//)
# If system-release is available, then try to identify the name
elif [ -f /etc/system-release ]; then
LINUX_DIST=$(cat /etc/system-release | cut -f 1 -d " ")
# Otherwise, use release info file
else
LINUX_DIST=$(ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1)
@@ -602,10 +608,7 @@ sendPayloadToConfigSysLog()
#$1 return the count of records in loggly, $2 is the query param to search in loggly
searchAndFetch()
{
URL_WITH_SPACE_CHARS=$2

#replacing all the spaces with %20
url="${URL_WITH_SPACE_CHARS//\ /%20}"
url=$2

result=$(wget -qO- /dev/null --user "$LOGGLY_USERNAME" --password "$LOGGLY_PASSWORD" "$url")

@@ -627,7 +630,7 @@ searchAndFetch()
eval $1="'$count'"
if [ "$count" -gt 0 ]; then
timestamp=$(echo "$result" | grep timestamp)
fi
fi
}

#get password in the form of asterisk
@@ -36,21 +36,18 @@ IS_ANY_FILE_CONFIGURED="false"
#value for temp directory
TEMP_DIR=

#time when the rsyslog is started and we want to monitor if the logs made to loggly
START_DATE_TIME=

MANUAL_CONFIG_INSTRUCTION="Manual instructions to configure a file is available at https://www.loggly.com/docs/file-monitoring/"

########## Variable Declarations - End ##########

# executing the script for loggly to install and configure syslog
installLogglyConfForFile()
installLogglyConfForS3()
{
#log message indicating starting of Loggly configuration
logMsgToConfigSysLog "INFO" "INFO: Initiating configure Loggly for file monitoring."

#check if the provided alias is correct or not
checkIfValidAliasForInvoke
checkIfS3AliasAlreadyTaken

#check if the linux environment is compatible for Loggly
checkLinuxLogglyCompatibility
@@ -62,7 +59,7 @@ installLogglyConfForFile()
checkIfValidS3Bucket

#check if s3bucket file is valid
checkIfValidS3FileName
checkIfValidS3File

#configure loggly for Linux
installLogglyConf
@@ -71,20 +68,17 @@ installLogglyConfForFile()
createTempDir

#download S3 files from bucket to temp directory
downloadS3FilesFromBucketToTempDir
downloadS3Bucket

#download S3 file to temp directory
downloadS3FilesToTempDir
downloadS3File

#invoke file monitoring on each file after checking if it is a text file or not
invokeFileMonitoring
invokeS3FileMonitoring

if [ "$IS_ANY_FILE_CONFIGURED" != "false" ]; then
#check if s3 logs made it to loggly
checkIfS3LogsMadeToLoggly

#log success message
logMsgToConfigSysLog "SUCCESS" "SUCCESS: Successfully configured to send $LOGGLY_FILE_TO_MONITOR logs via Loggly."
else
logMsgToConfigSysLog "WARN" "WARN: Did not find any files to configure. Nothing to do."
fi
@@ -94,8 +88,8 @@ installLogglyConfForFile()
}


#executing script to remove loggly configuration for File
removeLogglyConfForFile()
#executing script to remove loggly configuration for S3 files
removeLogglyConfForS3()
{
logMsgToConfigSysLog "INFO" "INFO: Initiating rollback."

@@ -106,16 +100,16 @@ removeLogglyConfForFile()
checkIfSupportedOS

#check if alias provided is the correct one
checkIfValidAliasForRevoke
checkIfS3AliasExist

#remove file monitoring
removeFileMonitoring
removeS3FileMonitoring

#log success message
logMsgToConfigSysLog "INFO" "INFO: Rollback completed."
}

checkIfValidAliasForInvoke()
checkIfS3AliasAlreadyTaken()
{
if ls $RSYSLOG_ETCDIR_CONF/*$LOGGLY_S3_ALIAS.conf &> /dev/null; then
logMsgToConfigSysLog "ERROR" "ERROR: $LOGGLY_S3_ALIAS is already taken. Please try with another one."
@@ -135,11 +129,12 @@ checkIfS3cmdInstalledAndConfigured()
fi
else
logMsgToConfigSysLog "ERROR" "ERROR: s3cmd is not present on your system. Setting it up on your system"
downloadAndConfigureS3cmd
downloadS3cmd
configureS3cmd
fi
}

downloadAndConfigureS3cmd()
downloadS3cmd()
{
#download and install s3cmd
case "$LINUX_DIST" in
@@ -156,7 +151,6 @@ downloadAndConfigureS3cmd()
;;
esac

configureS3cmd
}

configureS3cmd()
@@ -181,7 +175,7 @@ checkIfValidS3Bucket()
fi
}

checkIfValidS3FileName()
checkIfValidS3File()
{
if [ "$LOGGLY_S3_FILE_NAME" != "" ]; then
logMsgToConfigSysLog "INFO" "INFO: Check if valid S3 file name."
@@ -213,7 +207,7 @@ createTempDir()
fi
}

downloadS3FilesFromBucketToTempDir()
downloadS3Bucket()
{
if [ "$LOGGLY_S3_BUCKET_NAME" != "" ]; then
#Files are downloaded in nested directory
@@ -227,7 +221,7 @@ downloadS3FilesFromBucketToTempDir()
fi
}

downloadS3FilesToTempDir()
downloadS3File()
{
if [ "$LOGGLY_S3_FILE_NAME" != "" ]; then
cd $TEMP_DIR
@@ -240,12 +234,12 @@ downloadS3FilesToTempDir()
fi
}

invokeFileMonitoring()
invokeS3FileMonitoring()
{
dir=/tmp/$LOGGLY_S3_ALIAS
#TODO: Not supporting multiple files with same name in different directories
#only supporting file with naming convention *.*
for f in $(find $dir -name '*.*')
for f in $(find $dir -name '*')
do
fileNameWithExt=${f##*/}
uniqueFileName=$(echo "$fileNameWithExt" | tr . _)
@@ -267,8 +261,6 @@ invokeFileMonitoring()

if [ "$IS_ANY_FILE_CONFIGURED" != "false" ]; then
restartRsyslog
START_DATE_TIME=`date +"%F %T.%3N"`
echo "Start time found: $START_DATE_TIME"
fi
}

@@ -279,26 +271,19 @@ deleteTempDir()

checkIfS3LogsMadeToLoggly()
{
#LOGGLY_S3_ALIAS
#for alias in "${field[@]}"
#do
# LOGGLY_FILE_TO_MONITOR_ALIAS="$alias"
# checkIfFileLogsMadeToLoggly
#done
counter=1
maxCounter=10

fileInitialLogCount=0
fileLatestLogCount=0
#queryParam="syslog.appName%3A%2A$LOGGLY_S3_ALIAS&from=$START_DATE_TIME&until=now&size=1"
queryParam="syslog.appName%3A%2A$LOGGLY_S3_ALIAS&from=-15m&until=now&size=1"
queryParam="syslog.appName%3A%2A$LOGGLY_S3_ALIAS&from=-5m&until=now&size=1"

queryUrl="$LOGGLY_ACCOUNT_URL/apiv2/search?q=$queryParam"
logMsgToConfigSysLog "INFO" "INFO: Search URL: ${queryUrl//\ /%20}"
logMsgToConfigSysLog "INFO" "INFO: Search URL: $queryUrl"

logMsgToConfigSysLog "INFO" "INFO: Verifying if the logs made it to Loggly."
logMsgToConfigSysLog "INFO" "INFO: Verification # $counter of total $maxCounter."

#checking if the s3 logs from start_time to current_time have made to the loggly
#get the final count of file logs for past 5 minutes
searchAndFetch fileLatestLogCount "$queryUrl"
let counter=$counter+1

@@ -316,14 +301,15 @@ checkIfS3LogsMadeToLoggly()
done

if [ "$fileLatestLogCount" -gt "$fileInitialLogCount" ]; then
logMsgToConfigSysLog "SUCCESS" "SUCCESS: Logs successfully transferred to Loggly! You are now sending $LOGGLY_FILE_TO_MONITOR logs to Loggly."
if [ "$IS_FILE_MONITOR_SCRIPT_INVOKED" = "" ]; then
exit 0
if [ "$LOGGLY_S3_BUCKET_NAME" != "" ]; then
logMsgToConfigSysLog "SUCCESS" "SUCCESS: Logs successfully transferred to Loggly! You are now sending $LOGGLY_S3_BUCKET_NAME bucket logs to Loggly."
else
logMsgToConfigSysLog "SUCCESS" "SUCCESS: Logs successfully transferred to Loggly! You are now sending $LOGGLY_S3_FILE_NAME logs to Loggly."
fi
fi
}

checkIfValidAliasForRevoke()
checkIfS3AliasExist()
{
if ! ls $RSYSLOG_ETCDIR_CONF/*$LOGGLY_S3_ALIAS.conf &> /dev/null; then
#logMsgToConfigSysLog "INFO" "INFO: $LOGGLY_S3_ALIAS found."
@@ -333,7 +319,7 @@ checkIfValidAliasForRevoke()
fi
}

removeFileMonitoring()
removeS3FileMonitoring()
{
FILES=$RSYSLOG_ETCDIR_CONF/*$LOGGLY_S3_ALIAS.conf
for f in $FILES
@@ -346,6 +332,7 @@ removeFileMonitoring()
constructFileVariables
remove21ConfFile
done
echo "INFO: Removed all the modified files."
restartRsyslog
}

@@ -410,9 +397,9 @@ if [ "$LOGGLY_ACCOUNT" != "" -a "$LOGGLY_USERNAME" != "" -a "$LOGGLY_S3_ALIAS" !
if [ "$LOGGLY_PASSWORD" = "" ]; then
getPassword
fi
installLogglyConfForFile
installLogglyConfForS3
elif [ "$LOGGLY_ROLLBACK" != "" -a "$LOGGLY_ACCOUNT" != "" -a "$LOGGLY_S3_ALIAS" != "" ]; then
removeLogglyConfForFile
removeLogglyConfForS3
else
usage
fi
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.