Skip to content

Commit

Permalink
Merge pull request #766 from mackerelio/as-status
Browse files Browse the repository at this point in the history
support overwrite status
  • Loading branch information
yseto authored Oct 19, 2023
2 parents 010afd3 + 31eeb20 commit c93dad2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions check-tcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ command = ["check-tcp", "-H", "localhost", "-p", "4224", "-w", "3", "-c", "5"]
-S, --ssl Use SSL for the connection.
-U, --unix-sock= Unix Domain Socket
--no-check-certificate Do not check certificate
--status-as= Overwrite status=to-status, support multiple comma separetes.
-t, --timeout= Seconds before connection times out (default: 10)
-m, --maxbytes= Close connection once more than this number of bytes are received
-d, --delay= Seconds to wait between sending string and polling for response
Expand Down
9 changes: 8 additions & 1 deletion check-tcp/lib/check-tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type exchange struct {
SSL bool `short:"S" long:"ssl" description:"Use SSL for the connection."`
UnixSock string `short:"U" long:"unix-sock" description:"Unix Domain Socket"`
NoCheckCertificate bool `long:"no-check-certificate" description:"Do not check certificate"`
StatusAs string `long:"status-as" description:"Overwrite status=to-status, support multiple comma separetes."`
expectReg *regexp.Regexp
}

Expand All @@ -45,12 +46,18 @@ func Do() {
if err != nil {
os.Exit(1)
}
maps, err := checkers.ParseStatusMap(opts.StatusAs)
if err != nil {
fmt.Println(err)
os.Exit(1)
}

ckr := opts.run()
ckr.Name = "TCP"
if opts.Service != "" {
ckr.Name = opts.Service
}
ckr.Exit()
ckr.ExitStatusAs(maps)
}

func parseArgs(args []string) (*tcpOpts, error) {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mackerelio/go-check-plugins

go 1.18
go 1.20

require (
github.com/StackExchange/wmi v1.2.1
Expand All @@ -17,7 +17,7 @@ require (
github.com/jessevdk/go-flags v1.5.0
github.com/jmoiron/sqlx v1.3.5
github.com/lib/pq v1.10.7
github.com/mackerelio/checkers v0.0.4
github.com/mackerelio/checkers v0.2.0
github.com/mackerelio/go-osstat v0.2.4
github.com/mackerelio/golib v1.2.1
github.com/mattn/go-encoding v0.0.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/mackerelio/checkers v0.0.4 h1:dLxl3szIA1uW/+pFefamBPaFT9MCKkdH3uQND7c64bk=
github.com/mackerelio/checkers v0.0.4/go.mod h1:VEf9gFHvpvH7Zvcwjuj7x3ozQg5w3En6ww9UcWoWHeE=
github.com/mackerelio/checkers v0.2.0 h1:YBOQjpU2Qno66eUrUEH6DjWn+Wna5BXCKMdekz50XWs=
github.com/mackerelio/checkers v0.2.0/go.mod h1:CW3k/5bvHhxDrfKgWvMvNH0R51zco141ZVxlI7o/KAc=
github.com/mackerelio/go-osstat v0.2.4 h1:qxGbdPkFo65PXOb/F/nhDKpF2nGmGaCFDLXoZjJTtUs=
github.com/mackerelio/go-osstat v0.2.4/go.mod h1:Zy+qzGdZs3A9cuIqmgbJvwbmLQH9dJvtio5ZjJTbdlQ=
github.com/mackerelio/golib v1.2.1 h1:SDcDn6Jw3p9bi1N0bg1Z/ilG5qcBB23qL8xNwrU0gg4=
Expand Down

0 comments on commit c93dad2

Please sign in to comment.