HEX
Server: LiteSpeed
System: Linux baran.dnsprotection.me 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: ddir12 (3618)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/glances/exports/__pycache__/glances_couchdb.cpython-36.pyc
3

Eo�ca�@sTdZddlZddlmZddlmZddlmZddlZddlZGdd�de�Z	dS)zCouchDB interface class.�N)�datetime)�logger)�
GlancesExportcs:eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Z�ZS)�Exportz-This class manages the CouchDB export module.Ncs`tt|�j||d�d|_d|_d|_|jddddgddgd	�|_|jsRtj	d
�|j
�|_dS)zInit the CouchDB export IF.)�config�argsN�couchdb�host�port�db�user�password)ZmandatoriesZoptions�)�superr�__init__rrr
Z	load_conf�
export_enable�sys�exit�init�client)�selfrr)�	__class__��%/usr/lib/python3.6/glances_couchdb.pyrs
zExport.__init__cCs�|js
dS|jdkr&dj|j|j�}ndj|j|j|j|j�}ytj|�}Wn>tk
r�}z"t	j
d||f�tjd�WYdd}~XnXt	j
d�y||jWn tk
r�|j|j�YnXt	j
d|j�|S)z*Init the connection to the CouchDB server.Nz
http://{}:{}/zhttps://{}:{}@{}:{}/z(Cannot connect to CouchDB server %s (%s)rzConnected to the CouchDB serverzThere is already a %s database)rr�formatr	r
r
rZServer�	ExceptionrZcriticalrr�inforZcreate)rZ
server_uri�s�errrr-s"

zExport.initcCs|j|jS)z"Return the CouchDB database object)rr)rrrr�databaseLszExport.databasecCs�tjdj|��tt||��}||d<tjj�jt	j
��|d<y|j|jj
|�Wn4tk
r�}ztjdj||��WYdd}~XnXdS)z'Write the points to the CouchDB server.zExport {} stats to CouchDB�typeZtimez&Cannot export {} stats to CouchDB ({})N)r�debugr�dict�zipr�mappingZ
DateTimeFieldZ_to_jsonrZnowrrZsaver�error)r�name�columnsZpoints�datarrrr�exportPsz
Export.export)NN)	�__name__�
__module__�__qualname__�__doc__rrrr)�
__classcell__rr)rrrs
r)
r-rrZglances.loggerrZglances.exports.glances_exportrrZcouchdb.mappingrrrrr�<module>
s