Skip to content

Commit 58da52a

Browse files
committed
Implement adding additional meta-data to gw stats.
1 parent c01d39e commit 58da52a

File tree

10 files changed

+469
-3
lines changed

10 files changed

+469
-3
lines changed

cmd/lora-gateway-bridge/cmd/configfile.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,50 @@ marshaler="{{ .Integration.Marshaler }}"
296296
# The ip:port to bind the Prometheus metrics server to for serving the
297297
# metrics endpoint.
298298
bind="{{ .Metrics.Prometheus.Bind }}"
299+
300+
301+
# Gateway meta-data.
302+
#
303+
# The meta-data will be added to every stats message sent by the LoRa Gateway
304+
# Bridge.
305+
[meta_data]
306+
307+
# Static.
308+
#
309+
# Static key (string) / value (string) meta-data.
310+
[meta_data.static]
311+
# Example:
312+
# serial_number="A1B21234"
313+
{{ range $k, $v := .MetaData.Static }}
314+
{{ $k }}="{{ $v }}"
315+
{{ end }}
316+
317+
318+
# Dynamic meta-data.
319+
#
320+
# Dynamic meta-data is retrieved by executing external commands.
321+
# This makes it possible to for example execute an external command to
322+
# read the gateway temperature.
323+
[meta_data.dynamic]
324+
325+
# Execution interval of the commands.
326+
execution_interval="{{ .MetaData.Dynamic.ExecutionInterval }}"
327+
328+
# Max. execution duration.
329+
max_execution_duration="{{ .MetaData.Dynamic.MaxExecutionDuration }}"
330+
331+
# Commands to execute.
332+
#
333+
# The value of the stdout will be used as the key value (string).
334+
# In case the command failed, it is ignored. In case the same key is defined
335+
# both as static and dynamic, the dynamic value has priority (as long as the)
336+
# command does not fail.
337+
[meta_data.dynamic.commands]
338+
# Example:
339+
# temperature="/opt/gateway-temperature/gateway-temperature.sh"
340+
{{ range $k, $v := .MetaData.Dynamic.Commands }}
341+
{{ $k }}="{{ $v }}"
342+
{{ end }}
299343
`
300344

301345
var configCmd = &cobra.Command{

cmd/lora-gateway-bridge/cmd/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ func init() {
6262

6363
viper.SetDefault("integration.mqtt.auth.azure_iot_hub.sas_token_expiration", 24*time.Hour)
6464

65+
viper.SetDefault("meta_data.dynamic.execution_interval", time.Minute)
66+
viper.SetDefault("meta_data.dynamic.max_execution_duration", time.Second)
67+
6568
rootCmd.AddCommand(versionCmd)
6669
rootCmd.AddCommand(configCmd)
6770
}

cmd/lora-gateway-bridge/cmd/root_run.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/brocaar/lora-gateway-bridge/internal/config"
1414
"github.com/brocaar/lora-gateway-bridge/internal/forwarder"
1515
"github.com/brocaar/lora-gateway-bridge/internal/integration"
16+
"github.com/brocaar/lora-gateway-bridge/internal/metadata"
1617
"github.com/brocaar/lora-gateway-bridge/internal/metrics"
1718
)
1819

@@ -25,6 +26,7 @@ func run(cmd *cobra.Command, args []string) error {
2526
setupIntegration,
2627
setupForwarder,
2728
setupMetrics,
29+
setupMetaData,
2830
}
2931

3032
for _, t := range tasks {
@@ -81,3 +83,10 @@ func setupMetrics() error {
8183
}
8284
return nil
8385
}
86+
87+
func setupMetaData() error {
88+
if err := metadata.Setup(config.C); err != nil {
89+
return errors.Wrap(err, "setup meta-data error")
90+
}
91+
return nil
92+
}

docs/content/install/config.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,45 @@ marshaler="protobuf"
342342
# The ip:port to bind the Prometheus metrics server to for serving the
343343
# metrics endpoint.
344344
bind=""
345+
346+
347+
# Gateway meta-data.
348+
#
349+
# The meta-data will be added to every stats message sent by the LoRa Gateway
350+
# Bridge.
351+
[meta_data]
352+
353+
# Static.
354+
#
355+
# Static key (string) / value (string) meta-data.
356+
[meta_data.static]
357+
# Example:
358+
# serial_number="A1B21234"
359+
360+
361+
362+
# Dynamic meta-data.
363+
#
364+
# Dynamic meta-data is retrieved by executing external commands.
365+
# This makes it possible to for example execute an external command to
366+
# read the gateway temperature.
367+
[meta_data.dynamic]
368+
369+
# Execution interval of the commands.
370+
execution_interval="1m0s"
371+
372+
# Max. execution duration.
373+
max_execution_duration="1s"
374+
375+
# Commands to execute.
376+
#
377+
# The value of the stdout will be used as the key value (string).
378+
# In case the command failed, it is ignored. In case the same key is defined
379+
# both as static and dynamic, the dynamic value has priority (as long as the)
380+
# command does not fail.
381+
[meta_data.dynamic.commands]
382+
# Example:
383+
# temperature="/opt/gateway-temperature/gateway-temperature.sh"
345384
{{</highlight>}}
346385

347386
## Environment variables

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module github.com/brocaar/lora-gateway-bridge
22

33
require (
4-
github.com/brocaar/loraserver v0.0.0-20190409085620-14c6fb22dcc4
4+
github.com/brocaar/loraserver v0.0.0-20190422074053-c3336fb6b947
55
github.com/brocaar/lorawan v0.0.0-20190402092148-5bca41b178e9
66
github.com/dgrijalva/jwt-go v3.2.0+incompatible
7-
github.com/eclipse/paho.mqtt.golang v0.0.0-20190117150808-cb7eb9363b44
7+
github.com/eclipse/paho.mqtt.golang v1.1.1
88
github.com/golang/protobuf v1.3.1
99
github.com/goreleaser/goreleaser v0.101.0
1010
github.com/goreleaser/nfpm v0.9.7

go.sum

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
22
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
33
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
4+
github.com/Azure/azure-amqp-common-go v1.1.3/go.mod h1:FhZtXirFANw40UXI2ntweO+VOkfaw8s6vZxUiRhLYW8=
5+
github.com/Azure/azure-sdk-for-go v0.0.0-20180727220559-4e8cbbfb1aea/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
6+
github.com/Azure/azure-sdk-for-go v21.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
7+
github.com/Azure/azure-service-bus-go v0.4.1/go.mod h1:d9ho9e/06euiTwGpKxmlbpPhFUsfCsq6a4tZ68r51qI=
8+
github.com/Azure/go-autorest v0.0.0-20180809201959-39013ecb48ea/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
9+
github.com/Azure/go-autorest v11.0.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
10+
github.com/Azure/go-autorest v11.1.1+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
411
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
512
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
613
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
@@ -12,6 +19,7 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5Vpd
1219
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
1320
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
1421
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
22+
github.com/amenzhinsky/iothub v0.0.0-20190415141912-fb38f4d4c9fb/go.mod h1:5SMEOj96ci5bC7bp/RB1jH44yY5SzQnspyOov8hk39w=
1523
github.com/apex/log v1.1.0 h1:J5rld6WVFi6NxA6m8GJ1LJqu3+GiTFIt3mYv27gdQWI=
1624
github.com/apex/log v1.1.0/go.mod h1:yA770aXIDQrhVOIGurT/pVdfCpSq1GQV/auzMN5fzvY=
1725
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
@@ -23,6 +31,9 @@ github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2 h1:oMCHnXa6CCCafdPDb
2331
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI=
2432
github.com/brocaar/loraserver v0.0.0-20190409085620-14c6fb22dcc4 h1:W9rhK+dC/2QbOSU6TRJn0NeT6unLzB0cAALF+1Ye7JM=
2533
github.com/brocaar/loraserver v0.0.0-20190409085620-14c6fb22dcc4/go.mod h1:xN+gy4o/yEVwO8C+4miov9G39qMgrpJTEnvlyQMI2Y0=
34+
github.com/brocaar/loraserver v0.0.0-20190422074053-c3336fb6b947 h1:SIPjr39mqsD/Nw83rPaTlRzjQZW5dtx9DqjlFon5ZfY=
35+
github.com/brocaar/loraserver v0.0.0-20190422074053-c3336fb6b947/go.mod h1:JH3jKu0OI6DJEd/iO8DQvKU67WOosJ9DK3orohlJfLA=
36+
github.com/brocaar/loraserver v2.5.0+incompatible h1:Fna4CF0jW2Vl4UpjLIhR5ifW4g+oZD/w3Dq09TiJ8Z8=
2637
github.com/brocaar/lorawan v0.0.0-20190308082318-5ed881e0a2d7/go.mod h1:l9eO0JU49MD1s/7nbwf2wh9QoxBsCSmTHUswkYb1IkI=
2738
github.com/brocaar/lorawan v0.0.0-20190402092148-5bca41b178e9 h1:cX5HHyYJFZQLIeSNvydOr+CkoBmqYsv9oB6ZzYn8EN8=
2839
github.com/brocaar/lorawan v0.0.0-20190402092148-5bca41b178e9/go.mod h1:Fm+51pxK6mZoAQjIaWJqPmnRuXecozsM5Mf9c+kr/ko=
@@ -33,24 +44,29 @@ github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e/go.mod h1:9IOqJGCPMS
3344
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
3445
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
3546
github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk=
47+
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
3648
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
3749
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
3850
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
3951
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
4052
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4153
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4254
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55+
github.com/dgrijalva/jwt-go v0.0.0-20180308231308-06ea1031745c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
4356
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
4457
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
4558
github.com/dustin/go-humanize v0.0.0-20180713052910-9f541cc9db5d/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
4659
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
4760
github.com/eclipse/paho.mqtt.golang v0.0.0-20190117150808-cb7eb9363b44 h1:rb/YAc+4+BUTDrQhBZHNim9wxFmpaLZDICe5spmjMcs=
4861
github.com/eclipse/paho.mqtt.golang v0.0.0-20190117150808-cb7eb9363b44/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
62+
github.com/eclipse/paho.mqtt.golang v1.1.1 h1:iPJYXJLaViCshRTW/PSqImSS6HJ2Rf671WR0bXZ2GIU=
63+
github.com/eclipse/paho.mqtt.golang v1.1.1/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
4964
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
5065
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
5166
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
5267
github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
5368
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
69+
github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
5470
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
5571
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
5672
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
@@ -372,6 +388,7 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
372388
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
373389
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
374390
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
391+
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
375392
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
376393
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
377394
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
@@ -449,12 +466,17 @@ github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
449466
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
450467
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
451468
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
469+
github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex1PFV8g=
470+
github.com/uber/jaeger-client-go v2.15.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
471+
github.com/uber/jaeger-lib v1.5.0/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
452472
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
453473
github.com/unrolled/secure v0.0.0-20180918153822-f340ee86eb8b/go.mod h1:mnPT77IAdsi/kV7+Es7y+pXALeV3h7G6dQF6mNYjcLA=
454474
github.com/unrolled/secure v0.0.0-20181005190816-ff9db2ff917f/go.mod h1:mnPT77IAdsi/kV7+Es7y+pXALeV3h7G6dQF6mNYjcLA=
455475
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
456476
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
477+
go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0=
457478
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
479+
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
458480
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
459481
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
460482
golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -480,6 +502,7 @@ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTk
480502
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI=
481503
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
482504
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
505+
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
483506
golang.org/x/net v0.0.0-20180816102801-aaf60122140d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
484507
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
485508
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -498,6 +521,7 @@ golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73r
498521
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
499522
golang.org/x/net v0.0.0-20190301231341-16b79f2e4e95/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
500523
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
524+
golang.org/x/net v0.0.0-20190322120337-addf6b3196f6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
501525
golang.org/x/net v0.0.0-20190328230028-74de082e2cca h1:hyA6yiAgbUwuWqtscNvWAI7U1CtlaD1KilQ6iudt1aI=
502526
golang.org/x/net v0.0.0-20190328230028-74de082e2cca/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
503527
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
@@ -612,3 +636,5 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
612636
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
613637
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
614638
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
639+
pack.ag/amqp v0.8.0/go.mod h1:4/cbmt4EJXSKlG6LCfWHoqmN0uFdy5i/+YFz+fTfhV4=
640+
pack.ag/amqp v0.11.0/go.mod h1:4/cbmt4EJXSKlG6LCfWHoqmN0uFdy5i/+YFz+fTfhV4=

internal/config/config.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package config
22

3-
import "time"
3+
import (
4+
"time"
5+
)
46

57
// Config defines the configuration structure.
68
type Config struct {
@@ -91,6 +93,15 @@ type Config struct {
9193
Bind string `mapstructure:"bind"`
9294
}
9395
}
96+
97+
MetaData struct {
98+
Static map[string]string `mapstructure:"static"`
99+
Dynamic struct {
100+
ExecutionInterval time.Duration `mapstructure:"execution_interval"`
101+
MaxExecutionDuration time.Duration `mapstructure:"max_execution_duration"`
102+
Commands map[string]string `mapstructure:"commands"`
103+
} `mapstructure:"dynamic"`
104+
} `mapstructure:"meta_data"`
94105
}
95106

96107
// C holds the global configuration.

internal/forwarder/forwarder.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/brocaar/lora-gateway-bridge/internal/backend"
88
"github.com/brocaar/lora-gateway-bridge/internal/config"
99
"github.com/brocaar/lora-gateway-bridge/internal/integration"
10+
"github.com/brocaar/lora-gateway-bridge/internal/metadata"
1011
"github.com/brocaar/loraserver/api/gw"
1112
"github.com/brocaar/lorawan"
1213
)
@@ -108,6 +109,9 @@ func forwardGatewayStatsLoop() {
108109
var gatewayID lorawan.EUI64
109110
copy(gatewayID[:], stats.GatewayId)
110111

112+
// add meta-data to stats
113+
stats.MetaData = metadata.Get()
114+
111115
if err := integration.GetIntegration().PublishEvent(gatewayID, integration.EventStats, &stats); err != nil {
112116
log.WithError(err).WithFields(log.Fields{
113117
"gateway_id": gatewayID,

0 commit comments

Comments
 (0)