Fix for issue #77, create telegraf database if not exists

This commit is contained in:
Cameron Sparr 2015-08-10 15:59:56 -06:00
parent 46cdb40800
commit 7e1d1c19e6
2 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -3,8 +3,10 @@ package telegraf
import (
"fmt"
"log"
"net/url"
"os"
"sort"
"strings"
"sync"
"time"
@ -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)
@ -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 {