Fix for issue #77, create telegraf database if not exists
This commit is contained in:
parent
a3e20ab2d6
commit
c0cef8ca43
|
@ -6,6 +6,7 @@
|
||||||
- [#71](https://github.com/influxdb/telegraf/pull/71): HAProxy plugin. Thanks @kureikain!
|
- [#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!
|
- [#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!
|
- [#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!
|
- [#79](https://github.com/influxdb/telegraf/pull/56): Nginx plugin. Thanks @codeb2cc!
|
||||||
- [#86](https://github.com/influxdb/telegraf/pull/86): Lustre2 plugin. Thanks srfraser!
|
- [#86](https://github.com/influxdb/telegraf/pull/86): Lustre2 plugin. Thanks srfraser!
|
||||||
- [#91](https://github.com/influxdb/telegraf/pull/91): Unit testing
|
- [#91](https://github.com/influxdb/telegraf/pull/91): Unit testing
|
||||||
|
|
9
agent.go
9
agent.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -84,6 +85,14 @@ func (a *Agent) Connect() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err = c.Query(client.Query{
|
||||||
|
Command: fmt.Sprintf("CREATE DATABASE telegraf"),
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil && !strings.Contains(err.Error(), "database already exists") {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
a.conn = c
|
a.conn = c
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue