try rdns, add hostname column
This commit is contained in:
parent
bd7116fff4
commit
a98c697632
19
main.go
19
main.go
|
@ -33,6 +33,7 @@ type route struct {
|
||||||
UnreachableDuration time.Duration
|
UnreachableDuration time.Duration
|
||||||
UnreachableSince time.Time
|
UnreachableSince time.Time
|
||||||
ReachableSince time.Time
|
ReachableSince time.Time
|
||||||
|
Hostname string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r route) DurationUntilRounded(t time.Time) time.Duration {
|
func (r route) DurationUntilRounded(t time.Time) time.Duration {
|
||||||
|
@ -98,6 +99,15 @@ func (rs *routeStats) add(rm rtnetlink.RouteMessage) {
|
||||||
r := rs.stats[key]
|
r := rs.stats[key]
|
||||||
if r == nil {
|
if r == nil {
|
||||||
r = &route{Dst: dst}
|
r = &route{Dst: dst}
|
||||||
|
go func(r *route, rs *routeStats) {
|
||||||
|
names, err := net.LookupAddr(r.Dst.IP.String())
|
||||||
|
if err != nil || len(names) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rs.Lock()
|
||||||
|
r.Hostname = strings.TrimRight(names[0], ".")
|
||||||
|
rs.Unlock()
|
||||||
|
}(r, rs)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Counter++
|
r.Counter++
|
||||||
|
@ -226,7 +236,7 @@ func render(w io.Writer, rs []route) error {
|
||||||
padding: 0.1em 2em;
|
padding: 0.1em 2em;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
.dst {
|
.dst, .hostname {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
.unreachable {
|
.unreachable {
|
||||||
|
@ -236,7 +246,7 @@ func render(w io.Writer, rs []route) error {
|
||||||
table tr.noise {
|
table tr.noise {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
tbody tr:hover {
|
tbody tr:nth-child(n+2):hover {
|
||||||
background-color: silver;
|
background-color: silver;
|
||||||
}
|
}
|
||||||
#showAll:checked ~ table tr.noise {
|
#showAll:checked ~ table tr.noise {
|
||||||
|
@ -259,9 +269,11 @@ func render(w io.Writer, rs []route) error {
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Net</th>
|
<th>Net</th>
|
||||||
|
<th>Hostname</th>
|
||||||
<th colspan="3">Downtime</th>
|
<th colspan="3">Downtime</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th>Counts</th>
|
<th>Counts</th>
|
||||||
<th>rel</th>
|
<th>rel</th>
|
||||||
|
@ -269,7 +281,7 @@ func render(w io.Writer, rs []route) error {
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr><td colspan="4"><hr/></td></tr>
|
<tr><td colspan="5"><hr/></td></tr>
|
||||||
{{- $now := .Now -}}
|
{{- $now := .Now -}}
|
||||||
{{- range .R }}
|
{{- range .R }}
|
||||||
<tr class="
|
<tr class="
|
||||||
|
@ -277,6 +289,7 @@ func render(w io.Writer, rs []route) error {
|
||||||
{{- if .Noise $now }} noise{{end -}}
|
{{- if .Noise $now }} noise{{end -}}
|
||||||
">
|
">
|
||||||
<td class="dst">{{.Dst}}</td>
|
<td class="dst">{{.Dst}}</td>
|
||||||
|
<td class="hostname">{{with .Hostname}}<a href="//{{.}}" target="_blank">{{.}}</a>{{end}}</td>
|
||||||
<td class="counter">{{.Counter}}</td>
|
<td class="counter">{{.Counter}}</td>
|
||||||
<td class="downtime">{{.Downtime $now | printf "%.3f%%"}}</td>
|
<td class="downtime">{{.Downtime $now | printf "%.3f%%"}}</td>
|
||||||
<td class="duration">{{.DurationUntilRounded $now}}</td>
|
<td class="duration">{{.DurationUntilRounded $now}}</td>
|
||||||
|
|
Loading…
Reference in New Issue