Skip to content

Commit

Permalink
Merge pull request #11 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 2.4.0
  • Loading branch information
andyone authored Oct 2, 2017
2 parents b5c8f0b + 3e2e884 commit 451f009
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ sudo: false
language: go

go:
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
- tip

os:
- linux
- osx

branches:
only:
Expand Down
5 changes: 4 additions & 1 deletion common/redis-latency-monitor.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Summary: Tiny Redis client for latency measurement
Name: redis-latency-monitor
Version: 2.3.1
Version: 2.4.0
Release: 0%{?dist}
Group: Applications/System
License: EKOL
Expand Down Expand Up @@ -58,6 +58,9 @@ rm -rf %{buildroot}
###############################################################################

%changelog
* Tue Oct 03 2017 Anton Novojilov <[email protected]> - 2.4.0-0
- Added option -T/--timestamps for output time as unix timestamp

* Thu Jul 06 2017 Anton Novojilov <[email protected]> - 2.3.1-0
- Added auth error handling

Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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.6+ workspace ([instructions](https://golang.org/doc/install)), then:
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:

```
go get github.com/essentialkaos/redis-latency-monitor
Expand Down Expand Up @@ -61,6 +61,7 @@ Options
--password, -a password Password to use when connecting to the server
--timeout, -t 1-300 Connection timeout in seconds (3 by default)
--interval, -i 1-3600 Interval in seconds (60 by default)
--timestamps, -T Use unix timestamps in output
--output, -o file Path to output CSV file
--error-log, -e file Path to log with error messages
--no-color, -nc Disable colors in output
Expand Down
78 changes: 47 additions & 31 deletions redis-latency-monitor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build linux

package main

// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down Expand Up @@ -33,7 +35,7 @@ import (

const (
APP = "Redis Latency Monitor"
VER = "2.3.1"
VER = "2.4.0"
DESC = "Tiny Redis client for latency measurement"
)

Expand All @@ -43,34 +45,36 @@ const (
)

const (
OPT_HOST = "h:host"
OPT_PORT = "p:port"
OPT_AUTH = "a:password"
OPT_TIMEOUT = "t:timeout"
OPT_INTERVAL = "i:interval"
OPT_CONNECT = "c:connect"
OPT_OUTPUT = "o:output"
OPT_ERROR_LOG = "e:error-log"
OPT_NO_COLOR = "nc:no-color"
OPT_HELP = "help"
OPT_VER = "v:version"
OPT_HOST = "h:host"
OPT_PORT = "p:port"
OPT_AUTH = "a:password"
OPT_TIMEOUT = "t:timeout"
OPT_INTERVAL = "i:interval"
OPT_CONNECT = "c:connect"
OPT_TIMESTAMPS = "T:timestamps"
OPT_OUTPUT = "o:output"
OPT_ERROR_LOG = "e:error-log"
OPT_NO_COLOR = "nc:no-color"
OPT_HELP = "help"
OPT_VER = "v:version"
)

// ////////////////////////////////////////////////////////////////////////////////// //

// optMap is map with options
var optMap = options.Map{
OPT_HOST: {Value: "127.0.0.1"},
OPT_PORT: {Value: "6379"},
OPT_CONNECT: {Type: options.BOOL},
OPT_TIMEOUT: {Type: options.INT, Value: 3, Min: 1, Max: 300},
OPT_AUTH: {},
OPT_INTERVAL: {Type: options.INT, Value: 60, Min: 1, Max: 3600},
OPT_OUTPUT: {},
OPT_ERROR_LOG: {},
OPT_NO_COLOR: {Type: options.BOOL},
OPT_HELP: {Type: options.BOOL, Alias: "u:usage"},
OPT_VER: {Type: options.BOOL, Alias: "ver"},
OPT_HOST: {Value: "127.0.0.1"},
OPT_PORT: {Value: "6379"},
OPT_CONNECT: {Type: options.BOOL},
OPT_TIMEOUT: {Type: options.INT, Value: 3, Min: 1, Max: 300},
OPT_AUTH: {},
OPT_INTERVAL: {Type: options.INT, Value: 60, Min: 1, Max: 3600},
OPT_TIMESTAMPS: {Type: options.BOOL},
OPT_OUTPUT: {},
OPT_ERROR_LOG: {},
OPT_NO_COLOR: {Type: options.BOOL},
OPT_HELP: {Type: options.BOOL, Alias: "u:usage"},
OPT_VER: {Type: options.BOOL, Alias: "ver"},
}

// pingCommand is PING command data
Expand Down Expand Up @@ -338,14 +342,25 @@ func printMeasurements(t *table.Table, errors int, measurements []float64, prett
formatNumber(p95), formatNumber(p99),
)
} else {
outputWriter.WriteString(
fmt.Sprintf(
"%s;%d;%d;%.03f;%.03f;%.03f;%.03f;%.03f;%.03f;%.03f;%.03f;\n",
timeutil.Format(time.Now(), "%Y/%m/%d %H:%M:%S.%K"),
len(measurements), errors,
min, max, men, med, mgh, sdv, p95, p99,
),
)
if options.GetB(OPT_TIMESTAMPS) {
outputWriter.WriteString(
fmt.Sprintf(
"%d;%d;%d;%.03f;%.03f;%.03f;%.03f;%.03f;%.03f;%.03f;%.03f;\n",
time.Now().Unix(), len(measurements), errors,
min, max, men, med, mgh, sdv, p95, p99,
),
)
} else {
outputWriter.WriteString(
fmt.Sprintf(
"%s;%d;%d;%.03f;%.03f;%.03f;%.03f;%.03f;%.03f;%.03f;%.03f;\n",
timeutil.Format(time.Now(), "%Y/%m/%d %H:%M:%S.%K"),
len(measurements), errors,
min, max, men, med, mgh, sdv, p95, p99,
),
)
}

}
}

Expand Down Expand Up @@ -456,6 +471,7 @@ func showUsage() {
info.AddOption(OPT_AUTH, "Password to use when connecting to the server", "password")
info.AddOption(OPT_TIMEOUT, "Connection timeout in seconds {s-}(3 by default){!}", "1-300")
info.AddOption(OPT_INTERVAL, "Interval in seconds {s-}(60 by default){!}", "1-3600")
info.AddOption(OPT_TIMESTAMPS, "Use unix timestamps in output")
info.AddOption(OPT_OUTPUT, "Path to output CSV file", "file")
info.AddOption(OPT_ERROR_LOG, "Path to log with error messages", "file")
info.AddOption(OPT_NO_COLOR, "Disable colors in output")
Expand Down

0 comments on commit 451f009

Please sign in to comment.