pcrunner package

Submodules

pcrunner.configuration module

pcrunner.configuration

Global configuration handling

class pcrunner.configuration.Config(args=None, **kwargs)

Bases: dict

subset(*keys, **kwargs)

Return a sub set of Config dict of keys if kwargs also update the returned dictionary.

update_yaml()

Read Yaml config

pcrunner.configuration.read_check_commands(command_filename)
pcrunner.configuration.read_check_commands_txt(fd)
pcrunner.configuration.read_check_commands_yaml(fd)

pcrunner.daemon module

pcrunner.daemon

Generic linux daemon base class for python 3.x.

class pcrunner.daemon.Daemon(pid_file)

Bases: object

A generic daemon class. Usage: subclass the daemon class and override the run() method.

daemonize()

Daemonize class. UNIX double fork mechanism.

delpid()

Remove pid file.

run()

You should override this method when you subclass Daemon.

It will be called after the process has been daemonized by start()

start()

Start the daemon.

stop()

Stop the daemon.

pcrunner.exception module

pcrunner.exceptions

All exceptions used in the PassiveCheckRunner code base are defined here.

exception pcrunner.exception.PassiveCheckRunnerException

Bases: Exception

Base exception class. All PassiveCheckRunner specific exceptions should subclass this class.

exception pcrunner.exception.PostFailed

Bases: PassiveCheckRunnerException

Raised when an error occurs when posting results:
  • An error occurs while posting.

  • A non 200 HTTP return code.

exception pcrunner.exception.PostResultTooBig

Bases: PassiveCheckRunnerException

Raised when post result are bigger then max_post_size.

pcrunner.main module

pcrunner.main

Main entry point for the pcrunner command.

class pcrunner.main.Check(result_type, name, command, hostname)

Bases: object

property duration
property elapsed
end()
property plugin_output

Checks (loosely) if performance data is form of: rx_errors=0;;;0;tx_errors=0;;;0; Otherwise remove ‘|’ and everything after.

run()

Run the command and saves excection data

start()
terminate()

Terminates check if still running.

class pcrunner.main.CheckRun(hostname)

Bases: object

class pcrunner.main.PassiveCheckRunner(nsca_web_url, nsca_web_username, nsca_web_password, hostname, command_file, result_file, result_dir, max_procs, interval, lines_per_post, pid_file, http_timeout, max_line_size)

Bases: object

check_pcrunner_end()
check_results_from_finished_queue()
get_checks()
kill_running_checks()
property number_of_checks_finished
post(lines)
post_results()
post_results_previous_run()

If a previous result file exists post the results that are found in this file in chunks of number of lines per post. If post fails save failed checks in self.results_post_failed.

read_results_from_spool_dir()
run()
start()

Get checks, put them on start_queue and start threads. When max time reached kill all running processes.

stop()
write_failed_results()
class pcrunner.main.PassiveCheckRunnerDaemon(pcrunner)

Bases: Daemon

run()

You should override this method when you subclass Daemon.

It will be called after the process has been daemonized by start()

pcrunner.main.get_syslog_socket_or_win32()
pcrunner.main.is_socket(path)
pcrunner.main.main()

Entry point for the package, as defined in setup.py.

pcrunner.main.parse_pcrunner_args(args)

Parse the command-line arguments to pcrunner.

pcrunner.main.remove_root_logger_handlers()
pcrunner.main.run_process(start_queue, run_queue, finished_queue)

Function to be started as thread. Runs checks from start_queue, puts them on end_queue

pcrunner.main.setup_logging(log_file=None, verbose=False, console=False)
pcrunner.main.setup_logging_with_config_opts(no_daemon, log_file, verbose, syslog_server, syslog_port)
pcrunner.main.slice_up_file(fd, number_of_lines)

return lists

pcrunner.version module

Get the version string for the named package.

param distribution_name:

The name of the distribution package to query.

return:

The version string for the package as defined in the package’s “Version” metadata key.

pcrunner.windows_service module

pcrunner.windows_service

Entry poing for Passive Check Runner as Windows Service

class pcrunner.windows_service.PassiveCheckRunnerService(*args: Any, **kwargs: Any)

Bases: ServiceFramework

Passive Check Runner as Windows Service

SvcDoRun()
SvcStop()

Module contents

pcrunner

Main package for Passive Check Runner