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

All the changes between the two forks. #81

Merged
merged 28 commits into from Jul 13, 2016
Merged
Changes from 4 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
882b339
checking connectivity using telnet
varshneyjayant May 13, 2015
8eb4f1a
Added check for xcode command line tools
varshneyjayant May 15, 2015
b7c061f
fluent.conf now created in .loggly
varshneyjayant May 19, 2015
f8d885f
Added support to Tomcat 8 (package version)
Jul 9, 2015
8cca0cf
Added new syntax support
varshneyjayant Jan 11, 2016
3e40991
Added support for Access logs
varshneyjayant Jan 22, 2016
b87e366
Added support for Access logs
varshneyjayant Jan 22, 2016
13f4681
Merge pull request #3 from psquickitjayant/script-dev-2
varshneyjayant Jan 27, 2016
6961b2e
Added Mac script README link
varshneyjayant Jan 27, 2016
7c8a520
Create update-loggly-certificate.sh
varshneyjayant Feb 26, 2016
94c641b
Default Test Mode and Bug Fixes
varshneyjayant Feb 29, 2016
9620d00
Updated Certificate Path
varshneyjayant Mar 1, 2016
e03a420
Updated Certificate Path
varshneyjayant Mar 2, 2016
e4be7a7
Added Trapping Control + C
varshneyjayant Mar 3, 2016
b3ae0af
Added Sleep after updating Hosts file
varshneyjayant Mar 4, 2016
15dc9f7
Added MaxMessageSize
varshneyjayant Mar 9, 2016
69b90da
Configure Tomcat Access Logs
varshneyjayant Mar 9, 2016
97afefe
Added support for Systemd
varshneyjayant Mar 14, 2016
1c5ff65
Added support for Systemd
varshneyjayant Mar 14, 2016
09c09c3
Added support for Rsyslog Systemd service
varshneyjayant Mar 23, 2016
2f8d252
Added support for Systemd
varshneyjayant Mar 31, 2016
ee9768e
Delete configure-linux-systemd.sh
varshneyjayant Mar 31, 2016
a3200f0
Updated Script Version
varshneyjayant Mar 31, 2016
b78ff00
Changed Fluentd's install directory
varshneyjayant Apr 6, 2016
bae0b60
Fixed Base64 decode issue
varshneyjayant Apr 6, 2016
40f1b4e
Added support for amazon ami
varshneyjayant Apr 21, 2016
147ba9c
Merge pull request #6 from psquickitjayant/amazon-ami-support
varshneyjayant Apr 21, 2016
ad360ea
Merge pull request #5 from psquickitjayant/rsyslog-systemd
varshneyjayant May 4, 2016
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -9,7 +9,7 @@ source configure-linux.sh "being-invoked"
#name of the current script
SCRIPT_NAME=configure-file-monitoring.sh
#version of the current script
SCRIPT_VERSION=1.12
SCRIPT_VERSION=1.13

#file to monitor (contains complete path and file name) provided by user
LOGGLY_FILE_TO_MONITOR=
@@ -411,20 +411,38 @@ write21ConfFileContents()
"
fi

imfileStr+="
# File access file:
\$InputFileName $FILE_TO_MONITOR
\$InputFileTag $LOGGLY_FILE_TO_MONITOR_ALIAS:
\$InputFileStateFile stat-$STATE_FILE_ALIAS
\$InputFileSeverity info
\$InputFilePersistStateInterval 20000
\$InputRunFileMonitor
#Add a tag for file events
\$template $CONF_FILE_FORMAT_NAME,\"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [$LOGGLY_AUTH_TOKEN@41058 $TAG] %msg%\n\"
if \$programname == '$LOGGLY_FILE_TO_MONITOR_ALIAS' then @@logs-01.loggly.com:514;$CONF_FILE_FORMAT_NAME
if \$programname == '$LOGGLY_FILE_TO_MONITOR_ALIAS' then ~
"

rsyslog_version="$(rsyslogd -v)"
r_ver=${rsyslog_version:9:1}
if [ $r_ver -le 6 ]
then
imfileStr+="
# File access file:
\$InputFileName $FILE_TO_MONITOR
\$InputFileTag $LOGGLY_FILE_TO_MONITOR_ALIAS:
\$InputFileStateFile stat-$STATE_FILE_ALIAS
\$InputFileSeverity info
\$InputFilePersistStateInterval 20000
\$InputRunFileMonitor
#Add a tag for file events
\$template $CONF_FILE_FORMAT_NAME,\"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [$LOGGLY_AUTH_TOKEN@41058 $TAG] %msg%\n\"
if \$programname == '$LOGGLY_FILE_TO_MONITOR_ALIAS' then @@logs-01.loggly.com:514;$CONF_FILE_FORMAT_NAME
if \$programname == '$LOGGLY_FILE_TO_MONITOR_ALIAS' then ~
"
else
imfileStr+="
# File access file:
\$InputFileName $FILE_TO_MONITOR
\$InputFileTag $LOGGLY_FILE_TO_MONITOR_ALIAS
\$InputFileStateFile stat-$STATE_FILE_ALIAS
\$InputFileSeverity info
\$InputFilePersistStateInterval 20000
\$InputRunFileMonitor
#Add a tag for file events
template (name=\"$CONF_FILE_FORMAT_NAME\" type=\"string\" string=\"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [$LOGGLY_AUTH_TOKEN@41058 $TAG] %msg%\n\")
if \$programname == '$LOGGLY_FILE_TO_MONITOR_ALIAS' then action(type=\"omfwd\" protocol=\"tcp\" target=\"logs-01.loggly.com\" port=\"514\" template=\"$CONF_FILE_FORMAT_NAME\")
if \$programname == '$LOGGLY_FILE_TO_MONITOR_ALIAS' then ~
"
fi
#write to 21-<file-alias>.conf file
sudo cat << EOIPFW >> $FILE_SYSLOG_CONFFILE
$imfileStr
@@ -9,7 +9,7 @@ source configure-linux.sh "being-invoked"
#name of the current script
SCRIPT_NAME=configure-tomcat.sh
#version of the current script
SCRIPT_VERSION=1.4
SCRIPT_VERSION=1.5

#minimum version of tomcat to enable log rotation
MIN_TOMCAT_VERSION=6.0.33.0
@@ -53,6 +53,9 @@ TAG=
#this is not a mandatory input
LOGGLY_CATALINA_HOME=

#this variable will hold if the access-logs are invoked.
CONFIGURE_ACCESS_LOGS="false"

MANUAL_CONFIG_INSTRUCTION="Manual instructions to configure Tomcat is available at https://www.loggly.com/docs/tomcat-application-server/. Rsyslog troubleshooting instructions are available at https://www.loggly.com/docs/troubleshooting-rsyslog/"

#this variable will hold if the check env function for linux is invoked
@@ -98,6 +101,9 @@ installLogglyConfForTomcat()
#update logging.properties file for log rotation
updateLoggingPropertiesFile

#update server.xml to add renameOnRotate
updateServerXML

#multiple tags
addTagsInConfiguration

@@ -130,6 +136,9 @@ removeLogglyConfForTomcat()

#remove 21tomcat.conf file
remove21TomcatConfFile

#restore original server.xml from backup
restoreServerXML

#restore original loggly properties file from backup
restoreLogglyPropertiesFile
@@ -175,6 +184,25 @@ deduceAndCheckTomcatHomeAndVersion()
#checks if the deduced tomcat7 home is correct or not
checkIfValidTomcatHome validTomcatHome
fi

#if tomcat6 home is not valid one, move on to check for tomcat8
if [ "$validTomcatHome" = "false" ]; then

LOGGLY_CATALINA_HOME=

#lets check if tomcat6 is installed on the system
SERVICE=tomcat8

#try to deduce tomcat home considering tomcat6
assumeTomcatHome $SERVICE

#initialize validTomcatHome variable with value true. This value will be toggled
#in the function checkIfValidTomcatHome fails
validTomcatHome="true"

#checks if the deduced tomcat7 home is correct or not
checkIfValidTomcatHome validTomcatHome
fi

if [ "$validTomcatHome" = "true" ]; then
logMsgToConfigSysLog "INFO" "INFO: CATALINA HOME: $LOGGLY_CATALINA_HOME"
@@ -218,6 +246,8 @@ deduceAndCheckTomcatHomeAndVersion()
SERVICE=tomcat7
elif [ "$tomcatMajorVersion" = "6" ]; then
SERVICE=tomcat6
elif [ "$tomcatMajorVersion" = "8" ]; then
SERVICE=tomcat8
fi
else
logMsgToConfigSysLog "ERROR" "ERROR: Provided Catalina Home is not correct. Please recheck."
@@ -428,6 +458,26 @@ EOIPFW
}


#add renameOnRotate to true in the Valve element to stop access logs
#log rotation
updateServerXML()
{

if ! grep -q 'renameOnRotate="true"' "$LOGGLY_CATALINA_HOME/conf/server.xml";
then
CONFIGURE_ACCESS_LOGS="true"

#Creating backup of server.xml to server.xml.bk
logMsgToConfigSysLog "INFO" "INFO: Creating backup of server.xml to server.xml.bk"
sudo cp $LOGGLY_CATALINA_HOME/conf/server.xml $LOGGLY_CATALINA_HOME/conf/server.xml.bk
if grep -q '"localhost_access_log."' "$LOGGLY_CATALINA_HOME/conf/server.xml";
then
sed -i 's/"localhost_access_log."/"localhost_access_log"/g' $LOGGLY_CATALINA_HOME/conf/server.xml
fi
sed -i 's/"localhost_access_log"/"localhost_access_log"\ renameOnRotate="true"/g' $LOGGLY_CATALINA_HOME/conf/server.xml
logMsgToConfigSysLog "INFO" "INFO: Disabled log rotation for localhost_access_log file in server.xml"
fi
}
addTagsInConfiguration()
{
#split tags by comman(,)
@@ -554,6 +604,23 @@ write21TomcatFileContents()
"
fi

if [ $CONFIGURE_ACCESS_LOGS == "true" ];
then
imfileStr+="
# localhost_access_log.txt
\$InputFileName $LOGGLY_CATALINA_LOG_HOME/localhost_access_log.txt
\$InputFileTag tomcat-access
\$InputFileStateFile stat-tomcat-access
\$InputFileSeverity info
\$InputFilePersistStateInterval 20000
\$InputRunFileMonitor
if \$programname == 'tomcat-access' then @@logs-01.loggly.com:514;LogglyFormatTomcat
if \$programname == 'tomcat-access' then ~
"
fi


#change the tomcat-21 file to variable from above and also take the directory of the tomcat log file.
sudo cat << EOIPFW >> $TOMCAT_SYSLOG_CONFFILE
$imfileStr
@@ -623,6 +690,17 @@ restoreLogglyPropertiesFile()
restartTomcat
}

restoreServerXML()
{
if [ -f "$LOGGLY_CATALINA_HOME/conf/server.xml.bk" ];
then
logMsgToConfigSysLog "INFO" "INFO: Restoring server.xml file from backup"
sudo rm -rf $LOGGLY_CATALINA_HOME/conf/server.xml
sudo cp $LOGGLY_CATALINA_HOME/conf/server.xml.bk $LOGGLY_CATALINA_HOME/conf/server.xml
sudo rm -rf $LOGGLY_CATALINA_HOME/conf/server.xml.bk
fi
}

#remove 21tomcat.conf file
remove21TomcatConfFile()
{
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.