From f175418962b096d26e48522f32166d2bc005ff59 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Thu, 13 Jun 2019 15:19:54 +0300 Subject: [PATCH 1/5] Improvements --- .travis.yml | 1 + Makefile | 21 +++++++++++++-------- README.md | 4 ++-- common/redis-latency-monitor.spec | 9 ++++++--- redis-latency-monitor.go | 18 +++++++++--------- stats/stats.go | 2 +- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index f291b0b..1088627 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ language: go go: - 1.10.x - 1.11.x + - 1.12.x - tip os: diff --git a/Makefile b/Makefile index c44ce60..40a73b6 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,14 @@ ################################################################################ -# This Makefile generated by GoMakeGen 0.8.0 using next command: +# This Makefile generated by GoMakeGen 1.1.0 using next command: # gomakegen . +# +# More info: https://kaos.sh/gomakegen ################################################################################ .DEFAULT_GOAL := help -.PHONY = fmt all clean deps help +.PHONY = fmt all clean git-config deps help ################################################################################ @@ -15,15 +17,17 @@ all: redis-latency-monitor ## Build all binaries redis-latency-monitor: ## Build redis-latency-monitor binary go build redis-latency-monitor.go -install: ## Install binaries +install: ## Install all binaries cp redis-latency-monitor /usr/bin/redis-latency-monitor -uninstall: ## Uninstall binaries +uninstall: ## Uninstall all binaries rm -f /usr/bin/redis-latency-monitor -deps: ## Download dependencies +git-config: ## Configure git redirects for stable import path services git config --global http.https://pkg.re.followRedirects true - go get -d -v pkg.re/essentialkaos/ek.v9 + +deps: git-config ## Download dependencies + go get -d -v pkg.re/essentialkaos/ek.v10 fmt: ## Format source code with gofmt find . -name "*.go" -exec gofmt -s -w {} \; @@ -32,9 +36,10 @@ clean: ## Remove generated files rm -f redis-latency-monitor help: ## Show this info - @echo -e '\nSupported targets:\n' + @echo -e '\n\033[1mSupported targets:\033[0m\n' @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ - | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-12s\033[0m %s\n", $$1, $$2}' + | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-23s\033[0m %s\n", $$1, $$2}' @echo -e '' + @echo -e '\033[90mGenerated by GoMakeGen 1.1.0\033[0m\n' ################################################################################ diff --git a/README.md b/README.md index 9782778..2850404 100644 --- a/README.md +++ b/README.md @@ -40,14 +40,14 @@ go get -u github.com/essentialkaos/redis-latency-monitor #### From ESSENTIAL KAOS Public repo for RHEL6/CentOS6 ```bash -[sudo] yum install -y https://yum.kaos.st/6/release/x86_64/kaos-repo-9.1-0.el6.noarch.rpm +[sudo] yum install -y https://yum.kaos.st/kaos-repo-latest.el6.noarch.rpm [sudo] yum install redis-latency-monitor ``` #### From ESSENTIAL KAOS Public repo for RHEL7/CentOS7 ```bash -[sudo] yum install -y https://yum.kaos.st/7/release/x86_64/kaos-repo-9.1-0.el7.noarch.rpm +[sudo] yum install -y https://yum.kaos.st/kaos-repo-latest.el7.noarch.rpm [sudo] yum install redis-latency-monitor ``` diff --git a/common/redis-latency-monitor.spec b/common/redis-latency-monitor.spec index 6b82b31..ce95135 100644 --- a/common/redis-latency-monitor.spec +++ b/common/redis-latency-monitor.spec @@ -10,17 +10,17 @@ Summary: Tiny Redis client for latency measurement Name: redis-latency-monitor -Version: 3.0.3 +Version: 3.1.0 Release: 0%{?dist} Group: Applications/System License: EKOL URL: https://github.com/essentialkaos/redis-latency-monitor -Source0: https://source.kaos.io/%{name}/%{name}-%{version}.tar.bz2 +Source0: https://source.kaos.st/%{name}/%{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: golang >= 1.8 +BuildRequires: golang >= 1.12 Provides: %{name} = %{version}-%{release} @@ -58,6 +58,9 @@ rm -rf %{buildroot} ################################################################################ %changelog +* Thu Jun 13 2019 Anton Novojilov - 3.1.0-0 +- ek package updated to the latest stable version + * Wed Oct 31 2018 Anton Novojilov - 3.0.3-0 - Fixed bug with Max/Mean/StDev/Perc calculation - Minor UI improvements diff --git a/redis-latency-monitor.go b/redis-latency-monitor.go index 216f706..903599e 100644 --- a/redis-latency-monitor.go +++ b/redis-latency-monitor.go @@ -17,14 +17,14 @@ import ( "strings" "time" - "pkg.re/essentialkaos/ek.v9/fmtc" - "pkg.re/essentialkaos/ek.v9/fmtutil" - "pkg.re/essentialkaos/ek.v9/fmtutil/table" - "pkg.re/essentialkaos/ek.v9/log" - "pkg.re/essentialkaos/ek.v9/mathutil" - "pkg.re/essentialkaos/ek.v9/options" - "pkg.re/essentialkaos/ek.v9/timeutil" - "pkg.re/essentialkaos/ek.v9/usage" + "pkg.re/essentialkaos/ek.v10/fmtc" + "pkg.re/essentialkaos/ek.v10/fmtutil" + "pkg.re/essentialkaos/ek.v10/fmtutil/table" + "pkg.re/essentialkaos/ek.v10/log" + "pkg.re/essentialkaos/ek.v10/mathutil" + "pkg.re/essentialkaos/ek.v10/options" + "pkg.re/essentialkaos/ek.v10/timeutil" + "pkg.re/essentialkaos/ek.v10/usage" "github.com/essentialkaos/redis-latency-monitor/stats" ) @@ -34,7 +34,7 @@ import ( // App info const ( APP = "Redis Latency Monitor" - VER = "3.0.3" + VER = "3.1.0" DESC = "Tiny Redis client for latency measurement" ) diff --git a/stats/stats.go b/stats/stats.go index f7503e4..d6435e7 100644 --- a/stats/stats.go +++ b/stats/stats.go @@ -2,7 +2,7 @@ package stats // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2009-2018 ESSENTIAL KAOS // +// Copyright (c) 2009-2019 ESSENTIAL KAOS // // Essential Kaos Open Source License // // // // ////////////////////////////////////////////////////////////////////////////////// // From 50a0fa19c80ccb4fd4c437d6a3a879d72270c7ce Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Thu, 13 Jun 2019 15:30:52 +0300 Subject: [PATCH 2/5] Added completion generation for bash, zsh and fish --- common/redis-latency-monitor.spec | 29 +++++++++++++++++++++++++ redis-latency-monitor.go | 36 ++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/common/redis-latency-monitor.spec b/common/redis-latency-monitor.spec index ce95135..1d2298b 100644 --- a/common/redis-latency-monitor.spec +++ b/common/redis-latency-monitor.spec @@ -48,6 +48,34 @@ install -pm 755 %{name} %{buildroot}%{_bindir}/ %clean rm -rf %{buildroot} +%post +if [[ -d %{_sysconfdir}/bash_completion.d ]] ; then + %{name} --completion=bash 1> %{_sysconfdir}/bash_completion.d/%{name} 2>/dev/null +fi + +if [[ -d %{_datarootdir}/fish/vendor_completions.d ]] ; then + %{name} --completion=fish 1> %{_datarootdir}/fish/vendor_completions.d/%{name}.fish 2>/dev/null +fi + +if [[ -d %{_datadir}/zsh/site-functions ]] ; then + %{name} --completion=zsh 1> %{_datadir}/zsh/site-functions/_%{name} 2>/dev/null +fi + +%postun +if [[ $1 == 0 ]] ; then + if [[ -f %{_sysconfdir}/bash_completion.d/%{name} ]] ; then + rm -f %{_sysconfdir}/bash_completion.d/%{name} &>/dev/null || : + fi + + if [[ -f %{_datarootdir}/fish/vendor_completions.d/%{name}.fish ]] ; then + rm -f %{_datarootdir}/fish/vendor_completions.d/%{name}.fish &>/dev/null || : + fi + + if [[ -f %{_datadir}/zsh/site-functions/_%{name} ]] ; then + rm -f %{_datadir}/zsh/site-functions/_%{name} &>/dev/null || : + fi +fi + ################################################################################ %files @@ -60,6 +88,7 @@ rm -rf %{buildroot} %changelog * Thu Jun 13 2019 Anton Novojilov - 3.1.0-0 - ek package updated to the latest stable version +- Added completion generation for bash, zsh and fish * Wed Oct 31 2018 Anton Novojilov - 3.0.3-0 - Fixed bug with Max/Mean/StDev/Perc calculation diff --git a/redis-latency-monitor.go b/redis-latency-monitor.go index 903599e..c7fb051 100644 --- a/redis-latency-monitor.go +++ b/redis-latency-monitor.go @@ -25,6 +25,9 @@ import ( "pkg.re/essentialkaos/ek.v10/options" "pkg.re/essentialkaos/ek.v10/timeutil" "pkg.re/essentialkaos/ek.v10/usage" + "pkg.re/essentialkaos/ek.v10/usage/completion/bash" + "pkg.re/essentialkaos/ek.v10/usage/completion/fish" + "pkg.re/essentialkaos/ek.v10/usage/completion/zsh" "github.com/essentialkaos/redis-latency-monitor/stats" ) @@ -58,6 +61,8 @@ const ( OPT_NO_COLOR = "nc:no-color" OPT_HELP = "help" OPT_VER = "v:version" + + OPT_COMPLETION = "completion" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -76,6 +81,8 @@ var optMap = options.Map{ OPT_NO_COLOR: {Type: options.BOOL}, OPT_HELP: {Type: options.BOOL, Alias: "u:usage"}, OPT_VER: {Type: options.BOOL, Alias: "ver"}, + + OPT_COMPLETION: {}, } // pingCommand is PING command data @@ -105,6 +112,10 @@ func main() { os.Exit(1) } + if options.Has(OPT_COMPLETION) { + genCompletion() + } + if options.GetB(OPT_NO_COLOR) { fmtc.DisableColors = true } @@ -471,6 +482,11 @@ func shutdown(code int) { // showUsage print usage info func showUsage() { + genUsage().Render() +} + +// genUsage generates usage info +func genUsage() *usage.Info { info := usage.NewInfo("") info.AddSpoiler("Utility show PING command latency or connection latency in milliseconds (one thousandth of a second).") @@ -498,7 +514,25 @@ func showUsage() { "Start connection latency monitoring with 15 second interval and save result to CSV file", ) - info.Render() + return info +} + +// genCompletion generates completion for different shells +func genCompletion() { + info := genUsage() + + switch options.GetS(OPT_COMPLETION) { + case "bash": + fmt.Printf(bash.Generate(info, "redis-latency-monitor")) + case "fish": + fmt.Printf(fish.Generate(info, "redis-latency-monitor")) + case "zsh": + fmt.Printf(zsh.Generate(info, optMap, "redis-latency-monitor")) + default: + os.Exit(1) + } + + os.Exit(0) } // showAbout print info about version From 2648643dfa9144f9b32092e4944922ba133fa105 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Thu, 13 Jun 2019 15:31:40 +0300 Subject: [PATCH 3/5] Added gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c216819 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor +redis-latency-monitor From dced79ab39f07e032a1c63a74f7758ffbc427412 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Thu, 13 Jun 2019 16:20:30 +0300 Subject: [PATCH 4/5] Added document with Security Policies and Procedures --- SECURITY.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..f42c71e --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,36 @@ +# Security Policies and Procedures + +This document outlines security procedures and general policies for all +ESSENTIAL KAOS projects. + + * [Reporting a Bug](#reporting-a-bug) + * [Disclosure Policy](#disclosure-policy) + +## Reporting a Bug + +The ESSENTIAL KAOS team and community take all security bugs in our projects +very seriously. Thank you for improving the security of our project. We +appreciate your efforts and responsible disclosure and will make every effort +to acknowledge your contributions. + +Report security bugs by emailing our security team at security@essentialkaos.com. + +The security team will acknowledge your email within 48 hours and will send a +more detailed response within 48 hours, indicating the next steps in handling +your report. After the initial reply to your report, the security team will +endeavor to keep you informed of the progress towards a fix and full +announcement, and may ask for additional information or guidance. + +Report security bugs in third-party dependencies to the person or team +maintaining the dependencies. + +## Disclosure Policy + +When the security team receives a security bug report, they will assign it to a +primary handler. This person will coordinate the fix and release process, +involving the following steps: + + * Confirm the problem and determine the affected versions; + * Audit code to find any similar potential problems; + * Prepare fixes for all releases still under maintenance. These fixes will be + released as fast as possible. From a479f61ea1c85231abdc995b057ca6e9bb7a7138 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Fri, 14 Jun 2019 13:02:45 +0300 Subject: [PATCH 5/5] Minor improvements --- .travis.yml | 2 -- README.md | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1088627..dc80802 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -sudo: required - language: go go: diff --git a/README.md b/README.md index 2850404..16d13b0 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Before the initial install allows git to use redirects for [pkg.re](https://gith git config --global http.https://pkg.re.followRedirects true ``` -To build the `redis-latency-monitor` from scratch, make sure you have a working Go 1.7+ workspace (_[instructions](https://golang.org/doc/install)_), then: +To build the `redis-latency-monitor` from scratch, make sure you have a working Go 1.10+ workspace (_[instructions](https://golang.org/doc/install)_), then: ``` go get github.com/essentialkaos/redis-latency-monitor