api¶
numeter¶
numeter.queue.client¶
-
class
numeter.queue.client.
BaseAPIClient
(transport)¶ Bases:
oslo_messaging.rpc.client.RPCClient
-
__init__
(transport)¶
-
__module__
= 'numeter.queue.client'¶
-
ping
(context, topic, args=None)¶
-
poller_msg
(context, topic, args=None)¶
-
-
numeter.queue.client.
get_rpc_client
(hosts=[], password='guest')¶
numeter.queue¶
numeter.queue.server¶
-
class
numeter.queue.server.
OverrideMessageHandlingServer
(transport, dispatcher, executor='blocking')¶ Bases:
oslo_messaging.server.MessageHandlingServer
override MessageHandlingServer to bind multiple topics
-
__module__
= 'numeter.queue.server'¶
-
start
()¶
-
-
class
numeter.queue.server.
Targets
(targets)¶ Bases:
oslo_messaging.target.Target
Target objects with additionnal targets
-
__init__
(targets)¶
-
__module__
= 'numeter.queue.server'¶
-
-
numeter.queue.server.
_get_rpc_server
(transport, target, endpoints, executor='blocking', serializer=None)¶
-
numeter.queue.server.
get_rpc_server
(topics, server, hosts, endpoints, password='guest')¶
numeter.redis¶
-
class
numeter.redis.
RedisConnect
(host='127.0.0.1', port=6379, socket_timeout=2, password=None, db=0)¶ Bases:
object
Frontend redis avec try sur les get
-
__dict__
= dict_proxy({'redis_hmset': <function redis_hmset at 0x7f476e35f578>, '__module__': 'numeter.redis', 'redis_hmget': <function redis_hmget at 0x7f476e35f5f0>, 'redis_zadd': <function redis_zadd at 0x7f476e35f398>, 'redis_keys': <function redis_keys at 0x7f476e35f2a8>, 'redis_hget': <function redis_hget at 0x7f476e35f668>, 'redis_set': <function redis_set at 0x7f476e35f1b8>, '__dict__': <attribute '__dict__' of 'RedisConnect' objects>, 'redis_hexists': <function redis_hexists at 0x7f476e35f6e0>, '__weakref__': <attribute '__weakref__' of 'RedisConnect' objects>, '__init__': <function __init__ at 0x7f476e360f50>, 'redis_zremrangebyscore': <function redis_zremrangebyscore at 0x7f476e35f488>, 'redis_hkeys': <function redis_hkeys at 0x7f476e35f7d0>, 'redis_hgetall': <function redis_hgetall at 0x7f476e35f8c0>, 'redis_hdel': <function redis_hdel at 0x7f476e35f758>, 'redis_info': <function redis_info at 0x7f476e35f320>, 'redis_hlen': <function redis_hlen at 0x7f476e35f140>, 'redis_zcount': <function redis_zcount at 0x7f476e35f0c8>, 'redis_get': <function redis_get at 0x7f476e35f230>, 'redis_zrangebyscore': <function redis_zrangebyscore at 0x7f476e35f410>, 'redis_hvals': <function redis_hvals at 0x7f476e35f848>, 'redis_hset': <function redis_hset at 0x7f476e35f500>, 'redis_connect': <function redis_connect at 0x7f476e35f050>, '__doc__': 'Frontend redis avec try sur les get'})¶
-
__init__
(host='127.0.0.1', port=6379, socket_timeout=2, password=None, db=0)¶
-
__module__
= 'numeter.redis'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
redis_connect
()¶
-
redis_get
(key)¶
-
redis_hdel
(name, key)¶
-
redis_hexists
(name, key)¶
-
redis_hget
(name, key)¶
-
redis_hgetall
(name)¶
-
redis_hkeys
(name)¶
-
redis_hlen
(name)¶
-
redis_hmget
(name, key)¶
-
redis_hmset
(name, mapping)¶
-
redis_hset
(name, key, value)¶
-
redis_hvals
(name)¶
-
redis_info
()¶
-
redis_keys
(key)¶
-
redis_set
(key, value)¶
-
redis_zadd
(name, value, score)¶
-
redis_zcount
(name, valmin, valmax)¶
-
redis_zrangebyscore
(name, valmin, valmax, start=None, num=None)¶
-
redis_zremrangebyscore
(name, valmin, valmax)¶
-
numeter.storage.numeter_storage_endpoints¶
-
class
numeter.storage.numeter_storage_endpoints.
StorageEndpoint
(storage)¶ Bases:
object
-
__dict__
= dict_proxy({'__module__': 'numeter.storage.numeter_storage_endpoints', 'poller_msg': <function poller_msg at 0x7f476e2a49b0>, '__dict__': <attribute '__dict__' of 'StorageEndpoint' objects>, '__weakref__': <attribute '__weakref__' of 'StorageEndpoint' objects>, '_call_write_data': <function _call_write_data at 0x7f476e2a4a28>, 'ping': <function ping at 0x7f476e35f9b0>, '_call_write_info': <function _call_write_info at 0x7f476e2a4aa0>, '__init__': <function __init__ at 0x7f476e72c578>, '__doc__': None})¶
-
__init__
(storage)¶
-
__module__
= 'numeter.storage.numeter_storage_endpoints'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_call_write_data
(ctxt, args)¶
-
_call_write_info
(ctxt, args)¶
-
ping
(ctxt, args)¶
-
poller_msg
(ctxt, args)¶
-
numeter.storage¶
numeter.storage.numeter_storage¶
-
class
numeter.storage.numeter_storage.
Storage
(configFile='/etc/numeter_storage.cfg')¶ Bases:
object
-
__dict__
= dict_proxy({'__module__': 'numeter.storage.numeter_storage', '_get_host_list': <function _get_host_list at 0x7f476e344aa0>, 'jsonToPython': <function jsonToPython at 0x7f476e344b90>, 'redisStartConnexion': <function redisStartConnexion at 0x7f476e3449b0>, 'readConf': <function readConf at 0x7f476e344f50>, '_write_data': <function _write_data at 0x7f476e344c80>, 'cleanInfo': <function cleanInfo at 0x7f476e344de8>, 'cleanOldWSP': <function cleanOldWSP at 0x7f476e344ed8>, '__dict__': <attribute '__dict__' of 'Storage' objects>, '__weakref__': <attribute '__weakref__' of 'Storage' objects>, '__init__': <function __init__ at 0x7f476e3448c0>, 'pythonToJson': <function pythonToJson at 0x7f476e344c08>, '_write_info': <function _write_info at 0x7f476e344d70>, '_get_hostIDHash': <function _get_hostIDHash at 0x7f476e344cf8>, 'startStorage': <function startStorage at 0x7f476e344938>, 'getgloballog': <function getgloballog at 0x7f476e344a28>, 'paramsVerification': <function paramsVerification at 0x7f476e344b18>, 'cleanHosts': <function cleanHosts at 0x7f476e344e60>, '__doc__': None})¶
-
__init__
(configFile='/etc/numeter_storage.cfg')¶
-
__module__
= 'numeter.storage.numeter_storage'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_get_hostIDHash
(hostID)¶ Get cached hostID hash or add in cache
-
_get_host_list
()¶ Get host list
-
_write_data
(hostID, plugin, data_json)¶
-
_write_info
(hostID, info_json)¶
-
cleanHosts
(writedHosts)¶ Clean info in redis and wsp
-
cleanInfo
(writedInfos, hostID)¶ Clean info in redis and wsp
-
cleanOldWSP
()¶ Clean old wsps
-
getgloballog
()¶ Init du logger (fichier et stdr)
-
jsonToPython
(data)¶ Convert json to python
-
paramsVerification
()¶ Args verification
-
pythonToJson
(data)¶ Convert python to json
-
readConf
()¶ Read configuration file
-
redisStartConnexion
()¶
-
startStorage
()¶ Start storage
-
numeter.poller¶
numeter.poller.munin_connect¶
-
class
numeter.poller.munin_connect.
MuninConnection
(munin_host='127.0.0.1', munin_port=4949)¶ Bases:
object
Read lines from
MuninSock
. Provide also basic munin-node commandes :- Config
- Fetch
- List
- Nodes
-
__dict__
= dict_proxy({'__module__': 'numeter.poller.munin_connect', '_iterline': <function _iterline at 0x7f476e28a848>, '__weakref__': <attribute '__weakref__' of 'MuninConnection' objects>, 'munin_list': <function munin_list at 0x7f476e28a938>, 'munin_nodes': <function munin_nodes at 0x7f476e28a9b0>, 'munin_config': <function munin_config at 0x7f476e28aa28>, '__dict__': <attribute '__dict__' of 'MuninConnection' objects>, 'munin_fetch': <function munin_fetch at 0x7f476e28a8c0>, '_readline': <function _readline at 0x7f476e28a7d0>, '__doc__': 'Read lines from ``MuninSock``. Provide also basic munin-node commandes :\n\n * Config\n * Fetch\n * List\n * Nodes', '__init__': <function __init__ at 0x7f476e28a758>})¶
-
__init__
(munin_host='127.0.0.1', munin_port=4949)¶
-
__module__
= 'numeter.poller.munin_connect'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_iterline
()¶
-
_readline
()¶
-
munin_config
(key)¶
-
munin_fetch
(key)¶
-
munin_list
()¶
-
munin_nodes
()¶
-
class
numeter.poller.munin_connect.
MuninSock
(host, port)¶ Bases:
object
Open and close a socket with munin-node socket. This class allow you to use
with
statement (for python < 3).with MuninSock(self.munin_host, self.munin_port) as sock: ...
-
__dict__
= dict_proxy({'__module__': 'numeter.poller.munin_connect', '__exit__': <function __exit__ at 0x7f476e28a6e0>, '__enter__': <function __enter__ at 0x7f476e28a668>, '__dict__': <attribute '__dict__' of 'MuninSock' objects>, '__weakref__': <attribute '__weakref__' of 'MuninSock' objects>, '__doc__': 'Open and close a socket with munin-node socket. This class allow you\n to use ``with`` statement (for python < 3).\n\n ::\n\n with MuninSock(self.munin_host, self.munin_port) as sock:\n ...', '__init__': <function __init__ at 0x7f476e28a5f0>})¶
-
__enter__
()¶ Open socket with munin-node
-
__exit__
(type, value, traceback)¶ Close socket with munin-node
-
__init__
(host, port)¶ host
: munin-node hostport
: munin-node port
-
__module__
= 'numeter.poller.munin_connect'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
numeter.poller.storeandforward¶
-
class
numeter.poller.storeandforward.
StoreAndForward
(cache_file='/dev/shm/store_and_forward.json', logger='numeter.poller.storeandforward')¶ Bases:
object
Use case exemple :
Init logging level with debug stream handler:
logging.getLogger('StoreAndForward').setLevel(logging.INFO) logging.getLogger('StoreAndForward').addHandler(logging.StreamHandler()) from time import time with StoreAndForward(cache_file='./sandbox/cache_storeandforward.json') as cache : # Add stored message cache.add_message('DATA', 'munin.if_eth0.up', '{%s content}' % time()) Read stored message for message in cache.consume(): print message
-
__dict__
= dict_proxy({'__module__': 'numeter.poller.storeandforward', '_load_cache': <function _load_cache at 0x7f476deefaa0>, '__exit__': <function __exit__ at 0x7f476deef9b0>, '_dump_cache': <function _dump_cache at 0x7f476deefb18>, 'add_message': <function add_message at 0x7f476deefa28>, '__enter__': <function __enter__ at 0x7f476deef938>, '__dict__': <attribute '__dict__' of 'StoreAndForward' objects>, '__weakref__': <attribute '__weakref__' of 'StoreAndForward' objects>, '__doc__': "\n Use case exemple :\n\n Init logging level with debug stream handler::\n\n logging.getLogger('StoreAndForward').setLevel(logging.INFO)\n logging.getLogger('StoreAndForward').addHandler(logging.StreamHandler())\n\n from time import time\n\n with StoreAndForward(cache_file='./sandbox/cache_storeandforward.json') as cache :\n\n # Add stored message\n cache.add_message('DATA', 'munin.if_eth0.up', '{%s content}' % time())\n\n Read stored message\n for message in cache.consume():\n print message\n ", '__init__': <function __init__ at 0x7f476deef8c0>, 'consume': <function consume at 0x7f476deefb90>})¶
-
__enter__
()¶
-
__exit__
(type, value, traceback)¶
-
__init__
(cache_file='/dev/shm/store_and_forward.json', logger='numeter.poller.storeandforward')¶
-
__module__
= 'numeter.poller.storeandforward'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_dump_cache
()¶
-
_load_cache
()¶
-
add_message
(msgType, plugin, msgContent)¶
-
consume
()¶
-
numeter.poller.muninModule¶
-
class
numeter.poller.muninModule.
MuninModule
(configParser=None)¶ Bases:
numeter.poller.modulesGeneric.ModulesGeneric
This poller module fetch configs and datas from a munin-node daemon.
Configuration section for this module :
[MuninModule] plugins_enable = ^.*$ ; Regexp matching plugins to fetch munin_host = 127.0.0.1 ; Munin Host munin_port = 4949 ; Munin Port
-
__init__
(configParser=None)¶ When numeter load a module, the only one parameter is the config parser. It’s allow you to add section in numeter config file for your own module.
-
__module__
= 'numeter.poller.muninModule'¶
-
formatFetchData
(plugin)¶ Execute a
munin fetch
for a given plugin name. Get the result and format the raw result forgetData
:data = { 'TimeStamp': nowTimestamp, 'Plugin': plugin, 'Values': pluginData }
-
formatFetchInfo
(plugin)¶ Execute a
munin config
for a given plugin name. Get the result and format the raw result forgetInfo
:infos = { 'Plugin': plugin, 'Base': '1000', 'Describ': '', 'Title': plugin, 'Vlabel': '', 'Order': '', 'Infos': {} }
-
getData
()¶ get and return all datas collected from munin-node. See modulesGeneric return format
For each plugin matching
plugins_enable
regex in the config file, launchformatFetchData
and append result togetData
output
-
getInfo
()¶ get and return all infos collected from munin-node. See modulesGeneric return format
For each plugin matching
plugins_enable
regex in the config file, launchformatFetchInfo
and append result togetInfo
output
-
getParserConfig
()¶ Read MuninModule from configParser
-
numeter.poller.cachelastvalue¶
-
class
numeter.poller.cachelastvalue.
CacheLastValue
(cache_file='/dev/shm/cache_last_value.json', logger='numeter.poller.cachelastvalue')¶ Bases:
object
-
__dict__
= dict_proxy({'__module__': 'numeter.poller.cachelastvalue', '_load_cache': <function _load_cache at 0x7f476deef668>, '__exit__': <function __exit__ at 0x7f476deef5f0>, '_dump_cache': <function _dump_cache at 0x7f476deef6e0>, '__enter__': <function __enter__ at 0x7f476deef578>, 'get_value': <function get_value at 0x7f476deef7d0>, 'save_value': <function save_value at 0x7f476deef758>, '__dict__': <attribute '__dict__' of 'CacheLastValue' objects>, '__weakref__': <attribute '__weakref__' of 'CacheLastValue' objects>, '__doc__': None, '__init__': <function __init__ at 0x7f476deef500>})¶
-
__enter__
()¶
-
__exit__
(type, value, traceback)¶
-
__init__
(cache_file='/dev/shm/cache_last_value.json', logger='numeter.poller.cachelastvalue')¶
-
__module__
= 'numeter.poller.cachelastvalue'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_dump_cache
()¶
-
_load_cache
()¶
-
get_value
(key)¶
-
save_value
(key, timestamp, value)¶
-
numeter.poller.numeter_poller¶
-
class
numeter.poller.numeter_poller.
Poller
(configFile='/etc/numeter_poller.cfg')¶ Bases:
object
-
__dict__
= dict_proxy({'__module__': 'numeter.poller.numeter_poller', 'getMyInfo': <function getMyInfo at 0x7f476e28a050>, '_store_and_forward_sendMsg': <function _store_and_forward_sendMsg at 0x7f476deefd70>, '__dict__': <attribute '__dict__' of 'Poller' objects>, '_sendMsg': <function _sendMsg at 0x7f476deefde8>, '_sendData': <function _sendData at 0x7f476deefcf8>, 'loadModules': <function loadModules at 0x7f476deeff50>, 'getgloballog': <function getgloballog at 0x7f476e28a0c8>, 'readConf': <function readConf at 0x7f476e28a1b8>, 'convertToJson': <function convertToJson at 0x7f476deefc80>, 'writeInSimulateFile': <function writeInSimulateFile at 0x7f476deefed8>, 'pollerTimeToGo': <function pollerTimeToGo at 0x7f476e28a140>, '_sendInfo': <function _sendInfo at 0x7f476deefe60>, '__weakref__': <attribute '__weakref__' of 'Poller' objects>, '__doc__': None, '__init__': <function __init__ at 0x7f476deef488>, 'startPoller': <function startPoller at 0x7f476deefc08>})¶
-
__init__
(configFile='/etc/numeter_poller.cfg')¶
-
__module__
= 'numeter.poller.numeter_poller'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_sendData
(allDatas)¶ Send data in rpc
-
_sendInfo
(allInfos)¶ Send info in rpc
-
_sendMsg
(msgType, plugin, msgContent)¶
-
_store_and_forward_sendMsg
(msgType, plugin, msgContent)¶
-
convertToJson
(data)¶ Convert data to json
-
getMyInfo
()¶ Read my infos in conf file
-
getgloballog
()¶ Init logger (file and stdr)
-
loadModules
()¶ Get and write data / infos of all modules
-
pollerTimeToGo
()¶ LAST + poller_time <= NOW calcule aussi le refresh time
-
readConf
()¶ Read configuration file
-
startPoller
()¶ Start the poller
-
writeInSimulateFile
(message)¶ Write in simulate file
-
numeter.poller.modulesGeneric¶
-
class
numeter.poller.modulesGeneric.
ModulesGeneric
(configParser=None)¶ Bases:
object
Module generic is the skeleton to build your own numeter module. If you want to write your own numeter module, you can take this class and build your own with it.
-
__dict__
= dict_proxy({'__module__': 'numeter.poller.modulesGeneric', 'getInfo': <function getInfo at 0x7f476e28a320>, '__dict__': <attribute '__dict__' of 'ModulesGeneric' objects>, 'getData': <function getData at 0x7f476e28a398>, '__weakref__': <attribute '__weakref__' of 'ModulesGeneric' objects>, '__doc__': 'Module generic is the skeleton to build your own numeter module.\n If you want to write your own numeter module, you can take this\n class and build your own with it.\n ', '__init__': <function __init__ at 0x7f476e28a2a8>})¶
-
__init__
(configParser=None)¶ When numeter load a module, the only one parameter is the config parser. It’s allow you to add section in numeter config file for your own module.
-
__module__
= 'numeter.poller.modulesGeneric'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
getData
()¶ Get and return all collected datas. The output must be formated like that :
data= [{ 'TimeStamp': 1410907894, 'Plugin': 'if', 'Values': { 'up' : 40, 'down' : 15, } }]
-
getInfo
()¶ Return for all datas you have collected. The output must be formated like that :
infos= [{ 'Plugin': 'if', 'Base': '1000', 'Describ': '', 'Title': 'if eth0', 'Vlabel': '', 'Order': '', 'Infos': { "down":{"type": "COUNTER", "id": "down", "label": "received"}, "up":{"type": "COUNTER", "id": "up", "label": "upload"}, } }]
Warning
Each DataSource (each datas) you define in getData must have at least an entry in getInfo return like
"id":{"id": "up"}
-