为 ONVIF 设备增加经纬度标签以支持 Geomap

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Super User
2026-02-25 05:17:57 -05:00
parent 95a09fd9d8
commit 84d2bcc2cf
4 changed files with 35 additions and 15 deletions

View File

@@ -37,11 +37,11 @@ func main() {
up := prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "onvif_device_up",
Help: "1 if ONVIF device is reachable, 0 otherwise",
}, []string{"instance", "location", "model", "device_type"})
}, []string{"instance", "location", "model", "device_type", "lat", "lon"})
duration := prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "onvif_probe_duration_seconds",
Help: "ONVIF probe duration in seconds",
}, []string{"instance", "location", "model", "device_type"})
}, []string{"instance", "location", "model", "device_type", "lat", "lon"})
reg := prometheus.NewRegistry()
reg.MustRegister(up, duration)
@@ -87,6 +87,8 @@ func probe(targetsFile string, up, duration *prometheus.GaugeVec) {
user := strings.TrimSpace(g.Labels["username"])
pass := strings.TrimSpace(g.Labels["password"])
location := strings.TrimSpace(g.Labels["location"])
lat := strings.TrimSpace(g.Labels["lat"])
lon := strings.TrimSpace(g.Labels["lon"])
model := strings.TrimSpace(g.Labels["model"])
deviceType := strings.TrimSpace(g.Labels["device_type"])
instance := ip + ":" + port
@@ -95,6 +97,8 @@ func probe(targetsFile string, up, duration *prometheus.GaugeVec) {
"location": location,
"model": model,
"device_type": deviceType,
"lat": lat,
"lon": lon,
}
start := time.Now()