Postgresql_extensible, ran fmt
This commit is contained in:
@@ -18,7 +18,7 @@ type Postgresql struct {
|
|||||||
OrderedColumns []string
|
OrderedColumns []string
|
||||||
AllColumns []string
|
AllColumns []string
|
||||||
AdditionalTags []string
|
AdditionalTags []string
|
||||||
Query []struct {
|
Query []struct {
|
||||||
Sqlquery string
|
Sqlquery string
|
||||||
Version int
|
Version int
|
||||||
Withdbname bool
|
Withdbname bool
|
||||||
@@ -27,11 +27,11 @@ type Postgresql struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type query []struct {
|
type query []struct {
|
||||||
Sqlquery string
|
Sqlquery string
|
||||||
Version int
|
Version int
|
||||||
Withdbname bool
|
Withdbname bool
|
||||||
Tagvalue string
|
Tagvalue string
|
||||||
}
|
}
|
||||||
|
|
||||||
var ignoredColumns = map[string]bool{"datid": true, "datname": true, "stats_reset": true}
|
var ignoredColumns = map[string]bool{"datid": true, "datname": true, "stats_reset": true}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ func (p *Postgresql) Gather(acc telegraf.Accumulator) error {
|
|||||||
for i := range p.Query {
|
for i := range p.Query {
|
||||||
sql_query = p.Query[i].Sqlquery
|
sql_query = p.Query[i].Sqlquery
|
||||||
tag_value = p.Query[i].Tagvalue
|
tag_value = p.Query[i].Tagvalue
|
||||||
|
|
||||||
if p.Query[i].Withdbname {
|
if p.Query[i].Withdbname {
|
||||||
if len(p.Databases) != 0 {
|
if len(p.Databases) != 0 {
|
||||||
query_addon = fmt.Sprintf(` IN ('%s')`,
|
query_addon = fmt.Sprintf(` IN ('%s')`,
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ func TestPostgresqlGeneratesMetrics(t *testing.T) {
|
|||||||
Address: fmt.Sprintf("host=%s user=postgres sslmode=disable",
|
Address: fmt.Sprintf("host=%s user=postgres sslmode=disable",
|
||||||
testutil.GetLocalHost()),
|
testutil.GetLocalHost()),
|
||||||
Databases: []string{"postgres"},
|
Databases: []string{"postgres"},
|
||||||
Query: query{
|
Query: query{
|
||||||
{Sqlquery: "select * from pg_stat_database",
|
{Sqlquery: "select * from pg_stat_database",
|
||||||
Version: 901,
|
Version: 901,
|
||||||
Withdbname: false,
|
Withdbname: false,
|
||||||
Tagvalue: ""},
|
Tagvalue: ""},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
err := p.Gather(&acc)
|
err := p.Gather(&acc)
|
||||||
|
|||||||
Reference in New Issue
Block a user