Skip to content

Commit 77c9cdc

Browse files
authored
Merge pull request oliver006#64 from oliver006/oh_get_maxmemory_from_INFO
Get maxmemory from INFO command
2 parents 012673f + 700c0ed commit 77c9cdc

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ machine:
99
SRC_LOCATION: "/home/ubuntu/.go_workspace/src/github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME"
1010
COVERAGE_PROFILE: "/home/ubuntu/coverage.out"
1111
GO_LDFLAGS: '-extldflags "-static" -X main.VERSION=$CIRCLE_TAG -X main.COMMIT_SHA1=$CIRCLE_SHA1 -X main.BUILD_DATE=$(date +%F-%T)'
12-
MY_GO_VERSION: "1.8"
12+
MY_GO_VERSION: "1.8.1"
1313

1414
dependencies:
1515
pre:

exporter/redis.go

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var (
6161
"used_memory_rss": "memory_used_rss_bytes",
6262
"used_memory_peak": "memory_used_peak_bytes",
6363
"used_memory_lua": "memory_used_lua_bytes",
64-
"max_memory": "memory_max_bytes",
64+
"maxmemory": "memory_max_bytes",
6565
"mem_fragmentation_ratio": "memory_fragmentation_ratio",
6666

6767
// # Persistence
@@ -386,23 +386,6 @@ func (e *Exporter) extractInfoMetrics(info, addr string, alias string, scrapes c
386386
return nil
387387
}
388388

389-
func extractConfigMetrics(config []string, addr string, alias string, scrapes chan<- scrapeResult) error {
390-
391-
if len(config)%2 != 0 {
392-
return fmt.Errorf("invalid config: %#v", config)
393-
}
394-
395-
for pos := 0; pos < len(config)/2; pos++ {
396-
val, err := strconv.ParseFloat(config[pos*2+1], 64)
397-
if err != nil {
398-
log.Debugf("couldn't parse %s, err: %s", config[pos*2+1], err)
399-
continue
400-
}
401-
scrapes <- scrapeResult{Name: fmt.Sprintf("config_%s", config[pos*2]), Addr: addr, Alias: alias, Value: val}
402-
}
403-
return nil
404-
}
405-
406389
func (e *Exporter) scrape(scrapes chan<- scrapeResult) {
407390

408391
defer close(scrapes)
@@ -465,10 +448,6 @@ func (e *Exporter) scrape(scrapes chan<- scrapeResult) {
465448

466449
scrapes <- scrapeResult{Name: "up", Addr: addr, Alias: alias, Value: 1}
467450

468-
if config, err := redis.Strings(c.Do("CONFIG", "GET", "maxmemory")); err == nil {
469-
extractConfigMetrics(config, addr, alias, scrapes)
470-
}
471-
472451
for _, k := range e.keys {
473452
if _, err := c.Do("SELECT", k.db); err != nil {
474453
continue

main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525
logFormat = flag.String("log-format", "txt", "Log format, valid options are txt and json")
2626
showVersion = flag.Bool("version", false, "Show version information and exit")
2727

28-
// VERSION, BUILD_DATE, GIT_COMMIT are filled in by the CircleCI build
28+
// VERSION, BUILD_DATE, GIT_COMMIT are filled in by the build script
2929
VERSION = "<<< filled in by build >>>"
3030
BUILD_DATE = "<<< filled in by build >>>"
3131
COMMIT_SHA1 = "<<< filled in by build >>>"
@@ -39,7 +39,10 @@ func main() {
3939
default:
4040
log.SetFormatter(&log.TextFormatter{})
4141
}
42-
log.Printf("Redis Metrics Exporter %s build date: %s sha1: %s\n", VERSION, BUILD_DATE, COMMIT_SHA1)
42+
log.Printf("Redis Metrics Exporter %s build date: %s sha1: %s Go: %s\n",
43+
VERSION, BUILD_DATE, COMMIT_SHA1,
44+
runtime.Version(),
45+
)
4346
if *isDebug {
4447
log.SetLevel(log.DebugLevel)
4548
log.Debugln("Enabling debug output")

0 commit comments

Comments
 (0)