Skip to content

Commit

Permalink
Merge pull request #21 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 3.1.0
  • Loading branch information
andyone authored Jun 14, 2019
2 parents d1a11ea + a479f61 commit c573cda
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
redis-latency-monitor
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
sudo: required

language: go

go:
- 1.10.x
- 1.11.x
- 1.12.x
- tip

os:
Expand Down
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

################################################################################

Expand All @@ -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 {} \;
Expand All @@ -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'

################################################################################
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```

Expand Down
36 changes: 36 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -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 [email protected].

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.
38 changes: 35 additions & 3 deletions common/redis-latency-monitor.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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
Expand All @@ -58,6 +86,10 @@ rm -rf %{buildroot}
################################################################################

%changelog
* Thu Jun 13 2019 Anton Novojilov <[email protected]> - 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 <[email protected]> - 3.0.3-0
- Fixed bug with Max/Mean/StDev/Perc calculation
- Minor UI improvements
Expand Down
54 changes: 44 additions & 10 deletions redis-latency-monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ 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"
"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"
)
Expand All @@ -34,7 +37,7 @@ import (
// App info
const (
APP = "Redis Latency Monitor"
VER = "3.0.3"
VER = "3.1.0"
DESC = "Tiny Redis client for latency measurement"
)

Expand All @@ -58,6 +61,8 @@ const (
OPT_NO_COLOR = "nc:no-color"
OPT_HELP = "help"
OPT_VER = "v:version"

OPT_COMPLETION = "completion"
)

// ////////////////////////////////////////////////////////////////////////////////// //
Expand All @@ -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
Expand Down Expand Up @@ -105,6 +112,10 @@ func main() {
os.Exit(1)
}

if options.Has(OPT_COMPLETION) {
genCompletion()
}

if options.GetB(OPT_NO_COLOR) {
fmtc.DisableColors = true
}
Expand Down Expand Up @@ -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).")
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package stats

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2009-2018 ESSENTIAL KAOS //
// Copyright (c) 2009-2019 ESSENTIAL KAOS //
// Essential Kaos Open Source License <https://essentialkaos.com/ekol> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down

0 comments on commit c573cda

Please sign in to comment.