mirror of
https://github.com/cunnie/sslip.io.git
synced 2025-09-26 19:51:10 +08:00
🐞 Make metrics more readable (no Unicode)
When using dig to determine the metrics of my servers, e.g. "dig txt metrics.status.sslip.io @ns-ovh.sslip.io +short", one record looks particularly heinous: ``` "Answer \226\137\165 1: 67974722 (651.9/s)" ``` It's supposed to look like this: ``` "Answer ≥ 1: 67974722 (651.9/s)" ``` `dig` doesn't handle Unicode well. So I'm replacing "Answer ≥ 1" with "Answer > 0". No Unicode. It was a worthy effort, but ultimately failed.
This commit is contained in:
@@ -205,13 +205,12 @@ func getMetrics(port int) (m xip.Metrics) {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
var uptime int
|
var uptime int
|
||||||
var junk string
|
var junk string
|
||||||
var greaterThanOrEqualsUnicode string
|
|
||||||
_, err = fmt.Sscanf(string(stdout),
|
_, err = fmt.Sscanf(string(stdout),
|
||||||
"\"Uptime: %d\"\n"+
|
"\"Uptime: %d\"\n"+
|
||||||
"\"Blocklist: %s %s %s\n"+
|
"\"Blocklist: %s %s %s\n"+
|
||||||
"\"Queries: %d (%s\n"+ // %s "swallows" the `/s"` at the end
|
"\"Queries: %d (%s\n"+ // %s "swallows" the `/s"` at the end
|
||||||
"\"TCP/UDP: %d/%d\"\n"+
|
"\"TCP/UDP: %d/%d\"\n"+
|
||||||
"\"Answer %s 1: %d (%s\n"+ // %s "swallows" the `/s"` at the end
|
"\"Answer > 0: %d (%s\n"+ // %s "swallows" the `/s"` at the end
|
||||||
"\"A: %d\"\n"+
|
"\"A: %d\"\n"+
|
||||||
"\"AAAA: %d\"\n"+
|
"\"AAAA: %d\"\n"+
|
||||||
"\"TXT Source: %d\"\n"+
|
"\"TXT Source: %d\"\n"+
|
||||||
@@ -223,7 +222,7 @@ func getMetrics(port int) (m xip.Metrics) {
|
|||||||
&junk, &junk, &junk,
|
&junk, &junk, &junk,
|
||||||
&m.Queries, &junk,
|
&m.Queries, &junk,
|
||||||
&m.TCPQueries, &m.UDPQueries,
|
&m.TCPQueries, &m.UDPQueries,
|
||||||
&greaterThanOrEqualsUnicode, &m.AnsweredQueries, &junk,
|
&m.AnsweredQueries, &junk,
|
||||||
&m.AnsweredAQueries,
|
&m.AnsweredAQueries,
|
||||||
&m.AnsweredAAAAQueries,
|
&m.AnsweredAAAAQueries,
|
||||||
&m.AnsweredTXTSrcIPQueries,
|
&m.AnsweredTXTSrcIPQueries,
|
||||||
|
@@ -267,7 +267,7 @@ dig @ns-azure.sslip.io metrics.status.sslip.io txt +short
|
|||||||
"Blocklist: 2023-10-04 07:37:50-07 3,6"
|
"Blocklist: 2023-10-04 07:37:50-07 3,6"
|
||||||
"Queries: 14295231 (86.3/s)"
|
"Queries: 14295231 (86.3/s)"
|
||||||
"TCP/UDP: 5231/14290000"
|
"TCP/UDP: 5231/14290000"
|
||||||
"Answer ≥ 1: 4872793 (29.4/s)"
|
"Answer > 0: 4872793 (29.4/s)"
|
||||||
"A: 4025711"
|
"A: 4025711"
|
||||||
"AAAA: 247215"
|
"AAAA: 247215"
|
||||||
"TXT Source: 57"
|
"TXT Source: 57"
|
||||||
@@ -294,7 +294,7 @@ dig @ns-azure.sslip.io metrics.status.sslip.io txt +short
|
|||||||
<dt>TCP/UDP</dt>
|
<dt>TCP/UDP</dt>
|
||||||
<dd>This is the number of queries received on the TCP protocol versus the UDP protocol. The sum should equal
|
<dd>This is the number of queries received on the TCP protocol versus the UDP protocol. The sum should equal
|
||||||
the number of queries. DNS typically uses the UDP protocol</dd>
|
the number of queries. DNS typically uses the UDP protocol</dd>
|
||||||
<dt>Answer ≥ 1</dt>
|
<dt>Answer > 0</dt>
|
||||||
<dd>This consists of two numbers: the first is the number of queries we responded to with at least one record
|
<dd>This consists of two numbers: the first is the number of queries we responded to with at least one record
|
||||||
in the answer section, and the second is the first number divided by the uptime (i.e. queries/second). Note
|
in the answer section, and the second is the first number divided by the uptime (i.e. queries/second). Note
|
||||||
that the number of responses with an answer record is typically a fourth the size of the overall responses.
|
that the number of responses with an answer record is typically a fourth the size of the overall responses.
|
||||||
|
@@ -985,7 +985,7 @@ func TXTMetrics(x *Xip, _ net.IP) (txtResources []dnsmessage.TXTResource, err er
|
|||||||
len(x.BlocklistCIDRs)))
|
len(x.BlocklistCIDRs)))
|
||||||
metrics = append(metrics, fmt.Sprintf("Queries: %d (%.1f/s)", x.Metrics.Queries, float64(x.Metrics.Queries)/uptime.Seconds()))
|
metrics = append(metrics, fmt.Sprintf("Queries: %d (%.1f/s)", x.Metrics.Queries, float64(x.Metrics.Queries)/uptime.Seconds()))
|
||||||
metrics = append(metrics, fmt.Sprintf("TCP/UDP: %d/%d", x.Metrics.TCPQueries, x.Metrics.UDPQueries))
|
metrics = append(metrics, fmt.Sprintf("TCP/UDP: %d/%d", x.Metrics.TCPQueries, x.Metrics.UDPQueries))
|
||||||
metrics = append(metrics, fmt.Sprintf("Answer ≥ 1: %d (%.1f/s)", x.Metrics.AnsweredQueries, float64(x.Metrics.AnsweredQueries)/uptime.Seconds()))
|
metrics = append(metrics, fmt.Sprintf("Answer > 0: %d (%.1f/s)", x.Metrics.AnsweredQueries, float64(x.Metrics.AnsweredQueries)/uptime.Seconds()))
|
||||||
metrics = append(metrics, fmt.Sprintf("A: %d", x.Metrics.AnsweredAQueries))
|
metrics = append(metrics, fmt.Sprintf("A: %d", x.Metrics.AnsweredAQueries))
|
||||||
metrics = append(metrics, fmt.Sprintf("AAAA: %d", x.Metrics.AnsweredAAAAQueries))
|
metrics = append(metrics, fmt.Sprintf("AAAA: %d", x.Metrics.AnsweredAAAAQueries))
|
||||||
metrics = append(metrics, fmt.Sprintf("TXT Source: %d", x.Metrics.AnsweredTXTSrcIPQueries))
|
metrics = append(metrics, fmt.Sprintf("TXT Source: %d", x.Metrics.AnsweredTXTSrcIPQueries))
|
||||||
|
Reference in New Issue
Block a user