SNMP Booster Developer Reference¶
SNMP Booster root class¶
This module contains the SnmpBoosterArbiter class which is the part of SNMP Booster loaded in the Arbiter
SNMP Booster classes¶
This module contains the SnmpBoosterArbiter class which is the part of SNMP Booster loaded in the Arbiter
-
class
module.snmpbooster_arbiter.
SnmpBoosterArbiter
(mod_conf)[source]¶ Bases:
module.snmpbooster.SnmpBooster
SNMP Poller module class Improve SNMP checks
This module contains the SnmpBoosterScheduler class which is the part of SNMP Booster loaded in the Scheduler
-
class
module.snmpbooster_scheduler.
SnmpBoosterScheduler
(mod_conf)[source]¶ Bases:
module.snmpbooster.SnmpBooster
SNMP Poller module class Improve SNMP checks
This module contains the SnmpBoosterPoller class which is the part of SNMP Booster loaded in the Poller
-
class
module.snmpbooster_poller.
SnmpBoosterPoller
(mod_conf)[source]¶ Bases:
module.snmpbooster.SnmpBooster
SNMP Poller module class Improve SNMP checks
-
get_new_checks
()[source]¶ Get new checks if less than nb_checks_max If no new checks got and no check in queue, sleep for 1 sec REF: doc/shinken-action-queues.png (3)
-
launch_new_checks
()[source]¶ Launch checks that are in status REF: doc/shinken-action-queues.png (4)
-
SNMP Booster libs¶
This module contains two functions: * check_cache: Get data from cache * check_snmp: Get data from SNMP request
-
module.libs.checks.
check_snmp
(check, arguments, db_client, task_queue, result_queue)[source]¶ Prepare snmp requests
This module contains database/cache abstraction class
-
class
module.libs.dbclient.
DBClient
(db_host, db_port, db_name)[source]¶ Bases:
object
Class used to abstract the use of the database/cache
-
get_service
(host, service)[source]¶ This function gets one service from the database Return :query_result: dict
-
get_services
(host, check_interval)[source]¶ This function Gets all services with the same host and check_interval Return :query_result: list of dicts
-
This module contains a set of functions to format the plugin output which is shown on the UI
-
module.libs.output.
prepare_format
(value, ds_data)[source]¶ Prepare a dict to put in string formatting
This module contains a function to retrieve output and compute trigger
-
module.libs.result.
set_output_and_status
(check_result)[source]¶ get output, compute exit_code an return it
This module contains a class to create a Thread which make SNMP requests and handle answers with callbacks
-
class
module.libs.snmpworker.
SNMPWorker
(mapping_queue, max_prepared_tasks)[source]¶ Bases:
threading.Thread
Thread which execute all SNMP tasks/requests
-
run
()[source]¶ Process SNMP tasks SNMP task is a dict: - For a bulk request
{"authData": cmdgen.CommunityData('public') "transportTarget": cmdgen.UdpTransportTarget((transportTarget, 161)) "nonRepeaters": 0 "maxRepetitions": 64 "varNames": ['1.3.6.1.2.1.2.2.1.2.0', '...'] "cbInfo:: (cbFun, (arg1, arg2, ...)) }
For a next request
{"authData": cmdgen.CommunityData('public') "transportTarget": cmdgen.UdpTransportTarget((transportTarget, 161)) "varNames": ['1.3.6.1.2.1.2.2.1.2.0', '...'] "cbInfo:: (cbFun, (arg1, arg2, ...)) }
For a get request
{"authData": cmdgen.CommunityData('public) "transportTarget": cmdgen.UdpTransportTarget((transportTarget, 161)) "varNames": ['1.3.6.1.2.1.2.2.1.2.0', '...'] "cbInfo:: (cbFun, (arg1, arg2, ...)) }
-
-
module.libs.snmpworker.
callback_get
(send_request_handle, error_indication, error_status, error_index, var_binds, cb_ctx)[source]¶ Callback function for GET SNMP requests
-
module.libs.snmpworker.
callback_mapping_bulk
(send_request_handle, error_indication, error_status, error_index, var_binds, cb_ctx)[source]¶ Callback function for BULK SNMP requests
-
module.libs.snmpworker.
callback_mapping_next
(send_request_handle, error_indication, error_status, error_index, var_binds, cb_ctx)[source]¶ Callback function for GENEXT SNMP requests
-
module.libs.snmpworker.
handle_snmp_error
(error_indication, cb_ctx, request_type)[source]¶ Handle SNMP errors
This module contains the function which compute triggers and return the exit code of a service
-
module.libs.trigger.
get_trigger_result
(service)[source]¶ Get return code from trigger calculator return error_message, exit_code :error_message: is None if there no error :exit_code: 0, 1, 2 or 3
Usefull functions used everywhere in snmp booster
-
module.libs.utils.
calculation
(value, ds_calc)[source]¶ Get result from calc
>>> calculation(1, [2, "add"]) 3.0
-
module.libs.utils.
compute_value
(result)[source]¶ Get a computed value from raw_value, ds_type and calculation result argument must have this form
{'value_last': u'0', 'calc': None, 'check_time': 1410456115.376102, 'key': {'host': u'myhost1', 'ds_names': [u'ifOutErrors'], 'service': u'if.lo', 'oid_type': 'ds_oid'}, 'check_time_last': 1410456100.722268, 'value_last_computed': u'0', 'type': u'TEXT', 'value': Counter32(0), }
>>> data = {} >>> data['value_last'] = u'0' >>> data['calc'] = None >>> data['check_time'] = 1410456115.376102 >>> data['key'] = {} >>> data['key']['host'] = u'myhost1' >>> data['key']['ds_names'] = [u'ifOutErrors'] >>> data['key']['service'] = u'if.lo' >>> data['key']['oid_type'] = 'ds_oid' >>> data['check_time_last'] = 1410456100.722268 >>> data['value_last_computed'] = u'Text collected from SNMP' >>> data['type'] = u'TEXT' >>> data['value'] = "Text collected from SNMP" >>> compute_value(data) 'Text collected from SNMP'
-
module.libs.utils.
derive
(value, value_last, check_time, check_time_last, limit=4294967295)[source]¶ Get a derive
>>> derive(20, 10, 1412776670, 1412776660) 1.0 >>> derive(15, 4294967290, 1412776670, 1412776660) 2.0 >>> derive(20, 2**64 - 11, 1412776670, 1412776660, 2**64 - 1) 3.0
-
module.libs.utils.
dict_serialize
(serv, mac_resol, datasource)[source]¶ Get serv, datasource And return the service serialized
-
module.libs.utils.
flatten_dict
(tree_dict)[source]¶ Convert unlimited tree dictionnary to a flat dictionnary
>>> flatten_dict({'a': 1, 'b': {'c': {'d': 2, 'e': 4}}}) {'a': 1, 'b.c.d': 2, 'b.c.e': 4} >>> flatten_dict("bad_input")
-
module.libs.utils.
format_counter_value
(result, limit=4294967295)[source]¶ Format value for counter type
-
module.libs.utils.
format_derive_value
(result, limit=4294967295)[source]¶ Format value for derive type