Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gearman_top #29

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ceeeee6
Create initial files for extension
May 3, 2024
62d2589
Implementation of TCP connection and status retrieval from a gearman …
May 8, 2024
3904f00
Print gearman queues in right order in a table
May 8, 2024
07ba68e
Reworked logic of queue struct with more appropiate data types
May 8, 2024
b21ebba
Refactoring of utility functions to separate file
May 8, 2024
6314862
Support for additional hosts for query and impmentation of the batch …
May 10, 2024
f344f87
Display stats in loop and improvents in querying multiple hosts
May 10, 2024
4ab608b
Renamed functions with capital letters to lowercase letters if they'r…
May 15, 2024
f662644
Internval argument can now be a float. Minor improvements and refacto…
May 15, 2024
360959a
Aligned argument options with the original options. Fixed a bug where…
May 15, 2024
abc061b
Added handling and logging of errors
May 17, 2024
79d53f6
Implemented timeout for TCP connection
May 17, 2024
de22ad5
Improved reading of bigger networking payloads
May 17, 2024
1fd057c
Enable parallel querying and printing of hosts
May 23, 2024
a6bb647
Changed timeout logic to using default logic instead of custom one
May 23, 2024
bf7a943
Cleaned up commented code
May 23, 2024
ba112d9
Changed comment
May 23, 2024
921005a
Reuse TCP connections instead of creating a new one on each query
May 23, 2024
4475ba4
Sort queuenames in table alphabetically
May 24, 2024
f5198d9
Prettier print for hostnames and their ports
May 24, 2024
a357030
Better comments
May 29, 2024
094d3e2
Bugfix where initital content would only show after the set interval
May 29, 2024
a8c8921
Major refactoring for improved readability
May 31, 2024
8ebe0ed
Updated .gitignore and deleted binaries
Jun 5, 2024
1b8e93d
Delete .DS_Store
IsThisEvenCode Jun 5, 2024
b5b9ea5
Delete cmd/gearman_top/.DS_Store
IsThisEvenCode Jun 5, 2024
e62b73f
Delete cmd/.DS_Store
IsThisEvenCode Jun 5, 2024
9abd24a
Better error handling with TCP connection
Jun 5, 2024
2bba7c4
Worker progress
Jun 7, 2024
2f117e1
Merge branch 'master' into gearman_top
sni Jun 7, 2024
02abb15
Add utils package with pretty table formatting. Eliminate external de…
Jun 7, 2024
8643e4e
Add program exit with ctrl + c and minor error handling
Jun 12, 2024
86ef8f1
versions now come from queried host
Jun 12, 2024
dbbf9ff
Changed output to stdout or stderr
Jun 12, 2024
36a4a69
corrections for passing linter tests
Jun 12, 2024
ed79f8f
corrections for passing linter tests
Jun 12, 2024
e1b9740
corrections for passing linter tests and bugfixes
Jun 12, 2024
d841575
corrections for passing linter tests
Jun 12, 2024
2bfa710
formatting
Jun 14, 2024
596e4ca
add build number
Jun 14, 2024
420e586
correction for linter
Jun 14, 2024
bddf9ca
fix wrong filtering of dummy queue
Jun 18, 2024
02c8801
fix wrong filtering of dummy queue and satisfy linter
Jun 18, 2024
3e2f666
refactoring to avoid naming collisions
Jun 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod_gearman_worker
send_gearman
gearman_top
*.exe
*.linux.amd64
*.swp
Expand All @@ -11,3 +12,11 @@ tools/
go.work
go.work.sum
test*.pl
/.idea/.gitignore
/cmd/.idea/cmd.iml
/.idea/mod-gearman-worker-go.iml
/.idea/modules.xml
/cmd/.idea/modules.xml
/.idea/vcs.xml
/cmd/.idea/vcs.xml
/cmd/.idea/workspace.xml
39 changes: 39 additions & 0 deletions cmd/gearman_top/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"flag"
"fmt"
"os"

"github.com/consol-monitoring/mod-gearman-worker-go/pkg/modgearman"
)

// Build contains the current git commit id
// compile passing -ldflags "-X main.Build <build sha1>" to set the id.
var Build string

func main() {
args := modgearman.GmTopArgs{}
// Define a new FlagSet for avoiding collisions with other flags
flagSet := flag.NewFlagSet("gearman_top", flag.ExitOnError)

flagSet.BoolVar(&args.Usage, "h", false, "Print usage")
flagSet.BoolVar(&args.Version, "V", false, "Print version")
flagSet.BoolVar(&args.Quiet, "q", false, "Quiet mode")
flagSet.BoolVar(&args.Batch, "b", false, "Batch mode")
flagSet.BoolVar(&args.Verbose, "v", false, "Verbose output")
flagSet.Float64Var(&args.Interval, "i", 1.0, "Set interval")
flagSet.Func("H", "Add host", func(host string) error {
return modgearman.Add2HostList(host, &args.Hosts)
})

// Parse the flags in the custom FlagSet
err := flagSet.Parse(os.Args[1:])
if err != nil {
fmt.Fprintf(os.Stderr, "Error parsing flags -> %s", err.Error())
os.Exit(1)
}

// Call the GearmanTop function with the parsed arguments
modgearman.GearmanTop(&args, Build)
}
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
module github.com/consol-monitoring/mod-gearman-worker-go

go 1.22
go 1.22.0

toolchain go1.22.1
toolchain go1.22.2

require (
github.com/appscode/g2 v0.0.0-20190123131438-388ba74fd273
github.com/consol-monitoring/check_nsc_web/pkg/checknscweb v0.0.0-20240321161425-fd9209e96e1f
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/kdar/factorlog v0.0.0-20211012144011-6ea75a169038
github.com/nsf/termbox-go v1.1.1
github.com/prometheus/client_golang v1.19.1
github.com/sevlyar/go-daemon v0.1.6
github.com/sni/shelltoken v0.0.0-20240314123449-84b0a0c05450
github.com/stretchr/testify v1.9.0
)

require github.com/stretchr/testify v1.9.0
require github.com/consol-monitoring/snclient v0.0.0-20240606211131-676acdc0aa94

require (
github.com/appscode/go v0.0.0-20201105063637-5613f3b8169f // indirect
Expand All @@ -26,11 +28,14 @@ require (
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.54.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
golang.org/x/sys v0.21.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5 // indirect
Expand Down
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcju
github.com/codeskyblue/go-sh v0.0.0-20200712050446-30169cf553fe/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE=
github.com/consol-monitoring/check_nsc_web/pkg/checknscweb v0.0.0-20240321161425-fd9209e96e1f h1:y78+ANbT1a0HJbQ9WVmdlQFk7qEpros/o7lLIiY83hk=
github.com/consol-monitoring/check_nsc_web/pkg/checknscweb v0.0.0-20240321161425-fd9209e96e1f/go.mod h1:kGOlGyv+QdtHJMt/13U5UoETFrgGP/6MWtAAWz7tFus=
github.com/consol-monitoring/snclient v0.0.0-20240606211131-676acdc0aa94 h1:uK/UVdJeJZVhXhWlB4lonpcHbewhD25FAEgOytEDdoA=
github.com/consol-monitoring/snclient v0.0.0-20240606211131-676acdc0aa94/go.mod h1:qoZEXKOd6tvgBFetX7OHRGgsBNIfL9jUj4Rcol/jsTU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down Expand Up @@ -48,11 +50,16 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
github.com/nsf/termbox-go v1.1.1 h1:nksUPLCb73Q++DwbYUBEglYBRPZyoXJdrj5L+TkjyZY=
github.com/nsf/termbox-go v1.1.1/go.mod h1:T0cTdVuOwf7pHQNtfhnEbzHbcNyCEcVU4YPpouCbVxo=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
Expand All @@ -65,6 +72,9 @@ github.com/prometheus/common v0.54.0 h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM
github.com/prometheus/common v0.54.0/go.mod h1:/TQgMJP5CuVYveyT7n/0Ix8yLNNXy9yRSkhnLTHPDIQ=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/sevlyar/go-daemon v0.1.6 h1:EUh1MDjEM4BI109Jign0EaknA2izkOyi0LV3ro3QQGs=
Expand All @@ -81,6 +91,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 h1:LoYXNGAShUG3m/ehNk4iFctuhGX/+R1ZpfJ4/ia80JM=
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
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/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
Loading
Loading