Skip to content

Commit

Permalink
Merge pull request #1165 from mkadokawa-idcf/mackerel-plugin-redis-us…
Browse files Browse the repository at this point in the history
…ername

Allow mackerel-plugin-redis to specify username
  • Loading branch information
Arthur1 committed Mar 30, 2024
2 parents 99db858 + 7f498a1 commit c46e7c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mackerel-plugin-redis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Redis custom metrics plugin for mackerel.io agent.
## Synopsis

```shell
mackerel-plugin-redis [-host=<hostname>] [-port=<port>] [-password=<password>] [-socket=<unix socket>] [-timeout=<time>] [-metric-key-prefix=<prefix>] [-config-command=<CONFIG command name>] [-tls] [-tls-skip-verify]
mackerel-plugin-redis [-host=<hostname>] [-port=<port>] [-username=<username>] [-password=<password>] [-socket=<unix socket>] [-timeout=<time>] [-metric-key-prefix=<prefix>] [-config-command=<CONFIG command name>] [-tls] [-tls-skip-verify]
```

## Example of mackerel-agent.conf
Expand Down
4 changes: 4 additions & 0 deletions mackerel-plugin-redis/lib/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type RedisPlugin struct {

Host string
Port string
Username string
Password string
Socket string
Prefix string
Expand Down Expand Up @@ -131,6 +132,7 @@ func (m *RedisPlugin) Connect() {
}
options := &redis.Options{
Addr: address,
Username: m.Username,
Password: m.Password,
DB: 0,
Network: network,
Expand Down Expand Up @@ -371,6 +373,7 @@ func (m RedisPlugin) GraphDefinition() map[string]mp.Graphs {
func Do() {
optHost := flag.String("host", "localhost", "Hostname")
optPort := flag.String("port", "6379", "Port")
optUsername := flag.String("username", "default", "Username")
optPassword := flag.String("password", os.Getenv("REDIS_PASSWORD"), "Password")
optSocket := flag.String("socket", "", "Server socket (overrides host and port)")
optPrefix := flag.String("metric-key-prefix", "redis", "Metric key prefix")
Expand All @@ -396,6 +399,7 @@ func Do() {
} else {
redis.Host = *optHost
redis.Port = *optPort
redis.Username = *optUsername
redis.Password = *optPassword
redis.EnableTLS = *optEnableTLS
redis.InsecureSkipVerify = *optTLSSkipVerify
Expand Down

0 comments on commit c46e7c6

Please sign in to comment.