Beispiel #1
0
def cmd_spool(args=False):
    """[--maxage=<seconds>] [--warning=X] [--critical=X] <path> [--delete]
	Checks a certain spool directory for files (and files only) that
	are older than 'maxage'. It is intended to prevent buildup of
	checkresult files and unprocessed performance-data files in the
	various spool directories used by op5 Monitor.
	  --delete causes too old files to be removed.
	  --maxage is given in seconds and defaults to 300 (5 minutes).
	  <path> may be 'perfdata' or 'checks', in which case directory
	  names will be taken from op5 defaults.
	  --warning and --critical have no effect if '--delete' is given
	  and will otherwise specify threshold values.

	Only one directory at a time may be checked.
	"""
    maxage = 300
    warning = 5
    critical = 10
    path = False
    delete = False
    npcd_config = '/opt/monitor/etc/pnp/npcd.cfg'
    for arg in args:
        if arg.startswith('--maxage='):
            maxage = str_to_seconds(arg.split('=', 1)[1])
        elif arg.startswith('--warning='):
            warning = int(arg.split('=', 1)[1])
        elif arg.startswith('--critical='):
            critical = int(arg.split('=', 1)[1])
        elif arg == '--delete':
            delete = True
        elif path == False:
            path = arg

    if path == False:
        nplug.unknown("'path' is a required argument")

    if path == 'checks':
        path = check_result_path
    elif path == 'perfdata':
        if os.access(npcd_config, os.R_OK):
            comp = cconf.parse_conf(npcd_config)
            for k, v in comp.params:
                if k == 'perfdata_spool_dir':
                    path = v
                    break
            comp = False
        else:
            path = '/opt/monitor/var/spool/perfdata'

    bad = 0
    bad_paths = []
    now = int(time.time())
    try:
        result = get_files(path)
    except OSError, e:
        nplug.die(nplug.STATE_UNKNOWN,
                  "Spool directory \"%s\" doesn't exist" % (path, ))
Beispiel #2
0
def cmd_spool(args=False):
	"""[--maxage=<seconds>] [--warning=X] [--critical=X] <path> [--delete]
	Checks a certain spool directory for files (and files only) that
	are older than 'maxage'. It is intended to prevent buildup of
	checkresult files and unprocessed performance-data files in the
	various spool directories used by op5 Monitor.
	  --delete causes too old files to be removed.
	  --maxage is given in seconds and defaults to 300 (5 minutes).
	  <path> may be 'perfdata' or 'checks', in which case directory
	  names will be taken from op5 defaults.
	  --warning and --critical have no effect if '--delete' is given
	  and will otherwise specify threshold values.

	Only one directory at a time may be checked.
	"""
	maxage = 300
	warning = 5
	critical = 10
	path = False
	delete = False
	npcd_config = '/opt/monitor/etc/pnp/npcd.cfg'
	for arg in args:
		if arg.startswith('--maxage='):
			maxage = str_to_seconds(arg.split('=', 1)[1])
		elif arg.startswith('--warning='):
			warning = int(arg.split('=', 1)[1])
		elif arg.startswith('--critical='):
			critical = int(arg.split('=', 1)[1])
		elif arg == '--delete':
			delete = True
		elif path == False:
			path = arg

	if path == False:
		nplug.unknown("'path' is a required argument")

	if path == 'checks':
		path = check_result_path
	elif path == 'perfdata':
		if os.access(npcd_config, os.R_OK):
			comp = cconf.parse_conf(npcd_config)
			for k, v in comp.params:
				if k == 'perfdata_spool_dir':
					path = v
					break
			comp = False
		else:
			path = '/opt/monitor/var/spool/perfdata'

	bad = 0
	bad_paths = []
	now = int(time.time())
	try:
		result = get_files(path)
	except OSError, e:
		nplug.die(nplug.STATE_UNKNOWN, "Spool directory \"%s\" doesn't exist" % (path,))
Beispiel #3
0
				os.unlink(p)
		except OSError, e:
			pass

	state = nplug.STATE_OK
	if bad >= critical:
		state = nplug.STATE_CRITICAL
	elif bad >= warning:
		state = nplug.STATE_WARNING

	if delete:
		msg = "%d too old files were deleted|%s" % (bad, perfdata)
	else:
		msg = "%d files too old|%s" % (bad, perfdata)

	nplug.die(state, msg)
	sys.exit(state)

def cmd_cores(args=False):
	"""--warning=X --critical=X [--dir=]
	Checks for memory dumps resulting from segmentation violation from
	core parts of op5 Monitor. Detected core-files are moved to
	/tmp/mon-cores in order to keep working directories clean.
	  --warning  default is 0
	  --critical default is 1 (any corefile results in a critical alert)
	  --dir      lets you specify more paths to search for corefiles. This
	             option can be given multiple times.
	  --delete   deletes corefiles not coming from 'merlind' or 'monitor'
	"""
	warn = 0
	crit = 1