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 10, 2015
1 parent a3e20ab commit bee1f17
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/url"
"os"
"sort"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -84,6 +85,14 @@ func (a *Agent) Connect() error {
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

return nil
Expand Down

0 comments on commit bee1f17

Please sign in to comment.