Page Menu
Home
VyOS Platform
Search
Configure Global Search
Log In
Files
F118309868
dns_forwarding_statistics.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
768 B
Referenced Files
None
Subscribers
None
dns_forwarding_statistics.py
View Options
#!/usr/bin/env python3
import
jinja2
from
sys
import
exit
from
vyos.config
import
Config
from
vyos.utils.process
import
cmd
PDNS_CMD
=
'/usr/bin/rec_control --socket-dir=/run/powerdns'
OUT_TMPL_SRC
=
"""
DNS forwarding statistics:
Cache entries: {{ cache_entries }}
Cache size: {{ cache_size }} kbytes
"""
if
__name__
==
'__main__'
:
# Do nothing if service is not configured
c
=
Config
()
if
not
c
.
exists_effective
(
'service dns forwarding'
):
print
(
"DNS forwarding is not configured"
)
exit
(
0
)
data
=
{}
data
[
'cache_entries'
]
=
cmd
(
f
'{PDNS_CMD} get cache-entries'
)
data
[
'cache_size'
]
=
"{0:.2f}"
.
format
(
int
(
cmd
(
f
'{PDNS_CMD} get cache-bytes'
))
/
1024
)
tmpl
=
jinja2
.
Template
(
OUT_TMPL_SRC
)
print
(
tmpl
.
render
(
data
))
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Sat, Oct 17, 12:52 AM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4350937
Default Alt Text
dns_forwarding_statistics.py (768 B)
Attached To
Mode
rVYOSONEX vyos-1x
Attached
Detach File
Event Timeline
Log In to Comment