@@ -20,6 +20,17 @@ const (
20
20
)
21
21
22
22
var (
23
+ // Location Info
24
+ dishLocationInfo = prometheus .NewDesc (
25
+ prometheus .BuildFQName (namespace , "dish" , "location_info" ),
26
+ "Dish Location Info (GPS/Starlink)" ,
27
+ []string {
28
+ "location_source" ,
29
+ "lat" ,
30
+ "lon" ,
31
+ "alt" }, nil ,
32
+ )
33
+
23
34
// DeviceInfo
24
35
dishInfo = prometheus .NewDesc (
25
36
prometheus .BuildFQName (namespace , "dish" , "info" ),
@@ -395,6 +406,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
395
406
start := time .Now ()
396
407
397
408
ok := e .collectDishStatus (ch )
409
+ ok = ok && e .collectDishLocationStatus (ch )
398
410
ok = ok && e .collectDishObstructions (ch )
399
411
ok = ok && e .collectDishAlerts (ch )
400
412
ok = ok && e .collectDishConfig (ch )
@@ -437,6 +449,40 @@ func (e *Exporter) collectDishConfig(ch chan<- prometheus.Metric) bool {
437
449
return true
438
450
}
439
451
452
+ func (e * Exporter ) collectDishLocationStatus (ch chan <- prometheus.Metric ) bool {
453
+ req := & device.Request {
454
+ Request : & device.Request_GetLocation {},
455
+ }
456
+
457
+ ctx , cancel := context .WithTimeout (context .Background (), time .Second * 1 )
458
+ defer cancel ()
459
+
460
+ resp , err := e .Client .Handle (ctx , req )
461
+ if err != nil {
462
+ log .Errorf ("failed to collect dish location: %s" , err .Error ())
463
+ // don't return false since location service might not be enabled
464
+ return true
465
+ }
466
+
467
+ dishStatus := resp .GetGetLocation ()
468
+ locationSource := dishStatus .GetSource ()
469
+
470
+ lla := dishStatus .GetLla ()
471
+ lat := lla .GetLat ()
472
+ lon := lla .GetLon ()
473
+ alt := lla .GetAlt ()
474
+
475
+ ch <- prometheus .MustNewConstMetric (
476
+ dishLocationInfo , prometheus .GaugeValue , 1.00 ,
477
+ locationSource .String (),
478
+ fmt .Sprint (lat ),
479
+ fmt .Sprint (lon ),
480
+ fmt .Sprint (alt ),
481
+ )
482
+
483
+ return true
484
+ }
485
+
440
486
func (e * Exporter ) collectDishStatus (ch chan <- prometheus.Metric ) bool {
441
487
req := & device.Request {
442
488
Request : & device.Request_GetStatus {},
0 commit comments