├── .gitignore ├── .go-version ├── .travis.yml ├── .version ├── LICENSE ├── README.md ├── build.sh ├── go.mod ├── go.sum ├── gosmart ├── api.go └── gosmart.go ├── installerManifest.json ├── smartapps └── kadaan │ └── smartthings-exporter-api.src │ └── smartthings-exporter-api.groovy └── smartthings_exporter.go /.gitignore: -------------------------------------------------------------------------------- 1 | .st_token 2 | .bin/ 3 | .idea/ 4 | dist/ 5 | vendor/ 6 | -------------------------------------------------------------------------------- /.go-version: -------------------------------------------------------------------------------- 1 | 1.15.0 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.15 4 | script: "./build.sh" 5 | deploy: 6 | provider: releases 7 | api_key: 8 | secure: JuAICm7Uf3vOr5qvWsFxHzqA1fSiJMy06RZA6tDUNUHcRO2fmnWH1OAR45GOeI/AS9PKEUnz1Aoo95erpCoDY11nqgvfCE0jwND52n1cBnEWUcJPDTi8+xEt9eDEtxhP2hB6mW1IeHg88VohEWsvfm/NVZ5/wQdXs6p0bKtto0LyqlefYXy6qeI+pk0d78t4Lq1NVEt+6e4m79/PFfyf+LkttPbg8PNrenTXGYVSa5ZLXBj3+srms7MUeg82zp4p/DtqaJc99OdKHTUreytp1xNyOF/fgLLUWdBb11npEYq/bkoGoliKFKnA2onBnVVdZVkH8COfYMr1rZCeuhH+fl6BFX1o7y7N/+98fr6Fw+O8BIzO8sbWq74zvAC2loRytVy1MH/RWSD6S4NBQU/lmw14mYIc29MtkK5cmLDLWRB0+XMDmOMzbzieMCcKeRn3SxoXakLZ0RgWh5NB33CXuOO9TG2VVfBWIqJWQRAmuBEm44ZO2mmMwOOL52Ti1fo9VI8HmimoSBDd2ewUHL+LId/JyD0mXkVKhYbvrc7HCqUK7WM/xPMdqMppDZ7BWzPjqk4cQWamoPkjTUR+s9Cj182WRpXi7MacmYXMNvGpScWTqSnIOhdsZtzNNY71Ldu27sK8yMhX0jNL1HdhmMm2R1hahNkMTV4GqlvSiXY3xak= 9 | file_glob: true 10 | file: dist/*.tar.gz 11 | skip_cleanup: true 12 | on: 13 | repo: kadaan/smartthings_exporter 14 | tags: true 15 | -------------------------------------------------------------------------------- /.version: -------------------------------------------------------------------------------- 1 | 0.0.4 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # smarthings_exporter [![Build Status](https://travis-ci.org/kadaan/smartthings_exporter.svg?branch=master)](https://travis-ci.org/kadaan/smartthings_exporter) [![Coverage Status](https://img.shields.io/coveralls/github/kadaan/smartthings_exporter/master.svg)](https://coveralls.io/github/kadaan/smartthings_exporter) [![Go Report Card](https://goreportcard.com/badge/github.com/kadaan/smartthings_exporter)](https://goreportcard.com/report/github.com/kadaan/smartthings_exporter) 2 | 3 | Smartthings_exporter is a command line tool to export information about your SmartThings 4 | sensors in a format that can be scraped by [Prometheus](http://prometheus.io). The tool talks 5 | to the SmartThings API and collects sensor data which is exposed as metrics over http. 6 | 7 | ## Installation 8 | 9 | The installation instructions assume a properly installed and configured Go 10 | development environment. The very first step is to download and build 11 | Smartthings_exporter (this step will also download and compile the GoSmart library): 12 | 13 | 14 | ``` 15 | $ go get -u github.com/kadaan/smartthings_exporter 16 | ``` 17 | 18 | ### SmartThings Setup 19 | 20 | Before you can use Smartthings_exporter, you need to register it with SmartThings. 21 | 22 | The first step is to setup the API that Smartthings_exporter uses to communicate with SmartThings. To do this you need to: 23 | 24 | 1. Navigate to the [SmartThings API website](https://graph.api.smartthings.com/). Register a new account (or login if you already have an account). 25 | 2. Once logged in, click on My SmartApps. This will show a list of the current SmartApps installed (it could be blank for new accounts). 26 | 3. Click the `Settings` button at the top right. 27 | 4. Click the `Add new repository` link at the bottom of the settings dialog box. 28 | 5. In the new row fill in: 29 | 1. Owner: `kadaan` 30 | 2. Name: `smartthings_exporter` 31 | 3. Branch: `master` 32 | 6. Press `Save` 33 | 7. Click `Update from Repo` at the top right 34 | 8. Choose `smartthings_exporter (master)` 35 | 9. Under the `New` list on the right check `smartapps/kadaan/smartthings-exporter-api.src/smartthings-exporter-api.groovy` 36 | 10. Check `Publish` at the bottom 37 | 11. Click `Execute Update` 38 | 12. Click the `Edit Properties` button for the `kadaan : Smartthings Exporter API` entry 39 | 13. Click `OAuth` 40 | 14. Click `Enable OAuth in SmartApp` 41 | 15. In `Redirect URI`, enter `http://localhost:4567/OAuthCallback`. _Case is important here_ 42 | 16. Click `Update` 43 | 17. Click `OAuth` 44 | 18. Take note of the `Client ID` and `Client Secret`. These will be used to authenticate and retrieve a token. Once the token is saved locally by the library, authentication can proceed without user intervention. 45 | 46 | ### Smartthings_exporter configuration 47 | 48 | We now need to register Smartthings_exporter to with your SmartThings app. 49 | 50 | Run: 51 | 52 | ``` 53 | $ smartthings_exporter register --smartthings.oauth-client=[client_id] > .st_token 54 | ``` 55 | 56 | Follow the prompts to authorize the app. 57 | 58 | ## Running 59 | 60 | Now we can start Smartthings_exporter by running: 61 | 62 | ``` 63 | $ smartthings_exporter --smartthings.oauth-client=[client_id] --smartthings.oauth-token.file=.st_token 64 | ``` 65 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright © 2018 Joel Baranick 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | BUILD_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" 19 | BINARY_DIR="$BUILD_DIR/.bin" 20 | VERSION=$(cat $BUILD_DIR/.version) 21 | 22 | function verbose() { echo -e "$*"; } 23 | function error() { echo -e "ERROR: $*" 1>&2; } 24 | function fatal() { echo -e "ERROR: $*" 1>&2; exit 1; } 25 | function pushd () { command pushd "$@" > /dev/null; } 26 | function popd () { command popd > /dev/null; } 27 | 28 | function trap_add() { 29 | localtrap_add_cmd=$1; shift || fatal "${FUNCNAME} usage error" 30 | for trap_add_name in "$@"; do 31 | trap -- "$( 32 | extract_trap_cmd() { printf '%s\n' "$3"; } 33 | eval "extract_trap_cmd $(trap -p "${trap_add_name}")" 34 | printf '%s\n' "${trap_add_cmd}" 35 | )" "${trap_add_name}" || fatal "unable to add to trap ${trap_add_name}" 36 | done 37 | } 38 | declare -f -t trap_add 39 | 40 | function get_platform() { 41 | local unameOut="$(uname -s)" 42 | case "${unameOut}" in 43 | Linux*) 44 | echo "linux" 45 | ;; 46 | Darwin*) 47 | echo "darwin" 48 | ;; 49 | *) 50 | echo "Unsupported machine type :${unameOut}" 51 | exit 1 52 | ;; 53 | esac 54 | } 55 | 56 | PLATFORM=$(get_platform) 57 | GOX="gox" 58 | GOCILINTER=${BINARY_DIR}/golangci-lint 59 | GOCILINTER_URL=https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh 60 | GOCILINTER_VERSION=v1.30.0 61 | UPX="$BINARY_DIR/upx" 62 | 63 | function download_gocilinter() { 64 | if [[ ! -f "$GOCILINTER" ]]; then 65 | verbose " --> $GOCILINTER" 66 | curl -sSfL $GOCILINTER_URL | sh -s -- -b ${BINARY_DIR} $GOCILINTER_VERSION || fatal "failed to download '$GOCILINTER_URL': $?" 67 | fi 68 | } 69 | 70 | function download_gox() { 71 | if [[ ! -x "$(command -v $GOX)" ]]; then 72 | verbose " --> $GOX" 73 | go get github.com/mitchellh/gox || fatal "go get 'github.com/mitchellh/gox' failed: $?" 74 | fi 75 | } 76 | 77 | function download_goveralls() { 78 | if [[ -n "$TRAVIS" ]]; then 79 | if [[ ! -x "$(command -v goveralls)" ]]; then 80 | echo " --> goveralls" 81 | go get github.com/mattn/goveralls || fatal "go get 'github.com/mattn/goveralls' failed: $?" 82 | fi 83 | fi 84 | } 85 | 86 | function download_upx() { 87 | if [[ ! -x "$(command -v $UPX)" ]]; then 88 | verbose " --> $UPX " 89 | local upx_url="https://github.com/kadaan/upx/releases/download/20181231/upx_$PLATFORM" 90 | curl -o "$BINARY_DIR/upx" -sLO ${upx_url} || fatal "failed to download upx: $?" 91 | chmod +x "$BINARY_DIR/upx" 92 | fi 93 | } 94 | 95 | function download_binaries() { 96 | download_gox || fatal "failed to download 'gox': $?" 97 | download_gocilinter || fatal "failed to download 'gocilinter': $?" 98 | download_goveralls || fatal "failed to download 'goveralls': $?" 99 | download_upx || fatal "failed to download 'upx': $?" 100 | export PATH=$PATH:${BINARY_DIR} 101 | } 102 | 103 | function usage() { 104 | echo "Usage: build.sh [OPTIONS ...]" 105 | echo "Builds the binary for your platform, or all supported platforms when '--build_all' is specified." 106 | echo "" 107 | echo "Options:" 108 | echo " --build_all: build binaries for all supported platforms" 109 | echo " --clear_cache: clear the caches before running the build" 110 | echo " --help: display this help" 111 | echo "" 112 | } 113 | 114 | function parse_args() { 115 | for var in "${@}"; do 116 | case "$var" in 117 | --help) 118 | usage 119 | exit 0 120 | ;; 121 | --build_all) 122 | build_all=true 123 | ;; 124 | esac 125 | done 126 | } 127 | 128 | function run() { 129 | local build_all=false 130 | parse_args "$@" 131 | 132 | local revision=`git rev-parse HEAD` 133 | local branch=`git rev-parse --abbrev-ref HEAD` 134 | local host=`hostname` 135 | local buildDate=`date -u +"%Y-%m-%dT%H:%M:%SZ"` 136 | local go_version="$(cat ${BUILD_DIR}/.go-version)" 137 | go version | grep -q "go version go${go_version%*.0} " || fatal "go version is not ${go_version%*.0}" 138 | 139 | if [[ -z "$TRAVIS" ]]; then 140 | verbose "Cleanup dist..." 141 | rm -rf dist/* 142 | fi 143 | 144 | verbose "Fetching binaries..." 145 | download_binaries 146 | 147 | verbose "Getting dependencies..." 148 | go get || fatal "go get failed: $?" 149 | 150 | local gofiles=$(find . -path ./vendor -prune -o -print | grep '\.go$') 151 | 152 | verbose "Installing dependencies..." 153 | go install ./... || fatal "go install failed: $?" 154 | go test -i ./... || fatal "go test install failed: $?" 155 | 156 | verbose "Linting source..." 157 | ${GOCILINTER} run --disable-all --enable vet,gocyclo,golint,ineffassign,gofmt --verbose || fatal "gocilinter failed: $?" 158 | 159 | verbose "Checking licenses..." 160 | local licRes=$( 161 | for file in $(find . -type f -iname '*.go' ! -path './vendor/*'); do 162 | head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" || error " Missing license in: ${file}" 163 | done;) 164 | if [[ -n "${licRes}" ]]; then 165 | fatal "license header checking failed:\n${licRes}" 166 | fi 167 | 168 | verbose "Running tests..." 169 | if [[ -n "$TRAVIS" ]]; then 170 | goveralls -v -service=travis-ci -ignore=main.go,testutil/server.go,testutil/golden.go || fatal "goveralls: $?" 171 | else 172 | go test -v ./... || fatal "$gopackage tests failed: $?" 173 | fi 174 | 175 | XC_ARCH=${XC_ARCH:-"386 amd64 arm arm64"} 176 | XC_OS=${XC_OS:-"darwin linux windows"} 177 | if [[ -z "$TRAVIS" && "$build_all" != "true" ]]; then 178 | XC_OS=$(go env GOOS) 179 | XC_ARCH=$(go env GOARCH) 180 | fi 181 | 182 | verbose "Building binaries..." 183 | ${GOX} -os="${XC_OS}" -arch="${XC_ARCH}" -osarch="!darwin/arm !darwin/arm64 !darwin/386" -ldflags "-s -w -X github.com/kadaan/smartthings_exporter/vendor/github.com/prometheus/common/version.Version=$VERSION -X github.com/kadaan/smartthings_exporter/vendor/github.com/prometheus/common/version.Revision=$revision -X github.com/kadaan/smartthings_exporter/vendor/github.com/prometheus/common/version.Branch=$branch -X github.com/kadaan/smartthings_exporter/vendor/github.com/prometheus/common/version.BuildUser=$USER@$host -X github.com/kadaan/smartthings_exporter/vendor/github.com/prometheus/common/version.BuildDate=$buildDate" -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" || fatal "gox failed: $?" 184 | 185 | verbose "Compressing binaries..." 186 | for f in dist/*; do 187 | ${UPX} --best ${f} || fatal "failed to compress binary '$f': $?" 188 | done 189 | 190 | if [[ -n "$TRAVIS" ]]; then 191 | verbose "Creating archives..." 192 | cd dist 193 | set -x 194 | for f in *; do 195 | local filename=$(basename "$f") 196 | local extension="${filename##*.}" 197 | local filename="${filename%.*}" 198 | if [[ "$filename" != "$extension" ]] && [[ -n "$extension" ]]; then 199 | extension=".$extension" 200 | else 201 | extension="" 202 | fi 203 | local archivename="$filename.tar.gz" 204 | verbose " --> $archivename" 205 | local genericname="smartthings_exporter$extension" 206 | mv -f "$f" "$genericname" 207 | tar -czf ${archivename} "$genericname" 208 | rm -rf "$genericname" 209 | done 210 | fi 211 | } 212 | 213 | run "$@" 214 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/kadaan/smartthings_exporter 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/prometheus/client_golang v1.7.1 7 | github.com/prometheus/common v0.13.0 8 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 9 | golang.org/x/net v0.0.0-20200822124328-c89045814202 10 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d 11 | gopkg.in/alecthomas/kingpin.v2 v2.2.6 12 | ) 13 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 4 | github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= 5 | github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= 6 | github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= 7 | github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= 8 | github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= 9 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 10 | github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= 11 | github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 12 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 13 | github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 14 | github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= 15 | github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= 16 | github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= 17 | github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= 18 | github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= 19 | github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= 20 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= 21 | github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= 22 | github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= 23 | github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= 24 | github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= 25 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 26 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 27 | github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= 28 | github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= 29 | github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= 30 | github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= 31 | github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= 32 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 33 | github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= 34 | github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 35 | github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= 36 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 37 | github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= 38 | github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= 39 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 40 | github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 41 | github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 42 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 43 | github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= 44 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 45 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 46 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 47 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 48 | github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= 49 | github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= 50 | github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= 51 | github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= 52 | github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= 53 | github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= 54 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 55 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 56 | github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= 57 | github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= 58 | github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= 59 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 60 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 61 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 62 | github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 63 | github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= 64 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 65 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 66 | github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= 67 | github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= 68 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 69 | github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= 70 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 71 | github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 72 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 73 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 74 | github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 75 | github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 76 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 77 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 78 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 79 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 80 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 81 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 82 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 83 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 84 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 85 | github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= 86 | github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= 87 | github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 88 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 89 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 90 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 91 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 92 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 93 | github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= 94 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 95 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 96 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= 97 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 98 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 99 | github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 100 | github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 101 | github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 102 | github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 103 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 104 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 105 | github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 106 | github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= 107 | github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= 108 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 109 | github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= 110 | github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= 111 | github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= 112 | github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= 113 | github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= 114 | github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= 115 | github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= 116 | github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 117 | github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 118 | github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 119 | github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= 120 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 121 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 122 | github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= 123 | github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= 124 | github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= 125 | github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= 126 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 127 | github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= 128 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 129 | github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= 130 | github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= 131 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 132 | github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= 133 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 134 | github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 135 | github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 136 | github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 137 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 138 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 139 | github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= 140 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 141 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 142 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 143 | github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= 144 | github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 145 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 146 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 147 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 148 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 149 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 150 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 151 | github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= 152 | github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= 153 | github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= 154 | github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 155 | github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 156 | github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 157 | github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= 158 | github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= 159 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 160 | github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= 161 | github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= 162 | github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 163 | github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= 164 | github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= 165 | github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= 166 | github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 167 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 168 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 169 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 170 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 171 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 172 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 173 | github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 174 | github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= 175 | github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= 176 | github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= 177 | github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= 178 | github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= 179 | github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= 180 | github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= 181 | github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= 182 | github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= 183 | github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= 184 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 185 | github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 186 | github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 187 | github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= 188 | github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= 189 | github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= 190 | github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 191 | github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 192 | github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= 193 | github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= 194 | github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= 195 | github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= 196 | github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= 197 | github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= 198 | github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= 199 | github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= 200 | github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= 201 | github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= 202 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 203 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 204 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 205 | github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= 206 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 207 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 208 | github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= 209 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 210 | github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= 211 | github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= 212 | github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= 213 | github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= 214 | github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= 215 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 216 | github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 217 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 218 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 219 | github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 220 | github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= 221 | github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 222 | github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 223 | github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 224 | github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= 225 | github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= 226 | github.com/prometheus/common v0.13.0 h1:vJlpe9wPgDRM1Z+7Wj3zUUjY1nr6/1jNKyl7llliccg= 227 | github.com/prometheus/common v0.13.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= 228 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 229 | github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 230 | github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 231 | github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= 232 | github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= 233 | github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= 234 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= 235 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 236 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= 237 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 238 | github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= 239 | github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= 240 | github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= 241 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 242 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 243 | github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 244 | github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= 245 | github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= 246 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 247 | github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= 248 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 249 | github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= 250 | github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= 251 | github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 252 | github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= 253 | github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= 254 | github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= 255 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 256 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 257 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 258 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 259 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 260 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 261 | github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= 262 | github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= 263 | github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= 264 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 265 | go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 266 | go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= 267 | go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= 268 | go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= 269 | go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= 270 | go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 271 | go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= 272 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 273 | go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= 274 | go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= 275 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 276 | go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= 277 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 278 | golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 279 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 280 | golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 281 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 282 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 283 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= 284 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 285 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 286 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 287 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 288 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 289 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 290 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 291 | golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= 292 | golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 293 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 294 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 295 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 296 | golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 297 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 298 | golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 299 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 300 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 301 | golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 302 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 303 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 304 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 305 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 306 | golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 307 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 308 | golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 309 | golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 310 | golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= 311 | golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 312 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 313 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 314 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= 315 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 316 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 317 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 318 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 319 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 320 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 321 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 322 | golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 323 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 324 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 325 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 326 | golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 327 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 328 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 329 | golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 330 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 331 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 332 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 333 | golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 334 | golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 335 | golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 336 | golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 337 | golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 338 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 339 | golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 340 | golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= 341 | golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 342 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 343 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 344 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 345 | golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 346 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 347 | golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 348 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 349 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 350 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 351 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 352 | golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 353 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 354 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 355 | golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 356 | golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 357 | golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 358 | golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 359 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 360 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 361 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 362 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 363 | google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= 364 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 365 | google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 366 | google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= 367 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 368 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 369 | google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 370 | google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 371 | google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= 372 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 373 | google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= 374 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 375 | google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= 376 | google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= 377 | google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 378 | google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 379 | google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 380 | google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 381 | google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 382 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 383 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 384 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 385 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 386 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 387 | google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= 388 | google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 389 | gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= 390 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 391 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 392 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 393 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= 394 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 395 | gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= 396 | gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= 397 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 398 | gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= 399 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 400 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 401 | gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= 402 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 403 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 404 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 405 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 406 | gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 407 | gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= 408 | gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 409 | honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 410 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 411 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 412 | honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= 413 | sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= 414 | sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= 415 | -------------------------------------------------------------------------------- /gosmart/api.go: -------------------------------------------------------------------------------- 1 | // This file is part of gosmart, a set of libraries to communicate with 2 | // the Samsumg SmartThings API using Go (golang). 3 | // 4 | // http://github.com/marcopaganini/gosmart 5 | // (C) 2016 by Marco Paganini 6 | 7 | package gosmart 8 | 9 | import ( 10 | "encoding/json" 11 | "io/ioutil" 12 | "net/http" 13 | ) 14 | 15 | type getSensorsResult struct { 16 | Descriptions map[string]string `json:"descriptions"` 17 | Sensors map[string]sensorInfo `json:"sensors"` 18 | } 19 | 20 | type sensorInfo struct { 21 | Name string `json:"name"` 22 | DisplayName string `json:"displayName"` 23 | Attributes map[string]float64 `json:"attributes"` 24 | } 25 | 26 | type Attribute struct { 27 | Name string 28 | Description string 29 | Value float64 30 | } 31 | 32 | type Sensor struct { 33 | ID string 34 | Name string 35 | DisplayName string 36 | Attributes []Attribute 37 | } 38 | 39 | // GetSensors returns the list of devices from smartthings using 40 | // the specified http.client and endpoint URI. 41 | func GetSensors(client *http.Client, endpoint string) ([]Sensor, error) { 42 | contents, err := issueCommand(client, endpoint, "/sensors") 43 | if err != nil { 44 | return nil, err 45 | } 46 | 47 | ret := getSensorsResult{} 48 | if err := json.Unmarshal(contents, &ret); err != nil { 49 | return nil, err 50 | } 51 | 52 | var sensors []Sensor 53 | for id, sensorInfo := range ret.Sensors { 54 | var attributes []Attribute 55 | for name, value := range sensorInfo.Attributes { 56 | attribute := Attribute{ 57 | Name: name, 58 | Description: ret.Descriptions[name], 59 | Value: value, 60 | } 61 | attributes = append(attributes, attribute) 62 | } 63 | sensor := Sensor{ 64 | ID: id, 65 | Name: sensorInfo.Name, 66 | DisplayName: sensorInfo.DisplayName, 67 | Attributes: attributes, 68 | } 69 | sensors = append(sensors, sensor) 70 | } 71 | return sensors, nil 72 | } 73 | 74 | // issueCommand sends a given command to an URI and returns the contents 75 | func issueCommand(client *http.Client, endpoint string, cmd string) ([]byte, error) { 76 | uri := endpoint + cmd 77 | resp, err := client.Get(uri) 78 | if err != nil { 79 | return nil, err 80 | } 81 | contents, err := ioutil.ReadAll(resp.Body) 82 | resp.Body.Close() 83 | if err != nil { 84 | return nil, err 85 | } 86 | return contents, nil 87 | } 88 | -------------------------------------------------------------------------------- /gosmart/gosmart.go: -------------------------------------------------------------------------------- 1 | // This file is part of gosmart, a set of libraries to communicate with 2 | // the Samsung SmartThings API using Go (golang). 3 | // 4 | // http://github.com/marcopaganini/gosmart 5 | // (C) 2016 by Marco Paganini 6 | 7 | package gosmart 8 | 9 | import ( 10 | "crypto/rand" 11 | "encoding/json" 12 | "errors" 13 | "fmt" 14 | "golang.org/x/oauth2" 15 | "io/ioutil" 16 | "net/http" 17 | "os/user" 18 | "path/filepath" 19 | "strconv" 20 | "time" 21 | ) 22 | 23 | const ( 24 | authDone = "Authentication Completed." 25 | authError = "AUthentication error. Please see terminal output for details." 26 | 27 | // Endpoints URL 28 | endPointsURI = "https://graph.api.smartthings.com/api/smartapps/endpoints" 29 | 30 | // URL paths used for Oauth authentication on localhost 31 | callbackPath = "/OAuthCallback" 32 | donePath = "/OauthDone" 33 | rootPath = "/" 34 | 35 | // Token save file 36 | defaultTokenFile = ".st_token.json" 37 | 38 | // default local HTTP server port 39 | defaultPort = 4567 40 | ) 41 | 42 | // Auth contains the SmartThings authentication related data. 43 | type Auth struct { 44 | port int 45 | config *oauth2.Config 46 | rchan chan oauthReturn 47 | oauthStateString string 48 | } 49 | 50 | // oauthReturn contains the values returned by the OAuth callback handler. 51 | type oauthReturn struct { 52 | token *oauth2.Token 53 | err error 54 | } 55 | 56 | // endpoints holds the values returned by the SmartThings endpoints URI. 57 | type endpoints struct { 58 | OauthClient struct { 59 | ClientID string `json:"clientId"` 60 | } 61 | Location struct { 62 | ID string `json:"id"` 63 | Name string `json:"name"` 64 | } 65 | URI string `json:"uri"` 66 | BaseURL string `json:"base_url"` 67 | URL string `json:"url"` 68 | } 69 | 70 | // NewOAuthConfig creates a new oauth2.config structure with the 71 | // correct parameters to use smartthings. 72 | func NewOAuthConfig(client, secret string) *oauth2.Config { 73 | return &oauth2.Config{ 74 | ClientID: client, 75 | ClientSecret: secret, 76 | Scopes: []string{"app"}, 77 | Endpoint: oauth2.Endpoint{ 78 | AuthURL: "https://graph.api.smartthings.com/oauth/authorize", 79 | TokenURL: "https://graph.api.smartthings.com/oauth/token", 80 | }, 81 | } 82 | } 83 | 84 | // NewAuth creates a new Auth struct 85 | func NewAuth(port int, config *oauth2.Config) (*Auth, error) { 86 | rnd, err := randomString(16) 87 | if err != nil { 88 | return nil, err 89 | } 90 | 91 | return &Auth{ 92 | port: port, 93 | config: config, 94 | rchan: make(chan oauthReturn), 95 | oauthStateString: rnd, 96 | }, nil 97 | } 98 | 99 | // FetchOAuthToken sets up the handler and a local HTTP server and fetches an 100 | // Oauth token from the smartthings website. 101 | func (g *Auth) FetchOAuthToken() (*oauth2.Token, error) { 102 | mux := http.NewServeMux() 103 | mux.HandleFunc(rootPath, g.handleMain) 104 | mux.HandleFunc(donePath, g.handleDone) 105 | mux.HandleFunc(callbackPath, g.handleOAuthCallback) 106 | srv := &http.Server{ 107 | Addr: ":" + strconv.Itoa(g.port), 108 | Handler: mux, 109 | } 110 | 111 | go srv.ListenAndServe() 112 | 113 | // Block on the return channel (this is set by handleOauthCallback) 114 | ret := <-g.rchan 115 | time.Sleep(3 * time.Second) 116 | srv.Close() 117 | return ret.token, ret.err 118 | } 119 | 120 | // handleMain redirects the user to the main authentication page. 121 | func (g *Auth) handleMain(w http.ResponseWriter, r *http.Request) { 122 | url := g.config.AuthCodeURL(g.oauthStateString) 123 | http.Redirect(w, r, url, http.StatusTemporaryRedirect) 124 | } 125 | 126 | // handleError shows a page indicating the authentication has failed. 127 | func (g *Auth) handleError(w http.ResponseWriter, r *http.Request) { 128 | fmt.Fprintf(w, authError) 129 | } 130 | 131 | // handleDone shows a page indicating the authentication is finished. 132 | func (g *Auth) handleDone(w http.ResponseWriter, r *http.Request) { 133 | fmt.Fprintf(w, authDone) 134 | } 135 | 136 | // handleOauthCallback fetches the callback from the OAuth provider and parses 137 | // the URL, extracting the code and then exchanging it for a token. 138 | func (g *Auth) handleOAuthCallback(w http.ResponseWriter, r *http.Request) { 139 | // Make sure we have the same "state" as our request. 140 | state := r.FormValue("state") 141 | if state != g.oauthStateString { 142 | g.rchan <- oauthReturn{ 143 | token: nil, 144 | err: fmt.Errorf("invalid oauth state, expected %q, got %q", g.oauthStateString, state), 145 | } 146 | return 147 | } 148 | 149 | // Retrieve the code from the URL, and exchange for a token 150 | code := r.FormValue("code") 151 | token, err := g.config.Exchange(oauth2.NoContext, code) 152 | if err != nil { 153 | g.rchan <- oauthReturn{ 154 | token: nil, 155 | err: fmt.Errorf("code exchange failed: %q", err), 156 | } 157 | return 158 | } 159 | 160 | // Return token. 161 | g.rchan <- oauthReturn{ 162 | token: token, 163 | err: nil, 164 | } 165 | // Redirect user to "Authentication done" page 166 | http.Redirect(w, r, donePath, http.StatusTemporaryRedirect) 167 | return 168 | } 169 | 170 | // GetEndPointsURI returns the smartthing endpoints URI. The endpoints 171 | // URI is the base for all app requests. 172 | func GetEndPointsURI(client *http.Client) (string, error) { 173 | // Fetch the JSON containing our endpoint URI 174 | resp, err := client.Get(endPointsURI) 175 | if err != nil { 176 | return "", fmt.Errorf("error getting endpoints URI: %q", err) 177 | } 178 | contents, err := ioutil.ReadAll(resp.Body) 179 | if err != nil { 180 | return "", fmt.Errorf("error reading endpoints URI data: %q", err) 181 | } 182 | resp.Body.Close() 183 | if string(contents) == "[]" { 184 | return "", fmt.Errorf("endpoint URI returned no content") 185 | } 186 | 187 | // Only URI is fetched from JSON string. 188 | var ep []endpoints 189 | err = json.Unmarshal(contents, &ep) 190 | if err != nil { 191 | return "", fmt.Errorf("error decoding JSON: %q", err) 192 | } 193 | return ep[0].URI, nil 194 | } 195 | 196 | // LoadToken loads the token from a file on disk. If nil is used for filename 197 | // a default filename user the user's directory is used. 198 | func LoadToken(fname string) (*oauth2.Token, error) { 199 | // Generate token filename 200 | fname, err := makeTokenFile(fname) 201 | if err != nil { 202 | return nil, err 203 | } 204 | 205 | // Read & Decode JSON 206 | blob, err := ioutil.ReadFile(fname) 207 | if err != nil { 208 | return nil, err 209 | } 210 | token := &oauth2.Token{} 211 | if err := json.Unmarshal(blob, token); err != nil { 212 | return nil, err 213 | } 214 | 215 | return token, nil 216 | } 217 | 218 | // SaveToken saves the token to a file on disk. If nil is used for filename 219 | // a default filename user the user's directory is used. 220 | func SaveToken(fname string, token *oauth2.Token) error { 221 | // Generate token filename 222 | fname, err := makeTokenFile(fname) 223 | if err != nil { 224 | return err 225 | } 226 | 227 | // Encode & Save 228 | blob, err := json.Marshal(token) 229 | if err != nil { 230 | return err 231 | } 232 | return ioutil.WriteFile(fname, blob, 0600) 233 | } 234 | 235 | // randomString generates a random string of bytes of the specified size 236 | // and returns the its hexascii representation. 237 | func randomString(size int) (string, error) { 238 | b := make([]byte, size) 239 | _, err := rand.Read(b) 240 | if err != nil { 241 | return "", err 242 | } 243 | return fmt.Sprintf("%x", b), nil 244 | } 245 | 246 | // GetToken returns the token for the ClientID and Secret specified in config. 247 | // The function attempts to load the token from tokenFile first, and failing 248 | // that, starts a full token authentication cycle with SmartThings. If 249 | // tokenFile is blank, the function uses a default name under the current 250 | // user's home directory. The token is saved to local disk before being 251 | // returned to the caller. 252 | // 253 | // This function represents the most common (and possibly convenient) way to 254 | // retrieve a token for a given ClientID and Secret. 255 | func GetToken(tokenFile string, config *oauth2.Config) (*oauth2.Token, error) { 256 | // Attempt to load token from local storage. Fallback to full auth cycle. 257 | token, err := LoadToken(tokenFile) 258 | if err != nil || !token.Valid() { 259 | if config.ClientID == "" || config.ClientSecret == "" { 260 | return nil, errors.New("need ClientID and secret to generate a new token") 261 | } 262 | gst, err := NewAuth(defaultPort, config) 263 | if err != nil { 264 | return nil, err 265 | } 266 | 267 | fmt.Printf("Please login by visiting http://localhost:%d\n", defaultPort) 268 | token, err = gst.FetchOAuthToken() 269 | if err != nil { 270 | return nil, err 271 | } 272 | 273 | // Once we have the token, save it locally for future use. 274 | err = SaveToken(tokenFile, token) 275 | if err != nil { 276 | return nil, err 277 | } 278 | } 279 | return token, nil 280 | } 281 | 282 | // tokenFile generates a filename to store the token. 283 | func makeTokenFile(fname string) (string, error) { 284 | // If filename is an absolute path, return it as is. 285 | // If filename != "", return user_home/filename 286 | // Otherwise, return user_home/defaultTokenFile 287 | 288 | if filepath.IsAbs(fname) { 289 | return fname, nil 290 | } 291 | 292 | usr, err := user.Current() 293 | if err != nil { 294 | return "", err 295 | } 296 | if fname != "" { 297 | return filepath.Join(usr.HomeDir, fname), nil 298 | } 299 | return filepath.Join(usr.HomeDir, defaultTokenFile), nil 300 | } 301 | -------------------------------------------------------------------------------- /installerManifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "kadaan", 3 | "repoOwner": "kadaan", 4 | "repoName": "smartthings_exporter", 5 | "repoBranch": "master", 6 | "name": "Smartthings Exporter API", 7 | "author": "Joel Baranick", 8 | "description": "API used by smartthings_exporter to pull sensor information", 9 | "category": "My Apps", 10 | "videoUrl": "", 11 | "photoUrl": "", 12 | "bannerUrl": "", 13 | "smartApps": { 14 | "parent": { 15 | "name": "API", 16 | "iconUrl": "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 17 | "published": true, 18 | "oAuth": true, 19 | "appSettings": {}, 20 | "version": "0.0.2", 21 | "appUrl": "smartapps/kadaan/smartthings-exporter-api.src/smartthings-exporter-api.groovy" 22 | }, 23 | "children": [] 24 | }, 25 | "deviceHandlers": [] 26 | } -------------------------------------------------------------------------------- /smartapps/kadaan/smartthings-exporter-api.src/smartthings-exporter-api.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2020 Joel Baranick 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Smartthings Exporter API 14 | * 15 | * Author: kadaan 16 | */ 17 | 18 | import groovy.transform.EqualsAndHashCode 19 | 20 | definition( 21 | name: "Smartthings Exporter API", 22 | namespace: "kadaan", 23 | author: "Joel Baranick", 24 | description: "API used by Smartthings_exporter to read sensor data.", 25 | category: "My Apps", 26 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 27 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 28 | oauth: [displayName: "Smartthings_exporter API", displayLink: ""]) 29 | 30 | preferences { 31 | section() { 32 | paragraph "Select the sensors you want the API to have access to." 33 | } 34 | section() { 35 | input "sensors", "capability.sensor", multiple: true, title: "Which sensors?", required: false 36 | input "actuators", "capability.actuator", multiple: true, title: "Which actuators?", required: false 37 | input "switches", "capability.switch", multiple: true, title: "Which switches?", required: false 38 | } 39 | } 40 | 41 | def installed() { 42 | initialize() 43 | } 44 | 45 | def updated() { 46 | unsubscribe() 47 | initialize() 48 | } 49 | 50 | def initialize() { 51 | def devices = getDevices() 52 | devices.each { 53 | def device = it.value 54 | def supportedCapabilities = device.capabilities 55 | supportedCapabilities.each { 56 | if (attributeMappings.containsKey(it.name)) { 57 | def attributeMapping = attributeMappings.get(it.name) 58 | attributeMapping.each { 59 | if (it.value.type == "counter") { 60 | state["${device.id}__${it.key}"] = 0 61 | it.value.values.each {value -> 62 | def eventName = "${it.key}.${value}" 63 | log.debug("Subscribing to ${eventName} for device ${device}") 64 | subscribe(device, eventName, handleCounter) 65 | } 66 | } 67 | } 68 | } 69 | } 70 | } 71 | } 72 | 73 | mappings { 74 | path("/sensors") { 75 | action: [ 76 | GET: "listSensors" 77 | ] 78 | } 79 | } 80 | 81 | def Map getAttributeMappings() { 82 | return [ 83 | "Alarm" : [ 84 | "alarmState" : [ 85 | name: "alarm_triggered", 86 | type: "gauge", 87 | description: "1 if alarm triggered.", 88 | values: this.&valueAlarmState 89 | ] 90 | ], 91 | "Battery" : [ 92 | "battery": [ 93 | name: "battery_percentage", 94 | type: "gauge", 95 | description: "Percentage of battery remaining.", 96 | conversion: this.&valueFloat 97 | ] 98 | ], 99 | "Carbon Monoxide Detector" : [ 100 | "carbonMonoxide" : [ 101 | name: "carbon_monoxide_detected", 102 | type: "counter", 103 | description: "1 if carbon monoxide detected.", 104 | values: this.&valueDetectedClear 105 | ] 106 | ], 107 | "Color Temperature" : [ 108 | "colorTemperature" : [ 109 | name: "color_temperature_kelvins", 110 | type: "gauge", 111 | description: "Light color temperature.", 112 | conversion: this.&valueFloat 113 | ] 114 | ], 115 | "Contact Sensor" : [ 116 | "contact" : [ 117 | name: "contact_open", 118 | type: "gauge", 119 | description: "1 if the contact is open.", 120 | conversion: this.&valueOpenClose 121 | ] 122 | ], 123 | "Energy Meter" : [ 124 | "energy" : [ 125 | name: "energy_usage_joules", 126 | type: "gauge", 127 | description: "Energy usage in joules.", 128 | conversion: this.&valueJoules 129 | ] 130 | ], 131 | "Relative Humidity Measurement" : [ 132 | "humidity" : [ 133 | name: "relative_humidity_percentage", 134 | type: "gauge", 135 | description: "Current relative humidity percentage.", 136 | conversion: this.&valueFloat 137 | ] 138 | ], 139 | "Color Control" : [ 140 | "hue" : [ 141 | name: "color_hue_percentage", 142 | type: "gauge", 143 | description: "Light color hue percentage.", 144 | conversion: this.&valueFloat 145 | ], 146 | "saturation" : [ 147 | name: "color_saturation_percentage", 148 | type: "gauge", 149 | description: "Light color saturation percentage.", 150 | conversion: this.&valueFloat 151 | ] 152 | ], 153 | "Illuminance Measurement" : [ 154 | "illuminance" : [ 155 | name: "illuminance_lux", 156 | type: "gauge", 157 | description: "Light illuminance in lux.", 158 | conversion: this.&valueFloat 159 | ] 160 | ], 161 | "Switch Level" : [ 162 | "level" : [ 163 | name: "level", 164 | type: "gauge", 165 | description: "Level as a percentage.", 166 | conversion: this.&valueFloat 167 | ] 168 | ], 169 | "Motion Sensor" : [ 170 | "motion" : [ 171 | name: "motion_detected", 172 | type: "gauge", 173 | description: "1 if motion detected.", 174 | values: this.&valueActiveInactive 175 | ] 176 | ], 177 | "Power Meter" : [ 178 | "power" : [ 179 | name: "power_usage_watts", 180 | type: "gauge", 181 | description: "Current power usage in watts.", 182 | conversion: this.&valueFloat 183 | ] 184 | ], 185 | "Presence Sensor" : [ 186 | "presence" : [ 187 | name: "presence_detected", 188 | type: "gauge", 189 | description: "1 if presence detected.", 190 | values: this.&valuePresentNotPresent 191 | ] 192 | ], 193 | "Smoke Detector" : [ 194 | "smoke" : [ 195 | name: "smoke_detected", 196 | type: "gauge", 197 | description: "1 if smoke detected.", 198 | values: this.&valueDetectedClear 199 | ] 200 | ], 201 | "Switch" : [ 202 | "switch" : [ 203 | name: "switch_enabled", 204 | type: "gauge", 205 | description: "1 if the switch is on.", 206 | conversion: this.&valueOnOff 207 | ] 208 | ], 209 | "Tamper Alert" : [ 210 | "tamper" : [ 211 | name: "tamper_detected", 212 | type: "gauge", 213 | description: "1 if tamper detected.", 214 | values: this.&valueDetectedClear 215 | ] 216 | ], 217 | "Temperature Measurement" : [ 218 | "temperature" : [ 219 | name: "temperature_fahrenheit", 220 | type: "gauge", 221 | description: "Temperature in fahrenheit.", 222 | conversion: this.&valueFloat 223 | ] 224 | ], 225 | "Voltage Measurement" : [ 226 | "voltage" : [ 227 | name: "voltage_volts", 228 | type: "gauge", 229 | description: "Energy voltage in Volts.", 230 | conversion: this.&valueFloat 231 | ] 232 | ] 233 | ] 234 | } 235 | 236 | def handleCounter(evt) { 237 | def stateId = "${evt.deviceId}__${evt.name}" 238 | state[stateId] = state[stateId] + 1 239 | } 240 | 241 | def listSensors() { 242 | def attributeMappings = getAttributeMappings() 243 | def descriptions = [:] 244 | def metrics = [:] 245 | def devices = getDevices() 246 | devices.each { 247 | def device = it.value 248 | def metricDescriptions = [:] 249 | def metric = [:] 250 | def metricAttributes = [:] 251 | def supportedCapabilities = device.capabilities 252 | supportedCapabilities.each { 253 | if (attributeMappings.containsKey(it.name)) { 254 | def attributeMapping = attributeMappings.get(it.name) 255 | attributeMapping.each { 256 | if (it.value.type == "gauge") { 257 | def currentValue = device.currentValue(it.key) 258 | if (currentValue != null) { 259 | metricDescriptions[it.value.name] = it.value.description 260 | metricAttributes[it.value.name] = it.value.conversion(currentValue) 261 | } 262 | } else if (it.value.type == "counter") { 263 | metricDescriptions[it.value.name] = it.value.description 264 | metricAttributes[it.value.name] = state["${device.id}__${it.key}"] 265 | } 266 | } 267 | } 268 | } 269 | if (metricAttributes.size() > 0) { 270 | ["name", "displayName"].each { 271 | metric[it] = device."$it" 272 | } 273 | metric.attributes = metricAttributes 274 | descriptions = descriptions << metricDescriptions 275 | metrics[device.id] = metric 276 | } 277 | } 278 | [descriptions: descriptions, sensors: metrics] 279 | } 280 | 281 | private getDevices() { 282 | def devices = [:] 283 | actuators.each { 284 | devices[it.id] = it 285 | } 286 | sensors.each { 287 | if(!devices.containsKey(it.id)) { 288 | devices[it.id] = it 289 | } 290 | } 291 | switches.each { 292 | if(!devices.containsKey(it.id)) { 293 | devices[it.id] = it 294 | } 295 | } 296 | devices 297 | } 298 | 299 | private valueFloat(value) { 300 | if (!value) { 301 | return 0.0 302 | } 303 | try { 304 | float f = Float.valueOf(value).floatValue(); 305 | return f 306 | } catch (NumberFormatException nfe) { 307 | return 0.0 308 | } 309 | } 310 | 311 | private valueOneOf(value, options) { 312 | if (!value?.trim()) { 313 | return 0.0 314 | } 315 | if (value?.trim() == options[0]) { 316 | return 0.0 317 | } 318 | if (value?.trim() == options[1]) { 319 | return 1.0 320 | } 321 | return 0.0 322 | } 323 | 324 | private valueOnOff(value) { 325 | return valueOneOf(value, ["off", "on"]) 326 | } 327 | 328 | private valuePresentNotPresent(value) { 329 | return valueOneOf(value, ["not present", "present"]) 330 | } 331 | 332 | private valueActiveInactive(value) { 333 | return valueOneOf(value, ["inactive", "active"]) 334 | } 335 | 336 | private valueDetectedClear(value) { 337 | return valueOneOf(value, ["clear", "detected"]) 338 | } 339 | 340 | private valueOpenClose(value) { 341 | return valueOneOf(value, ["close", "open"]) 342 | } 343 | 344 | private valueAlarmState(value) { 345 | if (!value?.trim()) { 346 | return 0.0 347 | } 348 | if (value?.trim() == "off") { 349 | return 0.0 350 | } 351 | if (value?.trim() == "siren" || value?.trim() == "strobe" || value?.trim() == "both") { 352 | return 1.0 353 | } 354 | return 0.0 355 | } 356 | 357 | private valueJoules(value) { 358 | return valueFloat(value) * 3600000 359 | } 360 | -------------------------------------------------------------------------------- /smartthings_exporter.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 Joel Baranick 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Based on: 16 | // http://github.com/marcopaganini/smartcollector 17 | // (C) 2016 by Marco Paganini 18 | 19 | package main 20 | 21 | import ( 22 | "encoding/json" 23 | "fmt" 24 | "github.com/kadaan/smartthings_exporter/gosmart" 25 | "github.com/prometheus/client_golang/prometheus" 26 | "github.com/prometheus/client_golang/prometheus/promhttp" 27 | plog "github.com/prometheus/common/log" 28 | "github.com/prometheus/common/version" 29 | "golang.org/x/crypto/ssh/terminal" 30 | "golang.org/x/net/context" 31 | "golang.org/x/oauth2" 32 | "gopkg.in/alecthomas/kingpin.v2" 33 | "net/http" 34 | "os" 35 | "path/filepath" 36 | "syscall" 37 | ) 38 | 39 | const ( 40 | namespace = "smartthings" 41 | ) 42 | 43 | var ( 44 | application = kingpin.New("smartthings_exporter", "Smartthings exporter for Prometheus") 45 | 46 | registerCommand *kingpin.CmdClause 47 | registerPort *uint16 48 | registerOAuthClient *string 49 | registerOAuthTokenFile **os.File 50 | 51 | monitorCommand *kingpin.CmdClause 52 | listenAddress *string 53 | metricsPath *string 54 | monitorOAuthClient *string 55 | monitorOAuthTokenFile *string 56 | 57 | metrics = map[string]*prometheus.Desc{} 58 | ) 59 | 60 | // Exporter collects smartthings stats and exports them using the prometheus metrics package. 61 | type Exporter struct { 62 | client *http.Client 63 | endpoint string 64 | } 65 | 66 | // NewExporter returns an initialized Exporter. 67 | func NewExporter(oauthClient string, oauthToken *oauth2.Token) (*Exporter, error) { 68 | // Create the oauth2.config object with no secret to use with the token we already have 69 | config := gosmart.NewOAuthConfig(oauthClient, "") 70 | 71 | // Create a client with the token and fetch endpoints URI. 72 | ctx := context.Background() 73 | client := config.Client(ctx, oauthToken) 74 | endpoint, err := gosmart.GetEndPointsURI(client) 75 | if err != nil { 76 | plog.Fatalf("Error reading endpoints URI: %v\n", err) 77 | } 78 | 79 | _, verr := gosmart.GetSensors(client, endpoint) 80 | if verr != nil { 81 | plog.Fatalf("Error verifying connection to endpoints URI %v: %v\n", endpoint, err) 82 | } 83 | 84 | // Init our exporter. 85 | return &Exporter{ 86 | client: client, 87 | endpoint: endpoint, 88 | }, nil 89 | } 90 | 91 | // Describe describes all the metrics ever exported by the Kafka exporter. It 92 | // implements prometheus.Collector. 93 | func (e *Exporter) Describe(ch chan<- *prometheus.Desc) { 94 | for _, m := range metrics { 95 | ch <- m 96 | } 97 | } 98 | 99 | // Collect fetches the stats from configured Kafka location and delivers them 100 | // as Prometheus metrics. It implements prometheus.Collector. 101 | func (e *Exporter) Collect(ch chan<- prometheus.Metric) { 102 | // Iterate over all devices and collect timeseries info. 103 | sensors, err := gosmart.GetSensors(e.client, e.endpoint) 104 | if err != nil { 105 | plog.Errorf("Error reading list of sensors from %v: %v\n", e.endpoint, err) 106 | } 107 | 108 | for _, sensor := range sensors { 109 | for _, val := range sensor.Attributes { 110 | if _, ok := metrics[val.Name]; !ok { 111 | metric := prometheus.NewDesc( 112 | prometheus.BuildFQName(namespace, "", val.Name), 113 | val.Description, []string{"id", "name"}, nil) 114 | metrics[val.Name] = metric 115 | } 116 | ch <- prometheus.MustNewConstMetric(metrics[val.Name], prometheus.GaugeValue, val.Value, sensor.ID, sensor.DisplayName) 117 | } 118 | } 119 | } 120 | 121 | func init() { 122 | prometheus.MustRegister(version.NewCollector("smartthings_exporter")) 123 | 124 | registerCommand = application.Command("register", "Register smartthings_exporter with Smartthings and outputs the token.").Action(register) 125 | registerPort = registerCommand.Flag("register.listen-port", "The port to listen on for the OAuth register.").Default("4567").Uint16() 126 | registerOAuthClient = registerCommand.Flag("smartthings.oauth-client", "Smartthings OAuth client ID.").Required().String() 127 | 128 | monitorCommand = application.Command("start", "Start the smartthings_exporter.").Default().Action(monitor) 129 | listenAddress = monitorCommand.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9499").String() 130 | metricsPath = monitorCommand.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String() 131 | monitorOAuthClient = monitorCommand.Flag("smartthings.oauth-client", "Smartthings OAuth client ID.").Required().String() 132 | monitorOAuthTokenFile = monitorCommand.Flag("smartthings.oauth-token.file", "File containing the Smartthings OAuth token.").Required().ExistingFile() 133 | } 134 | 135 | func main() { 136 | plog.AddFlags(application) 137 | application.Version(version.Print("smartthings_exporter")) 138 | application.HelpFlag.Short('h') 139 | _, err := application.Parse(os.Args[1:]) 140 | if err != nil { 141 | application.Fatalf("%s, try --help", err) 142 | } 143 | } 144 | 145 | func register(_ *kingpin.ParseContext) error { 146 | _, _ = fmt.Fprintln(os.Stderr, "Registering smartthings_exporter with Smartthings") 147 | _, _ = fmt.Fprintln(os.Stderr, "Enter your Smartthings OAuth secret:") 148 | bytes, err := terminal.ReadPassword(int(syscall.Stdin)) 149 | if err != nil { 150 | _, _ = fmt.Fprintln(os.Stderr, "Failed to get Smartthings OAuth secret.") 151 | return err 152 | } 153 | 154 | config := gosmart.NewOAuthConfig(*registerOAuthClient, string(bytes)) 155 | gst, err := gosmart.NewAuth(int(*registerPort), config) 156 | if err != nil { 157 | _, _ = fmt.Fprintln(os.Stderr, "Failed to create Smartthings OAuth client.") 158 | return err 159 | } 160 | 161 | _, _ = fmt.Fprintf(os.Stderr, "Please login by visiting: http://localhost:%d\n", *registerPort) 162 | token, err := gst.FetchOAuthToken() 163 | if err != nil { 164 | _, _ = fmt.Fprintln(os.Stderr, "Failed to fetch Smartthings OAuth token.") 165 | return err 166 | } 167 | 168 | blob, err := json.Marshal(token) 169 | if err != nil { 170 | _, _ = fmt.Fprintln(os.Stderr, "Failed to serialize Smartthings OAuth token to JSON.", 171 | (*registerOAuthTokenFile).Name()) 172 | return err 173 | } 174 | 175 | fmt.Println(string(blob)) 176 | return nil 177 | } 178 | 179 | func monitor(_ *kingpin.ParseContext) error { 180 | plog.Infoln("Starting smartthings_exporter", version.Info()) 181 | plog.Infoln("Build context", version.BuildContext()) 182 | 183 | tokenFilePath, err := filepath.Abs(*monitorOAuthTokenFile) 184 | if err != nil { 185 | plog.Errorf("Failed to get absolution path to token file %s.\n", *monitorOAuthTokenFile) 186 | return err 187 | } 188 | 189 | token, err := gosmart.LoadToken(tokenFilePath) 190 | if err != nil || !token.Valid() { 191 | plog.Errorf("Failed to load Smartthings OAuth token from %s.\n", *monitorOAuthTokenFile) 192 | return err 193 | } 194 | 195 | exporter, err := NewExporter(*monitorOAuthClient, token) 196 | if err != nil { 197 | plog.Fatalln(err) 198 | return err 199 | 200 | } 201 | prometheus.MustRegister(exporter) 202 | 203 | http.Handle(*metricsPath, promhttp.Handler()) 204 | http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 205 | _, _ = w.Write([]byte(` 206 | SmartThings Exporter 207 | 208 |

SmartThings Exporter

209 |

Metrics

210 | 211 | `)) 212 | }) 213 | 214 | plog.Infoln("Listening on", *listenAddress) 215 | plog.Fatal(http.ListenAndServe(*listenAddress, nil)) 216 | return nil 217 | } 218 | --------------------------------------------------------------------------------