From 9efae24c835692f33636fa809e379cbacc715e39 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 17 May 2022 11:56:35 -0400 Subject: [PATCH 01/29] Added t3c-tail binary to t3c build --- cache-config/Makefile | 4 +++- cache-config/build/build_rpm.sh | 6 ++++++ .../build/trafficcontrol-cache-config.spec | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cache-config/Makefile b/cache-config/Makefile index bc871d0ce4..475190f822 100644 --- a/cache-config/Makefile +++ b/cache-config/Makefile @@ -24,7 +24,7 @@ TC_VERSION ?= $(shell cat ../VERSION) GO_FLAGS ?= PANDOC_FLAGS := --strip-comments -TARGETS := t3c/t3c t3c-apply/t3c-apply t3c-check/t3c-check t3c-check-refs/t3c-check-refs t3c-check-reload/t3c-check-reload t3c-diff/t3c-diff t3c-generate/t3c-generate t3c-preprocess/t3c-preprocess t3c-request/t3c-request t3c-update/t3c-update +TARGETS := t3c/t3c t3c-apply/t3c-apply t3c-check/t3c-check t3c-check-refs/t3c-check-refs t3c-check-reload/t3c-check-reload t3c-diff/t3c-diff t3c-generate/t3c-generate t3c-preprocess/t3c-preprocess t3c-request/t3c-request t3c-tail/t3c-tail t3c-update/t3c-update .PHONY: debug all man rst clean @@ -81,6 +81,8 @@ t3c-preprocess/t3c-preprocess: $(wildcard t3c-preprocess/**/*.go) $(wildcard t3c go build -o $@ $(GO_FLAGS) github.com/apache/trafficcontrol/cache-config/$(dir $@) t3c-request/t3c-request: $(wildcard t3c-request/**/*.go) $(wildcard t3c-request/*.go) go build -o $@ $(GO_FLAGS) github.com/apache/trafficcontrol/cache-config/$(dir $@) +t3c-tail/t3c-tail: $(wildcard t3c-tail/**/*.go) $(wildcard t3c-tail/*.go) + go build -o $@ $(GO_FLAGS) github.com/apache/trafficcontrol/cache-config/$(dir $@) t3c-update/t3c-update: $(wildcard t3c-update/**/*.go) $(wildcard t3c-update/*.go) go build -o $@ $(GO_FLAGS) github.com/apache/trafficcontrol/cache-config/$(dir $@) diff --git a/cache-config/build/build_rpm.sh b/cache-config/build/build_rpm.sh index c022da9ace..3e80f1ed33 100755 --- a/cache-config/build/build_rpm.sh +++ b/cache-config/build/build_rpm.sh @@ -115,6 +115,12 @@ initBuildArea() { buildManpage 't3c-diff'; ) + ( + cd t3c-tail; + go build -v -gcflags "$gcflags" -ldflags "${ldflags} -X main.GitRevision=$(git rev-parse HEAD) -X main.BuildTimestamp=$(date +'%Y-%M-%dT%H:%M:%s') -X main.Version=${TC_VERSION}" -tags "$tags"; + buildManpage 't3c-tail'; + ) + ( cd t3c-preprocess; go build -v -gcflags "$gcflags" -ldflags "${ldflags} -X main.GitRevision=$(git rev-parse HEAD) -X main.BuildTimestamp=$(date +'%Y-%M-%dT%H:%M:%s') -X main.Version=${TC_VERSION}" -tags "$tags"; diff --git a/cache-config/build/trafficcontrol-cache-config.spec b/cache-config/build/trafficcontrol-cache-config.spec index 04b57f901d..607758743b 100644 --- a/cache-config/build/trafficcontrol-cache-config.spec +++ b/cache-config/build/trafficcontrol-cache-config.spec @@ -123,6 +123,14 @@ go_t3c_preprocess_dir="$ccpath"/t3c-preprocess cp "$TC_DIR"/"$ccdir"/t3c-preprocess/t3c-preprocess.1 . ) || { echo "Could not copy go program at $(pwd): $!"; exit 1; } +# copy t3c-tail binary +go_t3c_tail_dir="$ccpath"/t3c-tail +( mkdir -p "$go_t3c_tail_dir" && \ + cd "$go_t3c_tail_dir" && \ + cp "$TC_DIR"/"$ccdir"/t3c-tail/t3c-tail . + cp "$TC_DIR"/"$ccdir"/t3c-tail/t3c-tail.1 . +) || { echo "Could not copy go program at $(pwd): $!"; exit 1; } + %install ccdir="cache-config/" installdir="/usr/bin" @@ -165,6 +173,10 @@ t3c_diff_src=src/github.com/apache/trafficcontrol/"$ccdir"/t3c-diff cp -p "$t3c_diff_src"/t3c-diff ${RPM_BUILD_ROOT}/"$installdir" gzip -c -9 "$src"/t3c-diff/t3c-diff.1 > ${RPM_BUILD_ROOT}/"$mandir"/"$man1dir"/t3c-diff.1.gz +t3c_tail_src=src/github.com/apache/trafficcontrol/"$ccdir"/t3c-tail +cp -p "$t3c_tail_src"/t3c-tail ${RPM_BUILD_ROOT}/"$installdir" +gzip -c -9 "$src"/t3c-tail/t3c-tail.1 > ${RPM_BUILD_ROOT}/"$mandir"/"$man1dir"/t3c-tail.1.gz + t3c_check_src=src/github.com/apache/trafficcontrol/"$ccdir"/t3c-check cp -p "$t3c_check_src"/t3c-check ${RPM_BUILD_ROOT}/"$installdir" gzip -c -9 "$src"/t3c-check/t3c-check.1 > ${RPM_BUILD_ROOT}/"$mandir"/"$man1dir"/t3c-check.1.gz @@ -224,6 +236,7 @@ fi /usr/bin/t3c-generate /usr/bin/t3c-preprocess /usr/bin/t3c-request +/usr/bin/t3c-tail /usr/bin/t3c-update /usr/share/man/man1/t3c.1.gz /usr/share/man/man1/t3c-apply.1.gz @@ -234,6 +247,7 @@ fi /usr/share/man/man1/t3c-generate.1.gz /usr/share/man/man1/t3c-preprocess.1.gz /usr/share/man/man1/t3c-request.1.gz +/usr/share/man/man1/t3c-tail.1.gz /usr/share/man/man1/t3c-update.1.gz %dir /var/lib/trafficcontrol-cache-config From 595fb108cc6cc12736cb021bce901290e79dd60b Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 2 Jun 2022 17:08:26 -0400 Subject: [PATCH 02/29] added tail to command list --- cache-config/t3c/t3c.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cache-config/t3c/t3c.go b/cache-config/t3c/t3c.go index efe56d9861..e47cf896e4 100644 --- a/cache-config/t3c/t3c.go +++ b/cache-config/t3c/t3c.go @@ -48,6 +48,7 @@ var commands = map[string]struct{}{ "generate": struct{}{}, "preprocess": struct{}{}, "request": struct{}{}, + "tail": struct{}{}, "update": struct{}{}, } @@ -115,6 +116,7 @@ These are the available commands: generate generate configuration from Traffic Ops data preprocess preprocess generated config files request request Traffic Ops data + tail tail a log file update update a cache's queue and reval status in Traffic Ops ` } From 0ab699b957b5682c84c141e71becb61cbb98359d Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 2 Jun 2022 17:09:07 -0400 Subject: [PATCH 03/29] Initial add --- cache-config/t3c-tail/README.md | 67 ++++++++++++++++ cache-config/t3c-tail/t3c-tail.go | 125 ++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 cache-config/t3c-tail/README.md create mode 100644 cache-config/t3c-tail/t3c-tail.go diff --git a/cache-config/t3c-tail/README.md b/cache-config/t3c-tail/README.md new file mode 100644 index 0000000000..8cdb1a0a2e --- /dev/null +++ b/cache-config/t3c-tail/README.md @@ -0,0 +1,67 @@ + + + +# NAME + +t3c-tail - Traffic Control Cache Configuration tail tool + +# SYNOPSIS + +t3c-tail + +[\-\-help] + +[\-\-version] + +# DESCRIPTION + +The t3c-tail application will tail a file, usually a log file. + +# OPTIONS + +-h, -\-help + + Print usage info and exit. + +-V, -\-version + + Print version information and exit. + +# AUTHORS + +The t3c application is maintained by Apache Traffic Control project. For help, bug reports, contributing, or anything else, see: + +https://trafficcontrol.apache.org/ + +https://github.com/apache/trafficcontrol diff --git a/cache-config/t3c-tail/t3c-tail.go b/cache-config/t3c-tail/t3c-tail.go new file mode 100644 index 0000000000..d75db7f4ca --- /dev/null +++ b/cache-config/t3c-tail/t3c-tail.go @@ -0,0 +1,125 @@ +package main + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "encoding/json" + "fmt" + "os" + "regexp" + "time" + + "github.com/apache/trafficcontrol/cache-config/t3cutil" + "github.com/nxadm/tail" + "github.com/pborman/getopt/v2" +) + + const AppName = "t3c-tail" + + // Version is the application version. +// This is overwritten by the build with the current project version. +var Version = "0.4" + +// GitRevision is the git revision the application was built from. +// This is overwritten by the build with the current project version. +var GitRevision = "nogit" + +//default time out is 15 seconds, if not included in json input. +var timeOutSeconds = 15 + + + + func main() { + version := getopt.BoolLong("version", 'V', "Print version information and exit.") + help := getopt.BoolLong("help", 'h', "Print usage information and exit") + getopt.Parse() + + if *help { + fmt.Println(usageStr()) + os.Exit(0) + } else if *version { + fmt.Println(t3cutil.VersionStr(AppName, Version, GitRevision)) + os.Exit(0) + } + + tailCfg := &TailCfg{} + if err := json.NewDecoder(os.Stdin).Decode(tailCfg); err != nil { + fmt.Println("Error reading json input", err) + } + + if tailCfg.Match == nil { + fmt.Println("must provide a regex to match") + fmt.Println(usageStr()) + os.Exit(1) + } + + logMatch := regexp.MustCompile(*tailCfg.Match) + timeOut := timeOutSeconds + if tailCfg.TimeOut != nil { + timeOut = *tailCfg.TimeOut + } + + file := tailCfg.File + t, err := tail.TailFile(*file, + tail.Config { + MustExist: true, + Follow: true , + Location: &tail.SeekInfo { + Offset: 0, + Whence: 2, + }, + }) + if err != nil { + fmt.Println("error running tail on ", file) + os.Exit(1) + } + go func() { + for line := range t.Lines { + if logMatch.MatchString(line.Text) { + fmt.Println(line.Text) + } + } + }() + + time.Sleep(time.Second * time.Duration(timeOut)) + fmt.Println("stopping") + err = t.Stop() + if err != nil { + fmt.Printf("ERROR: %s\n", err) + } + t.Cleanup() + +} + +type TailCfg struct { + File *string `json:"file"` + Match *string `json:"match"` + TimeOut *int `json:"timeOut"` +} + +func usageStr() string { + return `usage: t3c-tail [--help] + accepts json input from stdin in the following format: + file is file you want to tail + match is regex string you wish to match on, if you want everything use '.*' + timeOut is given in seconds the default is 15 + {"file":"diags.log", "serviceNeeds":"restart", "timeOut": 4} + ` +} \ No newline at end of file From 2b46ab910d881aadeb51f8b88c1c7ad9fc3fdcfc Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 16 Jun 2022 14:12:32 -0400 Subject: [PATCH 04/29] moved tail config struct t3cutil --- cache-config/t3c-tail/t3c-tail.go | 12 +++--------- cache-config/t3cutil/t3cutil.go | 6 ++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cache-config/t3c-tail/t3c-tail.go b/cache-config/t3c-tail/t3c-tail.go index d75db7f4ca..ef3e079d85 100644 --- a/cache-config/t3c-tail/t3c-tail.go +++ b/cache-config/t3c-tail/t3c-tail.go @@ -59,7 +59,7 @@ var timeOutSeconds = 15 os.Exit(0) } - tailCfg := &TailCfg{} + tailCfg := &t3cutil.TailCfg{} if err := json.NewDecoder(os.Stdin).Decode(tailCfg); err != nil { fmt.Println("Error reading json input", err) } @@ -72,7 +72,7 @@ var timeOutSeconds = 15 logMatch := regexp.MustCompile(*tailCfg.Match) timeOut := timeOutSeconds - if tailCfg.TimeOut != nil { + if tailCfg.TimeOut == nil { timeOut = *tailCfg.TimeOut } @@ -108,18 +108,12 @@ var timeOutSeconds = 15 } -type TailCfg struct { - File *string `json:"file"` - Match *string `json:"match"` - TimeOut *int `json:"timeOut"` -} - func usageStr() string { return `usage: t3c-tail [--help] accepts json input from stdin in the following format: file is file you want to tail match is regex string you wish to match on, if you want everything use '.*' timeOut is given in seconds the default is 15 - {"file":"diags.log", "serviceNeeds":"restart", "timeOut": 4} + {"file":"diags.log", "match":"", "timeOut": 4} ` } \ No newline at end of file diff --git a/cache-config/t3cutil/t3cutil.go b/cache-config/t3cutil/t3cutil.go index 5678ba9c3f..57db6cd04b 100644 --- a/cache-config/t3cutil/t3cutil.go +++ b/cache-config/t3cutil/t3cutil.go @@ -42,6 +42,12 @@ type ATSConfigFile struct { Warnings []string `json:"warnings"` } +type TailCfg struct { + File *string `json:"file"` + Match *string `json:"match"` + TimeOut *int `json:"timeOut"` +} + // ATSConfigFiles implements sort.Interface and sorts by the Location and then FileNameOnDisk, i.e. the full file path. type ATSConfigFiles []ATSConfigFile From dd6d9f830d8cb6a4d2939b74039ea20a3d2289f7 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 17 May 2022 11:56:35 -0400 Subject: [PATCH 05/29] Added t3c-tail binary to t3c build --- cache-config/Makefile | 4 +++- cache-config/build/build_rpm.sh | 6 ++++++ .../build/trafficcontrol-cache-config.spec | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cache-config/Makefile b/cache-config/Makefile index bc871d0ce4..475190f822 100644 --- a/cache-config/Makefile +++ b/cache-config/Makefile @@ -24,7 +24,7 @@ TC_VERSION ?= $(shell cat ../VERSION) GO_FLAGS ?= PANDOC_FLAGS := --strip-comments -TARGETS := t3c/t3c t3c-apply/t3c-apply t3c-check/t3c-check t3c-check-refs/t3c-check-refs t3c-check-reload/t3c-check-reload t3c-diff/t3c-diff t3c-generate/t3c-generate t3c-preprocess/t3c-preprocess t3c-request/t3c-request t3c-update/t3c-update +TARGETS := t3c/t3c t3c-apply/t3c-apply t3c-check/t3c-check t3c-check-refs/t3c-check-refs t3c-check-reload/t3c-check-reload t3c-diff/t3c-diff t3c-generate/t3c-generate t3c-preprocess/t3c-preprocess t3c-request/t3c-request t3c-tail/t3c-tail t3c-update/t3c-update .PHONY: debug all man rst clean @@ -81,6 +81,8 @@ t3c-preprocess/t3c-preprocess: $(wildcard t3c-preprocess/**/*.go) $(wildcard t3c go build -o $@ $(GO_FLAGS) github.com/apache/trafficcontrol/cache-config/$(dir $@) t3c-request/t3c-request: $(wildcard t3c-request/**/*.go) $(wildcard t3c-request/*.go) go build -o $@ $(GO_FLAGS) github.com/apache/trafficcontrol/cache-config/$(dir $@) +t3c-tail/t3c-tail: $(wildcard t3c-tail/**/*.go) $(wildcard t3c-tail/*.go) + go build -o $@ $(GO_FLAGS) github.com/apache/trafficcontrol/cache-config/$(dir $@) t3c-update/t3c-update: $(wildcard t3c-update/**/*.go) $(wildcard t3c-update/*.go) go build -o $@ $(GO_FLAGS) github.com/apache/trafficcontrol/cache-config/$(dir $@) diff --git a/cache-config/build/build_rpm.sh b/cache-config/build/build_rpm.sh index c022da9ace..3e80f1ed33 100755 --- a/cache-config/build/build_rpm.sh +++ b/cache-config/build/build_rpm.sh @@ -115,6 +115,12 @@ initBuildArea() { buildManpage 't3c-diff'; ) + ( + cd t3c-tail; + go build -v -gcflags "$gcflags" -ldflags "${ldflags} -X main.GitRevision=$(git rev-parse HEAD) -X main.BuildTimestamp=$(date +'%Y-%M-%dT%H:%M:%s') -X main.Version=${TC_VERSION}" -tags "$tags"; + buildManpage 't3c-tail'; + ) + ( cd t3c-preprocess; go build -v -gcflags "$gcflags" -ldflags "${ldflags} -X main.GitRevision=$(git rev-parse HEAD) -X main.BuildTimestamp=$(date +'%Y-%M-%dT%H:%M:%s') -X main.Version=${TC_VERSION}" -tags "$tags"; diff --git a/cache-config/build/trafficcontrol-cache-config.spec b/cache-config/build/trafficcontrol-cache-config.spec index 04b57f901d..607758743b 100644 --- a/cache-config/build/trafficcontrol-cache-config.spec +++ b/cache-config/build/trafficcontrol-cache-config.spec @@ -123,6 +123,14 @@ go_t3c_preprocess_dir="$ccpath"/t3c-preprocess cp "$TC_DIR"/"$ccdir"/t3c-preprocess/t3c-preprocess.1 . ) || { echo "Could not copy go program at $(pwd): $!"; exit 1; } +# copy t3c-tail binary +go_t3c_tail_dir="$ccpath"/t3c-tail +( mkdir -p "$go_t3c_tail_dir" && \ + cd "$go_t3c_tail_dir" && \ + cp "$TC_DIR"/"$ccdir"/t3c-tail/t3c-tail . + cp "$TC_DIR"/"$ccdir"/t3c-tail/t3c-tail.1 . +) || { echo "Could not copy go program at $(pwd): $!"; exit 1; } + %install ccdir="cache-config/" installdir="/usr/bin" @@ -165,6 +173,10 @@ t3c_diff_src=src/github.com/apache/trafficcontrol/"$ccdir"/t3c-diff cp -p "$t3c_diff_src"/t3c-diff ${RPM_BUILD_ROOT}/"$installdir" gzip -c -9 "$src"/t3c-diff/t3c-diff.1 > ${RPM_BUILD_ROOT}/"$mandir"/"$man1dir"/t3c-diff.1.gz +t3c_tail_src=src/github.com/apache/trafficcontrol/"$ccdir"/t3c-tail +cp -p "$t3c_tail_src"/t3c-tail ${RPM_BUILD_ROOT}/"$installdir" +gzip -c -9 "$src"/t3c-tail/t3c-tail.1 > ${RPM_BUILD_ROOT}/"$mandir"/"$man1dir"/t3c-tail.1.gz + t3c_check_src=src/github.com/apache/trafficcontrol/"$ccdir"/t3c-check cp -p "$t3c_check_src"/t3c-check ${RPM_BUILD_ROOT}/"$installdir" gzip -c -9 "$src"/t3c-check/t3c-check.1 > ${RPM_BUILD_ROOT}/"$mandir"/"$man1dir"/t3c-check.1.gz @@ -224,6 +236,7 @@ fi /usr/bin/t3c-generate /usr/bin/t3c-preprocess /usr/bin/t3c-request +/usr/bin/t3c-tail /usr/bin/t3c-update /usr/share/man/man1/t3c.1.gz /usr/share/man/man1/t3c-apply.1.gz @@ -234,6 +247,7 @@ fi /usr/share/man/man1/t3c-generate.1.gz /usr/share/man/man1/t3c-preprocess.1.gz /usr/share/man/man1/t3c-request.1.gz +/usr/share/man/man1/t3c-tail.1.gz /usr/share/man/man1/t3c-update.1.gz %dir /var/lib/trafficcontrol-cache-config From 01681f80e4cd35bc4c4cd39a0c2c9996180d66b4 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 2 Jun 2022 17:08:26 -0400 Subject: [PATCH 06/29] added tail to command list --- cache-config/t3c/t3c.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cache-config/t3c/t3c.go b/cache-config/t3c/t3c.go index efe56d9861..e47cf896e4 100644 --- a/cache-config/t3c/t3c.go +++ b/cache-config/t3c/t3c.go @@ -48,6 +48,7 @@ var commands = map[string]struct{}{ "generate": struct{}{}, "preprocess": struct{}{}, "request": struct{}{}, + "tail": struct{}{}, "update": struct{}{}, } @@ -115,6 +116,7 @@ These are the available commands: generate generate configuration from Traffic Ops data preprocess preprocess generated config files request request Traffic Ops data + tail tail a log file update update a cache's queue and reval status in Traffic Ops ` } From 3e407c19d75451823ed13b81e05ef26558c195d3 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 2 Jun 2022 17:09:07 -0400 Subject: [PATCH 07/29] Initial add --- cache-config/t3c-tail/README.md | 67 ++++++++++++++++ cache-config/t3c-tail/t3c-tail.go | 125 ++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 cache-config/t3c-tail/README.md create mode 100644 cache-config/t3c-tail/t3c-tail.go diff --git a/cache-config/t3c-tail/README.md b/cache-config/t3c-tail/README.md new file mode 100644 index 0000000000..8cdb1a0a2e --- /dev/null +++ b/cache-config/t3c-tail/README.md @@ -0,0 +1,67 @@ + + + +# NAME + +t3c-tail - Traffic Control Cache Configuration tail tool + +# SYNOPSIS + +t3c-tail + +[\-\-help] + +[\-\-version] + +# DESCRIPTION + +The t3c-tail application will tail a file, usually a log file. + +# OPTIONS + +-h, -\-help + + Print usage info and exit. + +-V, -\-version + + Print version information and exit. + +# AUTHORS + +The t3c application is maintained by Apache Traffic Control project. For help, bug reports, contributing, or anything else, see: + +https://trafficcontrol.apache.org/ + +https://github.com/apache/trafficcontrol diff --git a/cache-config/t3c-tail/t3c-tail.go b/cache-config/t3c-tail/t3c-tail.go new file mode 100644 index 0000000000..d75db7f4ca --- /dev/null +++ b/cache-config/t3c-tail/t3c-tail.go @@ -0,0 +1,125 @@ +package main + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "encoding/json" + "fmt" + "os" + "regexp" + "time" + + "github.com/apache/trafficcontrol/cache-config/t3cutil" + "github.com/nxadm/tail" + "github.com/pborman/getopt/v2" +) + + const AppName = "t3c-tail" + + // Version is the application version. +// This is overwritten by the build with the current project version. +var Version = "0.4" + +// GitRevision is the git revision the application was built from. +// This is overwritten by the build with the current project version. +var GitRevision = "nogit" + +//default time out is 15 seconds, if not included in json input. +var timeOutSeconds = 15 + + + + func main() { + version := getopt.BoolLong("version", 'V', "Print version information and exit.") + help := getopt.BoolLong("help", 'h', "Print usage information and exit") + getopt.Parse() + + if *help { + fmt.Println(usageStr()) + os.Exit(0) + } else if *version { + fmt.Println(t3cutil.VersionStr(AppName, Version, GitRevision)) + os.Exit(0) + } + + tailCfg := &TailCfg{} + if err := json.NewDecoder(os.Stdin).Decode(tailCfg); err != nil { + fmt.Println("Error reading json input", err) + } + + if tailCfg.Match == nil { + fmt.Println("must provide a regex to match") + fmt.Println(usageStr()) + os.Exit(1) + } + + logMatch := regexp.MustCompile(*tailCfg.Match) + timeOut := timeOutSeconds + if tailCfg.TimeOut != nil { + timeOut = *tailCfg.TimeOut + } + + file := tailCfg.File + t, err := tail.TailFile(*file, + tail.Config { + MustExist: true, + Follow: true , + Location: &tail.SeekInfo { + Offset: 0, + Whence: 2, + }, + }) + if err != nil { + fmt.Println("error running tail on ", file) + os.Exit(1) + } + go func() { + for line := range t.Lines { + if logMatch.MatchString(line.Text) { + fmt.Println(line.Text) + } + } + }() + + time.Sleep(time.Second * time.Duration(timeOut)) + fmt.Println("stopping") + err = t.Stop() + if err != nil { + fmt.Printf("ERROR: %s\n", err) + } + t.Cleanup() + +} + +type TailCfg struct { + File *string `json:"file"` + Match *string `json:"match"` + TimeOut *int `json:"timeOut"` +} + +func usageStr() string { + return `usage: t3c-tail [--help] + accepts json input from stdin in the following format: + file is file you want to tail + match is regex string you wish to match on, if you want everything use '.*' + timeOut is given in seconds the default is 15 + {"file":"diags.log", "serviceNeeds":"restart", "timeOut": 4} + ` +} \ No newline at end of file From 641b7a5356b501a385bbd1b5c5bc89eddcd290c2 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Thu, 16 Jun 2022 14:12:32 -0400 Subject: [PATCH 08/29] moved tail config struct t3cutil --- cache-config/t3c-tail/t3c-tail.go | 12 +++--------- cache-config/t3cutil/t3cutil.go | 6 ++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cache-config/t3c-tail/t3c-tail.go b/cache-config/t3c-tail/t3c-tail.go index d75db7f4ca..ef3e079d85 100644 --- a/cache-config/t3c-tail/t3c-tail.go +++ b/cache-config/t3c-tail/t3c-tail.go @@ -59,7 +59,7 @@ var timeOutSeconds = 15 os.Exit(0) } - tailCfg := &TailCfg{} + tailCfg := &t3cutil.TailCfg{} if err := json.NewDecoder(os.Stdin).Decode(tailCfg); err != nil { fmt.Println("Error reading json input", err) } @@ -72,7 +72,7 @@ var timeOutSeconds = 15 logMatch := regexp.MustCompile(*tailCfg.Match) timeOut := timeOutSeconds - if tailCfg.TimeOut != nil { + if tailCfg.TimeOut == nil { timeOut = *tailCfg.TimeOut } @@ -108,18 +108,12 @@ var timeOutSeconds = 15 } -type TailCfg struct { - File *string `json:"file"` - Match *string `json:"match"` - TimeOut *int `json:"timeOut"` -} - func usageStr() string { return `usage: t3c-tail [--help] accepts json input from stdin in the following format: file is file you want to tail match is regex string you wish to match on, if you want everything use '.*' timeOut is given in seconds the default is 15 - {"file":"diags.log", "serviceNeeds":"restart", "timeOut": 4} + {"file":"diags.log", "match":"", "timeOut": 4} ` } \ No newline at end of file diff --git a/cache-config/t3cutil/t3cutil.go b/cache-config/t3cutil/t3cutil.go index 782548301f..446aa07589 100644 --- a/cache-config/t3cutil/t3cutil.go +++ b/cache-config/t3cutil/t3cutil.go @@ -43,6 +43,12 @@ type ATSConfigFile struct { Warnings []string `json:"warnings"` } +type TailCfg struct { + File *string `json:"file"` + Match *string `json:"match"` + TimeOut *int `json:"timeOut"` +} + // ATSConfigFiles implements sort.Interface and sorts by the Location and then FileNameOnDisk, i.e. the full file path. type ATSConfigFiles []ATSConfigFile From 1c3b1c1e4558ea2dd17ffec8ec09999761c1c36a Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 28 Jun 2022 16:03:00 -0400 Subject: [PATCH 09/29] changes to matching for exit --- cache-config/t3c-tail/t3c-tail.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/cache-config/t3c-tail/t3c-tail.go b/cache-config/t3c-tail/t3c-tail.go index ef3e079d85..de05672fd0 100644 --- a/cache-config/t3c-tail/t3c-tail.go +++ b/cache-config/t3c-tail/t3c-tail.go @@ -24,6 +24,7 @@ import ( "fmt" "os" "regexp" + "strings" "time" "github.com/apache/trafficcontrol/cache-config/t3cutil" @@ -64,15 +65,21 @@ var timeOutSeconds = 15 fmt.Println("Error reading json input", err) } - if tailCfg.Match == nil { + if tailCfg.LogMatch == nil { fmt.Println("must provide a regex to match") fmt.Println(usageStr()) os.Exit(1) } - - logMatch := regexp.MustCompile(*tailCfg.Match) + var endMatch string + if tailCfg.EndMatch != nil { + endMatch = *tailCfg.EndMatch + } else { + endMatch = "use timeout" + } + + logMatch := regexp.MustCompile(*tailCfg.LogMatch) timeOut := timeOutSeconds - if tailCfg.TimeOut == nil { + if tailCfg.TimeOut != nil { timeOut = *tailCfg.TimeOut } @@ -95,11 +102,15 @@ var timeOutSeconds = 15 if logMatch.MatchString(line.Text) { fmt.Println(line.Text) } + if strings.Contains(line.Text, endMatch) { + fmt.Println("Stopping on stop match") + break + } } }() time.Sleep(time.Second * time.Duration(timeOut)) - fmt.Println("stopping") + fmt.Println("stopping with timeout") err = t.Stop() if err != nil { fmt.Printf("ERROR: %s\n", err) @@ -113,7 +124,8 @@ func usageStr() string { accepts json input from stdin in the following format: file is file you want to tail match is regex string you wish to match on, if you want everything use '.*' + stopMatch is a string used to exit tail when it is found in the logs timeOut is given in seconds the default is 15 - {"file":"diags.log", "match":"", "timeOut": 4} + {"file":"diags.log", "match":"", "endMatch": "", "timeOut": 4} ` } \ No newline at end of file From 120e4a5faf6afec73c9bee42b08c13b7817a2b94 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 28 Jun 2022 16:03:52 -0400 Subject: [PATCH 10/29] added filed for ending tail before timeout is reached --- cache-config/t3cutil/t3cutil.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cache-config/t3cutil/t3cutil.go b/cache-config/t3cutil/t3cutil.go index 446aa07589..026b04d5aa 100644 --- a/cache-config/t3cutil/t3cutil.go +++ b/cache-config/t3cutil/t3cutil.go @@ -44,9 +44,10 @@ type ATSConfigFile struct { } type TailCfg struct { - File *string `json:"file"` - Match *string `json:"match"` - TimeOut *int `json:"timeOut"` + File *string `json:"file"` + LogMatch *string `json:"logMatch"` + EndMatch *string `json:"endMatch"` + TimeOut *int `json:"timeOut"` } // ATSConfigFiles implements sort.Interface and sorts by the Location and then FileNameOnDisk, i.e. the full file path. From cffcda1a2b0dfd9f8a6021139fc30659c27d674f Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 28 Jun 2022 16:12:09 -0400 Subject: [PATCH 11/29] added call to t3c-tail for reload and restart --- cache-config/t3c-apply/torequest/torequest.go | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cache-config/t3c-apply/torequest/torequest.go b/cache-config/t3c-apply/torequest/torequest.go index e61168209e..de02c33036 100644 --- a/cache-config/t3c-apply/torequest/torequest.go +++ b/cache-config/t3c-apply/torequest/torequest.go @@ -47,6 +47,14 @@ const ( UpdateTropsFailed UpdateStatus = 3 ) +const ( + TailDiagsLog = "/opt/trafficserver/var/log/trafficserver/diags.log" + TailRestartTimeOut = 60 + TailReloadTimeOut = 30 + tailRestartEnd = "(load)|(cache enabled)" + tailReloadEnd = "(load)|(cache enabled)" +) + type Package struct { Name string `json:"name"` Version string `json:"version"` @@ -1103,6 +1111,14 @@ func (r *TrafficOpsReq) StartServices(syncdsUpdate *UpdateStatus) error { return errors.New("failed to restart trafficserver") } log.Infoln("trafficserver has been " + startStr + "ed") + if output, err := doTail(TailDiagsLog, ".*", "Traffic Server is fully initialized", TailRestartTimeOut); err != nil { + log.Errorln("error running tail") + } else { + for _, line := range strings.Split(output, "\n") { + log.Infoln(line) + } + + } if *syncdsUpdate == UpdateTropsNeeded { *syncdsUpdate = UpdateTropsSuccessful } @@ -1125,6 +1141,13 @@ func (r *TrafficOpsReq) StartServices(syncdsUpdate *UpdateStatus) error { *syncdsUpdate = UpdateTropsSuccessful } log.Infoln("ATS 'traffic_ctl config reload' was successful") + if output, err := doTail(TailDiagsLog, ".*", "remap.config finished loading", TailReloadTimeOut); err != nil { + log.Errorln("error running tail: ", err) + } else { + for _, line := range strings.Split(output, "\n") { + log.Infoln(line) + } + } } if *syncdsUpdate == UpdateTropsNeeded { *syncdsUpdate = UpdateTropsSuccessful From 4ad8539a62c37f3e03ba4e09e43623e3981bba65 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Tue, 28 Jun 2022 16:13:05 -0400 Subject: [PATCH 12/29] added doTail func to run t3c-tail --- cache-config/t3c-apply/torequest/cmd.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cache-config/t3c-apply/torequest/cmd.go b/cache-config/t3c-apply/torequest/cmd.go index fcf347e634..f91dd7e7e6 100644 --- a/cache-config/t3c-apply/torequest/cmd.go +++ b/cache-config/t3c-apply/torequest/cmd.go @@ -274,6 +274,27 @@ func sendUpdate(cfg config.Cfg, configApplyTime, revalApplyTime *time.Time, conf return nil } +//doTail calls t3c-tail and will run a tail on the log file provided with string for a regex to +//maatch on default is .* endMatch will make t3c-tail exit when a pattern is matched otherwise +//a timeout in a given number of seconds will occur. +func doTail(file string, logMatch string, endMatch string, timeoutSeconds int) (string,error) { + tailData := t3cutil.TailCfg{ + File: &file, + LogMatch: &logMatch, + EndMatch: &endMatch, + TimeOut: &timeoutSeconds, + } + tailInput, err := json.Marshal(&tailData) + if err != nil { + return "", fmt.Errorf("error loading json input") + } + stdOut, stdErr, code := t3cutil.DoInput(tailInput, `t3c-tail`, "") + if code > 1 { + return "", fmt.Errorf("t3c-tail returned error code %v stdout '%v' stderr '%v'", code, string(stdOut), string(stdErr)) + } + return string(stdOut), nil +} + // diff calls t3c-diff to diff the given new file and the file on disk. Returns whether they're different. // Logs the difference. // If the file on disk doesn't exist, returns true and logs the entire file as a diff. From 2c00646ab3bd67b2afc84c082249a2f788f2cfb4 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 6 Jul 2022 15:04:47 -0400 Subject: [PATCH 13/29] updated README documentation --- cache-config/t3c-tail/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cache-config/t3c-tail/README.md b/cache-config/t3c-tail/README.md index 8cdb1a0a2e..46ffcc4578 100644 --- a/cache-config/t3c-tail/README.md +++ b/cache-config/t3c-tail/README.md @@ -47,6 +47,14 @@ t3c-tail # DESCRIPTION The t3c-tail application will tail a file, usually a log file. +Reads json input from stdin. +Provide a file name to watch, a regex to filter or .* for all, +a regex match to exit tail (if omitted will exit on timeout), +timeout in seconds for how long you want it to run, default is 15 seconds. + + +# JSON Format + {"file":"", "logMatch":"", "endMatch":"", "timeOut": } # OPTIONS From 50c3c485eb88a9d30fe6a5227ba8be2bed218cae Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 6 Jul 2022 15:05:53 -0400 Subject: [PATCH 14/29] updated timeout for ats reload --- cache-config/t3c-apply/torequest/torequest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache-config/t3c-apply/torequest/torequest.go b/cache-config/t3c-apply/torequest/torequest.go index de02c33036..f43d4de254 100644 --- a/cache-config/t3c-apply/torequest/torequest.go +++ b/cache-config/t3c-apply/torequest/torequest.go @@ -50,7 +50,7 @@ const ( const ( TailDiagsLog = "/opt/trafficserver/var/log/trafficserver/diags.log" TailRestartTimeOut = 60 - TailReloadTimeOut = 30 + TailReloadTimeOut = 15 tailRestartEnd = "(load)|(cache enabled)" tailReloadEnd = "(load)|(cache enabled)" ) From c4af5bbfce1f2e9e2a127af77fd02a0bb40d0417 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 6 Jul 2022 15:06:52 -0400 Subject: [PATCH 15/29] added regex for end match --- cache-config/t3c-tail/t3c-tail.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cache-config/t3c-tail/t3c-tail.go b/cache-config/t3c-tail/t3c-tail.go index de05672fd0..0f84bef71c 100644 --- a/cache-config/t3c-tail/t3c-tail.go +++ b/cache-config/t3c-tail/t3c-tail.go @@ -24,7 +24,6 @@ import ( "fmt" "os" "regexp" - "strings" "time" "github.com/apache/trafficcontrol/cache-config/t3cutil" @@ -70,11 +69,11 @@ var timeOutSeconds = 15 fmt.Println(usageStr()) os.Exit(1) } - var endMatch string + + endMatch := regexp.MustCompile("^timeout") + if tailCfg.EndMatch != nil { - endMatch = *tailCfg.EndMatch - } else { - endMatch = "use timeout" + endMatch = regexp.MustCompile(*tailCfg.EndMatch) } logMatch := regexp.MustCompile(*tailCfg.LogMatch) @@ -102,7 +101,7 @@ var timeOutSeconds = 15 if logMatch.MatchString(line.Text) { fmt.Println(line.Text) } - if strings.Contains(line.Text, endMatch) { + if endMatch.MatchString(line.Text) { fmt.Println("Stopping on stop match") break } @@ -110,7 +109,6 @@ var timeOutSeconds = 15 }() time.Sleep(time.Second * time.Duration(timeOut)) - fmt.Println("stopping with timeout") err = t.Stop() if err != nil { fmt.Printf("ERROR: %s\n", err) @@ -126,6 +124,6 @@ func usageStr() string { match is regex string you wish to match on, if you want everything use '.*' stopMatch is a string used to exit tail when it is found in the logs timeOut is given in seconds the default is 15 - {"file":"diags.log", "match":"", "endMatch": "", "timeOut": 4} + {"file":"diags.log", "match":"", "endMatch": "", "timeOut": 4} ` } \ No newline at end of file From cee3f04b3587e018514c86180b77e0fc5d1116fb Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 6 Jul 2022 15:27:12 -0400 Subject: [PATCH 16/29] Changed ending matches for restart and reload --- cache-config/t3c-apply/torequest/torequest.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cache-config/t3c-apply/torequest/torequest.go b/cache-config/t3c-apply/torequest/torequest.go index f43d4de254..3a4fdb58d4 100644 --- a/cache-config/t3c-apply/torequest/torequest.go +++ b/cache-config/t3c-apply/torequest/torequest.go @@ -51,8 +51,8 @@ const ( TailDiagsLog = "/opt/trafficserver/var/log/trafficserver/diags.log" TailRestartTimeOut = 60 TailReloadTimeOut = 15 - tailRestartEnd = "(load)|(cache enabled)" - tailReloadEnd = "(load)|(cache enabled)" + tailRestartEnd = "Traffic Server is fully initialized" + tailReloadEnd = "remap.config finished loading" ) type Package struct { @@ -1111,7 +1111,7 @@ func (r *TrafficOpsReq) StartServices(syncdsUpdate *UpdateStatus) error { return errors.New("failed to restart trafficserver") } log.Infoln("trafficserver has been " + startStr + "ed") - if output, err := doTail(TailDiagsLog, ".*", "Traffic Server is fully initialized", TailRestartTimeOut); err != nil { + if output, err := doTail(TailDiagsLog, ".*", tailRestartEnd, TailRestartTimeOut); err != nil { log.Errorln("error running tail") } else { for _, line := range strings.Split(output, "\n") { @@ -1141,7 +1141,7 @@ func (r *TrafficOpsReq) StartServices(syncdsUpdate *UpdateStatus) error { *syncdsUpdate = UpdateTropsSuccessful } log.Infoln("ATS 'traffic_ctl config reload' was successful") - if output, err := doTail(TailDiagsLog, ".*", "remap.config finished loading", TailReloadTimeOut); err != nil { + if output, err := doTail(TailDiagsLog, ".*", tailReloadEnd, TailReloadTimeOut); err != nil { log.Errorln("error running tail: ", err) } else { for _, line := range strings.Split(output, "\n") { From 8504c220ae3a5d6b4259e46806c43409dd0dc5e5 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 13 Jul 2022 14:33:20 -0400 Subject: [PATCH 17/29] switched from sleep to timer and added logging --- cache-config/t3c-tail/t3c-tail.go | 32 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/cache-config/t3c-tail/t3c-tail.go b/cache-config/t3c-tail/t3c-tail.go index 0f84bef71c..04c18e885a 100644 --- a/cache-config/t3c-tail/t3c-tail.go +++ b/cache-config/t3c-tail/t3c-tail.go @@ -26,7 +26,9 @@ import ( "regexp" "time" + "github.com/apache/trafficcontrol/lib/go-log" "github.com/apache/trafficcontrol/cache-config/t3cutil" + "github.com/nxadm/tail" "github.com/pborman/getopt/v2" ) @@ -51,6 +53,8 @@ var timeOutSeconds = 15 help := getopt.BoolLong("help", 'h', "Print usage information and exit") getopt.Parse() + log.Init(os.Stderr, os.Stderr, os.Stderr, os.Stderr, os.Stderr) + if *help { fmt.Println(usageStr()) os.Exit(0) @@ -61,11 +65,12 @@ var timeOutSeconds = 15 tailCfg := &t3cutil.TailCfg{} if err := json.NewDecoder(os.Stdin).Decode(tailCfg); err != nil { - fmt.Println("Error reading json input", err) + log.Errorln("Error reading json input", err) + os.Exit(1) } if tailCfg.LogMatch == nil { - fmt.Println("must provide a regex to match") + log.Errorln("must provide a regex to match") fmt.Println(usageStr()) os.Exit(1) } @@ -93,37 +98,36 @@ var timeOutSeconds = 15 }, }) if err != nil { - fmt.Println("error running tail on ", file) + log.Errorln("error running tail on ", file) os.Exit(1) } + timer := time.NewTimer(time.Second * time.Duration(timeOut)) go func() { for line := range t.Lines { if logMatch.MatchString(line.Text) { fmt.Println(line.Text) } if endMatch.MatchString(line.Text) { - fmt.Println("Stopping on stop match") + if !timer.Stop() { + <-timer.C + } + timer.Reset(0) break } } }() - time.Sleep(time.Second * time.Duration(timeOut)) - err = t.Stop() - if err != nil { - fmt.Printf("ERROR: %s\n", err) - } + <-timer.C t.Cleanup() - } func usageStr() string { return `usage: t3c-tail [--help] accepts json input from stdin in the following format: - file is file you want to tail - match is regex string you wish to match on, if you want everything use '.*' - stopMatch is a string used to exit tail when it is found in the logs - timeOut is given in seconds the default is 15 + file: path to the file you want to tail + match: is regex string you wish to match on, if you want everything use '.*' + stopMatch: is a regex used to exit tail when it is found in the logs + timeOut: given in seconds the default is 15 {"file":"diags.log", "match":"", "endMatch": "", "timeOut": 4} ` } \ No newline at end of file From 332b0573452258b4933e3a1b42f2508b78c4062a Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 13 Jul 2022 14:34:28 -0400 Subject: [PATCH 18/29] added variables for matching --- cache-config/t3c-apply/torequest/torequest.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/cache-config/t3c-apply/torequest/torequest.go b/cache-config/t3c-apply/torequest/torequest.go index 3a4fdb58d4..75102c47f3 100644 --- a/cache-config/t3c-apply/torequest/torequest.go +++ b/cache-config/t3c-apply/torequest/torequest.go @@ -51,6 +51,7 @@ const ( TailDiagsLog = "/opt/trafficserver/var/log/trafficserver/diags.log" TailRestartTimeOut = 60 TailReloadTimeOut = 15 + tailMatch = `ET_(TASK|NET)\s\d{1,}` tailRestartEnd = "Traffic Server is fully initialized" tailReloadEnd = "remap.config finished loading" ) @@ -1111,13 +1112,8 @@ func (r *TrafficOpsReq) StartServices(syncdsUpdate *UpdateStatus) error { return errors.New("failed to restart trafficserver") } log.Infoln("trafficserver has been " + startStr + "ed") - if output, err := doTail(TailDiagsLog, ".*", tailRestartEnd, TailRestartTimeOut); err != nil { + if err := doTail(r.Cfg, TailDiagsLog, ".*", tailRestartEnd, TailRestartTimeOut); err != nil { log.Errorln("error running tail") - } else { - for _, line := range strings.Split(output, "\n") { - log.Infoln(line) - } - } if *syncdsUpdate == UpdateTropsNeeded { *syncdsUpdate = UpdateTropsSuccessful @@ -1141,12 +1137,8 @@ func (r *TrafficOpsReq) StartServices(syncdsUpdate *UpdateStatus) error { *syncdsUpdate = UpdateTropsSuccessful } log.Infoln("ATS 'traffic_ctl config reload' was successful") - if output, err := doTail(TailDiagsLog, ".*", tailReloadEnd, TailReloadTimeOut); err != nil { + if err := doTail(r.Cfg, TailDiagsLog, tailMatch, tailReloadEnd, TailReloadTimeOut); err != nil { log.Errorln("error running tail: ", err) - } else { - for _, line := range strings.Split(output, "\n") { - log.Infoln(line) - } } } if *syncdsUpdate == UpdateTropsNeeded { From 25926d7d976a35060019dd434ced2d5d8a746754 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 13 Jul 2022 14:35:55 -0400 Subject: [PATCH 19/29] strip datetime from diags log messages --- cache-config/t3c-apply/torequest/cmd.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cache-config/t3c-apply/torequest/cmd.go b/cache-config/t3c-apply/torequest/cmd.go index f91dd7e7e6..4c746ab496 100644 --- a/cache-config/t3c-apply/torequest/cmd.go +++ b/cache-config/t3c-apply/torequest/cmd.go @@ -32,6 +32,7 @@ import ( golog "log" "os" "os/exec" + "regexp" "strconv" "strings" "time" @@ -277,7 +278,7 @@ func sendUpdate(cfg config.Cfg, configApplyTime, revalApplyTime *time.Time, conf //doTail calls t3c-tail and will run a tail on the log file provided with string for a regex to //maatch on default is .* endMatch will make t3c-tail exit when a pattern is matched otherwise //a timeout in a given number of seconds will occur. -func doTail(file string, logMatch string, endMatch string, timeoutSeconds int) (string,error) { +func doTail(cfg config.Cfg, file string, logMatch string, endMatch string, timeoutSeconds int) error { tailData := t3cutil.TailCfg{ File: &file, LogMatch: &logMatch, @@ -286,13 +287,22 @@ func doTail(file string, logMatch string, endMatch string, timeoutSeconds int) ( } tailInput, err := json.Marshal(&tailData) if err != nil { - return "", fmt.Errorf("error loading json input") + return fmt.Errorf("error loading json input") } stdOut, stdErr, code := t3cutil.DoInput(tailInput, `t3c-tail`, "") if code > 1 { - return "", fmt.Errorf("t3c-tail returned error code %v stdout '%v' stderr '%v'", code, string(stdOut), string(stdErr)) + return fmt.Errorf("t3c-tail returned error code %v stdout '%v' stderr '%v'", code, string(stdOut), string(stdErr)) } - return string(stdOut), nil + logSubApp(`t3c-tail`, stdErr) + + stripDate := regexp.MustCompile(`\[\w{3}\s{1,2}\d{1,2}\s\d{2}:\d{2}:\d{2}\.\d{3}\]\s`) + stdOut = bytes.TrimSpace(stdOut) + lines := strings.Split(string(stdOut), "\n") + for _, line := range lines { + line = stripDate.ReplaceAllString(line, "") + log.Infoln(line) + } + return nil } // diff calls t3c-diff to diff the given new file and the file on disk. Returns whether they're different. From 3cdd7d7a2c99c2121d80e06a5849cbe2496c168a Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 13 Jul 2022 14:44:38 -0400 Subject: [PATCH 20/29] added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6646f45e5..9acc0d0cc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added layered profile feature to 4.0 for `GET` /deliveryservices/{id}/servers/ and /deliveryservices/{id}/servers/eligible. - Change to t3c regex_revalidate so that STALE is no longer explicitly added for default revalidate rule for ATS version backwards compatibility. - Change to t3c diff to flag a config file for replacement if owner/group settings are not `ats` [#6879](https://github.com/apache/trafficcontrol/issues/6879). +- Added a sub-app t3c-tail to tail diags.log and caputre output when t3c reloads and restarts trafficserver ### Fixed - Fixed TO to default route ID to 0, if it is not present in the request context. From 30567aa426591f691e5bdebf5ecbbfeb1bb04e61 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 13 Jul 2022 15:25:08 -0400 Subject: [PATCH 21/29] fixed formatting issues --- cache-config/t3c-apply/torequest/cmd.go | 10 +++--- cache-config/t3c-apply/torequest/torequest.go | 10 +++--- cache-config/t3c-tail/t3c-tail.go | 32 +++++++++---------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/cache-config/t3c-apply/torequest/cmd.go b/cache-config/t3c-apply/torequest/cmd.go index 4c746ab496..e49ba7df7f 100644 --- a/cache-config/t3c-apply/torequest/cmd.go +++ b/cache-config/t3c-apply/torequest/cmd.go @@ -277,13 +277,13 @@ func sendUpdate(cfg config.Cfg, configApplyTime, revalApplyTime *time.Time, conf //doTail calls t3c-tail and will run a tail on the log file provided with string for a regex to //maatch on default is .* endMatch will make t3c-tail exit when a pattern is matched otherwise -//a timeout in a given number of seconds will occur. +//a timeout in a given number of seconds will occur. func doTail(cfg config.Cfg, file string, logMatch string, endMatch string, timeoutSeconds int) error { tailData := t3cutil.TailCfg{ - File: &file, + File: &file, LogMatch: &logMatch, EndMatch: &endMatch, - TimeOut: &timeoutSeconds, + TimeOut: &timeoutSeconds, } tailInput, err := json.Marshal(&tailData) if err != nil { @@ -291,7 +291,7 @@ func doTail(cfg config.Cfg, file string, logMatch string, endMatch string, timeo } stdOut, stdErr, code := t3cutil.DoInput(tailInput, `t3c-tail`, "") if code > 1 { - return fmt.Errorf("t3c-tail returned error code %v stdout '%v' stderr '%v'", code, string(stdOut), string(stdErr)) + return fmt.Errorf("t3c-tail returned error code %v stdout '%v' stderr '%v'", code, string(stdOut), string(stdErr)) } logSubApp(`t3c-tail`, stdErr) @@ -302,7 +302,7 @@ func doTail(cfg config.Cfg, file string, logMatch string, endMatch string, timeo line = stripDate.ReplaceAllString(line, "") log.Infoln(line) } - return nil + return nil } // diff calls t3c-diff to diff the given new file and the file on disk. Returns whether they're different. diff --git a/cache-config/t3c-apply/torequest/torequest.go b/cache-config/t3c-apply/torequest/torequest.go index 75102c47f3..aace7a3e60 100644 --- a/cache-config/t3c-apply/torequest/torequest.go +++ b/cache-config/t3c-apply/torequest/torequest.go @@ -48,12 +48,12 @@ const ( ) const ( - TailDiagsLog = "/opt/trafficserver/var/log/trafficserver/diags.log" + TailDiagsLog = "/opt/trafficserver/var/log/trafficserver/diags.log" TailRestartTimeOut = 60 - TailReloadTimeOut = 15 - tailMatch = `ET_(TASK|NET)\s\d{1,}` - tailRestartEnd = "Traffic Server is fully initialized" - tailReloadEnd = "remap.config finished loading" + TailReloadTimeOut = 15 + tailMatch = `ET_(TASK|NET)\s\d{1,}` + tailRestartEnd = "Traffic Server is fully initialized" + tailReloadEnd = "remap.config finished loading" ) type Package struct { diff --git a/cache-config/t3c-tail/t3c-tail.go b/cache-config/t3c-tail/t3c-tail.go index 04c18e885a..c7f913a3e2 100644 --- a/cache-config/t3c-tail/t3c-tail.go +++ b/cache-config/t3c-tail/t3c-tail.go @@ -26,16 +26,16 @@ import ( "regexp" "time" - "github.com/apache/trafficcontrol/lib/go-log" "github.com/apache/trafficcontrol/cache-config/t3cutil" + "github.com/apache/trafficcontrol/lib/go-log" "github.com/nxadm/tail" "github.com/pborman/getopt/v2" ) - const AppName = "t3c-tail" +const AppName = "t3c-tail" - // Version is the application version. +// Version is the application version. // This is overwritten by the build with the current project version. var Version = "0.4" @@ -46,9 +46,7 @@ var GitRevision = "nogit" //default time out is 15 seconds, if not included in json input. var timeOutSeconds = 15 - - - func main() { +func main() { version := getopt.BoolLong("version", 'V', "Print version information and exit.") help := getopt.BoolLong("help", 'h', "Print usage information and exit") getopt.Parse() @@ -74,29 +72,29 @@ var timeOutSeconds = 15 fmt.Println(usageStr()) os.Exit(1) } - + endMatch := regexp.MustCompile("^timeout") if tailCfg.EndMatch != nil { endMatch = regexp.MustCompile(*tailCfg.EndMatch) } - + logMatch := regexp.MustCompile(*tailCfg.LogMatch) timeOut := timeOutSeconds if tailCfg.TimeOut != nil { timeOut = *tailCfg.TimeOut } - + file := tailCfg.File t, err := tail.TailFile(*file, - tail.Config { + tail.Config{ MustExist: true, - Follow: true , - Location: &tail.SeekInfo { + Follow: true, + Location: &tail.SeekInfo{ Offset: 0, Whence: 2, - }, - }) + }, + }) if err != nil { log.Errorln("error running tail on ", file) os.Exit(1) @@ -107,7 +105,7 @@ var timeOutSeconds = 15 if logMatch.MatchString(line.Text) { fmt.Println(line.Text) } - if endMatch.MatchString(line.Text) { + if endMatch.MatchString(line.Text) { if !timer.Stop() { <-timer.C } @@ -116,7 +114,7 @@ var timeOutSeconds = 15 } } }() - + <-timer.C t.Cleanup() } @@ -130,4 +128,4 @@ func usageStr() string { timeOut: given in seconds the default is 15 {"file":"diags.log", "match":"", "endMatch": "", "timeOut": 4} ` -} \ No newline at end of file +} From 9b11c7abed15b134dd96dd705cbcaef8a350b8bf Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Wed, 13 Jul 2022 15:29:23 -0400 Subject: [PATCH 22/29] fixed one more formating issue --- cache-config/t3cutil/t3cutil.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cache-config/t3cutil/t3cutil.go b/cache-config/t3cutil/t3cutil.go index 026b04d5aa..dd30fba131 100644 --- a/cache-config/t3cutil/t3cutil.go +++ b/cache-config/t3cutil/t3cutil.go @@ -44,10 +44,10 @@ type ATSConfigFile struct { } type TailCfg struct { - File *string `json:"file"` - LogMatch *string `json:"logMatch"` - EndMatch *string `json:"endMatch"` - TimeOut *int `json:"timeOut"` + File *string `json:"file"` + LogMatch *string `json:"logMatch"` + EndMatch *string `json:"endMatch"` + TimeOut *int `json:"timeOut"` } // ATSConfigFiles implements sort.Interface and sorts by the Location and then FileNameOnDisk, i.e. the full file path. From b8a1d63e83883af22974e240490c302bc730bc07 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 22 Jul 2022 16:09:16 -0400 Subject: [PATCH 23/29] fixed typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9acc0d0cc5..f2eef1fb66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added layered profile feature to 4.0 for `GET` /deliveryservices/{id}/servers/ and /deliveryservices/{id}/servers/eligible. - Change to t3c regex_revalidate so that STALE is no longer explicitly added for default revalidate rule for ATS version backwards compatibility. - Change to t3c diff to flag a config file for replacement if owner/group settings are not `ats` [#6879](https://github.com/apache/trafficcontrol/issues/6879). -- Added a sub-app t3c-tail to tail diags.log and caputre output when t3c reloads and restarts trafficserver +- Added a sub-app t3c-tail to tail diags.log and capture output when t3c reloads and restarts trafficserver ### Fixed - Fixed TO to default route ID to 0, if it is not present in the request context. From 78f9d0f9347951238f9b7e30c848abf71d8666e6 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 22 Jul 2022 16:23:19 -0400 Subject: [PATCH 24/29] moved must compile outside of func, use flags instead of stdin --- cache-config/t3c-apply/torequest/cmd.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/cache-config/t3c-apply/torequest/cmd.go b/cache-config/t3c-apply/torequest/cmd.go index e49ba7df7f..21f06ecede 100644 --- a/cache-config/t3c-apply/torequest/cmd.go +++ b/cache-config/t3c-apply/torequest/cmd.go @@ -32,6 +32,7 @@ import ( golog "log" "os" "os/exec" + "path/filepath" "regexp" "strconv" "strings" @@ -49,6 +50,8 @@ type ServerAndConfigs struct { ConfigFiles json.RawMessage } +var stripDate = regexp.MustCompile(`\[\w{3}\s{1,2}\d{1,2}\s\d{2}:\d{2}:\d{2}\.\d{3}\]\s`) + // generate runs t3c-generate and returns the result. func generate(cfg config.Cfg) ([]t3cutil.ATSConfigFile, error) { configData, err := requestConfig(cfg) @@ -278,24 +281,19 @@ func sendUpdate(cfg config.Cfg, configApplyTime, revalApplyTime *time.Time, conf //doTail calls t3c-tail and will run a tail on the log file provided with string for a regex to //maatch on default is .* endMatch will make t3c-tail exit when a pattern is matched otherwise //a timeout in a given number of seconds will occur. -func doTail(cfg config.Cfg, file string, logMatch string, endMatch string, timeoutSeconds int) error { - tailData := t3cutil.TailCfg{ - File: &file, - LogMatch: &logMatch, - EndMatch: &endMatch, - TimeOut: &timeoutSeconds, - } - tailInput, err := json.Marshal(&tailData) - if err != nil { - return fmt.Errorf("error loading json input") +func doTail(cfg config.Cfg, file string, logMatch string, endMatch string, timeoutInMS int) error { + args := []string{ + "--file=" + filepath.Join(cfg.TsHome, file), + "--match=" + logMatch, + "--end-match=" + endMatch, + "--timeout-ms=" + strconv.Itoa(timeoutInMS), } - stdOut, stdErr, code := t3cutil.DoInput(tailInput, `t3c-tail`, "") + stdOut, stdErr, code := t3cutil.Do(`t3c-tail`, args...) if code > 1 { return fmt.Errorf("t3c-tail returned error code %v stdout '%v' stderr '%v'", code, string(stdOut), string(stdErr)) } logSubApp(`t3c-tail`, stdErr) - stripDate := regexp.MustCompile(`\[\w{3}\s{1,2}\d{1,2}\s\d{2}:\d{2}:\d{2}\.\d{3}\]\s`) stdOut = bytes.TrimSpace(stdOut) lines := strings.Split(string(stdOut), "\n") for _, line := range lines { From 9447526253ee417d0e93f8984d1beb819e27ec0e Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 22 Jul 2022 16:26:11 -0400 Subject: [PATCH 25/29] changed and renamed timeout vars to MS, updated diags log to relative path --- cache-config/t3c-apply/torequest/torequest.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cache-config/t3c-apply/torequest/torequest.go b/cache-config/t3c-apply/torequest/torequest.go index aace7a3e60..542d6a8145 100644 --- a/cache-config/t3c-apply/torequest/torequest.go +++ b/cache-config/t3c-apply/torequest/torequest.go @@ -48,12 +48,12 @@ const ( ) const ( - TailDiagsLog = "/opt/trafficserver/var/log/trafficserver/diags.log" - TailRestartTimeOut = 60 - TailReloadTimeOut = 15 - tailMatch = `ET_(TASK|NET)\s\d{1,}` - tailRestartEnd = "Traffic Server is fully initialized" - tailReloadEnd = "remap.config finished loading" + TailDiagsLogRelative = "/var/log/trafficserver/diags.log" + TailRestartTimeOutMS = 60000 + TailReloadTimeOutMS = 15000 + tailMatch = `ET_(TASK|NET)\s\d{1,}` + tailRestartEnd = "Traffic Server is fully initialized" + tailReloadEnd = "remap.config finished loading" ) type Package struct { @@ -1112,7 +1112,7 @@ func (r *TrafficOpsReq) StartServices(syncdsUpdate *UpdateStatus) error { return errors.New("failed to restart trafficserver") } log.Infoln("trafficserver has been " + startStr + "ed") - if err := doTail(r.Cfg, TailDiagsLog, ".*", tailRestartEnd, TailRestartTimeOut); err != nil { + if err := doTail(r.Cfg, TailDiagsLogRelative, ".*", tailRestartEnd, TailRestartTimeOutMS); err != nil { log.Errorln("error running tail") } if *syncdsUpdate == UpdateTropsNeeded { @@ -1137,7 +1137,7 @@ func (r *TrafficOpsReq) StartServices(syncdsUpdate *UpdateStatus) error { *syncdsUpdate = UpdateTropsSuccessful } log.Infoln("ATS 'traffic_ctl config reload' was successful") - if err := doTail(r.Cfg, TailDiagsLog, tailMatch, tailReloadEnd, TailReloadTimeOut); err != nil { + if err := doTail(r.Cfg, TailDiagsLogRelative, tailMatch, tailReloadEnd, TailReloadTimeOutMS); err != nil { log.Errorln("error running tail: ", err) } } From bef55b6ec9c2c19a09eaaf43b232d6866ca15f57 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 22 Jul 2022 16:27:16 -0400 Subject: [PATCH 26/29] removed struct that is no longer needed/used --- cache-config/t3cutil/t3cutil.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cache-config/t3cutil/t3cutil.go b/cache-config/t3cutil/t3cutil.go index dd30fba131..782548301f 100644 --- a/cache-config/t3cutil/t3cutil.go +++ b/cache-config/t3cutil/t3cutil.go @@ -43,13 +43,6 @@ type ATSConfigFile struct { Warnings []string `json:"warnings"` } -type TailCfg struct { - File *string `json:"file"` - LogMatch *string `json:"logMatch"` - EndMatch *string `json:"endMatch"` - TimeOut *int `json:"timeOut"` -} - // ATSConfigFiles implements sort.Interface and sorts by the Location and then FileNameOnDisk, i.e. the full file path. type ATSConfigFiles []ATSConfigFile From ad24b5b3a5deccec4f52b67970afcaf4b0eba203 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 22 Jul 2022 16:27:56 -0400 Subject: [PATCH 27/29] updated to use flags instead of stdin --- cache-config/t3c-tail/t3c-tail.go | 55 +++++++++++++------------------ 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/cache-config/t3c-tail/t3c-tail.go b/cache-config/t3c-tail/t3c-tail.go index c7f913a3e2..1979de686c 100644 --- a/cache-config/t3c-tail/t3c-tail.go +++ b/cache-config/t3c-tail/t3c-tail.go @@ -20,7 +20,6 @@ package main */ import ( - "encoding/json" "fmt" "os" "regexp" @@ -43,10 +42,14 @@ var Version = "0.4" // This is overwritten by the build with the current project version. var GitRevision = "nogit" -//default time out is 15 seconds, if not included in json input. -var timeOutSeconds = 15 +// defaultTimeOutMs is 15000 milliseconds, if not included in input. +var defaultTimeOutMs = 15000 func main() { + file := getopt.StringLong("file", 'f', "", "Path to file to watch") + match := getopt.StringLong("match", 'm', ".*", "Regex pattern you want to match while running tail default is .*") + endMatch := getopt.StringLong("end-match", 'e', "^timeout", "Regex pattern that will cause tail to exit before timeout") + timeOutMs := getopt.Int64Long("timeout-ms", 't', int64(defaultTimeOutMs), "Timeout in milliseconds that will cause tail to exit default is 15000 MS") version := getopt.BoolLong("version", 'V', "Print version information and exit.") help := getopt.BoolLong("help", 'h', "Print usage information and exit") getopt.Parse() @@ -61,31 +64,16 @@ func main() { os.Exit(0) } - tailCfg := &t3cutil.TailCfg{} - if err := json.NewDecoder(os.Stdin).Decode(tailCfg); err != nil { - log.Errorln("Error reading json input", err) - os.Exit(1) - } - - if tailCfg.LogMatch == nil { - log.Errorln("must provide a regex to match") + if *file == "" || file == nil { + fmt.Println("Please provide file path for t3c-tail") fmt.Println(usageStr()) os.Exit(1) } - endMatch := regexp.MustCompile("^timeout") + logMatch := regexp.MustCompile(*match) + tailStop := regexp.MustCompile(*endMatch) + timeOut := *timeOutMs - if tailCfg.EndMatch != nil { - endMatch = regexp.MustCompile(*tailCfg.EndMatch) - } - - logMatch := regexp.MustCompile(*tailCfg.LogMatch) - timeOut := timeOutSeconds - if tailCfg.TimeOut != nil { - timeOut = *tailCfg.TimeOut - } - - file := tailCfg.File t, err := tail.TailFile(*file, tail.Config{ MustExist: true, @@ -96,16 +84,16 @@ func main() { }, }) if err != nil { - log.Errorln("error running tail on ", file) + log.Errorln("error running tail on ", file, err) os.Exit(1) } - timer := time.NewTimer(time.Second * time.Duration(timeOut)) + timer := time.NewTimer(time.Millisecond * time.Duration(timeOut)) go func() { for line := range t.Lines { if logMatch.MatchString(line.Text) { fmt.Println(line.Text) } - if endMatch.MatchString(line.Text) { + if tailStop.MatchString(line.Text) { if !timer.Stop() { <-timer.C } @@ -121,11 +109,14 @@ func main() { func usageStr() string { return `usage: t3c-tail [--help] - accepts json input from stdin in the following format: - file: path to the file you want to tail - match: is regex string you wish to match on, if you want everything use '.*' - stopMatch: is a regex used to exit tail when it is found in the logs - timeOut: given in seconds the default is 15 - {"file":"diags.log", "match":"", "endMatch": "", "timeOut": 4} + -f -m -e -t + + file is path to the file you want to tail + + match is regex string you wish to match on, default is '.*' + + endMatch is a regex used to exit tail when it is found in the logs with out waiting for timeout + + timeOutMs is when tail will stop if endMatch isn't found default is 15000 ` } From 83723652b01e9c516e22dda09753484e94d24ad2 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 22 Jul 2022 16:28:34 -0400 Subject: [PATCH 28/29] updated to reflect changes. --- cache-config/t3c-tail/README.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/cache-config/t3c-tail/README.md b/cache-config/t3c-tail/README.md index 46ffcc4578..0777b67eef 100644 --- a/cache-config/t3c-tail/README.md +++ b/cache-config/t3c-tail/README.md @@ -38,7 +38,7 @@ t3c-tail - Traffic Control Cache Configuration tail tool # SYNOPSIS -t3c-tail +t3c-tail \-f \ \-m \ \-e \ \-t \ [\-\-help] @@ -47,21 +47,29 @@ t3c-tail # DESCRIPTION The t3c-tail application will tail a file, usually a log file. -Reads json input from stdin. -Provide a file name to watch, a regex to filter or .* for all, +Provide a file name to watch, a regex to filter or .* is the default, a regex match to exit tail (if omitted will exit on timeout), -timeout in seconds for how long you want it to run, default is 15 seconds. - - -# JSON Format - {"file":"", "logMatch":"", "endMatch":"", "timeOut": } +timeout in milliseconds for how long you want it to run, default is 15000 milliseconds. # OPTIONS +-e, -\-end-match + + Regex pattern that will cause tail to exit before timeout. + +-f, -\-file + Path to file to watch. + -h, -\-help Print usage info and exit. +-m, -\-match + Regex pattern you want to match while running tail default is .*. + +-t -\-timeout-ms + Timeout in milliseconds that will cause tail to exit default is 15000 MS. + -V, -\-version Print version information and exit. From 344577886a829b3b0e9cb0f2507c6fa26ae7d289 Mon Sep 17 00:00:00 2001 From: jpappa200 Date: Fri, 22 Jul 2022 16:42:08 -0400 Subject: [PATCH 29/29] fixed formatting errors --- cache-config/t3c-apply/torequest/torequest.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cache-config/t3c-apply/torequest/torequest.go b/cache-config/t3c-apply/torequest/torequest.go index 542d6a8145..22905ed910 100644 --- a/cache-config/t3c-apply/torequest/torequest.go +++ b/cache-config/t3c-apply/torequest/torequest.go @@ -49,8 +49,8 @@ const ( const ( TailDiagsLogRelative = "/var/log/trafficserver/diags.log" - TailRestartTimeOutMS = 60000 - TailReloadTimeOutMS = 15000 + TailRestartTimeOutMS = 60000 + TailReloadTimeOutMS = 15000 tailMatch = `ET_(TASK|NET)\s\d{1,}` tailRestartEnd = "Traffic Server is fully initialized" tailReloadEnd = "remap.config finished loading"