Skip to content

Commit

Permalink
Fix for issue #77, create telegraf database if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Aug 11, 2015
1 parent 46cdb40 commit 7e1d1c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [#71](https://github.com/influxdb/telegraf/pull/71): HAProxy plugin. Thanks @kureikain!
- [#72](https://github.com/influxdb/telegraf/pull/72): Adding TokuDB metrics to MySQL. Thanks vadimtk!
- [#73](https://github.com/influxdb/telegraf/pull/73): RabbitMQ plugin. Thanks @ianunruh!
- [#77](https://github.com/influxdb/telegraf/issues/77): Automatically create database.
- [#79](https://github.com/influxdb/telegraf/pull/56): Nginx plugin. Thanks @codeb2cc!
- [#86](https://github.com/influxdb/telegraf/pull/86): Lustre2 plugin. Thanks srfraser!
- [#91](https://github.com/influxdb/telegraf/pull/91): Unit testing
Expand Down
11 changes: 11 additions & 0 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package telegraf
import (
"fmt"
"log"
"net/url"
"os"
"sort"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -57,9 +59,16 @@ func NewAgent(config *Config) (*Agent, error) {
agent.Hostname = hostname
}

if config.Tags == nil {
config.Tags = map[string]string{}
}

config.Tags["host"] = agent.Hostname

return agent, nil
}

// Connect connects to the agent's config URL
func (a *Agent) Connect() error {
for _, o := range a.outputs {
err := o.output.Connect(a.Hostname)
Expand Down Expand Up @@ -194,7 +203,9 @@ func (a *Agent) crankSeparate(shutdown chan struct{}, plugin *runningPlugin) err
return err
}

acc.Tags = a.Config.Tags
acc.Time = time.Now()
acc.Database = a.Config.Database

err = a.flush(&acc)
if err != nil {
Expand Down

0 comments on commit 7e1d1c1

Please sign in to comment.