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

Enhancements #71

Merged
merged 53 commits into from May 13, 2015
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
3a59a73
Added support to Debian OS
Oct 27, 2014
7210c7d
Added a check for syslog-ng
Oct 28, 2014
b782617
Check if logs are parsed in Loggly
Oct 28, 2014
ca64536
Check if logs are parsed in Loggly
Oct 28, 2014
c217c36
Check if logs are parsed in Loggly
Oct 28, 2014
c60835a
Added support to suppress prompts
Oct 31, 2014
c53de77
Added support to suppress prompts
Oct 31, 2014
995d96a
Added support to suppress prompts
Oct 31, 2014
ac4f3f1
Added support to suppress prompts
Oct 31, 2014
8ea9e55
Added support to suppress prompts
Oct 31, 2014
6e316ad
Added support to suppress prompts
Oct 31, 2014
32cb0b8
Linux Script: Minor Bug Fix
Oct 31, 2014
743fc92
Linux Script: Bug Fix
Nov 4, 2014
48e750b
File Monitoring: Check if logs are rotated.
Nov 6, 2014
1afae10
File Monitoring: Check if logs are rotated.
Nov 11, 2014
bdddbb0
Updated Mac logs link
Nov 12, 2014
ee39dc6
Checks if log rotation is enabled on the File
Nov 20, 2014
76af2ad
Checks if log rotation is enabled on the Log files
Nov 20, 2014
65e3be8
Checks if log rotation is enabled on the Log files
Nov 20, 2014
8aff0e5
Minor modifications
Nov 21, 2014
9d3f561
Minor modifications
Nov 21, 2014
25754be
Minor modifications
Nov 21, 2014
33d993d
Added support to multiple tags
Nov 25, 2014
75c172c
Added support to multiple tags
Nov 25, 2014
f8a92a1
Added support to multiple tags
Nov 25, 2014
e083b05
Added support to multiple tags
Nov 26, 2014
5b59acb
Linux Script: Bug Fixes.
Dec 2, 2014
4669afc
Removed Log Rotation Check
Dec 2, 2014
8e33628
Removed Log Rotation Check
Dec 2, 2014
b907287
Removed Log Rotation Check
Dec 2, 2014
245c946
Bug Fixes
Dec 3, 2014
0f2b748
Bug Fixes
Dec 3, 2014
2d26c06
Remove state files on same alias
Dec 15, 2014
d642646
Bug Fixes
varshneyjayant Jan 21, 2015
c382fc1
Added troubleshooting rsyslog link
varshneyjayant Jan 23, 2015
4a6fba1
Added troubleshooting rsyslog link
varshneyjayant Jan 23, 2015
352212d
Revert "Added troubleshooting rsyslog link"
Jan 23, 2015
af0be39
Revert "Added troubleshooting rsyslog link"
Jan 23, 2015
b67a2c8
Added rsyslog troubleshooting link
Jan 23, 2015
95cb2ab
Added support to Disk Assisted queues
varshneyjayant Mar 4, 2015
bf14a8e
Added support to Directory Monitoring
varshneyjayant Mar 4, 2015
884113e
Added Mac Script
Mar 4, 2015
ded22fe
Added README
varshneyjayant Mar 4, 2015
3215989
Bug Fixes
Mar 18, 2015
62fce97
Bug fixes for syslog-ng detection
varshneyjayant Mar 24, 2015
164b2f4
Improved syslog-ng detection
varshneyjayant Mar 27, 2015
2a44bab
Improved error text
Mar 27, 2015
074e02a
Bug Fixes
varshneyjayant Apr 3, 2015
35cda1c
version number update from 1.0 to 1.1
varshneyjayant Apr 22, 2015
9afecfa
version number update from 1.12 to 1.13
varshneyjayant Apr 22, 2015
271d3cd
checks if cron is running during rollback
varshneyjayant Apr 22, 2015
6da5dad
Added script to publish on S3
varshneyjayant May 6, 2015
4d7af77
Updated Manual instructions
varshneyjayant May 6, 2015
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Bug Fixes

1. Updated File monitoring to support recursive directories
2. Made s3 script compatible to updated file monitoring script
  • Loading branch information
Jayant Varshney
Jayant Varshney committed Mar 18, 2015
commit 3215989b4c6853f99174d618bdd4569c6a55df48
@@ -169,8 +169,8 @@ configureDirectoryFileMonitoring()
case $yn in
[Yy]* )
installLogglyConf
for file in $( ls ${LOGGLY_FILE_TO_MONITOR} )
do
for file in $(find $LOGGLY_FILE_TO_MONITOR -name '*')
do
configureFilesPresentInDirectory $file $FILE_ALIAS
done
break;;
@@ -194,34 +194,29 @@ configureDirectoryFileMonitoring()
done
else
installLogglyConf
for file in $( ls ${LOGGLY_FILE_TO_MONITOR} )
do
for file in $(find $LOGGLY_FILE_TO_MONITOR -name '*')
do
configureFilesPresentInDirectory $file $FILE_ALIAS
if [[ ! -f "$HOME/.loggly/file-monitoring-cron-$FILE_ALIAS.sh" ]]; then
doCronInstallation
fi
done
done
if [[ ! -f "/root/.loggly/file-monitoring-cron-$FILE_ALIAS.sh" ]]; then
doCronInstallation
fi
fi
}

#actually configures a file present in the directory for monitoring
configureFilesPresentInDirectory()
{
if [ "$IS_WILDCARD" == "true" ]; then
FILE_TO_MONITOR=$1
else
FILE_TO_MONITOR=$LOGGLY_FILE_TO_MONITOR/$1
fi
FILE_TO_MONITOR=$1
fileNameWithExt=${1##*/}
uniqueFileName=$(echo "$fileNameWithExt" | tr . _)
var=$(file $FILE_TO_MONITOR)


#checking if it is a text file otherwise ignore it
#it may be possible that the "text" may contain some uppercase letters like "Text"
var=$(echo $var | tr "[:upper:]" "[:lower:]")

if [[ $var == *text* ]]; then
LOGGLY_FILE_TO_MONITOR_ALIAS=$uniqueFileName-$2

if [ -f ${FILE_TO_MONITOR} ]; then
constructFileVariables
checkFileReadPermission
@@ -361,21 +356,19 @@ addTagsInConfiguration()

doCronInstallation()
{
if [[ ! -d "$HOME/.loggly" ]]; then
mkdir $HOME/.loggly
if [[ ! -d "/root/.loggly" ]]; then
mkdir /root/.loggly
fi
CRON_SCRIPT="$HOME/.loggly/file-monitoring-cron-$FILE_ALIAS.sh"
CRON_SCRIPT="/root/.loggly/file-monitoring-cron-$FILE_ALIAS.sh"
logMsgToConfigSysLog "INFO" "INFO: Creating cron script $CRON_SCRIPT"

sudo touch $CRON_SCRIPT
sudo chmod +x $CRON_SCRIPT

cronScriptStr="#!/bin/bash
#curl -s -o configure-file-monitoring.sh https://www.loggly.com/install/configure-file-monitoring.sh
curl -s -o configure-file-monitoring.sh https://www.loggly.com/install/configure-file-monitoring.sh
sudo mv -f $FILE_SYSLOG_CONFFILE $FILE_SYSLOG_CONFFILE.bk
sudo rm -f $FILE_SYSLOG_CONFFILE
sudo bash configure-file-monitoring.sh -a $LOGGLY_ACCOUNT -u $LOGGLY_USERNAME -p $LOGGLY_PASSWORD -f $LOGGLY_FILE_TO_MONITOR -l $FILE_ALIAS -tag $LOGGLY_FILE_TAG -s
"
#write to cron script file
@@ -530,15 +523,15 @@ remove21ConfFile()

deleteFileFromCrontab()
{
if [ -f "$HOME/.loggly/file-monitoring-cron-$FILE_ALIAS.sh" ];then
if [ -f "/root/.loggly/file-monitoring-cron-$FILE_ALIAS.sh" ];then

logMsgToConfigSysLog "INFO" "INFO: Deleting sync Cron."

#delete cron
sudo crontab -l | grep -v "$FILE_ALIAS" | crontab -
sudo crontab -l | grep -v "file-monitoring-cron-$FILE_ALIAS.sh" | crontab -

#delete cron script
sudo rm -f $HOME/.loggly/file-monitoring-cron-$FILE_ALIAS.sh
sudo rm -f /root/.loggly/file-monitoring-cron-$FILE_ALIAS.sh

fi

@@ -8,13 +8,21 @@ source configure-file-monitoring.sh "being-invoked"
#name of the current script
SCRIPT_NAME=configure-s3-file-monitoring.sh
#version of the current script
SCRIPT_VERSION=1.4
SCRIPT_VERSION=1.5

#s3 bucket name to configure
LOGGLY_S3_BUCKET_NAME=

#alias name, will be used as tag & state file name etc. provided by user
LOGGLY_S3_ALIAS=
FILE_ALIAS=
STATE_FILE_ALIAS=

#file as tag sent with the logs
LOGGLY_FILE_TAG="s3file"

#format name for the conf file. Can be set by calling script
CONF_FILE_FORMAT_NAME="LogglyFormatS3"

#file alias provided by the user
APP_TAG="\"s3file-alias\":\"\""
@@ -55,9 +63,6 @@ installLogglyConfForS3()
#check if s3bucket is valid
checkIfValidS3Bucket

#configure loggly for Linux
installLogglyConf

#create temporary directory
createTempDir

@@ -250,37 +255,15 @@ downloadS3Bucket()
fi
}


invokeS3FileMonitoring()
{
dir=/tmp/s3monitoring/$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 '*')
do
fileNameWithExt=${f##*/}
uniqueFileName=$(echo "$fileNameWithExt" | tr . _)
var=$(file $f)

#it may be possible that the "text" may contain some uppercase letters like "Text"
var=$(echo $var | tr "[:upper:]" "[:lower:]")

if [[ $var == *text* ]]; then
LOGGLY_FILE_TO_MONITOR_ALIAS=$uniqueFileName-$LOGGLY_S3_ALIAS
LOGGLY_FILE_TO_MONITOR=$f
LOGGLY_FILE_TAG="s3file"
CONF_FILE_FORMAT_NAME="LogglyFormatS3"
constructFileVariables
checkFileReadPermission
checkLogFileSize $LOGGLY_FILE_TO_MONITOR
write21ConfFileContents
IS_ANY_FILE_CONFIGURED="true"
#ignoring directory
elif [[ $var != *directory* ]]; then
logMsgToConfigSysLog "WARN" "WARN: File $fileNameWithExt is not a text file. Ignoring."
fi
done
LOGGLY_FILE_TO_MONITOR=$dir

configureDirectoryFileMonitoring

IS_ANY_FILE_CONFIGURED="true"

if [ "$IS_ANY_FILE_CONFIGURED" != "false" ]; then
restartRsyslog
fi
@@ -293,7 +276,7 @@ installCronToSyncS3BucketPeriodically()
read -p "Would you like install a Cron job to sync the files currently in your bucket every 5 minutes? (yes/no)" yn
case $yn in
[Yy]* )
doCronInstallation
doS3CronInstallation
break;;
[Nn]* )
logMsgToConfigSysLog "INFO" "INFO: Skipping Cron installation."
@@ -302,11 +285,11 @@ installCronToSyncS3BucketPeriodically()
esac
done
else
doCronInstallation
doS3CronInstallation
fi
}

doCronInstallation()
doS3CronInstallation()
{
#copying .s3cfg file to /root so that it can be used by crontab for sync
if ! sudo test -f "/root/.s3cfg" ; then
@@ -477,7 +460,9 @@ while [ "$1" != "" ]; do

-s3l | --s3alias ) shift
LOGGLY_S3_ALIAS=$1
echo "File alias: $LOGGLY_S3_ALIAS"
FILE_ALIAS=$LOGGLY_S3_ALIAS
STATE_FILE_ALIAS=$LOGGLY_S3_ALIAS
echo "File alias: $FILE_ALIAS"
;;
-s | --suppress )
SUPPRESS_PROMPT="true"
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.