3 `= @syddlmZmZWn$ek r8ddlmZmZYnXddlZddlZddlZddlZGdddejZ e dkr~e j dS))urlopenRequestNc@seZdZdZddZdS)PluginZpowerdnsc 7Cstj|jtddd|jtdid}d}t}d}t}|j}|jtdr^t|jtd}|jtd rtj|||jtd d }n4|jtd rtj|||jtd d }ntj||d }t j |d<yt j |j }Wnt k rdSXdO} dP} t} x|D]} dK| krdL| krdM| kr| dMdNkr| dK| krv|j| dKt| dL||| dK<t| dL| | dK<n"| dK| krt| dL|| dK<qWt j | d<|j| |S)Qa Experimental plugin for PowerDNS authoritative server. Might also work with PowerDNS recursor, but it may need extra delta_keys / absolute_keys. Add to /etc/nixstats.ini: [powerdns] enabled=yes statistics_url=http://localhost:8081/api/v1/servers/localhost/statistics api_key=changeme ;ca_file= ;ca_path= ;timeout=10 Zstatistics_urlz X-API-Keyz%sZapi_key)headers NtimeoutZca_file)rZcafileZca_path)rZcapath)rtsFcorrupt-packetsdeferred-cache-insertsdeferred-cache-lookupdeferred-packetcache-insertsdeferred-packetcache-lookupdnsupdate-answersdnsupdate-changesdnsupdate-queriesdnsupdate-refusedincoming-notificationsoverload-dropspacketcache-hitpacketcache-missquery-cache-hitquery-cache-miss rd-queriesrecursing-answersrecursing-questionsrecursion-unansweredservfail-packets signaturessys-msec tcp-answerstcp-answers-bytes tcp-queries tcp4-answerstcp4-answers-bytes tcp4-queries tcp6-answerstcp6-answers-bytes tcp6-queriestimedout-packets udp-answersudp-answers-bytesudp-do-queries udp-in-errorsudp-noport-errors udp-queriesudp-recvbuf-errorsudp-sndbuf-errors udp4-answersudp4-answers-bytes udp4-queries udp6-answersudp6-answers-bytes udp6-queries user-mseckey-cache-sizelatencyfd-usagemeta-cache-sizeopen-tcp-connectionspacketcache-sizeqsize-qquery-cache-sizereal-memory-usagesecurity-statussignature-cache-sizeuptimenamevaluetypeZ StatisticItem)/r r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7) r8r9r:r;r<r=r>r?r@rArBrC)urllib2rget__name__dictZget_agent_cache has_optionintrtimejsonloadsread ExceptionZabsolute_to_per_secondfloatZset_agent_cache) selfconfigZrequestrresultsZ raw_responseZ next_cacheZ prev_cacheZstatsZ delta_keysZ absolute_keysdatastatrXH/usr/local/lib/python3.6/site-packages/nixstatsagent/plugins/powerdns.pyruns&     "  z Plugin.runN)rI __module__ __qualname__rZrXrXrXrYr sr__main__) Zurllib.requestrr ImportErrorrGrMZpluginsrNZ BasePluginrrIexecuterXrXrXrYsy