Skip to content

Commit c573cda

Browse files
authored
Merge pull request #21 from essentialkaos/develop
Version 3.1.0
2 parents d1a11ea + a479f61 commit c573cda

8 files changed

+135
-27
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor
2+
redis-latency-monitor

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
sudo: required
2-
31
language: go
42

53
go:
64
- 1.10.x
75
- 1.11.x
6+
- 1.12.x
87
- tip
98

109
os:

Makefile

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
################################################################################
22

3-
# This Makefile generated by GoMakeGen 0.8.0 using next command:
3+
# This Makefile generated by GoMakeGen 1.1.0 using next command:
44
# gomakegen .
5+
#
6+
# More info: https://kaos.sh/gomakegen
57

68
################################################################################
79

810
.DEFAULT_GOAL := help
9-
.PHONY = fmt all clean deps help
11+
.PHONY = fmt all clean git-config deps help
1012

1113
################################################################################
1214

@@ -15,15 +17,17 @@ all: redis-latency-monitor ## Build all binaries
1517
redis-latency-monitor: ## Build redis-latency-monitor binary
1618
go build redis-latency-monitor.go
1719

18-
install: ## Install binaries
20+
install: ## Install all binaries
1921
cp redis-latency-monitor /usr/bin/redis-latency-monitor
2022

21-
uninstall: ## Uninstall binaries
23+
uninstall: ## Uninstall all binaries
2224
rm -f /usr/bin/redis-latency-monitor
2325

24-
deps: ## Download dependencies
26+
git-config: ## Configure git redirects for stable import path services
2527
git config --global http.https://pkg.re.followRedirects true
26-
go get -d -v pkg.re/essentialkaos/ek.v9
28+
29+
deps: git-config ## Download dependencies
30+
go get -d -v pkg.re/essentialkaos/ek.v10
2731

2832
fmt: ## Format source code with gofmt
2933
find . -name "*.go" -exec gofmt -s -w {} \;
@@ -32,9 +36,10 @@ clean: ## Remove generated files
3236
rm -f redis-latency-monitor
3337

3438
help: ## Show this info
35-
@echo -e '\nSupported targets:\n'
39+
@echo -e '\n\033[1mSupported targets:\033[0m\n'
3640
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
37-
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-12s\033[0m %s\n", $$1, $$2}'
41+
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-23s\033[0m %s\n", $$1, $$2}'
3842
@echo -e ''
43+
@echo -e '\033[90mGenerated by GoMakeGen 1.1.0\033[0m\n'
3944

4045
################################################################################

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Before the initial install allows git to use redirects for [pkg.re](https://gith
2525
git config --global http.https://pkg.re.followRedirects true
2626
```
2727

28-
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:
28+
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:
2929

3030
```
3131
go get github.com/essentialkaos/redis-latency-monitor
@@ -40,14 +40,14 @@ go get -u github.com/essentialkaos/redis-latency-monitor
4040
#### From ESSENTIAL KAOS Public repo for RHEL6/CentOS6
4141

4242
```bash
43-
[sudo] yum install -y https://yum.kaos.st/6/release/x86_64/kaos-repo-9.1-0.el6.noarch.rpm
43+
[sudo] yum install -y https://yum.kaos.st/kaos-repo-latest.el6.noarch.rpm
4444
[sudo] yum install redis-latency-monitor
4545
```
4646

4747
#### From ESSENTIAL KAOS Public repo for RHEL7/CentOS7
4848

4949
```bash
50-
[sudo] yum install -y https://yum.kaos.st/7/release/x86_64/kaos-repo-9.1-0.el7.noarch.rpm
50+
[sudo] yum install -y https://yum.kaos.st/kaos-repo-latest.el7.noarch.rpm
5151
[sudo] yum install redis-latency-monitor
5252
```
5353

SECURITY.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Security Policies and Procedures
2+
3+
This document outlines security procedures and general policies for all
4+
ESSENTIAL KAOS projects.
5+
6+
* [Reporting a Bug](#reporting-a-bug)
7+
* [Disclosure Policy](#disclosure-policy)
8+
9+
## Reporting a Bug
10+
11+
The ESSENTIAL KAOS team and community take all security bugs in our projects
12+
very seriously. Thank you for improving the security of our project. We
13+
appreciate your efforts and responsible disclosure and will make every effort
14+
to acknowledge your contributions.
15+
16+
Report security bugs by emailing our security team at [email protected].
17+
18+
The security team will acknowledge your email within 48 hours and will send a
19+
more detailed response within 48 hours, indicating the next steps in handling
20+
your report. After the initial reply to your report, the security team will
21+
endeavor to keep you informed of the progress towards a fix and full
22+
announcement, and may ask for additional information or guidance.
23+
24+
Report security bugs in third-party dependencies to the person or team
25+
maintaining the dependencies.
26+
27+
## Disclosure Policy
28+
29+
When the security team receives a security bug report, they will assign it to a
30+
primary handler. This person will coordinate the fix and release process,
31+
involving the following steps:
32+
33+
* Confirm the problem and determine the affected versions;
34+
* Audit code to find any similar potential problems;
35+
* Prepare fixes for all releases still under maintenance. These fixes will be
36+
released as fast as possible.

common/redis-latency-monitor.spec

+35-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010

1111
Summary: Tiny Redis client for latency measurement
1212
Name: redis-latency-monitor
13-
Version: 3.0.3
13+
Version: 3.1.0
1414
Release: 0%{?dist}
1515
Group: Applications/System
1616
License: EKOL
1717
URL: https://github.com/essentialkaos/redis-latency-monitor
1818

19-
Source0: https://source.kaos.io/%{name}/%{name}-%{version}.tar.bz2
19+
Source0: https://source.kaos.st/%{name}/%{name}-%{version}.tar.bz2
2020

2121
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
2222

23-
BuildRequires: golang >= 1.8
23+
BuildRequires: golang >= 1.12
2424

2525
Provides: %{name} = %{version}-%{release}
2626

@@ -48,6 +48,34 @@ install -pm 755 %{name} %{buildroot}%{_bindir}/
4848
%clean
4949
rm -rf %{buildroot}
5050

51+
%post
52+
if [[ -d %{_sysconfdir}/bash_completion.d ]] ; then
53+
%{name} --completion=bash 1> %{_sysconfdir}/bash_completion.d/%{name} 2>/dev/null
54+
fi
55+
56+
if [[ -d %{_datarootdir}/fish/vendor_completions.d ]] ; then
57+
%{name} --completion=fish 1> %{_datarootdir}/fish/vendor_completions.d/%{name}.fish 2>/dev/null
58+
fi
59+
60+
if [[ -d %{_datadir}/zsh/site-functions ]] ; then
61+
%{name} --completion=zsh 1> %{_datadir}/zsh/site-functions/_%{name} 2>/dev/null
62+
fi
63+
64+
%postun
65+
if [[ $1 == 0 ]] ; then
66+
if [[ -f %{_sysconfdir}/bash_completion.d/%{name} ]] ; then
67+
rm -f %{_sysconfdir}/bash_completion.d/%{name} &>/dev/null || :
68+
fi
69+
70+
if [[ -f %{_datarootdir}/fish/vendor_completions.d/%{name}.fish ]] ; then
71+
rm -f %{_datarootdir}/fish/vendor_completions.d/%{name}.fish &>/dev/null || :
72+
fi
73+
74+
if [[ -f %{_datadir}/zsh/site-functions/_%{name} ]] ; then
75+
rm -f %{_datadir}/zsh/site-functions/_%{name} &>/dev/null || :
76+
fi
77+
fi
78+
5179
################################################################################
5280

5381
%files
@@ -58,6 +86,10 @@ rm -rf %{buildroot}
5886
################################################################################
5987

6088
%changelog
89+
* Thu Jun 13 2019 Anton Novojilov <[email protected]> - 3.1.0-0
90+
- ek package updated to the latest stable version
91+
- Added completion generation for bash, zsh and fish
92+
6193
* Wed Oct 31 2018 Anton Novojilov <[email protected]> - 3.0.3-0
6294
- Fixed bug with Max/Mean/StDev/Perc calculation
6395
- Minor UI improvements

redis-latency-monitor.go

+44-10
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ import (
1717
"strings"
1818
"time"
1919

20-
"pkg.re/essentialkaos/ek.v9/fmtc"
21-
"pkg.re/essentialkaos/ek.v9/fmtutil"
22-
"pkg.re/essentialkaos/ek.v9/fmtutil/table"
23-
"pkg.re/essentialkaos/ek.v9/log"
24-
"pkg.re/essentialkaos/ek.v9/mathutil"
25-
"pkg.re/essentialkaos/ek.v9/options"
26-
"pkg.re/essentialkaos/ek.v9/timeutil"
27-
"pkg.re/essentialkaos/ek.v9/usage"
20+
"pkg.re/essentialkaos/ek.v10/fmtc"
21+
"pkg.re/essentialkaos/ek.v10/fmtutil"
22+
"pkg.re/essentialkaos/ek.v10/fmtutil/table"
23+
"pkg.re/essentialkaos/ek.v10/log"
24+
"pkg.re/essentialkaos/ek.v10/mathutil"
25+
"pkg.re/essentialkaos/ek.v10/options"
26+
"pkg.re/essentialkaos/ek.v10/timeutil"
27+
"pkg.re/essentialkaos/ek.v10/usage"
28+
"pkg.re/essentialkaos/ek.v10/usage/completion/bash"
29+
"pkg.re/essentialkaos/ek.v10/usage/completion/fish"
30+
"pkg.re/essentialkaos/ek.v10/usage/completion/zsh"
2831

2932
"github.com/essentialkaos/redis-latency-monitor/stats"
3033
)
@@ -34,7 +37,7 @@ import (
3437
// App info
3538
const (
3639
APP = "Redis Latency Monitor"
37-
VER = "3.0.3"
40+
VER = "3.1.0"
3841
DESC = "Tiny Redis client for latency measurement"
3942
)
4043

@@ -58,6 +61,8 @@ const (
5861
OPT_NO_COLOR = "nc:no-color"
5962
OPT_HELP = "help"
6063
OPT_VER = "v:version"
64+
65+
OPT_COMPLETION = "completion"
6166
)
6267

6368
// ////////////////////////////////////////////////////////////////////////////////// //
@@ -76,6 +81,8 @@ var optMap = options.Map{
7681
OPT_NO_COLOR: {Type: options.BOOL},
7782
OPT_HELP: {Type: options.BOOL, Alias: "u:usage"},
7883
OPT_VER: {Type: options.BOOL, Alias: "ver"},
84+
85+
OPT_COMPLETION: {},
7986
}
8087

8188
// pingCommand is PING command data
@@ -105,6 +112,10 @@ func main() {
105112
os.Exit(1)
106113
}
107114

115+
if options.Has(OPT_COMPLETION) {
116+
genCompletion()
117+
}
118+
108119
if options.GetB(OPT_NO_COLOR) {
109120
fmtc.DisableColors = true
110121
}
@@ -471,6 +482,11 @@ func shutdown(code int) {
471482

472483
// showUsage print usage info
473484
func showUsage() {
485+
genUsage().Render()
486+
}
487+
488+
// genUsage generates usage info
489+
func genUsage() *usage.Info {
474490
info := usage.NewInfo("")
475491

476492
info.AddSpoiler("Utility show PING command latency or connection latency in milliseconds (one thousandth of a second).")
@@ -498,7 +514,25 @@ func showUsage() {
498514
"Start connection latency monitoring with 15 second interval and save result to CSV file",
499515
)
500516

501-
info.Render()
517+
return info
518+
}
519+
520+
// genCompletion generates completion for different shells
521+
func genCompletion() {
522+
info := genUsage()
523+
524+
switch options.GetS(OPT_COMPLETION) {
525+
case "bash":
526+
fmt.Printf(bash.Generate(info, "redis-latency-monitor"))
527+
case "fish":
528+
fmt.Printf(fish.Generate(info, "redis-latency-monitor"))
529+
case "zsh":
530+
fmt.Printf(zsh.Generate(info, optMap, "redis-latency-monitor"))
531+
default:
532+
os.Exit(1)
533+
}
534+
535+
os.Exit(0)
502536
}
503537

504538
// showAbout print info about version

stats/stats.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package stats
22

33
// ////////////////////////////////////////////////////////////////////////////////// //
44
// //
5-
// Copyright (c) 2009-2018 ESSENTIAL KAOS //
5+
// Copyright (c) 2009-2019 ESSENTIAL KAOS //
66
// Essential Kaos Open Source License <https://essentialkaos.com/ekol> //
77
// //
88
// ////////////////////////////////////////////////////////////////////////////////// //

0 commit comments

Comments
 (0)