From 81f829b1b9ff3febdf01134711ffbdca5d2dc8d3 Mon Sep 17 00:00:00 2001 From: mikael Date: Wed, 29 Apr 2020 17:32:00 +0200 Subject: Use dup2 on FreeBSD aarch64 --- logging/logging_arm64.go | 2 +- logging/logging_other.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/logging/logging_arm64.go b/logging/logging_arm64.go index 03848bb..339d108 100644 --- a/logging/logging_arm64.go +++ b/logging/logging_arm64.go @@ -1,4 +1,4 @@ -// +build arm64 +// +build linux,arm64 package logging diff --git a/logging/logging_other.go b/logging/logging_other.go index fd88b83..792ae1e 100644 --- a/logging/logging_other.go +++ b/logging/logging_other.go @@ -1,5 +1,5 @@ // +build linux openbsd freebsd darwin -// +build !arm64 +// +build !linux,arm64 package logging -- cgit v1.2.3 From 310a6d084d5ff56ebb26cd667f46f578b39c737a Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Tue, 12 May 2020 18:42:45 -0500 Subject: Replaces the Prometheus client with VictoriaMetrics/metrics --- CHANGELOG.md | 1 + README.md | 1 + cmd/gotop/main.go | 6 +- go.mod | 16 ++--- go.sum | 168 ++++++------------------------------------------ widgets/battery.go | 23 +++---- widgets/batterygauge.go | 29 ++------- widgets/cpu.go | 42 +++++------- widgets/disk.go | 22 ++----- widgets/mem.go | 41 ++++++------ widgets/metrics.go | 19 ++++++ widgets/net.go | 25 ++----- widgets/temp.go | 21 ++---- 13 files changed, 114 insertions(+), 300 deletions(-) create mode 100644 widgets/metrics.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 316e451..318c4f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Extensions are now built with a build tool; this is an interim solution until issues with the Go plugin API are resolved. - Command line help text is cleaned up. - Version bump of gopsutil +- Prometheus client replaced by [VictoriaMetrics/metrics](https://github.com/VictoriaMetrics/metrics). This eliminated 6 indirect package dependencies and saved 3.5MB (25%) of the compiled binary size. ### Removed diff --git a/README.md b/README.md index 8a3e55e..4d3e571 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,7 @@ Run `gotop -h` to see the list of all command line options. - [shirou/gopsutil](https://github.com/shirou/gopsutil) - [goreleaser/nfpm](https://github.com/goreleaser/nfpm) - [distatus/battery](https://github.com/distatus/battery) +- [VictoriaMetrics/metrics](https://github.com/VictoriaMetrics/metrics) Check this out! The API is clean, elegant, introduces many fewer indirect dependencies than the Prometheus client, and adds 50% less size to binaries. ## History diff --git a/cmd/gotop/main.go b/cmd/gotop/main.go index 25dd5b8..dc869ce 100644 --- a/cmd/gotop/main.go +++ b/cmd/gotop/main.go @@ -17,8 +17,8 @@ import ( //_ "net/http/pprof" + "github.com/VictoriaMetrics/metrics" ui "github.com/gizak/termui/v3" - "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/shibukawa/configdir" "github.com/xxxserxxx/opflag" @@ -447,7 +447,9 @@ func run() int { if conf.ExportPort != "" { go func() { - http.Handle("/metrics", promhttp.Handler()) + http.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) { + metrics.WritePrometheus(w, true) + }) http.ListenAndServe(conf.ExportPort, nil) }() } diff --git a/go.mod b/go.mod index 975ca3d..1763e3d 100644 --- a/go.mod +++ b/go.mod @@ -1,25 +1,19 @@ module github.com/xxxserxxx/gotop/v4 require ( - github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect + github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect + github.com/VictoriaMetrics/metrics v1.11.2 github.com/distatus/battery v0.9.0 - github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815 github.com/gizak/termui/v3 v3.0.0 - github.com/go-ole/go-ole v1.2.1 // indirect + github.com/go-ole/go-ole v1.2.4 // indirect github.com/mattn/go-runewidth v0.0.4 - github.com/mitchellh/go-wordwrap v1.0.0 // indirect - github.com/prometheus/client_golang v1.4.1 github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 github.com/shirou/gopsutil v2.20.3+incompatible - github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect github.com/stretchr/testify v1.4.0 github.com/xxxserxxx/iSMC v1.0.1 github.com/xxxserxxx/opflag v1.0.5 - golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect - golang.org/x/tools v0.0.0-20200425043458-8463f397d07c // indirect - golang.org/x/tools/gopls v0.4.0 // indirect - howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect - mvdan.cc/xurls/v2 v2.2.0 // indirect + golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25 // indirect + howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5 // indirect ) go 1.14 diff --git a/go.sum b/go.sum index 2e2c454..d698b71 100644 --- a/go.sum +++ b/go.sum @@ -1,52 +1,18 @@ -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -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/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= +github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/VictoriaMetrics/metrics v1.11.2 h1:t/ceLP6SvagUqypCKU7cI7+tQn54+TIV/tGoxihHvx8= +github.com/VictoriaMetrics/metrics v1.11.2/go.mod h1:LU2j9qq7xqZYXz8tF3/RQnB2z2MbZms5TDiIg9/NHiQ= github.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd h1:XtfPmj9tQRilnrEmI1HjQhxXWRhEM+m8CACtaMJE/kM= github.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd/go.mod h1:vjcQJUZJYD3MeVGhtZXSMnCHfUNZxsyYzJt90eCYxK4= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 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/distatus/battery v0.9.0 h1:8NS5o00/j3Oh2xgocA6pQROTp5guoR+s8CZlWzHC4QM= github.com/distatus/battery v0.9.0/go.mod h1:gGO7GxHTi1zlRT+cAj8uGG0/8HFiqAeH0TJvoipnuPs= -github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815 h1:HMAfwOa33y82IaQEKQDfUCiwNlxtM1iw7HLM9ru0RNc= -github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:l7JNRynTRuqe45tpIyItHNqZWTxywYjp87MWTOnU5cg= github.com/gizak/termui/v3 v3.0.0 h1:NYTUG6ig/sJK05O5FyhWemwlVPO8ilNpvS/PgRtrKAE= github.com/gizak/termui/v3 v3.0.0/go.mod h1:uinu2dMdtMI+FTIdEFUJQT5y+KShnhQRshvPblXq3lY= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.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-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= +github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -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= @@ -55,134 +21,38 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= -github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840= github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= github.com/panotza/gosmc v0.0.0-20190601191911-810267459a2a h1:P0QSyHOubLI2e6hccBBEjVX0vPWXoXui5QCAVNWdJSk= github.com/panotza/gosmc v0.0.0-20190601191911-810267459a2a/go.mod h1:u8Q8dpnMAam0MElxP2KjEROzXMk9G8X168RTpAZ9tPc= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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 v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.4.1 h1:FFSuS004yOQEtDdTq+TAOLP5xUq63KqAFYyOi8zA+Y8= -github.com/prometheus/client_golang v1.4.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -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/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U= -github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 h1:Xuk8ma/ibJ1fOy4Ee11vHhUFHQNpHhrBneOCNHVXS5w= github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0/go.mod h1:7AwjWCpdPhkSmNAgUv5C7EJ4AbmjEB3r047r3DXWu3Y= -github.com/shirou/gopsutil v2.18.11+incompatible h1:PMFTKnFTr/YTRW5rbLK4vWALV3a+IGXse5nvhSjztmg= -github.com/shirou/gopsutil v2.18.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v2.20.3+incompatible h1:0JVooMPsT7A7HqEYdydp/OfjSOYSjhXV7w1hkKj/NPQ= github.com/shirou/gopsutil v2.20.3+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U= -github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 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 v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/xxxserxxx/gotop v0.0.0-20200228201131-d16cf1c6d2b9 h1:Sn+TuKkfF+CVaJjm4oVmeADtrOaHtrWpgqVLtsMpUqg= -github.com/xxxserxxx/gotop/v3 v3.5.1 h1:aBf++Oxg7qCZpKqYpPPnXKFOxT1KYLPtiEXRh57ywu0= -github.com/xxxserxxx/gotop/v3 v3.5.1/go.mod h1:DGPTiAmUhqE21xvokK64BuMxW+EmnOptaxpdOlqiH6s= +github.com/valyala/fastrand v1.0.0 h1:LUKT9aKer2dVQNUi3waewTbKV+7H17kvWFNKs2ObdkI= +github.com/valyala/fastrand v1.0.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ= +github.com/valyala/histogram v1.0.1 h1:FzA7n2Tz/wKRMejgu3PV1vw3htAklTjjuoI6z3d4KDg= +github.com/valyala/histogram v1.0.1/go.mod h1:lQy0xA4wUz2+IUnf97SivorsJIp8FxsnRd6x25q7Mto= github.com/xxxserxxx/iSMC v1.0.1 h1:M9Gkwnnkl+evvnugoB5yRYrbUP+cRIVOPM+xrHZc3Hs= github.com/xxxserxxx/iSMC v1.0.1/go.mod h1:TGgNjU7BF2DZSuxiTft+BdzxzcujFJYqFfMCzcTl/aY= -github.com/xxxserxxx/opflag v1.0.0 h1:NabxbubvejqcdzQUHnsU8pBMAiWM+a/Rh2IJe56moiU= -github.com/xxxserxxx/opflag v1.0.0/go.mod h1:Zf9bGkOcA35ypGfN25KX0iujVpZB5XwauEFjcfSKcBo= -github.com/xxxserxxx/opflag v1.0.2 h1:TanW4Ck/RNal4fP2VVAvhEu7eBq4z+9hhGq9Q8OTq68= -github.com/xxxserxxx/opflag v1.0.2/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4= -github.com/xxxserxxx/opflag v1.0.3 h1:ugsBWZtSXUaMLEjPLW0WKGjq/gsrc0GpZYbCJY6ZHVY= -github.com/xxxserxxx/opflag v1.0.3/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4= -github.com/xxxserxxx/opflag v1.0.4 h1:g979b8oReAERfDKFTTwdvAYIarFxpVYOzYrHa/hMvNs= -github.com/xxxserxxx/opflag v1.0.4/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4= github.com/xxxserxxx/opflag v1.0.5 h1:2H4Qtl1qe+dSkEcGt+fBe2mQ8z14MgkWPqcLaoa6k90= github.com/xxxserxxx/opflag v1.0.5/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -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/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 h1:ywK/j/KkyTHcdyYSZNXGjMwgmDSfjglYZ3vStQ/gSCU= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200407041343-bf15fae40dea h1:DUwLyMDMUauGMd9kSLIlhhYJNELm06HuxeBdkFkeax4= -golang.org/x/tools v0.0.0-20200407041343-bf15fae40dea/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200425043458-8463f397d07c h1:iHhCR0b26amDCiiO+kBguKZom9aMF+NrFxh9zeKR/XU= -golang.org/x/tools v0.0.0-20200425043458-8463f397d07c/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools/gopls v0.4.0 h1:G4+YP9kaV4dJb79J5MobyApxX493Qa6VoiTceUmxqik= -golang.org/x/tools/gopls v0.4.0/go.mod h1:fdOZ8zb6nqlePvfek79JCskQXI4W+i2e1xT+xOPKMcY= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25 h1:OKbAoGs4fGM5cPLlVQLZGYkFC8OnOfgo6tt0Smf9XhM= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 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/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= 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= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -honnef.co/go/tools v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M= -howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= -mvdan.cc/xurls/v2 v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA= -mvdan.cc/xurls/v2 v2.1.0/go.mod h1:5GrSd9rOnKOpZaji1OZLYL/yeAAtGDlo/cFe+8K5n8E= -mvdan.cc/xurls/v2 v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A= -mvdan.cc/xurls/v2 v2.2.0/go.mod h1:EV1RMtya9D6G5DMYPGD8zTQzaHet6Jh8gFlRgGRJeO8= +howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5 h1:AQkaJpH+/FmqRjmXZPELom5zIERYZfwTjnHpfoVMQEc= +howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= diff --git a/widgets/battery.go b/widgets/battery.go index 7167668..77b102f 100644 --- a/widgets/battery.go +++ b/widgets/battery.go @@ -7,8 +7,8 @@ import ( "strconv" "time" + "github.com/VictoriaMetrics/metrics" "github.com/distatus/battery" - "github.com/prometheus/client_golang/prometheus" ui "github.com/xxxserxxx/gotop/v4/termui" ) @@ -16,7 +16,6 @@ import ( type BatteryWidget struct { *ui.LineGraph updateInterval time.Duration - metric []prometheus.Gauge } func NewBatteryWidget(horizontalScale int) *BatteryWidget { @@ -49,16 +48,14 @@ func (b *BatteryWidget) EnableMetric() { log.Printf("error setting up metrics: %v", err) return } - b.metric = make([]prometheus.Gauge, len(bats)) - for i, bat := range bats { - gauge := prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: "gotop", - Subsystem: "battery", - Name: fmt.Sprintf("%d", i), + for i, _ := range bats { + id := makeID(i) + metrics.NewGauge(makeName("battery", i), func() float64 { + if ds, ok := b.Data[id]; ok { + return ds[len(ds)-1] + } + return 0.0 }) - gauge.Set(bat.Current / bat.Full) - b.metric[i] = gauge - prometheus.MustRegister(gauge) } } @@ -97,10 +94,8 @@ func (b *BatteryWidget) update() { id := makeID(i) perc := battery.Current / battery.Full percentFull := math.Abs(perc) * 100.0 + // TODO: look into this sort of thing; doesn't the array grow forever? Is the widget library truncating it? b.Data[id] = append(b.Data[id], percentFull) b.Labels[id] = fmt.Sprintf("%3.0f%% %.0f/%.0f", percentFull, math.Abs(battery.Current), math.Abs(battery.Full)) - if b.metric != nil { - b.metric[i].Set(perc) - } } } diff --git a/widgets/batterygauge.go b/widgets/batterygauge.go index 45fec1c..3a89707 100644 --- a/widgets/batterygauge.go +++ b/widgets/batterygauge.go @@ -6,15 +6,15 @@ import ( "time" + "github.com/VictoriaMetrics/metrics" "github.com/distatus/battery" - "github.com/prometheus/client_golang/prometheus" "github.com/xxxserxxx/gotop/v4/termui" ) type BatteryGauge struct { *termui.Gauge - metric prometheus.Gauge + metric *metrics.Gauge } func NewBatteryGauge() *BatteryGauge { @@ -35,25 +35,9 @@ func NewBatteryGauge() *BatteryGauge { } func (b *BatteryGauge) EnableMetric() { - bats, err := battery.GetAll() - if err != nil { - log.Printf("error setting up metrics: %v", err) - return - } - mx := 0.0 - cu := 0.0 - for _, bat := range bats { - mx += bat.Full - cu += bat.Current - gauge := prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: "gotop", - Subsystem: "battery", - Name: "total", - }) - gauge.Set(cu / mx) - b.metric = gauge - prometheus.MustRegister(gauge) - } + metrics.NewGauge(makeName("battery", "total"), func() float64 { + return float64(b.Percent) + }) } func (b *BatteryGauge) update() { @@ -80,7 +64,4 @@ func (b *BatteryGauge) update() { d, _ := time.ParseDuration(fmt.Sprintf("%fh", tn)) b.Percent = int((cu / mx) * 100.0) b.Label = fmt.Sprintf(charging, b.Percent, d.Truncate(time.Minute)) - if b.metric != nil { - b.metric.Set(cu / mx) - } } diff --git a/widgets/cpu.go b/widgets/cpu.go index 03346bf..d8d9a50 100644 --- a/widgets/cpu.go +++ b/widgets/cpu.go @@ -2,11 +2,10 @@ package widgets import ( "fmt" - "log" "sync" "time" - "github.com/prometheus/client_golang/prometheus" + "github.com/VictoriaMetrics/metrics" "github.com/xxxserxxx/gotop/v4/devices" ui "github.com/xxxserxxx/gotop/v4/termui" @@ -19,7 +18,7 @@ type CPUWidget struct { ShowPerCPULoad bool updateInterval time.Duration updateLock sync.Mutex - metric map[string]prometheus.Gauge + cpuLoads map[string]float64 } var cpuLabels []string @@ -31,6 +30,7 @@ func NewCPUWidget(updateInterval time.Duration, horizontalScale int, showAverage updateInterval: updateInterval, ShowAverageLoad: showAverageLoad, ShowPerCPULoad: showPerCPULoad, + cpuLoads: make(map[string]float64), } self.Title = " CPU Usage " self.HorizontalScale = horizontalScale @@ -66,26 +66,22 @@ func NewCPUWidget(updateInterval time.Duration, horizontalScale int, showAverage return self } +const AVRG = "AVRG" + func (cpu *CPUWidget) EnableMetric() { if cpu.ShowAverageLoad { - cpu.metric = make(map[string]prometheus.Gauge) - cpu.metric["AVRG"] = prometheus.NewGauge(prometheus.GaugeOpts{ - Subsystem: "cpu", - Name: "avg", + metrics.NewGauge(makeName("cpu", " avg"), func() float64 { + return cpu.cpuLoads[AVRG] }) } else { cpus := make(map[string]int) devices.UpdateCPU(cpus, cpu.updateInterval, cpu.ShowPerCPULoad) - cpu.metric = make(map[string]prometheus.Gauge) for key, perc := range cpus { - gauge := prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: "gotop", - Subsystem: "cpu", - Name: key, + kc := key + cpu.cpuLoads[key] = float64(perc) + metrics.NewGauge(makeName("cpu", key), func() float64 { + return cpu.cpuLoads[kc] }) - gauge.Set(float64(perc)) - prometheus.MustRegister(gauge) - cpu.metric[key] = gauge } } } @@ -108,11 +104,9 @@ func (cpu *CPUWidget) update() { val = float64(v) break } - cpu.Data["AVRG"] = append(cpu.Data["AVRG"], val) - cpu.Labels["AVRG"] = fmt.Sprintf("%3.0f%%", val) - if cpu.metric != nil { - cpu.metric["AVRG"].Set(val) - } + cpu.Data[AVRG] = append(cpu.Data[AVRG], val) + cpu.Labels[AVRG] = fmt.Sprintf("%3.0f%%", val) + cpu.cpuLoads[AVRG] = val }() } @@ -127,13 +121,7 @@ func (cpu *CPUWidget) update() { for key, percent := range cpus { cpu.Data[key] = append(cpu.Data[key], float64(percent)) cpu.Labels[key] = fmt.Sprintf("%d%%", percent) - if cpu.metric != nil { - if cpu.metric[key] == nil { - log.Printf("no metrics for %s", key) - } else { - cpu.metric[key].Set(float64(percent)) - } - } + cpu.cpuLoads[key] = float64(percent) } }() } diff --git a/widgets/disk.go b/widgets/disk.go index fb77ace..dd49b9a 100644 --- a/widgets/disk.go +++ b/widgets/disk.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/prometheus/client_golang/prometheus" + "github.com/VictoriaMetrics/metrics" psDisk "github.com/shirou/gopsutil/disk" ui "github.com/xxxserxxx/gotop/v4/termui" @@ -29,7 +29,6 @@ type DiskWidget struct { *ui.Table updateInterval time.Duration Partitions map[string]*Partition - metric map[string]prometheus.Gauge } // TODO: Add filtering @@ -65,17 +64,11 @@ func NewDiskWidget() *DiskWidget { } func (disk *DiskWidget) EnableMetric() { - disk.metric = make(map[string]prometheus.Gauge) for key, part := range disk.Partitions { - gauge := prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: "gotop", - Subsystem: "disk", - Name: strings.ReplaceAll(key, "/", ":"), - //Name: strings.Replace(strings.Replace(part.Device, "/dev/", "", -1), "mapper/", "", -1), + pc := part + metrics.NewGauge(makeName("disk", strings.ReplaceAll(key, "/", ":")), func() float64 { + return float64(pc.UsedPercent) / 100.0 }) - gauge.Set(float64(part.UsedPercent) / 100.0) - prometheus.MustRegister(gauge) - disk.metric[key] = gauge } } @@ -176,12 +169,5 @@ func (disk *DiskWidget) update() { disk.Rows[i][3] = partition.Free disk.Rows[i][4] = partition.BytesReadRecently disk.Rows[i][5] = partition.BytesWrittenRecently - if disk.metric != nil { - if disk.metric[key] == nil { - log.Printf("ERROR: missing metric %s", key) - } else { - disk.metric[key].Set(float64(partition.UsedPercent) / 100.0) - } - } } } diff --git a/widgets/mem.go b/widgets/mem.go index 6b5d326..b994276 100644 --- a/widgets/mem.go +++ b/widgets/mem.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/prometheus/client_golang/prometheus" + "github.com/VictoriaMetrics/metrics" "github.com/xxxserxxx/gotop/v4/devices" ui "github.com/xxxserxxx/gotop/v4/termui" @@ -14,52 +14,47 @@ import ( type MemWidget struct { *ui.LineGraph updateInterval time.Duration - metrics map[string]prometheus.Gauge } func NewMemWidget(updateInterval time.Duration, horizontalScale int) *MemWidget { - self := &MemWidget{ + widg := &MemWidget{ LineGraph: ui.NewLineGraph(), updateInterval: updateInterval, } - self.Title = " Memory Usage " - self.HorizontalScale = horizontalScale + widg.Title = " Memory Usage " + widg.HorizontalScale = horizontalScale mems := make(map[string]devices.MemoryInfo) devices.UpdateMem(mems) for name, mem := range mems { - self.Data[name] = []float64{0} - self.renderMemInfo(name, mem) + widg.Data[name] = []float64{0} + widg.renderMemInfo(name, mem) } go func() { - for range time.NewTicker(self.updateInterval).C { - self.Lock() + for range time.NewTicker(widg.updateInterval).C { + widg.Lock() devices.UpdateMem(mems) for label, mi := range mems { - self.renderMemInfo(label, mi) - if self.metrics != nil && self.metrics[label] != nil { - self.metrics[label].Set(mi.UsedPercent) - } + widg.renderMemInfo(label, mi) } - self.Unlock() + widg.Unlock() } }() - return self + return widg } func (mem *MemWidget) EnableMetric() { - mem.metrics = make(map[string]prometheus.Gauge) mems := make(map[string]devices.MemoryInfo) devices.UpdateMem(mems) - for l, m := range mems { - mem.metrics[l] = prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: "gotop", - Subsystem: "memory", - Name: l, + for l, _ := range mems { + lc := l + metrics.NewGauge(makeName("memory", l), func() float64 { + if ds, ok := mem.Data[lc]; ok { + return ds[len(ds)-1] + } + return 0.0 }) - mem.metrics[l].Set(m.UsedPercent) - prometheus.MustRegister(mem.metrics[l]) } } diff --git a/widgets/metrics.go b/widgets/metrics.go new file mode 100644 index 0000000..683b196 --- /dev/null +++ b/widgets/metrics.go @@ -0,0 +1,19 @@ +package widgets + +import ( + "fmt" + "strings" +) + +// makeName creates a prometheus metric name in the gotop space +// This function doesn't have to be very efficient because it's only +// called at init time, and only a few dozen times... and it isn't +// (very efficient). +func makeName(parts ...interface{}) string { + args := make([]string, len(parts)+1) + args[0] = "gotop" + for i, v := range parts { + args[i+1] = fmt.Sprintf("%v", v) + } + return strings.Join(args, "_") +} diff --git a/widgets/net.go b/widgets/net.go index 9cd4211..b76d6b4 100644 --- a/widgets/net.go +++ b/widgets/net.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/prometheus/client_golang/prometheus" + "github.com/VictoriaMetrics/metrics" psNet "github.com/shirou/gopsutil/net" ui "github.com/xxxserxxx/gotop/v4/termui" @@ -28,8 +28,8 @@ type NetWidget struct { totalBytesRecv uint64 totalBytesSent uint64 NetInterface []string - sentMetric prometheus.Counter - recvMetric prometheus.Counter + sentMetric *metrics.Counter + recvMetric *metrics.Counter Mbps bool } @@ -66,19 +66,8 @@ func NewNetWidget(netInterface string) *NetWidget { } func (net *NetWidget) EnableMetric() { - net.recvMetric = prometheus.NewCounter(prometheus.CounterOpts{ - Namespace: "gotop", - Subsystem: "net", - Name: "recv", - }) - prometheus.MustRegister(net.recvMetric) - - net.sentMetric = prometheus.NewCounter(prometheus.CounterOpts{ - Namespace: "gotop", - Subsystem: "net", - Name: "sent", - }) - prometheus.MustRegister(net.sentMetric) + net.recvMetric = metrics.NewCounter(makeName("net", "recv")) + net.sentMetric = metrics.NewCounter(makeName("net", "sent")) } func (net *NetWidget) update() { @@ -138,8 +127,8 @@ func (net *NetWidget) update() { net.Lines[0].Data = append(net.Lines[0].Data, int(recentBytesRecv)) net.Lines[1].Data = append(net.Lines[1].Data, int(recentBytesSent)) if net.sentMetric != nil { - net.sentMetric.Add(float64(recentBytesSent)) - net.recvMetric.Add(float64(recentBytesRecv)) + net.sentMetric.Add(int(recentBytesSent)) + net.recvMetric.Add(int(recentBytesRecv)) } } diff --git a/widgets/temp.go b/widgets/temp.go index f2b0f93..5a22897 100644 --- a/widgets/temp.go +++ b/widgets/temp.go @@ -6,8 +6,8 @@ import ( "sort" "time" + "github.com/VictoriaMetrics/metrics" ui "github.com/gizak/termui/v3" - "github.com/prometheus/client_golang/prometheus" "github.com/xxxserxxx/gotop/v4/devices" "github.com/xxxserxxx/gotop/v4/utils" @@ -28,7 +28,7 @@ type TempWidget struct { TempLowColor ui.Color TempHighColor ui.Color TempScale TempScale - tempsMetric map[string]prometheus.Gauge + temps map[string]float64 } func NewTempWidget(tempScale TempScale, filter []string) *TempWidget { @@ -68,16 +68,12 @@ func NewTempWidget(tempScale TempScale, filter []string) *TempWidget { } func (temp *TempWidget) EnableMetric() { - temp.tempsMetric = make(map[string]prometheus.Gauge) - for k, v := range temp.Data { - gauge := prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: "gotop", - Subsystem: "temp", - Name: k, + temp.temps = make(map[string]float64) + for k, _ := range temp.Data { + kc := k + metrics.NewGauge(makeName("temp", k), func() float64 { + return float64(temp.Data[kc]) }) - gauge.Set(float64(v)) - prometheus.MustRegister(gauge) - temp.tempsMetric[k] = gauge } } @@ -109,9 +105,6 @@ func (temp *TempWidget) Draw(buf *ui.Buffer) { image.Pt(temp.Inner.Min.X, temp.Inner.Min.Y+y), ) - if temp.tempsMetric != nil { - temp.tempsMetric[key].Set(float64(temp.Data[key])) - } temperature := fmt.Sprintf("%3d°%c", temp.Data[key], temp.TempScale) buf.SetString( -- cgit v1.2.3 From f5fc8b18547bcd71e60190a9c408d482c33bcb00 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Wed, 13 May 2020 10:08:43 -0500 Subject: Missed a no-longer-used attribute --- widgets/batterygauge.go | 1 - 1 file changed, 1 deletion(-) diff --git a/widgets/batterygauge.go b/widgets/batterygauge.go index 3a89707..c2cab1d 100644 --- a/widgets/batterygauge.go +++ b/widgets/batterygauge.go @@ -14,7 +14,6 @@ import ( type BatteryGauge struct { *termui.Gauge - metric *metrics.Gauge } func NewBatteryGauge() *BatteryGauge { -- cgit v1.2.3 From 2401d63362709091e616c95418c62ab19be19783 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Wed, 13 May 2020 10:22:48 -0500 Subject: gopsutil 2.20 doesn't compile on FreeBSD; rolling back. --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1763e3d..fdda298 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/go-ole/go-ole v1.2.4 // indirect github.com/mattn/go-runewidth v0.0.4 github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 - github.com/shirou/gopsutil v2.20.3+incompatible + github.com/shirou/gopsutil v2.18.11+incompatible github.com/stretchr/testify v1.4.0 github.com/xxxserxxx/iSMC v1.0.1 github.com/xxxserxxx/opflag v1.0.5 -- cgit v1.2.3 From 0406a680e0e69d20d0cf17e37059bb69e57cb901 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Wed, 13 May 2020 10:29:33 -0500 Subject: Revert "gopsutil 2.20 doesn't compile on FreeBSD; rolling back." This wasn't gopsutil's issue; it was a change in x/sys/util that broke the API. This reverts commit 2401d63362709091e616c95418c62ab19be19783. --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index fdda298..1763e3d 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/go-ole/go-ole v1.2.4 // indirect github.com/mattn/go-runewidth v0.0.4 github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 - github.com/shirou/gopsutil v2.18.11+incompatible + github.com/shirou/gopsutil v2.20.3+incompatible github.com/stretchr/testify v1.4.0 github.com/xxxserxxx/iSMC v1.0.1 github.com/xxxserxxx/opflag v1.0.5 -- cgit v1.2.3 From 28df77fe42f4c78e51e62a99c467ff6c37c513d4 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Wed, 13 May 2020 12:29:09 -0500 Subject: Have the build workflow ignore commits containing only doc changes. --- .github/workflows/build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c87949b..6de087d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,11 @@ name: Build Go binaries -on: push +on: + push: + paths-ignore: + - 'docs/release.svg' + - 'README.md' + - 'CHANGELOG.md' jobs: build: -- cgit v1.2.3 From 9e4750f7ff5accb610053014155958cb5b7956bd Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Wed, 13 May 2020 12:31:51 -0500 Subject: Adds a current-release badge to the README --- .github/workflows/release.yml | 18 ++++++++++++++++++ README.md | 11 ++++++++--- docs/release.svg | 8 ++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 docs/release.svg diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a90118a..b158768 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,3 +36,21 @@ jobs: token: ${{ secrets.homebrew }} formula: gotop revision: ${{ steps.tag_name.outputs.tag }} + + - name: Update current release badge + shell: bash + run: sed -i "s/v[0-9]*\.[0-9]*\.[0-9]*/${{steps.tag_name.outputs.tag}}/g" docs/release.svg + + - name: Commit current release badge + uses: stefanzweifel/git-auto-commit-action@v4.1.0 + with: + branch: 'master' + commit_message: Update release badge to version "${{ steps.tag_name.outputs.tag }}" + + # Optional glob pattern of files which should be added to the commit + file_pattern: docs/release.svg + + # Optional commit user and author settings + commit_user_name: Badge Updater + commit_user_email: ser@ser1.net + commit_author: Badge Updater diff --git a/README.md b/README.md index 4d3e571..d2c4b0c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,14 @@ Another terminal based graphical activity monitor, inspired by [gtop](https://gi Join us in [\#gotop:matrix.org](https://riot.im/app/#/room/#gotop:matrix.org) ([matrix clients](https://matrix.to/#/#gotop:matrix.org)). +![](https://github.com/xxxserxxx/gotop/workflows/Build%20Go%20binaries/badge.svg) +![](https://github.com/xxxserxxx/gotop/workflows/Create%20pre-release/badge.svg) + +![](https://github.com/xxxserxxx/gotop/docs/release.svg) + +See the [mini-blog](/xxxserxxx/gotop/wiki/blog) for updates on the build status, and the [change log](/xxxserxxx/gotop/blob/master/CHANGELOG.md) for release updates. + + @@ -16,9 +24,6 @@ Join us in [\#gotop:matrix.org](https://riot.im/app/#/room/#gotop:matrix.org) ([ ## Installation -![](https://github.com/xxxserxxx/gotop/workflows/Build%20Go%20binaries/badge.svg) -![](https://github.com/xxxserxxx/gotop/workflows/Create%20pre-release/badge.svg) - Working and tested on Linux, FreeBSD and MacOS. Windows binaries are provided, but have limited testing. OpenBSD works with some caveats; cross-compiling is difficult and binaries are not provided. If you install gotop by hand, or you download or create new layouts or colorschemes, you will need to put the layout files where gotop can find them. To see the list of directories gotop looks for files, run `gotop -h`. The first directory is always the directory from which gotop is run. diff --git a/docs/release.svg b/docs/release.svg new file mode 100644 index 0000000..cb7132a --- /dev/null +++ b/docs/release.svg @@ -0,0 +1,8 @@ + + + + Current release: v3.5.2 + + + + -- cgit v1.2.3 From 63c69872f8d64121ccd2cd81568b74495bd88e35 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Wed, 13 May 2020 12:35:54 -0500 Subject: Fixes the release version badge. --- README.md | 2 +- docs/release.svg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d2c4b0c..9ec4b3d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Join us in [\#gotop:matrix.org](https://riot.im/app/#/room/#gotop:matrix.org) ([ ![](https://github.com/xxxserxxx/gotop/workflows/Build%20Go%20binaries/badge.svg) ![](https://github.com/xxxserxxx/gotop/workflows/Create%20pre-release/badge.svg) -![](https://github.com/xxxserxxx/gotop/docs/release.svg) +![](https://raw.githubusercontent.com/xxxserxxx/gotop/master/docs/release.svg) See the [mini-blog](/xxxserxxx/gotop/wiki/blog) for updates on the build status, and the [change log](/xxxserxxx/gotop/blob/master/CHANGELOG.md) for release updates. diff --git a/docs/release.svg b/docs/release.svg index cb7132a..a586423 100644 --- a/docs/release.svg +++ b/docs/release.svg @@ -1,4 +1,4 @@ - + Current release: v3.5.2 -- cgit v1.2.3 From 76192092a74637fad21159f834ed5b9ec0d37491 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Wed, 13 May 2020 12:40:29 -0500 Subject: Getting the text width right is difficult with github in the way. --- docs/release.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release.svg b/docs/release.svg index a586423..52723c1 100644 --- a/docs/release.svg +++ b/docs/release.svg @@ -1,4 +1,4 @@ - + Current release: v3.5.2 -- cgit v1.2.3 From b47acdc8f2e037af1461805d9cd6dc1dcc71f5c1 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Wed, 13 May 2020 12:43:53 -0500 Subject: Release badge width --- docs/release.svg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/release.svg b/docs/release.svg index 52723c1..d42dd25 100644 --- a/docs/release.svg +++ b/docs/release.svg @@ -1,6 +1,6 @@ - + - + Current release: v3.5.2 -- cgit v1.2.3 From b8f3683f07015f0c6fbf3090aecd5ba1457ebe39 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Mon, 18 May 2020 07:35:48 -0500 Subject: Release SVG a bit taller, and add the size test bisect script. --- docs/release.svg | 2 +- scripts/size.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 scripts/size.sh diff --git a/docs/release.svg b/docs/release.svg index d42dd25..5f08114 100644 --- a/docs/release.svg +++ b/docs/release.svg @@ -1,4 +1,4 @@ - + Current release: v3.5.2 diff --git a/scripts/size.sh b/scripts/size.sh new file mode 100755 index 0000000..f772a77 --- /dev/null +++ b/scripts/size.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# size.sh is used to bisect the repository and find changes that negatively +# impacted the gotop binary size. It does this by building gotop and exiting +# successfully if the binary size is under a defined amount. +# +# Example: +# ``` +# git bisect start +# git bisect bad master +# git bisect good 755037d211cc8e58e9ce43ee74a95a3036053dee +# git bisect run ./size +# ``` + +GOODSIZE=6000000 + +# Caleb's directory structure was different from the current structure, so +# we have to find the main package first. +pt=$(dirname $(find . -name main.go)) +# Give the executable a unique-ish name +fn=gotop_$(git rev-list -1 HEAD) +go build -o $fn $pt +sz=$(ls -l $fn | awk '{print $5}') +git checkout -- . +[[ $sz -gt $GOODSIZE ]] && exit 1 +exit 0 -- cgit v1.2.3 From 6807f54e8080707e1cd3edf399e606376b3d7b63 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Tue, 19 May 2020 13:49:19 -0500 Subject: Closes #36 -- switch to MIT license. --- LICENSE | 690 +++------------------------------------------------------ devices/cpu.go | 3 + 2 files changed, 32 insertions(+), 661 deletions(-) diff --git a/LICENSE b/LICENSE index dbbe355..0a126e1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,661 +1,29 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is e