Keimond
4 years agoNeophyte
xml and xpaths
Hey all I'm having troubles figuring this out.. so I have set up a datasource that pulls the xml directly from a bind statistics web server and that's working but I can't get the values to show up ...
Thanks again, I just wanted to show my final output as I added the boot-time and config-time that I wanted as well.
/etc/snmp/scripts/runstats.sh
boottime:79395 conftime:79395 ina:3098500 ina6:8 inaaaa:1107344 inany:69885 incname:43835 inmx:147801 innaptr:23 inns:1 inptr:2260082 insoa:65773 inspf:2244 insrv:97583 intxt:146317 rsnx:16075 outa:1605153 outa6: outaaaa:385541 outany: outcname:18206 outmx:212 outnaptr: outns:75 outptr:123973 outsoa:209 outspf: outsrv:1227 outtxt:288 rsnx:16075 rsfail:477 rserr:455 rsipv4qs:1875597 rsipv4rr:1866673 rsmismatch:1 rsqr:349108 rsqt:9010 rsrtt10:707770 rsrtt100500:76413 rsrtt10100:1082061 rsrtt1600:6 rsrtt500800:300 rsrtt8001600:15 sockopen:1876127 sockclosed:1876115 sockbf:169 consest:1863133 recverr:108
My modified /etc/snmp/script/runstats.sh is
#!/bin/sh rm -rf /var/named/named.stats rndc stats stats=$(cat /var/named/named.stats | /etc/snmp/scripts/dnsstats.pl 2>/dev/null) now=$(date +%s) host=localhost port=8653 xmlstats=$(curl -s http://${host}:${port} 2>/dev/null | xml2) boottime=$(date -d $(echo "${xmlstats}" | egrep -i 'boot-time' | cut -d= -f2) +%s) conftime=$(date -d $(echo "${xmlstats}" | egrep -i 'config-time' | cut -d= -f2) +%s) boottimeseconds=$(echo "${now} - ${boottime}" | bc) conftimeseconds=$(echo "${now} - ${conftime}" | bc) echo "boottime:${boottimeseconds} conftime:${conftimeseconds} ${stats}"
Note to anyone out there that also might see this, adding boot-time and config-time does require this in your named.conf
statistics-channels {
inet 127.0.0.1 port 8653 allow { 127.0.0.1; };
};