Beispiel #1
0
def main():
    checks = ['proc', 'offset', 'peers', 'reach', 'sync', 'vars', 'trace']
    args = get_args()

    if 'COLLECTD_HOSTNAME' in os.environ:
        args.mode = 'collectd'
        hostname = os.environ['COLLECTD_HOSTNAME']
    else:
        hostname = socket.getfqdn()

    if 'COLLECTD_INTERVAL' in os.environ:
        args.mode = 'collectd'
        if args.interval is None:
            args.interval = float(os.environ['COLLECTD_INTERVAL'])

    if args.interval is None:
        args.interval = 60

    if args.mode != 'collectd':
        warnings.warn('Only collectd mode is currently supported')
        sys.exit(1)

    while True:
        # run the checks
        checkobjs = ntpchecks(checks, debug=False)

        # alert on what we've collected
        alerter = NTPAlerter(checks, checkobjs)
        alerter.alert_collectd(hostname, args.interval)
        sleep_until(args.interval)
Beispiel #2
0
def main():
    checks = ['proc', 'offset', 'peers', 'reach', 'sync', 'vars', 'trace']
    args = get_args()

    if 'COLLECTD_HOSTNAME' in os.environ:
        args.mode = 'collectd'
        hostname = os.environ['COLLECTD_HOSTNAME']
    else:
        hostname = socket.getfqdn()

    if 'COLLECTD_INTERVAL' in os.environ:
        args.mode = 'collectd'
        if args.interval is None:
            args.interval = float(os.environ['COLLECTD_INTERVAL'])

    if args.interval is None:
        args.interval = 60

    if args.mode != 'collectd':
        warnings.warn('Only collectd mode is currently supported')
        sys.exit(1)

    while True:
        # run the checks
        checkobjs = ntpchecks(checks, debug=False)

        # alert on what we've collected
        alerter = NTPAlerter(checks, checkobjs)
        alerter.alert_collectd(hostname, args.interval)
        sleep_until(args.interval)