Probes API reference¶
#.. module:: monitoring.nagios.probes
API Reference for all probes.
Base class¶
This is the base class for all plugin classes.
Base module for all probes.
- class monitoring.nagios.probes.base.Probe¶
Base class for defining a new Probe.
Network protocols¶
Plugins that interact with SNMP or SSH protocols.
SNMP¶
SNMP probe module.
- class monitoring.nagios.probes.snmp.ProbeSNMP(hostaddress='', port=161, community='public', snmpv2=False)¶
Class ProbeSNMP.
- get(oidstable)¶
Query a SNMP OID using Get command.
- getnext(oidstable)¶
Query a SNMP OID using Getnext command.
- table(columns)¶
Query SNMP OIDs and format results like a table.
NOT YET IMPLEMENTED.
SSH¶
SSH probe module.
- class monitoring.nagios.probes.secureshell.CommandResult(channel)¶
This class is for manipulating a remote command execution result.
It takes a ssh.Channel object as his first parameter. Then provides the following attributes:
- input¶
This is stdin for the command.
- output¶
This is a list of lines on stdout or output of the command.
- errors¶
This is a list of lines on stderr or all errors for the command.
- status¶
An integer for the command exit code.
- class monitoring.nagios.probes.secureshell.ProbeSSH(hostaddress='', port=22, username=None, password=None, timeout=10.0)¶
A SSH probe.
Parameters: - hostaddress (str) – The host to connect to.
- port (int) – The remote port the remote host listen on.
- username (str) – Login user name. Default is to use the current authenticated user.
- password (str) – Login user password. Default is to use the public key.
- timeout (float) – Connection timeout in seconds (default to 10 secs).
- exception SSHCommandFailed(message)¶
Exception triggered when a SSH command has failed.
- exception ProbeSSH.SSHCommandNotFound(message)¶
Exception triggered when a SSH command is not found.
- exception ProbeSSH.SSHCommandTimeout(message)¶
Exception triggered when a SSH command timed out.
- exception ProbeSSH.SSHError(message)¶
Base class for all SSH related errors.
- ProbeSSH.close()¶
Close the SSH connection.
- ProbeSSH.execute(command, timeout=None)¶
Execute a command on the remote server and return results.
Parameters: - command (str, unicode) – Command line to execute on the remote server.
- timeout (float) – Command execution timeout. Default to 10 secs.
Returns: An instance of CommandResult.
Raises ProbeSSH.SSHCommandTimeout: if executed command timed out.
- ProbeSSH.get_file_lastmodified_minutes(filename, **kwargs)¶
Return minutes since file was last modified.
Parameters: filename – path to the file that should be checked. Returns: Minutes. Return type: int
- ProbeSSH.get_file_lastmodified_timestamp(filename, stime='/usr/local/nagios/bin/stime')¶
Return the last modified Unix Epoch timestamp of a file.
Parameters: - filename – path to the file that should be checked.
- stime – location of the stime binary. Default to /usr/local/nagios/bin/stime.
Returns: Unix timestamp.
Return type: int
- ProbeSSH.list_files(directory='.', glob='*', depth=1)¶
List all files in a directory. Optionnaly, you can specify a regexp to filter files.
Parameters: - directory (str) – Directory to look in. Default is the current working directory.
- glob (str) – Pattern to filter files. Default to ‘*’ all.
- depth (int) – Recursive level for scanning files. Default to disable recursive scanning.
Returns: list(str)
WMI¶
WMI probe module.
- class monitoring.nagios.probes.wmi.ProbeWMI(hostaddress, login, password, domain, namespace='root/cimv2')¶
A WMI probe.
Parameters: - hostaddress (str) – The IP address of host to connect to.
- login (str) – Login name.
- password (str) – Login password.
- domain (str) – Login AD domain.
- namespace (str) – WMI namespace (default is root/cimv2).
- execute(query)¶
Execute a WMI query on the remote server and return results.
Parameters: query (str, unicode) – The WMI query. Returns: CSV with delimiter |.
HTTP¶
HTTP probe module.
- class monitoring.nagios.probes.http.HTTPResponse(response)¶
This class represents the HTTP response from the server.
This is a wrapper arround requests.Response object with extensions like parsing response to others formats.
Check out requests.Response API reference for more details.
- xml()¶
Parse response as XML and make a BeautifulSoup out of it.
Returns: an instance of BeautifulSoup class.
- class monitoring.nagios.probes.http.ProbeHTTP(hostaddress, port=80, ssl=False, auth=None)¶
An HTTP probe doing HTTP GET/POST request from your plugins.
This is basically just a wrapper arround requests library.
- get(path, **kwargs)¶
Send a HTTP GET request. See requests.get() api reference.
Parameters: - path (str, unicode) – the URL location. This is the part after the hostaddress.
- kwargs – optional arguments that requests takes.
Returns: return of requests.get().
- post(path, data, **kwargs)¶
Send a HTTP POST request. See requests.post() api reference.
Parameters: - path (str, unicode) – the URL location. This is the part after the hostaddress.
- data – Dictionary, bytes, or file-like object to send in the body of the Request.
- kwargs – optional arguments that requests takes.
Returns: return of requests.get().
Databases¶
Plugins that interact with a database.
Microsoft SQL Server¶
MSSQL probe module.
- class monitoring.nagios.probes.mssql.ProbeMSSQL(hostaddress, username, password, database=None, query_timeout=30, login_timeout=15)¶
A MS SQL Server probe.
Parameters: - hostaddress (str) – The host to connect to.
- username (str) – Login user name.
- password (str) – Login user password.
- database (str) – Database to connect to, by default selects the database which is set as default for specific user.
- query_timeout (int) – Query timeout in seconds, default is 30 secs.
- login_timeout (int) – Timeout for connection and login in seconds, default is 15 secs.
- close()¶
Close the connection.
- execute(query)¶
Execute a SQL query.
Parameters: query (str) – SQL query. Returns: pymssql.Cursor