Ejemplo n.º 1
0
def main():
  """Run the server."""
  global OPTIONS # pylint: disable=W0603
  parser = OptionParser()
  parser.add_option("-d", "--checkdir", dest="checkdir", metavar="DIR",
                    default="/usr/lib/nagios/plugins", help="directory with check scripts")
  parser.add_option("-l", "--log-level", dest="loglevel", metavar="LEVEL",
                    help="logging level", default='info')
  parser.add_option("-g", "--graphite", dest="graphite", metavar="GRAPHITE_HOST",
                    help="graphite host, specify as host:post", default='')
  parser.add_option("-p", "--port", dest="port", metavar="PORT",
                    help="port to listen on", default=8111, type="int")
  OPTIONS = parser.parse_args()[0]

  levelName = {'debug': logging.DEBUG, 'info': logging.INFO, 'warn': logging.WARN, 'error': logging.ERROR}
  logging.basicConfig(level=levelName.get(OPTIONS.loglevel.lower(), logging.WARN))

  if OPTIONS.graphite:
    from greplin.scales import util

    host, port = OPTIONS.graphite.split(':')

    global GRAPHITE # pylint: disable=W0603
    GRAPHITE = util.GraphiteReporter(host, int(port))
    GRAPHITE.start()

  wsgi.server(eventlet.listen(('', int(OPTIONS.port))), APP)
Ejemplo n.º 2
0
    def __init__(self, host, port, prefix=None):
        """If prefix is given, it will be prepended to all Graphite
    stats. If it is not given, then a prefix will be derived from the
    hostname."""
        self.rules = []
        self.pruneRules = []

        self.prefix = prefix or gethostname().lower()

        if self.prefix and self.prefix[-1] != '.':
            self.prefix += '.'

        self.graphite = util.GraphiteReporter(host, port)
Ejemplo n.º 3
0
  def __init__(self, host, port, prefix, period=60):
    """If prefix is given, it will be prepended to all Graphite
    stats. If it is not given, then a prefix will be derived from the
    hostname."""
    threading.Thread.__init__(self)
    self.daemon = True

    self.period = period
    self.forbidden = set()
    self.rules = []

    self.prefix = prefix

    if self.prefix and self.prefix[-1] != '.':
      self.prefix += '.'

    self.oldPrefix = None
    self.graphite = util.GraphiteReporter(host, port)