3 `@sHddlZddlZddlZddlZGdddejZedkrDejdS)Nc@seZdZdZddZdS)Pluginhaproxyc#CsNt}t}y$|jdd}|jdd}||f}Wnd}YnXtj|jdd|d}tj|d<|j}|jdkr|jjd } n d j|jSd@} dA} t j | } t} t t g}x| D]v}i||d=d>|d?<i| |d=d>|d?<y$|d||d=d>|d?d<Wn.t k r@i||d=d>|d?<YnXx|jD]\}}x2|D]*}y ||}Wntk rYnXqZW|| kr|||d=d>|d?|<nx|| krLt|t k rL|j|t |||d=d>|d?||d=d>|d?|<t || |d=d>|d?|<nqLWqWtj| d<|j| |S)BNrusernamepasswordFZstatus_page_url)Zauthts z&Could not load haproxy status page: {}qcurqmaxscursmaxslimstotweightqlimitthrottlelbtottrackedraterate_limrate_maxhanafailreq_rate req_rate_maxreq_tot conn_rate conn_rate_maxconn_totbinboutcli_abrtsrv_abrt interceptedhrsp_1xxhrsp_2xxhrsp_3xxhrsp_4xx check_rise check_fall check_health agent_rise agent_fallhrsp_5xxcomp_incomp_outcomp_bypcomp_rsp hrsp_otherdcondreqdrespereqeconerespwretrwredisdsesz# pxname/Zsvname)r r r r r rrrrrrrrrrrrrrrr)rrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:)dictgetrequeststimeZget_agent_cacheZ status_codetextsplitformatcsvZ DictReaderstrfloatKeyErroritems ValueErrortypeZabsolute_to_per_secondZset_agent_cache)selfconfigresultsZ next_cacherrZ user_passZrequestZ prev_cacheresponseZ non_deltadeltaZ csv_readerdataZ constructorsrowkvcrTG/usr/local/lib/python3.6/site-packages/nixstatsagent/plugins/haproxy.pyrun s         $    >"   z Plugin.runN)__name__ __module__ __qualname__rVrTrTrTrUr sr__main__)r?ZpluginsrCr>Z BasePluginrrWexecuterTrTrTrUs