Beispiel #1
0
import socket, select, struct, zlib, ssl, logging, os, time
from ext.groper import define_opt, options

from util import parse_addrs, format_connection_message, normalize_path

define_opt('server', 'default_port', type=int, default=5566)
define_opt('server', 'listen_ipv4', default='127.0.0.1')
define_opt('server', 'listen_ipv6', default='[::1]')

define_opt('server', 'default_port_ssl', type=int, default=5577)
define_opt('server', 'listen_ipv4_ssl', default='')
define_opt('server', 'listen_ipv6_ssl', default='')

define_opt('server', 'pemfile', default='')
define_opt('server', 'cacert', default='')


class ServerError(Exception):
    '''Raised when the server experiences an error.'''


class ServerStartupError(Exception):
    '''Raised when the server cannot start.'''


class Server(object):
    '''Main server class.

    A single instance of this class typically acts as the event loop for LogHog.
    The main event loop is implemented in the run() method.
    '''
Beispiel #2
0
from __future__ import with_statement, print_function
import threading, logging, os, errno, re, gzip
from subprocess import Popen, PIPE
from collections import deque
try:
    from queue import Queue
except ImportError:
    from Queue import Queue

from ext.groper import define_opt, options

FALLBACK_COMPRESSOR = 'gzip'
STREAM_COMPRESSOR = 'gzip'

# Try to use xz by default. It provides the best compression/speed ratio
define_opt('compressor', 'format', default='xz')
define_opt('compressor', 'level', type=int, default=6)
define_opt('compressor', 'compress_on_write', type=bool)

class CompressorStartupError(Exception):
    '''Raised by Compressor instances if a misconfigruation is detected.'''

class Compressor(object):
    '''Class used for compressing external files.
    
    Typically a single instance of this class will run in a separate thread.
    Requests for file compression will be sent to it via the input queue.'''

    COMPRESS_LIBS = set((
        'gzip',
        'bzip2',
Beispiel #3
0
from __future__ import with_statement, print_function
import threading, logging, os, errno, re, gzip
from subprocess import Popen, PIPE
from collections import deque
try:
    from queue import Queue
except ImportError:
    from Queue import Queue

from ext.groper import define_opt, options

FALLBACK_COMPRESSOR = 'gzip'
STREAM_COMPRESSOR = 'gzip'

# Try to use xz by default. It provides the best compression/speed ratio
define_opt('compressor', 'format', default='xz')
define_opt('compressor', 'level', type=int, default=6)
define_opt('compressor', 'compress_on_write', type=bool)


class CompressorStartupError(Exception):
    '''Raised by Compressor instances if a misconfigruation is detected.'''


class Compressor(object):
    '''Class used for compressing external files.
    
    Typically a single instance of this class will run in a separate thread.
    Requests for file compression will be sent to it via the input queue.'''

    COMPRESS_LIBS = set((
Beispiel #4
0
try:
    import configparser
except ImportError:
    import ConfigParser as configparser

from server import Server
from writer import Writer
from processor import Processor
from facilities import FacilityDB, FacilityError
from compressor import Compressor
from daemon import daemonize, write_pid, drop_privileges
from util import normalize_path, get_file_md5

from ext.groper import define_opt, options, init_options, generate_sample_config, OptionsError, usage

define_opt('main', 'help', type=bool, cmd_name='help', cmd_short_name='h', cmd_group='help', is_help=True)
define_opt('main', 'generate_config', type=bool, cmd_name='gen-config', cmd_group='gen-config', cmd_only=True)

define_opt('main', 'check_config', type=bool, cmd_name='check-config', cmd_only=True)
define_opt('main', 'config', cmd_name='config', cmd_short_name='c', is_config_file=True, cmd_only=True)
define_opt('main', 'facilities_config', cmd_name='facilities-config', cmd_short_name='F')
define_opt('main', 'pidfile', cmd_name='pid', cmd_short_name='p', default='loghogd.pid')
define_opt('main', 'daemon', type=bool, cmd_name='daemon', cmd_short_name='d')
define_opt('main', 'user', cmd_name='user', default=None)

define_opt('main', 'logdir', cmd_name='log-dir', cmd_short_name='L', default='/var/log/loghogd')
define_opt('main', 'workdir', cmd_name='work-dir', default='/var/lib/loghogd')
define_opt('main', 'rundir', cmd_name='run-dir', default='/var/run/loghogd')

define_opt('log', 'filename', cmd_name='log', cmd_short_name='l', default='/var/log/loghogd/loghogd.log')
define_opt('log', 'backup_count', type=int, default=14)
Beispiel #5
0
    import ConfigParser as configparser

from server import Server
from writer import Writer
from processor import Processor
from facilities import FacilityDB, FacilityError
from compressor import Compressor
from daemon import daemonize, write_pid, drop_privileges
from util import normalize_path, get_file_md5

from ext.groper import define_opt, options, init_options, generate_sample_config, OptionsError, usage

define_opt('main',
           'help',
           type=bool,
           cmd_name='help',
           cmd_short_name='h',
           cmd_group='help',
           is_help=True)
define_opt('main',
           'generate_config',
           type=bool,
           cmd_name='gen-config',
           cmd_group='gen-config',
           cmd_only=True)

define_opt('main',
           'check_config',
           type=bool,
           cmd_name='check-config',
           cmd_only=True)
Beispiel #6
0
import socket, select, struct, zlib, ssl, logging, os, time
from ext.groper import define_opt, options

from util import parse_addrs, format_connection_message, normalize_path

define_opt('server', 'default_port', type=int, default=5566)
define_opt('server', 'listen_ipv4', default='127.0.0.1')
define_opt('server', 'listen_ipv6', default='[::1]')

define_opt('server', 'default_port_ssl', type=int, default=5577)
define_opt('server', 'listen_ipv4_ssl', default='')
define_opt('server', 'listen_ipv6_ssl', default='')

define_opt('server', 'pemfile', default='')
define_opt('server', 'cacert', default='')

class ServerError(Exception):
    '''Raised when the server experiences an error.'''

class ServerStartupError(Exception):
    '''Raised when the server cannot start.'''

class Server(object):
    '''Main server class.

    A single instance of this class typically acts as the event loop for LogHog.
    The main event loop is implemented in the run() method.
    '''
    
    SHUTDOWN_TIMEOUT = 0.25 # small timeout between socket.shutdown() and socket.close()