Skip to content

Commit c93dad2

Browse files
authored
Merge pull request mackerelio#766 from mackerelio/as-status
support overwrite status
2 parents 010afd3 + 31eeb20 commit c93dad2

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

check-tcp/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ command = ["check-tcp", "-H", "localhost", "-p", "4224", "-w", "3", "-c", "5"]
5151
-S, --ssl Use SSL for the connection.
5252
-U, --unix-sock= Unix Domain Socket
5353
--no-check-certificate Do not check certificate
54+
--status-as= Overwrite status=to-status, support multiple comma separetes.
5455
-t, --timeout= Seconds before connection times out (default: 10)
5556
-m, --maxbytes= Close connection once more than this number of bytes are received
5657
-d, --delay= Seconds to wait between sending string and polling for response

check-tcp/lib/check-tcp.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type exchange struct {
3636
SSL bool `short:"S" long:"ssl" description:"Use SSL for the connection."`
3737
UnixSock string `short:"U" long:"unix-sock" description:"Unix Domain Socket"`
3838
NoCheckCertificate bool `long:"no-check-certificate" description:"Do not check certificate"`
39+
StatusAs string `long:"status-as" description:"Overwrite status=to-status, support multiple comma separetes."`
3940
expectReg *regexp.Regexp
4041
}
4142

@@ -45,12 +46,18 @@ func Do() {
4546
if err != nil {
4647
os.Exit(1)
4748
}
49+
maps, err := checkers.ParseStatusMap(opts.StatusAs)
50+
if err != nil {
51+
fmt.Println(err)
52+
os.Exit(1)
53+
}
54+
4855
ckr := opts.run()
4956
ckr.Name = "TCP"
5057
if opts.Service != "" {
5158
ckr.Name = opts.Service
5259
}
53-
ckr.Exit()
60+
ckr.ExitStatusAs(maps)
5461
}
5562

5663
func parseArgs(args []string) (*tcpOpts, error) {

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/mackerelio/go-check-plugins
22

3-
go 1.18
3+
go 1.20
44

55
require (
66
github.com/StackExchange/wmi v1.2.1
@@ -17,7 +17,7 @@ require (
1717
github.com/jessevdk/go-flags v1.5.0
1818
github.com/jmoiron/sqlx v1.3.5
1919
github.com/lib/pq v1.10.7
20-
github.com/mackerelio/checkers v0.0.4
20+
github.com/mackerelio/checkers v0.2.0
2121
github.com/mackerelio/go-osstat v0.2.4
2222
github.com/mackerelio/golib v1.2.1
2323
github.com/mattn/go-encoding v0.0.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
8989
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
9090
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
9191
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
92-
github.com/mackerelio/checkers v0.0.4 h1:dLxl3szIA1uW/+pFefamBPaFT9MCKkdH3uQND7c64bk=
93-
github.com/mackerelio/checkers v0.0.4/go.mod h1:VEf9gFHvpvH7Zvcwjuj7x3ozQg5w3En6ww9UcWoWHeE=
92+
github.com/mackerelio/checkers v0.2.0 h1:YBOQjpU2Qno66eUrUEH6DjWn+Wna5BXCKMdekz50XWs=
93+
github.com/mackerelio/checkers v0.2.0/go.mod h1:CW3k/5bvHhxDrfKgWvMvNH0R51zco141ZVxlI7o/KAc=
9494
github.com/mackerelio/go-osstat v0.2.4 h1:qxGbdPkFo65PXOb/F/nhDKpF2nGmGaCFDLXoZjJTtUs=
9595
github.com/mackerelio/go-osstat v0.2.4/go.mod h1:Zy+qzGdZs3A9cuIqmgbJvwbmLQH9dJvtio5ZjJTbdlQ=
9696
github.com/mackerelio/golib v1.2.1 h1:SDcDn6Jw3p9bi1N0bg1Z/ilG5qcBB23qL8xNwrU0gg4=

0 commit comments

Comments
 (0)