Skip to content

Commit

Permalink
Merge pull request #125 from circonus-labs/CIRC-10017
Browse files Browse the repository at this point in the history
v0.2.11
  • Loading branch information
maier committed Mar 28, 2023
2 parents 2d7f054 + d935407 commit 6f7c983
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 78 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# **unreleased**

# v0.2.11

* CIRC-10017 feat: multiple circonus outputs with full metrics to all (sub_output=false)
* feat: add payload size metrics to agent check
* build(deps): update go-trapcheck from v0.0.9 to v0.0.10
* build(deps): update go-trapmetrics from v0.0.10 to v0.0.11
* CIRC-10016 feat(elasticsearch): add option `strip_tag_prefix` to remote the `tag.` prefix from tag
* CIRC-9909 feat: trim spaces from front/back of check target
* CIRC-9909 feat: strip non-printable characters from check target

# v0.2.10

* feat(ping): add option `no_rtt_histograms`
Expand Down
17 changes: 17 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"sort"
"strconv"
"strings"
"sync"
"time"
"unicode"

Expand Down Expand Up @@ -1192,6 +1193,12 @@ func (c *Config) addInput(name string, table *ast.Table) error {
name = "diskio"
}

if runtime.GOOS == "darwin" {
if name == "diskio" || name == "cpu" {
return nil
}
}

creator, ok := inputs.Inputs[name]
if !ok {
return fmt.Errorf("Undefined but requested input: %s", name)
Expand Down Expand Up @@ -1869,6 +1876,7 @@ object = [
// for containerized agent instances. (they can be controlled
// via an environment variable `ENABLE_DEFAULT_PLUGINS` - empty
// or any value other than "false" will ENABLE the default plugins)
var defaultPluginListMU sync.Mutex
var defaultPluginList = map[string]circonusPlugin{
"cpu": {
Enabled: true,
Expand Down Expand Up @@ -1920,8 +1928,11 @@ ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squash
//

func getDefaultPluginList() *map[string]circonusPlugin {

switch runtime.GOOS {
case "darwin":
defaultPluginListMU.Lock()
defer defaultPluginListMU.Unlock()
// disable plugins which don't work on darwin
if cfg, ok := defaultPluginList["cpu"]; ok {
cfg.Enabled = false
Expand Down Expand Up @@ -1962,6 +1973,8 @@ func IsDefaultPlugin(name string) bool {
name = "internal"
}

defaultPluginListMU.Lock()
defer defaultPluginListMU.Unlock()
if _, ok := (*plugList)[name]; ok {
return true
}
Expand All @@ -1978,6 +1991,8 @@ func (c *Config) disableDefaultPlugin(name string) {
return
}

defaultPluginListMU.Lock()
defer defaultPluginListMU.Unlock()
if cfg, ok := (*plugList)[name]; ok {
cfg.Enabled = false
(*plugList)[name] = cfg
Expand All @@ -1997,6 +2012,8 @@ func (c *Config) addDefaultPlugins() error {
return fmt.Errorf("no default plugin list available for GOOS %s", runtime.GOOS)
}

defaultPluginListMU.Lock()
defer defaultPluginListMU.Unlock()
for pluginName, pluginConfig := range *plugList {
if !pluginConfig.Enabled {
continue // user override in configuration
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ require (
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
github.com/cenkalti/backoff v2.0.0+incompatible // indirect
github.com/circonus-labs/go-apiclient v0.7.23
github.com/circonus-labs/go-trapcheck v0.0.9
github.com/circonus-labs/go-trapmetrics v0.0.10
github.com/circonus-labs/go-trapcheck v0.0.10
github.com/circonus-labs/go-trapmetrics v0.0.11
github.com/cisco-ie/nx-telemetry-proto v0.0.0-20220628142927-f4160bcb943c
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/couchbase/go-couchbase v0.0.0-20180501122049-16db1f1fe037
Expand Down Expand Up @@ -114,11 +114,11 @@ require (
github.com/yuin/gopher-lua v0.0.0-20180630135845-46796da1b0b4 // indirect
go.starlark.net v0.0.0-20200901195727-6e684ef5eeee
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b
golang.org/x/net v0.8.0
golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
golang.org/x/sys v0.5.0
golang.org/x/text v0.3.7
golang.org/x/sync v0.1.0
golang.org/x/sys v0.6.0
golang.org/x/text v0.8.0
golang.zx2c4.com/wireguard v0.0.0-20210604143328-f9b48a961cd2 // indirect
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20210506160403-92e472f520a5
google.golang.org/api v0.91.0
Expand Down
34 changes: 24 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ github.com/cilium/ebpf v0.5.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJ
github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs=
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/circonus-labs/go-apiclient v0.7.18/go.mod h1:NCu3kJ282ZGzr7vxzFH/S28y1nW9DZ37f8L7veDENFc=
github.com/circonus-labs/go-apiclient v0.7.22/go.mod h1:NCu3kJ282ZGzr7vxzFH/S28y1nW9DZ37f8L7veDENFc=
github.com/circonus-labs/go-apiclient v0.7.23 h1:Bk+l9qLUHPGYND8z8Zxw3+d913ZIybD4CH1y5xSdtCk=
github.com/circonus-labs/go-apiclient v0.7.23/go.mod h1:arbbVvv/xFMvD1eSJqkS+Je1sN/JCpHtiL2GV6oA1Mg=
github.com/circonus-labs/go-trapcheck v0.0.9 h1:avgxD4QyB44sNl8IkjeA68/L8Yanl0YdwrCJdME0Qfg=
github.com/circonus-labs/go-trapcheck v0.0.9/go.mod h1:xZpt1/2XJTmhcvW/OOGrv4zW4SHNzj4twr6tY9IkXeQ=
github.com/circonus-labs/go-trapmetrics v0.0.10 h1:G0qTlbkrTShAG5tRBX61KwBLGsjfFZGMdklRspaFW8I=
github.com/circonus-labs/go-trapmetrics v0.0.10/go.mod h1:ojDq1/l0z+CYgrnOjvU2xKejBHjn0wHGLLjxfxCHCr8=
github.com/circonus-labs/go-trapcheck v0.0.10 h1:1L5BY3aBZKQea5MHl5Ozio1+K4DUtPGP3FAHk16zDs4=
github.com/circonus-labs/go-trapcheck v0.0.10/go.mod h1:wI9cSB8ICPM6HgFrygnWFbJkbXbj8rwCMSnNwBvR0Y0=
github.com/circonus-labs/go-trapmetrics v0.0.11 h1:GTao7LCFYSaQ3hgcJzYyGnoLIwlRf62e/htkJ2ReUP8=
github.com/circonus-labs/go-trapmetrics v0.0.11/go.mod h1:QL3GjJ0WAwTKLCZ1UET8FoeAy/c+wTowmZCH+HT4Zjc=
github.com/cisco-ie/nx-telemetry-proto v0.0.0-20220628142927-f4160bcb943c h1:k3y2XtIffIk230a+e0d7vbs5ebTvH3OcCMKN/jS6IAY=
github.com/cisco-ie/nx-telemetry-proto v0.0.0-20220628142927-f4160bcb943c/go.mod h1:rJDd05J5hqWVU9MjJ+5jw1CuLn/jRhvU0xtFEzzqjwM=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand Down Expand Up @@ -1186,6 +1186,7 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/gopher-lua v0.0.0-20180630135845-46796da1b0b4 h1:f6CCNiTjQZ0uWK4jPwhwYB8QIGGfn0ssD9kVzRUUUpk=
github.com/yuin/gopher-lua v0.0.0-20180630135845-46796da1b0b4/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
Expand Down Expand Up @@ -1279,6 +1280,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -1350,8 +1353,10 @@ golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -1385,8 +1390,10 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -1513,12 +1520,15 @@ golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1527,8 +1537,10 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -1600,6 +1612,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
1 change: 1 addition & 0 deletions internal/circonus/circonus.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ func NewMetricDestination(opts *MetricDestConfig, logger cua.Logger) (*trapmetri
}

// ignore any non-printable characters
checkTarget = strings.TrimSpace(checkTarget) // strip whitespace from front/back of string
checkTarget = strings.Map(func(r rune) rune {
if unicode.IsPrint(r) {
return r
Expand Down
89 changes: 45 additions & 44 deletions plugins/outputs/circonus/circonus.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ const (
defaultWorkerPoolSize = 2
)

var (
agentDestination *metricDestination
hostDestination *metricDestination
checkmu sync.Mutex
)
// var (
// agentDestination *metricDestination
// hostDestination *metricDestination
// checkmu sync.Mutex
// )

// Circonus values are used to output data to the Circonus platform.
type Circonus struct {
Expand All @@ -35,21 +35,23 @@ type Circonus struct {
DebugAPI *bool `toml:"debug_api"`
TraceMetrics *string `toml:"trace_metrics"`
processors processors
DebugChecks map[string]string `toml:"debug_checks"` // optional: use when instructed by circonus support
DebugChecks map[string]string `toml:"debug_checks"`
metricDestinations map[string]*metricDestination
CacheDir string `toml:"cache_dir"` // optional: where to cache the check bundle configurations - must be read/write for user running cua
APITLSCA string `toml:"api_tls_ca"` // optional: override agent.circonus api ca cert file
APIApp string `toml:"api_app"` // optional: override agent.circonus api app (default: circonus-unified-agent)
APIURL string `toml:"api_url"` // optional: override agent.circonus api url (default: https://api.circonus.com/v2)
Broker string `toml:"broker"` // optional: override agent.circonus broker ID - numeric portion of _cid from broker api object (default is selected: enterprise or public httptrap broker)
APIToken string `toml:"api_token"` // optional: override agent.circonus api token
AgentTarget string `toml:"agent_check_target"` // optional: send agent metrics to a dedicated check if there are multiple agents on the same host
CheckSearchTags []string `toml:"check_search_tags"` // optional: set of tags to use when searching for checks (default: service:circonus-unified-agentd)
PoolSize int `toml:"pool_size"` // size of the processor pool for a given output instance - default 2
DebugMetrics bool `toml:"debug_metrics"` // output the metrics as they are being parsed, use to verify proper parsing/tags/etc.
SubOutput bool `toml:"sub_output"` // a dedicated, special purpose, output, don't send internal cua version, etc.
CacheConfigs bool `toml:"cache_configs"` // optional: cache check bundle configurations - efficient for large number of inputs
AllowSNMPTrapEvents bool `toml:"allow_snmp_trap_events"` // optional: send snmp_trap text events to circonus - may result in high billing costs
hostDestination *metricDestination
agentDestination *metricDestination
APIApp string `toml:"api_app"`
APIURL string `toml:"api_url"`
Broker string `toml:"broker"`
APIToken string `toml:"api_token"`
AgentTarget string `toml:"agent_check_target"`
APITLSCA string `toml:"api_tls_ca"`
CacheDir string `toml:"cache_dir"`
CheckSearchTags []string `toml:"check_search_tags"`
PoolSize int `toml:"pool_size"`
DebugMetrics bool `toml:"debug_metrics"`
SubOutput bool `toml:"sub_output"`
CacheConfigs bool `toml:"cache_configs"`
AllowSNMPTrapEvents bool `toml:"allow_snmp_trap_events"`
}

// processors handle incoming batches
Expand Down Expand Up @@ -136,34 +138,33 @@ var description = "Configuration for Circonus output plugin."
// Conenct creates the initial check the plugin will use
func (c *Circonus) Connect() error {

checkmu.Lock()
defer checkmu.Unlock()
// checkmu.Lock()
// defer checkmu.Unlock()

if c.metricDestinations == nil {
c.Lock()
c.metricDestinations = make(map[string]*metricDestination)
c.Unlock()
}

if agentDestination == nil {
meta := circmgr.MetricMeta{
PluginID: "agent",
InstanceID: config.DefaultInstanceID(),
}
if !c.SubOutput {
if c.agentDestination == nil {
meta := circmgr.MetricMeta{
PluginID: "agent",
InstanceID: config.DefaultInstanceID(),
}

if err := c.initMetricDestination(meta, map[string]string{}, c.AgentTarget, ""); err != nil {
c.Log.Errorf("unable to initialize circonus metric destination (%s)", err)
return err
}
destKey := meta.Key()
if d, ok := c.metricDestinations[destKey]; ok {
agentDestination = d
if err := c.initMetricDestination(meta, map[string]string{}, c.AgentTarget, ""); err != nil {
c.Log.Errorf("unable to initialize circonus metric destination (%s)", err)
return err
}
destKey := meta.Key()
if d, ok := c.metricDestinations[destKey]; ok {
c.agentDestination = d
}
}
}

if !c.SubOutput {
if config.DefaultPluginsEnabled() {
if hostDestination == nil {
if c.hostDestination == nil {
meta := circmgr.MetricMeta{
PluginID: "host",
InstanceID: config.DefaultInstanceID(),
Expand All @@ -174,7 +175,7 @@ func (c *Circonus) Connect() error {
}
destKey := meta.Key()
if d, ok := c.metricDestinations[destKey]; ok {
hostDestination = d
c.hostDestination = d
}
}
}
Expand All @@ -198,18 +199,18 @@ func (c *Circonus) Connect() error {

func (c *Circonus) emitAgentVersion() {
agentVersion := inter.Version()
if agentDestination != nil {
if c.agentDestination != nil {
ts := time.Now()
_ = agentDestination.metrics.TextSet("cua_version", nil, agentVersion, &ts)
agentDestination.queuedMetrics++
_ = c.agentDestination.metrics.TextSet("cua_version", nil, agentVersion, &ts)
c.agentDestination.queuedMetrics++
}
}

func (c *Circonus) emitRuntime() {
if agentDestination != nil {
if c.agentDestination != nil {
ts := time.Now()
_ = agentDestination.metrics.GaugeSet("cua_runtime", trapmetrics.Tags{{Category: "units", Value: "seconds"}}, time.Since(c.startTime).Seconds(), &ts)
agentDestination.queuedMetrics++
_ = c.agentDestination.metrics.GaugeSet("cua_runtime", trapmetrics.Tags{{Category: "units", Value: "seconds"}}, time.Since(c.startTime).Seconds(), &ts)
c.agentDestination.queuedMetrics++
}
}

Expand Down

0 comments on commit 6f7c983

Please sign in to comment.