Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: etsy/logster
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: syndeca/logster
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Jan 5, 2015

  1. Copy the full SHA
    f3e6221 View commit details
  2. update to for pygtail

    synapsechris committed Jan 5, 2015
    Copy the full SHA
    d3022f0 View commit details
  3. simplify readme

    synapsechris committed Jan 5, 2015
    Copy the full SHA
    7b574dc View commit details
Showing with 9 additions and 25 deletions.
  1. +1 −12 README.md
  2. +5 −13 bin/logster
  3. +3 −0 setup.py
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -34,18 +34,7 @@ our engineers to write log parsers quickly.

## Installation

Logster depends on the "logtail" utility that can be obtained from the logcheck
package, either from a Debian package manager or from source:

http://packages.debian.org/source/sid/logcheck

RPMs for logcheck can be found here:

http://rpmfind.net/linux/rpm2html/search.php?query=logcheck

Once you have logtail installed via the logcheck package, you make want to look
over the actual logster script itself to adjust any paths necessary. Then the
only other thing you need to do is run the installation commands from the
Then the only thing you need to do is run the installation commands from the
`setup.py` file:

$ sudo python setup.py install
18 changes: 5 additions & 13 deletions bin/logster
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ import fcntl
import socket
import traceback
import platform
import pygtail

from time import time, strftime, gmtime
from math import floor
@@ -60,7 +61,6 @@ from logster.logster_helper import LogsterParsingException, LockingError, CloudW

# Globals
gmetric = "/usr/bin/gmetric"
logtail = "/usr/sbin/logtail2"
log_dir = "/var/log/logster"
state_dir = "/var/run"
send_nsca = "/usr/sbin/send_nsca"
@@ -70,8 +70,6 @@ script_start_time = time()
# Command-line options and parsing.
cmdline = optparse.OptionParser(usage="usage: %prog [options] parser logfile",
description="Tail a log file and filter each line to generate metrics that can be sent to common monitoring packages.")
cmdline.add_option('--logtail', action='store', default=logtail,
help='Specify location of logtail. Default %s' % logtail)
cmdline.add_option('--metric-prefix', '-p', action='store',
help='Add prefix to all published metrics. This is for people that may multiple instances of same service on same host.',
default='')
@@ -142,8 +140,6 @@ if class_name.find('.') == -1:
log_file = arguments[1]
state_dir = options.state_dir
log_dir = options.log_dir
logtail = options.logtail


# Logging infrastructure for use throughout the script.
# Uses appending log file, rotated at 100 MB, keeping 5.
@@ -363,7 +359,6 @@ def main():
dirsafe_logfile = log_file.replace('/','-')
logtail_state_file = '%s/logtail-%s%s.state' % (state_dir, class_name, dirsafe_logfile)
logtail_lock_file = '%s/logtail-%s%s.lock' % (state_dir, class_name, dirsafe_logfile)
shell_tail = "%s -f %s -o %s" % (logtail, log_file, logtail_state_file)

logger.info("Executing parser %s on logfile %s" % (class_name, log_file))
logger.debug("Using state file %s" % logtail_state_file)
@@ -398,24 +393,21 @@ def main():

except OSError as e:
logger.info('Writing new state file and exiting. (Was either first run, or state file went missing.)')
input = os.popen(shell_tail)
retval = input.close()
if not retval is None:
logger.warning('%s returned bad exit code %s' % (shell_tail, retval))
input = pygtail.Pygtail(log_file, offset_file=logtail_state_file).readlines()
end_locking(lockfile, logtail_lock_file)
sys.exit(0)

# Open a pipe to read input from logtail.
input = os.popen(shell_tail)
input = pygtail.Pygtail(log_file, logtail_state_file)

except SystemExit as e:
raise

except Exception as e:
# note - there is no exception when logtail doesn't exist.
# I don't know when this exception will ever actually be triggered.
print("Failed to run %s to get log data (line %s): %s" %
(shell_tail, lineno(), e))
print ("Failed to get log data (line %s): %s" %
(lineno(), e))
end_locking(lockfile, logtail_lock_file)
sys.exit(1)

3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,9 @@
'logster',
'logster/parsers'
],
install_requires = [
'pygtail==0.5.1'
],
zip_safe=False,
scripts=[
'bin/logster'