diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d34786e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM golang AS build-env +COPY . /root + +WORKDIR /root + +RUN \ + export GO111MODULE=on &&\ + export GOPROXY=https://goproxy.io &&\ + CGO_ENABLED=0 go build -v + +FROM alpine + +COPY --from=build-env /root/check /root/conf.toml / +CMD ["/check"] + diff --git a/README.md b/README.md new file mode 100644 index 0000000..ad3d233 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# this is check service +## env +``` +go version 1.12.5 +linux +``` +## api info +```$xslt +http://127.0.0.1:7789/checkport #check service port,tcp only +http://127.0.0.1:7789/checkpod #check k8s pods running status +http://127.0.0.1:7789/checkmgo #check mongo running status +http://127.0.0.1:7789/checkes #check es-cluster running status +http://127.0.0.1:7789/checknode #check k8scluster nodes running status,,,error +http://127.0.0.1:7789/checktotalag #check kafka consumer total lag + +``` +http://127.0.0.1:7789/postport #post port data to db +eg: +```cassandraql +{"topic":"test","data":"127.0.0.1:1234"} +``` + + + diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..46f991a --- /dev/null +++ b/build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -e +# build bin file +export GO111MODULE=on +export GOPROXY=https://goproxy.io +go build -v +# make my dir +mkdir -p $BUILD_ROOT +mv check $BUILD_ROOT +mv conf.toml $BUILD_ROOT diff --git a/conf.toml b/conf.toml new file mode 100644 index 0000000..fb7d165 --- /dev/null +++ b/conf.toml @@ -0,0 +1,28 @@ +[check] +hostPort = "0.0.0.0:7789" + +ipPort = [""] + +[SendMsg] +AppID = +AppKey = +MsgGw = +To = + +[db] #pod db +addr = +dbuser = +dbpass = + +[mongo] +conn = [] +replset_authdb = +replset_user = +replset_passwd = + +[es] +eslist = [] +nodes = + + + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..552b66e --- /dev/null +++ b/go.mod @@ -0,0 +1,20 @@ +module check + +go 1.12 + +require ( + github.com/PuerkitoBio/goquery v1.5.0 + github.com/Shopify/sarama v1.23.1 // indirect + github.com/bsm/sarama-cluster v2.1.15+incompatible // indirect + github.com/fsnotify/fsnotify v1.4.7 + github.com/imdario/mergo v0.3.7 // indirect + github.com/julienschmidt/httprouter v1.2.0 + github.com/spf13/viper v1.4.0 + go.uber.org/zap v1.10.0 + gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce + gopkg.in/natefinch/lumberjack.v2 v2.0.0 + k8s.io/api v0.0.0-20190717022910-653c86b0609b + k8s.io/apimachinery v0.0.0-20190717022731-0bb8574e0887 + k8s.io/client-go v12.0.0+incompatible + k8s.io/utils v0.0.0-20190712204705-3dccf664f023 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..13446cb --- /dev/null +++ b/go.sum @@ -0,0 +1,312 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/go-autorest v11.1.2+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798 h1:2T/jmrHeTezcCM58lvEQXs0UpQJCo5SoGAcg+mbSTIg= +github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/PuerkitoBio/goquery v1.5.0 h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP7EJk= +github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg= +github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/Shopify/sarama v1.23.1 h1:XxJBCZEoWJtoWjf/xRbmGUpAmTZGnuuF0ON0EvxxBrs= +github.com/Shopify/sarama v1.23.1/go.mod h1:XLH1GYJnLVE0XCr6KdJGVJRTwY30moWNJ4sERjXX6fs= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o= +github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/bsm/sarama-cluster v2.1.15+incompatible h1:RkV6WiNRnqEEbp81druK8zYhmnIgdOjqSVi0+9Cnl2A= +github.com/bsm/sarama-cluster v2.1.15+incompatible/go.mod h1:r7ao+4tTNXvWm+VRpRJchr2kQhqxgmAp2iEX5W96gMM= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= +github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= +github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/evanphx/json-patch v0.0.0-20190203023257-5858425f7550/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= +github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= +github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= +github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v0.0.0-20171007142547-342cbe0a0415/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20160524151835-7d79101e329e/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gnostic v0.0.0-20170426233943-68f4ded48ba9/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= +github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gophercloud/gophercloud v0.0.0-20190126172459-c818fa66e4c8/go.mod h1:3WdhXV3rUYy9p6AUW8d94kr+HS62Y4VL9mBnFxsD8q4= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= +github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03 h1:FUwcHNlEqkqLjLBdCp5PRlCFijNjvcYANOZXzCfXwCM= +github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v0.0.0-20190113212917-5533ce8a0da3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41 h1:GeinFsrjWz97fAxVUEd748aV0cYL+I6k44gFJTCVvpU= +github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= +github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181025213731-e84da0312774/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5 h1:bselrhR0Or1vomJZC8ZIjWtbDmn9OYFLX5Ik9alpJpE= +golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190206173232-65e2d4e15006/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= +golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4= +golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20161028155119-f51c12702a4d/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o= +gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/jcmturner/aescts.v1 v1.0.1 h1:cVVZBK2b1zY26haWB4vbBiZrfFQnfbTVrE3xZq6hrEw= +gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo= +gopkg.in/jcmturner/dnsutils.v1 v1.0.1 h1:cIuC1OLRGZrld+16ZJvvZxVJeKPsvd5eUIvxfoN5hSM= +gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eRhxkJMWSIz9Q= +gopkg.in/jcmturner/gokrb5.v7 v7.2.3 h1:hHMV/yKPwMnJhPuPx7pH2Uw/3Qyf+thJYlisUc44010= +gopkg.in/jcmturner/gokrb5.v7 v7.2.3/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= +gopkg.in/jcmturner/rpc.v1 v1.1.0 h1:QHIUxTX1ISuAv9dD2wJ9HWQVuWDX/Zc0PfeC2tjc4rU= +gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8= +gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce h1:xcEWjVhvbDy+nHP67nPDDpbYrY+ILlfndk4bRioVHaU= +gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/api v0.0.0-20190620084959-7cf5895f2711/go.mod h1:TBhBqb1AWbBQbW3XRusr7n7E4v2+5ZY8r8sAMnyFC5A= +k8s.io/api v0.0.0-20190717022910-653c86b0609b h1:WiE134uexhvhHw4DjJuYsghv792UCe2xN5SHQOayf28= +k8s.io/api v0.0.0-20190717022910-653c86b0609b/go.mod h1:5UP0nKwb/iEVBSMrDGsFuoIlrOOjKvatkMrhuY0czQk= +k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719/go.mod h1:I4A+glKBHiTgiEjQiCCQfCAIcIMFGt291SmsvcrFzJA= +k8s.io/apimachinery v0.0.0-20190717022731-0bb8574e0887 h1:JVVkMN2P4a3MNzTkjgCCRwBDAGAENrCsZGLoLtQ5jvI= +k8s.io/apimachinery v0.0.0-20190717022731-0bb8574e0887/go.mod h1:sBJWIJZfxLhp7mRsRyuAE/NfKTr3kXGR1iaqg8O0gJo= +k8s.io/client-go v12.0.0+incompatible h1:YlJxncpeVUC98/WMZKC3JZGk/OXQWCZjAB4Xr3B17RY= +k8s.io/client-go v12.0.0+incompatible/go.mod h1:E95RaSlHr79aHaX0aGSwcPNfygDiPKOVXdmivCIZT0k= +k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/klog v0.3.1 h1:RVgyDHY/kFKtLqh67NvEWIgkMneNoIrdkN0CxDSQc68= +k8s.io/klog v0.3.1/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= +k8s.io/kube-openapi v0.0.0-20190709113604-33be087ad058/go.mod h1:nfDlWeOsu3pUf4yWGL+ERqohP4YsZcBJXWMK+gkzOA4= +k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0= +k8s.io/utils v0.0.0-20190712204705-3dccf664f023 h1:1H4Jyzb0z2X0GfBMTwRjnt5ejffRHrGftUgJcV/ZfDc= +k8s.io/utils v0.0.0-20190712204705-3dccf664f023/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/httpd/escheck.go b/httpd/escheck.go new file mode 100644 index 0000000..060f1ab --- /dev/null +++ b/httpd/escheck.go @@ -0,0 +1,100 @@ +package httpd + +import ( + "encoding/json" + "io/ioutil" + "net/http" + + "go.uber.org/zap" + + "github.com/julienschmidt/httprouter" + + "github.com/spf13/viper" +) + +type EsClusterStat struct { + ClusterName string `json:"cluster_name"` + Status string `json:"status"` + TimeOut bool `json:"time_out"` + NumberOfNodes int `json:"number_of_nodes"` + NumberOfDataNodes int `json:"number_of_data_nodes"` + ActivePrimaryShards int `json:"active_primary_shards"` + ActiveShards int `json:"active_shards"` + RelocatingShards int `json:"relocating_shards"` + InitializingShards int `json:"initializing_shards"` + UnassignedShards int `json:"unassigned_shards"` + DelayedUnassignedShards int `json:"delayed_unassigned_shards"` + NumberOfPendingTasks int `json:"number_of_pending_tasks"` + NumberOfInFlightFetch int `json:"number_of_in_flight_fetch"` + TaskMaxWaitingInQueueMillis int `json:"task_max_waiting_in_queue_millis"` + ActiveShardsPercentAsNumber float32 `json:"active_shards_percent_as_number"` +} + +type EsStatus struct { + Msg string `json:"msg"` + Data string `json:"data"` +} + +type HttpEs struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data []EsStatus `json:"data"` +} + +func Escheck(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + + httpStat := HttpEs{} + esList := viper.GetStringSlice("es.eslist") + for _, ip := range esList { + ch := make(chan EsClusterStat) + go func(ip string) { + url := "http://" + ip + "/_cluster/health?pretty" + + req, err := http.NewRequest("GET", url, nil) + if err != nil { + Loges.Error("new request is err:", zap.Error(err)) + } + + req.SetBasicAuth(viper.GetString("es.es-user"), viper.GetString("es.es-pwd")) + client := &http.Client{} + res, err := client.Do(req) + if err != nil { + Loges.Error("do request is err:", zap.Error(err)) + + ch <- EsClusterStat{Status: "red"} + return + } + defer res.Body.Close() + + resData := EsClusterStat{} + body, _ := ioutil.ReadAll(res.Body) + err = json.Unmarshal(body, &resData) + if err != nil { + Loges.Error("json exchange is err:", zap.Error(err)) + } + + ch <- resData + }(ip) + + v := <-ch + + if v.Status == "red" { + httpStat.Msg = "yellow" + // SendWechat(ip) + httpStat.Data = append(httpStat.Data, EsStatus{Msg: "red", Data: ip}) + } else if v.Status == "yellow" { + httpStat.Msg = "yellow" + httpStat.Data = append(httpStat.Data, EsStatus{Msg: "yellow", Data: ip}) + } else if v.NumberOfNodes != viper.GetInt("es.nodes") { + httpStat.Msg = "yellow" + // SendWechat(ip) + httpStat.Data = append(httpStat.Data, EsStatus{Msg: "yellow", Data: ip}) + } else { + httpStat.Code = 200 + httpStat.Msg = "green" + httpStat.Data = append(httpStat.Data, EsStatus{Msg: "green", Data: ip}) + } + } + w2, _ := json.Marshal(httpStat) + w.Write(w2) +} diff --git a/httpd/kfkcheck.go b/httpd/kfkcheck.go new file mode 100644 index 0000000..ea16001 --- /dev/null +++ b/httpd/kfkcheck.go @@ -0,0 +1,55 @@ +package httpd + +import ( + "github.com/PuerkitoBio/goquery" + "github.com/julienschmidt/httprouter" + "go.uber.org/zap" + "net/http" + "strconv" + "strings" +) + +func KfkCheck(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + + //fmt.Println("kafka topic check ") + url := "http://127.0.0.1/clusters/kafkalog_tj/consumers/newsclientLogConsumerES72/topic/newsclientLog/type/KF" + req, err := http.NewRequest("GET", url, nil) + if err != nil { + Loges.Error("error : ", zap.Error(err)) + } + + req.SetBasicAuth("admin", "passwd") + + client := &http.Client{} + res, err := client.Do(req) + if err != nil { + Loges.Error("error : ", zap.Error(err)) + } + defer res.Body.Close() + if res.StatusCode != 200 { + Loges.Info("status code error:", zap.Any("statusCode", res.StatusCode)) + } + + doc, err := goquery.NewDocumentFromReader(res.Body) + if err != nil { + Loges.Error("error : ", zap.Error(err)) + } + + doc.Find("tr:contains(Total)").Each(func(i int, selection *goquery.Selection) { + ss := selection.Text() + + aa := strings.SplitAfter(ss, "Total Lag") + + dd, err := strconv.Atoi(strings.ReplaceAll(strings.TrimSpace(aa[1]), ",", "")) + if err != nil { + Loges.Error("error : ", zap.Error(err)) + } + if dd >= 10000000 { + Loges.Info("kafka total lag is error :", zap.Any("total lag", dd)) + SendWechat("newsClientES total lag :", strings.ReplaceAll(strings.TrimSpace(aa[1]), ",", "")) + } + + }) + w.Write([]byte("check ok")) + +} diff --git a/httpd/loginit.go b/httpd/loginit.go new file mode 100644 index 0000000..f3c60ba --- /dev/null +++ b/httpd/loginit.go @@ -0,0 +1,59 @@ +package httpd + +import ( + "os" + + "go.uber.org/zap" + "go.uber.org/zap/zapcore" + "gopkg.in/natefinch/lumberjack.v2" +) + +var Loges = LogInit() + +func LogInit() *zap.Logger { + hook := lumberjack.Logger{ + Filename: "./info.log", + MaxSize: 128, + MaxBackups: 30, + MaxAge: 30, + Compress: true, + } + encoderConfig := zapcore.EncoderConfig{ + TimeKey: "time", + LevelKey: "level", + NameKey: "logger", + CallerKey: "lenum", + MessageKey: "msg", + StacktraceKey: "stacktrace", + LineEnding: zapcore.DefaultLineEnding, + EncodeLevel: zapcore.LowercaseLevelEncoder, + EncodeTime: zapcore.ISO8601TimeEncoder, + EncodeDuration: zapcore.SecondsDurationEncoder, + EncodeCaller: zapcore.FullCallerEncoder, + EncodeName: zapcore.FullNameEncoder, + } + atomicLevel := zap.NewAtomicLevel() + atomicLevel.SetLevel(zap.InfoLevel) + + core := zapcore.NewCore( + zapcore.NewJSONEncoder(encoderConfig), + zapcore.NewMultiWriteSyncer(zapcore.AddSync(os.Stdout), zapcore.AddSync(&hook)), + atomicLevel, + ) + + caller := zap.AddCaller() + + development := zap.Development() + + //filed := zap.Fields(zap.String("serviceName", "serviceName")) + + logger := zap.New(core, caller, development) + return logger + + //logger.Info("log 初始化成功") + //logger.Info("无法获取网址", + // zap.String("url", "http://www.baidu.com"), + // zap.Int("attempt", 3), + // zap.Duration("backoff", time.Second)) + +} diff --git a/httpd/mongocheck.go b/httpd/mongocheck.go new file mode 100644 index 0000000..6209fb9 --- /dev/null +++ b/httpd/mongocheck.go @@ -0,0 +1,106 @@ +package httpd + +import ( + "encoding/json" + "fmt" + "net/http" + + "go.uber.org/zap" + + "github.com/julienschmidt/httprouter" + + "github.com/spf13/viper" + "gopkg.in/mgo.v2" + "gopkg.in/mgo.v2/bson" +) + +type MemStat struct { + Name string `json:"name"` + Health int `json:"health"` + Self bool `json:"self"` +} + +type MgodStats struct { + Set string `json:"set"` + Members []MemStat `json:"members"` + Ok int `json:"ok"` +} + +type HttpMgo struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data []MgodStats `json:"data"` +} + +func MongoCheck(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Methods", "DELETE, GET, OPTIONS, POST, PUT") + w.Header().Set("Access-Control-Allow-Headers", "Accept, Accept-Encoding, Authorization, Content-Length, Content-Type, X-CSRF-Token, X-HTTP-Method-Override, AuthToken, NS, Resource, X-Requested-With") + + htpSta := HttpMgo{} + + for _, conn := range viper.GetStringSlice("mongo.conn") { + + ch := make(chan MgodStats) + + go func(conn string) { + + sess, err := mgo.Dial(conn) + if err != nil { + fmt.Println("11111111", err) + ch <- MgodStats{Ok: 0, Set: conn} + return + + } + defer sess.Close() + + err = sess.DB(viper.GetString("mongo.replset_authdb")).Login(viper.GetString("mongo.replset_user"), viper.GetString("mongo.replset_passwd")) + if err != nil { + Loges.Error("auth mgo is err:", zap.Error(err)) + ch <- MgodStats{Ok: 0, Set: conn} + return + } + + result := MgodStats{} + + err = sess.DB("admin").Run(bson.D{{"replSetGetStatus", 1}}, &result) + if err != nil { + Loges.Error("mgo run is err:", zap.Error(err)) + } + var i int + for _, v := range result.Members { + if v.Health == 1 { + i = i + 1 + } + } + + if i != len(result.Members) { + ch <- MgodStats{Ok: 0, Members: result.Members, Set: result.Set} + } else { + ch <- MgodStats{Ok: result.Ok, Members: result.Members, Set: result.Set} + } + + }(conn) + + v := <-ch + + htpSta.Data = append(htpSta.Data, v) + + } + htpSta.Code = 200 + htpSta.Msg = "green" + for _, k := range htpSta.Data { + if k.Ok != 1 { + htpSta.Msg = "yellow" + for _, j := range k.Members { + if j.Health != 1 { + SendWechat(j.Name, GetHostNname(j.Name)) + } + } + } + } + + w2, _ := json.Marshal(htpSta) + w.Write(w2) + +} diff --git a/httpd/nodecheck.go b/httpd/nodecheck.go new file mode 100644 index 0000000..563c567 --- /dev/null +++ b/httpd/nodecheck.go @@ -0,0 +1,87 @@ +package httpd + +import ( + "encoding/json" + "github.com/julienschmidt/httprouter" + "go.uber.org/zap" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/clientcmd" + "net/http" +) + +type HttpNode struct { + ClusterCount int `json:"clustercount"` + NodeNumber int `json:"node_number"` + Data []NodeStat `json:"data"` +} + +type NodeStat struct { + Name string `json:"name"` + Cluster string `json:"cluster"` + Status string `json:"status"` +} + +func NodeCheck(ClusterCfgs K8sConfigs) httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + httpStat := HttpNode{} + + nodestat := NodeStat{} + + nodeList := v1.NodeList{}.Items + + for _, ClusterCfg := range ClusterCfgs { + httpStat.ClusterCount = len(ClusterCfgs) + + config, err := clientcmd.RESTConfigFromKubeConfig([]byte(ClusterCfg.Configfile)) + if err != nil { + Loges.Error("REST Config From KubeConfig is err:", zap.Error(err)) + } + + clientset, err := kubernetes.NewForConfig(config) + if err != nil { + Loges.Error("new KubeConfig is err:", zap.Error(err)) + } + nodes, err := clientset.CoreV1().Nodes().List(metav1.ListOptions{}) + if err != nil { + Loges.Error("get nodes info is err:", zap.Error(err)) + } + + nodeList = append(nodeList, nodes.Items...) + } + for _, i := range nodeList { + ch := make(chan NodeStat) + go func(i v1.Node) { + if i.Status.Conditions[len(i.Status.Conditions)-1].Type != "Ready" { + nodestat.Status = "NotReady" + // i.ClusterName = ClusterCfgs[1].Clustername + nodestat.Name = i.Name + } + + nodestat.Status = "Ready" + //nodestat.Cluster = i.ClusterName + nodestat.Name = i.Name + + ch <- nodestat + + }(i) + nodest := <-ch + close(ch) + + if nodest.Status != "Ready" { + //if nodest.Name == "10.180.8.8" { + err := SendWechat("NodeCheck", nodest.Name, nodest.Status) + if err != nil { + Loges.Error("send msg is err", zap.Error(err)) + } + } + + httpStat.Data = append(httpStat.Data, nodest) + httpStat.NodeNumber = len(httpStat.Data) + } + w2, _ := json.Marshal(httpStat) + w.Write(w2) + + } +} diff --git a/httpd/podcheck.go b/httpd/podcheck.go new file mode 100644 index 0000000..3bc639d --- /dev/null +++ b/httpd/podcheck.go @@ -0,0 +1,212 @@ +package httpd + +import ( + "encoding/json" + "net/http" + "strings" + + "go.uber.org/zap" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/clientcmd" + + "gopkg.in/mgo.v2" + + "github.com/julienschmidt/httprouter" + "github.com/spf13/viper" + v1 "k8s.io/api/core/v1" +) + +type K8sConfig struct { + Clustername string `json:"clustername"` + Configfile string `json:"configfile"` +} + +type K8sConfigs []K8sConfig + +type HttpPod struct { + ClusterCount int `json:"clustercount"` + PodNumber int `json:"pod_number"` + Data []PodStat `json:"data"` +} + +type PodStat struct { + Name string `json:"name"` + Cluster string `json:"cluster"` + Namespace string `json:"namespace"` + Status string `json:"status"` + Hostip string `json:"hostip"` + Msg string `json:"msg"` + Deployment string `json:"deployment"` + // Ready bool `json:"ready"` +} + +func Podcheck(ClusterCfgs K8sConfigs) httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + httpStat := HttpPod{} + + for _, ClusterCfg := range ClusterCfgs { + httpStat.ClusterCount = len(ClusterCfgs) + + ch := make(chan []PodStat) + + go func(ClusterCfg K8sConfig) { + postat := []PodStat{} + config, err := clientcmd.RESTConfigFromKubeConfig([]byte(ClusterCfg.Configfile)) + if err != nil { + Loges.Error("REST Config From KubeConfig is err:", zap.Error(err)) + } + + clientset, err := kubernetes.NewForConfig(config) + if err != nil { + Loges.Error("new KubeConfig is err:", zap.Error(err)) + } + + pods, err := clientset.CoreV1().Pods("kube-system").List(metav1.ListOptions{}) + if err != nil { + Loges.Error("get pod info is err:", zap.Error(err)) + } + + for _, po := range pods.Items { //for pod-status + chpostat := make(chan PodStat) + go podstat(chpostat, po, ClusterCfg.Clustername) + v := <-chpostat + close(chpostat) + postat = append(postat, v) + } + ch <- postat + }(ClusterCfg) + + vv := <-ch + close(ch) + httpStat.Data = append(httpStat.Data, vv...) + + //config, err := clientcmd.RESTConfigFromKubeConfig([]byte(ClusterCfg.Configfile)) + //if err != nil { + // fmt.Println("6666666666666666", err) + //} + // + //clientset, err := kubernetes.NewForConfig(config) + //if err != nil { + // log.Fatalln(err) + //} + // + //pods, err := clientset.CoreV1().Pods("").List(metav1.ListOptions{}) + //if err != nil { + // log.Println(err.Error()) + //} + // + //httpStat.ClusterCount = len(ClusterCfgs) + // + //for _, po := range pods.Items { //for pod-status + // chpostat := make(chan PodStat) + // go podstat(chpostat, po, ClusterCfg.Clustername) + // v := <-chpostat + // close(chpostat) + // httpStat.Data = append(httpStat.Data, v) + //} + + } + + //do alter + alter(httpStat.Data) + + httpStat.PodNumber = len(httpStat.Data) + + w2, _ := json.Marshal(httpStat) + w.Write(w2) + + } +} + +func podstat(chpostat chan PodStat, po v1.Pod, Clustername string) { + s1 := PodStat{} + for _, pds := range po.Status.ContainerStatuses { + if pds.Ready != true { + //if pds.Name == "trace-test" /*|| pds.Name == "imcp-web" */ { + s1.Msg = "Yellow" + } + + } + s1.Name = po.Name + s1.Namespace = po.Namespace + s1.Status = string(po.Status.Phase) + s1.Cluster = Clustername + s1.Hostip = po.Status.HostIP + s1.Deployment = strings.Split(po.Name, "-dpt-")[0] + + chpostat <- s1 + +} + +func alter(pos []PodStat) { + ss := "podName : " + alterList := make(map[string][]PodStat) + for _, j := range pos { + + if j.Msg == "Yellow" { + alterList[j.Deployment] = append(alterList[j.Deployment], j) + } + + } + + for k, v := range alterList { + for _, j := range v { + ss = ss + j.Name + "," + } + //fmt.Println("PodCheck", "project: "+k, "cluster: "+v[0].Cluster, "ns: "+v[0].Namespace, ss) + go SendWechat("PodCheck", "project: "+k, "cluster: "+v[0].Cluster, "ns: "+v[0].Namespace, ss) + } + +} + +func GetConfig() K8sConfigs { + session, err := mgo.Dial(viper.GetString("db.addr")) + if err != nil { + Loges.Error("conn mgo is err:", zap.Error(err)) + } + defer session.Close() + session.SetMode(mgo.Monotonic, true) + err = session.DB("admin").Login(viper.GetString("db.dbuser"), viper.GetString("db.dbpass")) + if err != nil { + Loges.Error("auth mgo is err:", zap.Error(err)) + } + aa := K8sConfigs{} + c := session.DB("check").C("k8sconfig") + err = c.Find(nil).All(&aa) + if err != nil { + Loges.Error("select db is err:", zap.Error(err)) + } + + return aa +} + +//func AddConfig(){ +// bb,err := ioutil.ReadFile("/home/han/config") +// if err !=nil { +// fmt.Println("111111111",err) +// } +// k8sc := K8sConfig{} +// k8sc.Clustername = "" +// k8sc.Configfile = string(bb) +// +// //fmt.Println(k8sc) +// +// +// session,err := mgo.Dial(viper.GetString("db.addr")) +// if err !=nil { +// fmt.Println("333333333333333333333",err) +// } +// defer session.Close() +// session.SetMode(mgo.Monotonic, true) +// err = session.DB("admin").Login(viper.GetString("db.dbuser"),viper.GetString("db.dbpass")) +// if err !=nil{ +// fmt.Println("2222222222222222222",err) +// } +// c := session.DB("check").C("k8sconfig") +// err = c.Insert(&k8sc) +// if err !=nil{ +// fmt.Println("44444444444444444444",err) +// } +//} diff --git a/httpd/portcheck.go b/httpd/portcheck.go new file mode 100644 index 0000000..dafcefa --- /dev/null +++ b/httpd/portcheck.go @@ -0,0 +1,209 @@ +package httpd + +import ( + "encoding/json" + "fmt" + "gopkg.in/mgo.v2" + "io/ioutil" + "net" + "net/http" + "strings" + + "go.uber.org/zap" + + "github.com/julienschmidt/httprouter" + + "github.com/spf13/viper" +) + +type PortStatus struct { + Msg string `json:"msg"` + Data string `json:"data"` + Topic string `json:"topic"` +} + +type HttpStat struct { + Number int `json:"number"` + Msg string `json:"msg"` + Data []PortStatus `json:"data"` +} + +type SearchMachine struct { + Httpstatus int `json:"httpstatus"` + Data map[string][]struct { + Hostname string `json:"hostname"` + Ip string `json:"ip"` + Sn string `json:"sn"` + } +} + +func PostPort() httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + session, err := mgo.Dial(viper.GetString("db.addr")) + if err != nil { + Loges.Error("conn mgo is err:", zap.Error(err)) + } + defer session.Close() + session.SetMode(mgo.Monotonic, true) + err = session.DB("admin").Login(viper.GetString("db.dbuser"), viper.GetString("db.dbpass")) + if err != nil { + Loges.Error("auth mgo is err:", zap.Error(err)) + } + t, err := ioutil.ReadAll(r.Body) + if err != nil { + Loges.Error("error : ", zap.Error(err)) + } + var port1 PortStatus + err = json.Unmarshal(t, &port1) + if err != nil { + Loges.Error("format json error : ", zap.Error(err)) + } + c := session.DB("check").C("checkport") + err = c.Insert(&port1) + if err != nil { + Loges.Error("insert db error : ", zap.Error(err)) + } + } + +} + +func GetPort() []PortStatus { + session, err := mgo.Dial(viper.GetString("db.addr")) + if err != nil { + Loges.Error("conn mgo is err:", zap.Error(err)) + } + defer session.Close() + session.SetMode(mgo.Monotonic, true) + err = session.DB("admin").Login(viper.GetString("db.dbuser"), viper.GetString("db.dbpass")) + if err != nil { + Loges.Error("auth mgo is err:", zap.Error(err)) + } + + var aa []PortStatus + c := session.DB("check").C("checkport") + err = c.Find(nil).All(&aa) + if err != nil { + Loges.Error("select db is err:", zap.Error(err)) + } + //fmt.Println(aa) + //var portList []string + //for _, j := range aa { + // portList = append(portList, j.Data) + //} + + return aa + +} + +func PortCheck(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + + httpStat := HttpStat{} + //portList := viper.GetStringSlice("check.ipPort") + portList := GetPort() + + for _, node := range portList { + ch := make(chan PortStatus) + go func(ip string) { + //s1 := PortStatus{} + //s1.Data = ip + conn, err := net.Dial("tcp", ip) + if err != nil { + Loges.Error("port is err", zap.Error(err)) + node.Msg = "red" + } else { + node.Msg = "green" + conn.Close() + } + + ch <- node + + }(node.Data) + + v := <-ch + close(ch) + if v.Msg == "red" { + fmt.Println(v.Data) + hostname := GetHostNname(v.Data) + + err := SendWechat("PortCheck", v.Topic, v.Data, hostname) + if err != nil { + Loges.Error("send msg is err", zap.Error(err)) + } + httpStat.Msg = "yellow" + } + httpStat.Data = append(httpStat.Data, v) + } + + if httpStat.Msg != "yellow" { + httpStat.Msg = "green" + } + + httpStat.Number = len(httpStat.Data) + w2, _ := json.Marshal(httpStat) + w.Write(w2) + +} + +func GetHostNname(iport string) string { + ss := strings.Split(iport, ":") + ip := ss[0] + url := "https://registry.monitor.ifengidc.com/api/v1/resource/search?ns=loda&type=machine&v=" + ip + req, err := http.NewRequest("GET", url, nil) + if err != nil { + Loges.Error("new request is err", zap.Error(err)) + } + + req.Header.Add("Authtoken", "hanlei3:NwMiBoSpDbEJYdl5mVLJ") + req.Header.Add("NS", "loda") + req.Header.Add("Resource", "machine") + + client := http.Client{} + res, err := client.Do(req) + if err != nil { + Loges.Error("do request is err", zap.Error(err)) + } + defer res.Body.Close() + s, err := ioutil.ReadAll(res.Body) + if err != nil { + Loges.Error("read res.body is err:", zap.Error(err)) + } + + kk := SearchMachine{} + err = json.Unmarshal(s, &kk) + if err != nil { + Loges.Error("json exchange is err", zap.Error(err)) + } + + for k, _ := range kk.Data { + return kk.Data[k][0].Hostname + } + + return "no hostname" + +} + +//func ClientGet(url string, seconds time.Duration) httprouter.Handle { +// return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { +// for { +// req, err := http.NewRequest("GET", url, nil) +// if err != nil { +// fmt.Println("client get func is err : ", err) +// } +// client := http.Client{} +// res, err := client.Do(req) +// if err != nil { +// fmt.Println("client get func is err2 ", err) +// } +// +// defer res.Body.Close() +// +// sleepTime := time.Second * seconds +// +// time.Sleep(sleepTime) +// +// } +// //w2, _ := json.Marshal(HttpBody{code: 200, Msg: "ok", Data: ""}) +// //w.Write(w2) +// +// } +//} diff --git a/httpd/sendmsg.go b/httpd/sendmsg.go new file mode 100644 index 0000000..2a5b825 --- /dev/null +++ b/httpd/sendmsg.go @@ -0,0 +1,90 @@ +package httpd + +import ( + "encoding/json" + "io/ioutil" + "net/http" + "net/url" + "strings" + "time" + + "go.uber.org/zap" + + "github.com/spf13/viper" +) + +type HttpBody struct { + code int `json:"code"` + Msg string `json:"msg"` + Data string `json:"data"` +} + +func GetJwt() string { + jwtUrl := viper.GetString("SendMsg.MsgGw") + "/api/v1/jwt" + req, err := http.NewRequest("GET", jwtUrl, nil) + if err != nil { + Loges.Error("new request is err:", zap.Error(err)) + } + req.Header.Add("AppID", viper.GetString("SendMsg.AppID")) + req.Header.Add("AppKey", viper.GetString("SendMsg.AppKey")) + + client := http.Client{} + res, err := client.Do(req) + if err != nil { + Loges.Error("do request is err:", zap.Error(err)) + } + + defer res.Body.Close() + + s, err := ioutil.ReadAll(res.Body) + if err != nil { + Loges.Error("read res.body is err:", zap.Error(err)) + } + jh := HttpBody{} + err = json.Unmarshal(s, &jh) + if err != nil { + Loges.Error("json exchange is err:", zap.Error(err)) + } + + return jh.Data + +} + +func SendWechat(msg ...string) error { + + sendUrl := viper.GetString("SendMsg.MsgGw") + "/api/v1/wechat" + msg = append(msg, time.Now().Format(time.RFC3339)) + data := url.Values{ + "account": {viper.GetString("SendMsg.To")}, + "title": {msg[0]}, + "content": {strings.Join(msg, "\n")}, + } + + req, err := http.NewRequest("POST", sendUrl, strings.NewReader(data.Encode())) + if err != nil { + Loges.Error("new request is err:", zap.Error(err)) + } + ss := GetJwt() + req.Header.Add("AppJWTKey", ss) + req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + + client := http.Client{} + + res, err := client.Do(req) + if err != nil { + Loges.Error("do request is err:", zap.Error(err)) + } + defer res.Body.Close() + if res.StatusCode != 200 { + return err + } + + s, err := ioutil.ReadAll(res.Body) + if err != nil { + Loges.Error("read res.body is err:", zap.Error(err)) + } + + Loges.Info("send msg code", zap.ByteString("info", s)) + + return nil +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..f0e950a --- /dev/null +++ b/main.go @@ -0,0 +1,47 @@ +package main //import "check" + +import ( + "check/httpd" + "fmt" + "net/http" + + "go.uber.org/zap" + + "github.com/julienschmidt/httprouter" + + "github.com/fsnotify/fsnotify" + "github.com/spf13/viper" +) + +func main() { + + viper.SetConfigName("conf") + viper.SetConfigType("toml") + viper.AddConfigPath(".") + err := viper.ReadInConfig() + if err != nil { + panic(fmt.Errorf("Fatal error config file: %s \n", err)) + } + + viper.WatchConfig() + viper.OnConfigChange(func(e fsnotify.Event) { + //fmt.Printf("Config file changed: %s", e.Name) + httpd.Loges.Info("Config file changed: ", zap.Any("", e.Name)) + }) + + ClusterCfgs := httpd.GetConfig() + + httpd.Loges.Info("this is log test") + router := httprouter.New() + router.GET("/checkport", httpd.PortCheck) + router.GET("/checkpod", httpd.Podcheck(ClusterCfgs)) + router.GET("/checkmgo", httpd.MongoCheck) + router.GET("/checkes", httpd.Escheck) + router.GET("/checktotalag", httpd.KfkCheck) + router.GET("/checknode", httpd.NodeCheck(ClusterCfgs)) + router.POST("/postport", httpd.PostPort()) + + //log.Fatal(http.ListenAndServe(viper.GetString("check.hostPort"), router)) + httpd.Loges.Fatal("services :", zap.Any("", http.ListenAndServe(viper.GetString("check.hostPort"), router))) + +} diff --git a/service.sh b/service.sh new file mode 100644 index 0000000..b6bb33c --- /dev/null +++ b/service.sh @@ -0,0 +1,5 @@ +#!/bin/bash +killall check +cd /data/check/ +nohup /data/check/check & +#nohup /data/check/check 2>&1 &