diff --git a/configure-syslog.py b/configure-syslog.py index 840c1c7..2a3a255 100755 --- a/configure-syslog.py +++ b/configure-syslog.py @@ -65,34 +65,56 @@ LOGGLY_BASH_SCRIPT = 'configure-syslog.%s.sh' % os.getpid() PROCESS_ID = -1 -STR_PYTHON_FAIL_MESSAGE = ("Python version check fails: Installed version is " - "%s. Minimum required version is %s.") -STR_MULTIPLE_SYSLOG_MESSAGE = ("Multiple syslogd are running.") -STR_AUTHTOKEN_NOTFOUND_MESSAGE = ("No Customer Tokens were found.") -STR_AUTHENTICATION_FAIL_MESSAGE = ("Authentication fail for user %s") -VERIFICATION_FAIL_MESSAGE = ("Loggly verification failed. " - "Please visit http://loggly.com/docs/sending-logs-unixlinux-system-setup/" - " for more information.") -STR_EXIT_MESSAGE = ("\nThis environment (OS : %s) is not supported by " - "the Loggly Syslog Configuration Script. Please visit " - "http://loggly.com/docs/sending-logs-unixlinux-system-setup/ for more information.\n") +STR_PYTHON_FAIL_MESSAGE = ''' +Python version check fails: Installed version is "%s. \ +Minimum required version is %s. +'''.strip() + +STR_MULTIPLE_SYSLOG_MESSAGE = "Multiple syslogd are running." +STR_AUTHTOKEN_NOTFOUND_MESSAGE = "No Customer Tokens were found." +STR_AUTHENTICATION_FAIL_MESSAGE = "Authentication fail for user %s" + +VERIFICATION_FAIL_MESSAGE = ''' +Loggly verification failed. Please visit \ +http://loggly.com/docs/sending-logs-unixlinux-system-setup/ for more information. +'''.strip() + +STR_EXIT_MESSAGE = ''' +This environment (OS : %s) is not supported by the Loggly Syslog \ +Configuration Script. Please visit \ +http://loggly.com/docs/sending-logs-unixlinux-system-setup/ \ +for more information. +''' + STR_NO_SYSLOG_MESSAGE = "\nSupported syslog type/version not found." -STR_ERROR_MESSAGE = ("Can not automatically re-configure syslog for " - "this Linux distribution. " - "\nUse the help option for instructions " - "to manually re-configure syslog for Loggly.") -STR_SYSLOG_DAEMON_MESSAGE = ("\nSyslog daemon (%s) is not running. " - "Please start %s daemon and try again.\n") -REST_URL_GET_AUTH_TOKEN = ("http://%s.%s/apiv2/customer") -REST_URL_GET_SEARCH_ID = ("http://%s.%s/apiv2/search?q=%s&from=-2h&until=now&size=10") -REST_URL_GET_SEARCH_RESULT = ("http://%s.%s/apiv2/events?rsid=%s") -USER_NAME_TEXT = ("Enter the username that you use to log into your Loggly account.") -ACCOUNT_NAME_TEXT = ("Enter your Loggly account name. This is your subdomain. " - "For example if you login at mycompany.loggly.com," - "\nyour account name is mycompany.\n") -AUTHTOKEN_MODIFICATION_TEXT = ("\nIf you wish to use a different Customer Token, " - "replace %s\nwith the token you wish to use, in" - " the file %s.") + +STR_ERROR_MESSAGE = ''' +Can not automatically re-configure syslog for this Linux distribution. +Use the help option for instructions to manually re-configure syslog for Loggly. +'''.strip() + +STR_SYSLOG_DAEMON_MESSAGE = ''' +Syslog daemon (%s) is not running. Please start %s daemon and try again. +''' + +REST_URL_GET_AUTH_TOKEN = "http://%s.%s/apiv2/customer" +REST_URL_GET_SEARCH_ID = "http://%s.%s/apiv2/search?q=%s&from=-2h&until=now&size=10" +REST_URL_GET_SEARCH_RESULT = "http://%s.%s/apiv2/events?rsid=%s" + +USER_NAME_TEXT = "Enter the username that you use to log into your loggly account." + +ACCOUNT_NAME_TEXT = ''' +Enter your Loggly account name. This is your subdomain. For example if \ +you login at mycompany.loggly.com, +your account name is mycompany. +'''.lstrip() + +AUTHTOKEN_MODIFICATION_TEXT = ''' +If you wish to use a different Customer Token, replace %s +with the token you wish to use, in the file %s. +''' + +INSTALLATION_COMPLETED_TEXT = "Installation completed.\n" _LOG_SOCKET = None OUR_PROGNAME = "configure-syslog" @@ -122,7 +144,7 @@ %s template LogglyFormat { template("<${PRI}>1 ${ISODATE} ${HOST} ${PROGRAM} \ -${PID} ${MSGID} [%s@%s tag=\\"example\\"] $MSG\\n");}; +${PID} ${MSGID} [%s@%s] $MSG\\n");}; destination d_loggly { tcp("%s" port(%s) template(LogglyFormat) flush_timeout(1000) frac_digits(3)); }; log { source(%s); destination(d_loggly); }; @@ -139,9 +161,9 @@ # Define the template used for sending logs to Loggly. Do not change this format. $template LogglyFormat,"<%%pri%%>%%protocol-version%% %%timestamp:::date-rfc3339%% \ -%%HOSTNAME%% %%app-name%% %%procid%% %%msgid%% [%s@%s tag=\\"example\\"] %%msg%%" -# Send messages to syslog server listening on TCP port using template +%%HOSTNAME%% %%app-name%% %%procid%% %%msgid%% [%s@%s] %%msg%%" +# Send messages to Loggly over TCP using the template. *.* @@%s:%s;LogglyFormat # ------------------------------------------------------- @@ -1308,7 +1330,7 @@ def install(current_environment): printLog(AUTHTOKEN_MODIFICATION_TEXT % (authorization_details['token'], modified_config_file)) - printLog("Installation completed") + printLog(INSTALLATION_COMPLETED_TEXT) return syslog_name_for_configuration def verify(current_environment):