]>
Commit | Line | Data |
---|---|---|
a8b14a22 | 1 | "use strict"; |
2 | ||
3 | var gdata={} | |
4 | ||
5 | $(document).ready(function() { | |
6 | $.ajaxSetup({ cache: false }); | |
7 | ||
8 | var qpsgraph = new Rickshaw.Graph( { | |
5024c067 | 9 | element: document.getElementById("qpschart"), |
10 | width: 400, | |
11 | height: 200, | |
12 | renderer: 'line', | |
13 | series: new Rickshaw.Series.FixedDuration([{ name: 'servfailps' }, {name: 'qps'}], undefined, { | |
a8b14a22 | 14 | timeInterval: 1000, |
15 | maxDataPoints: 100, | |
16 | timeBase: new Date().getTime() / 1000 | |
5024c067 | 17 | }) |
a8b14a22 | 18 | } ); |
19 | var y_ticks = new Rickshaw.Graph.Axis.Y( { | |
5024c067 | 20 | graph: qpsgraph, |
21 | orientation: 'left', | |
22 | tickFormat: Rickshaw.Fixtures.Number.formatKMBT, | |
23 | element: document.getElementById('qpsy_axis') | |
a8b14a22 | 24 | } ); |
25 | ||
26 | qpsgraph.render(); | |
27 | ||
28 | var cpugraph = new Rickshaw.Graph( { | |
5024c067 | 29 | element: document.getElementById("cpuchart"), |
30 | width: 400, | |
31 | height: 200, | |
32 | renderer: 'line', | |
6cb33433 | 33 | series: new Rickshaw.Series.FixedDuration([{ name: 'one' }, {name: 'two'}], undefined, { |
a8b14a22 | 34 | timeInterval: 1000, |
35 | maxDataPoints: 100, | |
36 | timeBase: new Date().getTime() / 1000 | |
5024c067 | 37 | }) |
a8b14a22 | 38 | } ); |
39 | var y_ticks = new Rickshaw.Graph.Axis.Y( { | |
5024c067 | 40 | graph: cpugraph, |
41 | orientation: 'left', | |
42 | tickFormat: Rickshaw.Fixtures.Number.formatKMBT, | |
43 | element: document.getElementById('cpuy_axis') | |
a8b14a22 | 44 | } ); |
45 | ||
46 | cpugraph.render(); | |
47 | var intervalcount=0; | |
48 | ||
49 | function updateRingBuffers() | |
50 | { | |
5024c067 | 51 | var filtered=$("#filter1").is(':checked') |
52 | var qstring='jsonstat?command=get-query-ring&name=queries'; | |
53 | if(filtered) | |
54 | qstring=qstring+"&public-filtered=1"; | |
55 | ||
56 | $.getJSON(qstring, | |
57 | function(data) { | |
58 | console.log(data); | |
59 | var bouw="<table><tr><th>Number</th><th>Domain</th><th>Type</th></tr>"; | |
60 | var num=0; | |
61 | var total=0, rest=0; | |
62 | $.each(data["entries"], function(a,b) { | |
63 | total+=b[0]; | |
64 | if(num++ > 10) { | |
65 | rest+=b[0]; | |
66 | return; | |
67 | } | |
68 | if(b[1].length > 25) | |
69 | b[1]=b[1].substring(0,25); | |
70 | ||
71 | bouw=bouw+("<tr><td>"+b[0]+"</td><td>"+b[1]+"</td><td>"+b[2]+"</td></tr>"); | |
72 | }); | |
73 | bouw+="<tr><td>"+rest+"</td><td>Rest</td></tr>"; | |
74 | bouw=bouw+"</table>"; | |
75 | $("#queryring").html(bouw); | |
76 | ||
77 | }); | |
78 | ||
79 | filtered=$("#filter2").is(':checked') | |
80 | qstring='jsonstat?command=get-query-ring&name=servfail-queries'; | |
81 | if(filtered) | |
82 | qstring=qstring+"&public-filtered=1"; | |
83 | ||
84 | $.getJSON(qstring, | |
85 | function(data) { | |
86 | var bouw="<table><tr><th>Number</th><th>Servfail domain</th><th>Type</th></tr>"; | |
87 | var num=0, total=0, rest=0; | |
88 | $.each(data["entries"], function(a,b) { | |
89 | total+=b[0]; | |
90 | if(num++ > 10) { | |
91 | rest+=b[0]; | |
92 | return; | |
93 | } | |
94 | if(b[1].length > 25) | |
95 | b[1]=b[1].substring(0,25); | |
96 | bouw=bouw+("<tr><td>"+b[0]+"</td><td>"+b[1]+"</td><td>"+b[2]+"</td></tr>"); | |
97 | }); | |
98 | bouw+="<tr><td>"+rest+"</td><td>Rest</td></tr>"; | |
99 | bouw=bouw+"</table>"; | |
100 | $("#servfailqueryring").html(bouw); | |
101 | ||
102 | }); | |
103 | ||
104 | $.getJSON('jsonstat?command=get-remote-ring&name=remotes', | |
105 | function(data) { | |
106 | var bouw="<table><tr><th>Number</th><th>Remote</th></tr>"; | |
107 | var num=0, total=0, rest=0; | |
108 | $.each(data["entries"], function(a,b) { | |
109 | total+=b[0]; | |
110 | if(num++ > 10) { | |
111 | rest +=b[0]; | |
112 | return; | |
113 | } | |
114 | bouw=bouw+("<tr><td>"+b[0]+"</td><td>"+b[1]+"</td></tr>"); | |
115 | }); | |
116 | bouw+="<tr><td>"+rest+"</td><td>Rest</td></tr>"; | |
117 | bouw=bouw+"</table>"; | |
118 | $("#remotering").html(bouw); | |
119 | ||
120 | }); | |
121 | ||
122 | $.getJSON('jsonstat?command=get-remote-ring&name=servfail-remotes', | |
123 | function(data) { | |
124 | var bouw="<table><tr><th>Number</th><th>Servfail Remote</th></tr>"; | |
125 | var num=0, total=0, rest=0; | |
126 | $.each(data["entries"], function(a,b) { | |
127 | total+=b[0]; | |
128 | if(num++ > 10) { | |
129 | rest += b[0]; | |
130 | return; | |
131 | } | |
132 | bouw=bouw+("<tr><td>"+b[0]+"</td><td>"+b[1]+"</td></tr>"); | |
133 | }); | |
134 | bouw+="<tr><td>"+rest+"</td><td>Rest</td></tr>"; | |
135 | bouw=bouw+"</table>"; | |
136 | $("#servfailremotering").html(bouw); | |
137 | }); | |
a8b14a22 | 138 | } |
139 | ||
140 | function update() | |
141 | { | |
5024c067 | 142 | $.ajax({ |
454470b1 | 143 | url: 'jsonstat?command=stats', |
a8b14a22 | 144 | type: 'GET', |
864a6641 | 145 | dataType: 'json', |
ed5d8c79 | 146 | jsonp: false, |
a8b14a22 | 147 | success: function(data, x, y) { |
5024c067 | 148 | $("#questions").text(data["queries"]); |
b0d5d099 | 149 | $("#acl-drops").text(data["acl-drops"]); |
127e7920 | 150 | $("#dyn-drops").text(data["dyn-blocked"]); |
151 | $("#rule-drops").text(data["rule-drop"]); | |
5024c067 | 152 | $("#uptime").text(moment.duration(data["uptime"]*1000.0).humanize()); |
6cb33433 | 153 | $("#latency").text((data["latency-avg10000"]/1000.0).toFixed(2)); |
51ec1331 RG |
154 | $("#latency-tcp").text((data["latency-tcp-avg10000"]/1000.0).toFixed(2)); |
155 | $("#latency-dot").text((data["latency-dot-avg10000"]/1000.0).toFixed(2)); | |
156 | $("#latency-doh").text((data["latency-doh-avg10000"]/1000.0).toFixed(2)); | |
5057253a | 157 | $("#latency-doq").text((data["latency-doq-avg10000"]/1000.0).toFixed(2)); |
5024c067 | 158 | if(!gdata["cpu-sys-msec"]) |
159 | gdata=data; | |
160 | ||
161 | var cpu=((1.0*data["cpu-sys-msec"]+1.0*data["cpu-user-msec"] - 1.0*gdata["cpu-sys-msec"]-1.0*gdata["cpu-user-msec"])/10.0); | |
162 | ||
163 | $("#cpu").text(cpu.toFixed(2)); | |
164 | var qps=1.0*data["queries"]-1.0*gdata["queries"]; | |
5564e9ca | 165 | $("#qps").text(qps.toFixed(2)); |
5024c067 | 166 | $("#server-policy").text(data["server-policy"]); |
167 | ||
168 | var servfailps=1.0*data["servfail-responses"]-1.0*gdata["servfail-responses"]; | |
169 | ||
6cb33433 | 170 | var totpcache=1.0*data["cache-hits"]-1.0*gdata["cache-hits"]+1.0*data["cache-misses"]-1.0*gdata["cache-misses"]; |
171 | var hitrate=0; | |
172 | if(totpcache > 0) { | |
173 | hitrate=100.0*(data["cache-hits"]-1.0*gdata["cache-hits"])/totpcache; | |
174 | $("#phitrate").text(hitrate.toFixed(2)); | |
175 | } | |
5024c067 | 176 | else |
177 | $("#phitrate").text(0); | |
178 | ||
179 | qpsgraph.series.addData({ qps: qps, servfailps: servfailps}); | |
180 | qpsgraph.render(); | |
181 | ||
6cb33433 | 182 | cpugraph.series.addData({ one: cpu, two: hitrate}); |
5024c067 | 183 | cpugraph.render(); |
184 | ||
185 | gdata=data; | |
a8b14a22 | 186 | }, |
187 | error: function() { | |
188 | ||
189 | }, | |
190 | }); | |
5024c067 | 191 | |
864a6641 | 192 | $.ajax({ url: 'api/v1/servers/localhost', type: 'GET', dataType: 'json', jsonp: false, |
5024c067 | 193 | success: function(data) { |
194 | $("#version").text(data["daemon_type"]+" "+data["version"]); | |
5e4a8e62 | 195 | $("#acl").text(data["acl"]); |
196 | $("#local").text(data["local"]); | |
cbd17252 | 197 | var bouw='<table width="100%"><tr align=right><th>#</th><th align=left>Name</th><th align=left>Address</th><th>Status</th><th>UDP Latency</th><th>TCP Latency</th><th>Queries</th><th>Drops</th><th>QPS</th><th>Out</th><th>Weight</th><th>Order</th><th align=left>Pools</th></tr>'; |
5024c067 | 198 | $.each(data["servers"], function(a,b) { |
199 | bouw = bouw + ("<tr align=right><td>"+b["id"]+"</td><td align=left>"+b["name"]+"</td><td align=left>"+b["address"]+"</td><td>"+b["state"]+"</td>"); | |
cbd17252 CHB |
200 | var latency = (b["latency"] === null || b["latency"] === 0.0) ? "-" : b["latency"].toFixed(2); |
201 | var tcpLatency = (b["tcpLatency"] === null || b["tcpLatency"] === 0.0) ? "-" : b["tcpLatency"].toFixed(2); | |
202 | bouw = bouw + ("<td>"+latency+"</td><td>"+tcpLatency+"</td><td>"+b["queries"]+"</td><td>"+b["reuseds"]+"</td><td>"+(b["qps"]).toFixed(2)+"</td><td>"+b["outstanding"]+"</td>"); | |
fcadd56e | 203 | bouw = bouw + ("<td>"+b["weight"]+"</td><td>"+b["order"]+"</td><td align=left>"+b["pools"]+"</td></tr>"); |
5024c067 | 204 | }); |
a8b14a22 | 205 | bouw = bouw + "</table>"; |
5024c067 | 206 | $("#downstreams").html(bouw); |
207 | ||
a6d98578 | 208 | bouw='<table width="100%"><tr align=left><th>#</th><th align=left>Name</th><th align=left>Rule</th><th>Action</th><th>Matches</th></tr>'; |
5024c067 | 209 | if(data["rules"].length) { |
210 | $.each(data["rules"], function(a,b) { | |
a6d98578 | 211 | bouw = bouw + ("<tr align=left><td>"+b["id"]+"</td><td align=left>"+b["name"]+"</td><td align=left>"+b["rule"]+"</td><td>"+b["action"]+"</td>"); |
5024c067 | 212 | bouw = bouw + ("<td>"+b["matches"]+"</td></tr>"); |
213 | }); | |
214 | } | |
215 | else | |
216 | bouw = bouw + '<tr><td align="center" colspan="4"><font color="#aaaaaa">No rules defined</font></td></tr>'; | |
fcadd56e | 217 | bouw = bouw + "</table>"; |
5024c067 | 218 | $("#rules").html(bouw); |
46e8b49e | 219 | |
a6d98578 | 220 | bouw='<table width="100%"><tr align=left><th>#</th><th align=left>Name</th><th align=left>Response Rule</th><th>Action</th><th>Matches</th></tr>'; |
46e8b49e RG |
221 | if(data["response-rules"].length) { |
222 | $.each(data["response-rules"], function(a,b) { | |
a6d98578 | 223 | bouw = bouw + ("<tr align=left><td>"+b["id"]+"</td><td align=left>"+b["name"]+"</td><td align=left>"+b["rule"]+"</td><td>"+b["action"]+"</td>"); |
46e8b49e RG |
224 | bouw = bouw + ("<td>"+b["matches"]+"</td></tr>"); |
225 | }); | |
226 | } | |
227 | else | |
228 | bouw = bouw + '<tr><td align="center" colspan="4"><font color="#aaaaaa">No response rules defined</font></td></tr>'; | |
229 | bouw = bouw + "</table>"; | |
230 | $("#response-rules").html(bouw); | |
5024c067 | 231 | } |
232 | }); | |
fcadd56e | 233 | |
a8b14a22 | 234 | |
78ffa782 | 235 | // if((intervalcount++)%5) |
236 | // return; | |
5024c067 | 237 | // updateRingBuffers(); |
a8b14a22 | 238 | |
864a6641 | 239 | $.ajax({ url: 'jsonstat?command=dynblocklist', type: 'GET', dataType: 'json', jsonp: false, |
5024c067 | 240 | success: function(data) { |
2b8de4d5 | 241 | var bouw='<table width="100%"><tr align=left><th>Dyn blocked netmask</th><th>Seconds</th><th>Blocks</th><th>eBPF</th><th align=left>Reason</th></tr>'; |
78ffa782 | 242 | var gotsome=false; |
243 | $.each(data, function(a,b) { | |
2b8de4d5 | 244 | bouw=bouw+("<tr><td>"+a+"</td><td>"+b.seconds+"</td><td>"+b.blocks+"</td><td>"+b.ebpf+"</td><td>"+b.reason+"</td></tr>"); |
78ffa782 | 245 | gotsome=true; |
246 | }); | |
247 | ||
248 | if(!gotsome) | |
249 | bouw = bouw + '<tr><td align="center" colspan="4"><font color="#aaaaaa">No dynamic blocks active</font></td></tr>'; | |
a8b14a22 | 250 | |
5024c067 | 251 | bouw=bouw+"</table>"; |
252 | $("#dynblock").html(bouw); | |
7be71139 | 253 | |
5024c067 | 254 | }}); |
7be71139 | 255 | |
8429ad04 RG |
256 | $.ajax({ url: 'jsonstat?command=ebpfblocklist', type: 'GET', dataType: 'json', jsonp: false, |
257 | success: function(data) { | |
258 | var bouw='<table width="100%"><tr align=left><th>Kernel-based dyn blocked netmask</th><th>Seconds</th></th><th>Blocks</th></tr>'; | |
259 | var gotsome=false; | |
260 | $.each(data, function(a,b) { | |
261 | bouw=bouw+("<tr><td>"+a+"</td><td>"+b.seconds+"</td><td>"+b.blocks+"</td></tr>"); | |
262 | gotsome=true; | |
263 | }); | |
264 | ||
265 | if(!gotsome) | |
266 | bouw = bouw + '<tr><td align="center" colspan="4"><font color="#aaaaaa">No eBPF blocks active</font></td></tr>'; | |
267 | ||
268 | bouw=bouw+"</table>"; | |
269 | $("#ebpfblock").html(bouw); | |
270 | ||
271 | }}); | |
a8b14a22 | 272 | |
273 | }; | |
5024c067 | 274 | |
a8b14a22 | 275 | $("#filter1").click(updateRingBuffers); |
276 | $("#filter2").click(updateRingBuffers); | |
277 | ||
278 | update(); | |
279 | setInterval(update, 1000); | |
280 | }); |