Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.6/site-packages/agent360/plugins/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.6/site-packages/agent360/plugins/__pycache__/mongodb.cpython-36.pyc

3

�uGh��@sDddlZddlZddlmZGdd�dej�Zedkr@e�j�dS)�N)�MongoClientc@seZdZdZdd�ZdS)�Plugin�mongodbc#Cs�t|jdd��}|j}|jd�}|j�}i}i}y4|dddkrFdnd|d	<t|dd
�|d<WnYnXy�|dd
|d<|dd|d<|dd|d<|dd|d<|dd|d<|dd|d<|dd|d<|dd|d<|dd|d<WnYnX|dd |d!<|dd"|d#<|dd$|d%<|d&d'|d(<|d&d)|d*<|d&d+|d,<|d&d-|d.<|d&d/|d0<|d&d1|d2<|d3d4d5|d6<|d3d4d7|d8<|d3d9d5|d:<|d3d9d7|d;<|d3d<d5|d=<|d3d<d7|d><|d?d@dA|dB<|d?d@dC|dD<|d?d@dE|dF<|d?dGdA|dH<|d?dGdC|dI<|d?dGdE|dJ<|dKdL|dM<|dKdN|dO<|dKdP|dQ<|dKdR|dS<|dKdT|dU<yfx`|dVj�D]P\}}	xD|	j�D]8\}
}x,|j�D] \}}
|
|dWj|j�|
|�<�qW�qW�q�WWnYnXyd|dXd'|dY<|dXd)|dZ<|dXd+|d[<|dXd-|d\<|dXd/|d]<|dXd1|d^<Wnt	k
�r�YnXx(|j�D]\}}	|j
||	|�||<�q�Wy@|d6|d8|d_<|d=|d>|d`<|d:|d;|da<WnYnX|}tj�|db<|j|�|dcdd|de<|dcdf|dg<|dcdh|di<|dcdjdk�r�dnd|dk<|S)lz$
        Mongodb monitoring
        rZconnection_stringZserverStatus�replZismasterFr�Z	isprimary�hosts�membersZtransactionsZretriedCommandsCountz!transactions-retriedCommandsCountZretriedStatementsCountz#transactions-retriedStatementsCountZ transactionsCollectionWriteCountz-transactions-transactionsCollectionWriteCountZtotalAbortedztransactions-totalAbortedZtotalCommittedztransactions-totalCommittedZtotalStartedztransactions-totalStartedZ
currentActiveztransactions-currentActiveZcurrentInactiveztransactions-currentInactiveZcurrentOpenztransactions-currentOpen�connectionsZtotalCreatedzconnections.totalCreated�	availablezconnections.available�currentzconnections.currentZ
opcounters�commandzopcounters.command�deletezopcounters.deleteZgetmorezopcounters.getmore�insertzopcounters.insert�queryzopcounters.query�updatezopcounters.updateZopLatencies�commandsZlatencyzopLatencies.commands.latency�opszopLatencies.commands.opsZreadszopLatencies.reads.latencyzopLatencies.reads.opsZwriteszopLatencies.writes.latencyzopLatencies.writes.opsZ
globalLockZcurrentQueue�totalzglobalLock.currentQueue.totalZreaderszglobalLock.currentQueue.readersZwriterszglobalLock.currentQueue.writersZ
activeClientszglobalLock.activeClients.totalz globalLock.activeClients.readersz globalLock.activeClients.writersZasserts�msgzasserts.msgZregularzasserts.regularZ	rolloverszasserts.rollovers�userzasserts.user�warningzasserts.warningZlockszlocks-{}-{}-{}ZopcountersReplzopcountersRepl.commandzopcountersRepl.deletezopcountersRepl.getmorezopcountersRepl.insertzopcountersRepl.queryzopcountersRepl.updatezopLatencies.commandszopLatencies.writeszopLatencies.reads�tsZmemZresidentzmem.resident�bitszmem.bitsZvirtualzmem.virtual�	supportedz
mem.supported)
r�getZadminrZget_agent_cache�len�items�format�lower�KeyErrorZabsolute_to_per_second�timeZset_agent_cache)�self�config�client�dbZ
statisticsZ
prev_cache�data�results�key�val�key2Zval2Zkey3Zval3Z
next_cache�r*�A/root/tmp/pip-build-gzoz1_uw/agent360/agent360/plugins/mongodb.py�run
s�
,
z
Plugin.runN)�__name__�
__module__�__qualname__r,r*r*r*r+rsr�__main__)r ZpluginsZpymongorZ
BasePluginrr-�executer*r*r*r+�<module>s
k

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists