A pluguin tool set of functions for pandorafms
Project description
Python: module plugintools for PandoraFMS Developers
Modules
Classes
class Agent(builtins.object)
Basic agent class. Requires agent parameters (config {dictionary})
and module definition (modules_def [list of dictionaries])
Methods defined here:
__init__(self, config, modules_def)
Initialize self. See help(type(self)) for accurate signature.
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
Functions
auth_call(session, authtype, user, passw)
Authentication for url request. Requires request.sessions.Session() object.
Args:
- session (object): request Session() object.
- authtype (str): 'ntlm', 'basic' or 'digest'.
- user (str): auth user.
- passw (str): auth password.
call_url(url, authtype, user, passw, time_out)
Call URL. Uses request module to get url contents.
Args:
- url (str): URL
- authtype (str): ntlm', 'basic', 'digest'. Optional.
- user (str): auth user. Optional.
- passw (str): auth password. Optional.
Returns:
- str: call output
debug_dict(func)
debug_dict [Decorator]. Prints an indented json.
Write @debug_dict above any function that returns a dictionary or a list of dictionaries.
now(print_flag=None, utimestamp=None)
Returns time in yyyy/mm/dd HH:MM:SS format by default. Use 1 as an argument
to get epoch time (utimestamp)
parse_configuration(file='/etc/pandora/pandora_server.conf', separator=' ')
Parse configuration. Reads configuration file and stores its data as dict.
Args:
- file (str): configuration file path. Defaults to "/etc/pandora/pandora_server.conf".
- separator (str, optional): Separator for option and value. Defaults to " ".
Returns:
- dict: containing all keys and values from file.
print_agent(agent, modules, data_dir='/var/spool/pandora/data_in/', log_modules=None, print_flag=None)
Prints agent XML. Requires agent conf (dict) and modules (list) as arguments.
- Use print_flag to show modules' XML in STDOUT.
- Returns a tuple (xml, data_file).
print_log_module(module, print_flag=None)
Returns log module in XML format. Accepts only {dict}.
- Only works with one module at a time: otherwise iteration is needed.
- Module "value" field accepts str type.
- Use not_print_flag to avoid printing the XML (only populates variables).
print_module(module, print_flag=None)
Returns module in XML format. Accepts only {dict}.
- Only works with one module at a time: otherwise iteration is needed.
- Module "value" field accepts str type or [list] for datalists.
- Use print_flag to show modules' XML in STDOUT.
tentacle_xml(file, tentacle_ops, tentacle_path='', debug=0)
Sends file using tentacle protocol
- Only works with one file at time.
- file variable needs full file path.
- tentacle_opts should be a dict with tentacle options (address [password] [port]).
- tentacle_path allows to define a custom path for tentacle client in case is not in sys path).
- if debug is enabled, the data file will not be removed after being sent.
Returns 0 for OK and 1 for errors.
write_xml(xml, agent_name, data_dir='/var/spool/pandora/data_in/')
Creates a agent .data file in the specified data_dir folder.
Args:
- xml (str): XML string to be written in the file.
- agent_name (str): agent name for the xml and file name.
- data_dir (str): folder in which the file will be created.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.