Code Monkey home page Code Monkey logo

bareos_exporter's People

Contributors

d-rupp avatar dreyau avatar karlism avatar mvkozlov avatar vierbergenlars avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bareos_exporter's Issues

BareOS exporter stops working when there multiple filesets with the same name

BareOS exporter (version 0.5.6) stops working when there are failed backup jobs:

$ curl -s localhost:9625/metrics
An error has occurred while serving metrics:

480 error(s) occurred:
* collected metric "bareos_jobs_run" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > counter:<value:8 > } was collected before with the same name and label values
* collected metric "bareos_bytes_saved" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > counter:<value:0 > } was collected before with the same name and label values
* collected metric "bareos_files_saved" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > counter:<value:0 > } was collected before with the same name and label values
* collected metric "bareos_last_job_bytes_saved" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > counter:<value:0 > } was collected before with the same name and label values
* collected metric "bareos_last_job_files_saved" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > counter:<value:0 > } was collected before with the same name and label values
* collected metric "bareos_last_job_errors" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > counter:<value:1 > } was collected before with the same name and label values
* collected metric "bareos_last_job_start_unix_timestamp" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > counter:<value:1.626365576e+09 > } was collected before with the same name and label values
* collected metric "bareos_last_job_end_unix_timestamp" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > counter:<value:1.626365577e+09 > } was collected before with the same name and label values
* collected metric "bareos_last_job_status" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > label:<name:"status" value:"C" > counter:<value:0 > } was collected before with the same name and label values
* collected metric "bareos_last_job_status" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > label:<name:"status" value:"R" > counter:<value:0 > } was collected before with the same name and label values
* collected metric "bareos_last_job_status" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > label:<name:"status" value:"B" > counter:<value:0 > } was collected before with the same name and label values
* collected metric "bareos_last_job_status" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > label:<name:"status" value:"T" > counter:<value:0 > } was collected before with the same name and label values
* collected metric "bareos_last_job_status" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > label:<name:"status" value:"E" > counter:<value:0 > } was collected before with the same name and label values
* collected metric "bareos_last_job_status" { label:<name:"client" value:"devdb2" > label:<name:"fileset" value:"PostgreSQL" > label:<name:"jobname" value:"backup-devdb2-postgresql" > label:<name:"jobtype" value:"B" > label:<name:"last_selector" value:"last" > label:<name:"status" value:"e" > counter:<value:0 > } was collected before with the same name and label values

Here's database entries related to this backup job:

$ echo "select * from job where name='backup-devdb2-postgresql';" | psql bareos -x
-[ RECORD 1 ]---+---------------------------------------------------
jobid           | 253
job             | backup-devdb2-postgresql.2021-07-15_15.29.01_08
name            | backup-devdb2-postgresql
type            | B
level           | F
clientid        | 4
jobstatus       | f
schedtime       | 2021-07-15 15:29:01
starttime       | 2021-07-15 15:29:03
endtime         | 2021-07-15 15:29:03
realendtime     | 2021-07-15 15:29:03
jobtdate        | 1626362943
volsessionid    | 215
volsessiontime  | 1625060238
jobfiles        | 0
jobbytes        | 0
readbytes       | 0
joberrors       | 1
jobmissingfiles | 0
poolid          | 3
filesetid       | 17
priorjobid      | 0
purgedfiles     | 0
hasbase         | 0
hascache        | 1
reviewed        | 0
comment         | 
-[ RECORD 2 ]---+---------------------------------------------------
jobid           | 247
job             | backup-devdb2-postgresql.2021-07-15_14.09.47_53
name            | backup-devdb2-postgresql
type            | B
level           | F
clientid        | 4
jobstatus       | f
schedtime       | 2021-07-15 14:09:47
starttime       | 2021-07-15 14:09:49
endtime         | 2021-07-15 14:09:50
realendtime     | 2021-07-15 14:09:50
jobtdate        | 1626358190
volsessionid    | 209
volsessiontime  | 1625060238
jobfiles        | 0
jobbytes        | 0
readbytes       | 0
joberrors       | 2
jobmissingfiles | 0
poolid          | 3
filesetid       | 14
priorjobid      | 0
purgedfiles     | 0
hasbase         | 0
hascache        | 1
reviewed        | 0
comment         | 
-[ RECORD 3 ]---+---------------------------------------------------
jobid           | 244
job             | backup-devdb2-postgresql.2021-07-15_10.13.56_17
name            | backup-devdb2-postgresql
type            | B
level           | F
clientid        | 4
jobstatus       | f
schedtime       | 2021-07-15 10:13:56
starttime       | 2021-07-15 10:13:59
endtime         | 2021-07-15 10:13:59
realendtime     | 2021-07-15 10:13:59
jobtdate        | 1626344039
volsessionid    | 206
volsessiontime  | 1625060238
jobfiles        | 0
jobbytes        | 0
readbytes       | 0
joberrors       | 1
jobmissingfiles | 0
poolid          | 3
filesetid       | 15
priorjobid      | 0
purgedfiles     | 0
hasbase         | 0
hascache        | 1
reviewed        | 0
comment         | 
-[ RECORD 4 ]---+---------------------------------------------------
jobid           | 250
job             | backup-devdb2-postgresql.2021-07-15_14.28.29_23
name            | backup-devdb2-postgresql
type            | B
level           | F
clientid        | 4
jobstatus       | f
schedtime       | 2021-07-15 14:28:29
starttime       | 2021-07-15 14:28:31
endtime         | 2021-07-15 14:28:32
realendtime     | 2021-07-15 14:28:32
jobtdate        | 1626359312
volsessionid    | 212
volsessiontime  | 1625060238
jobfiles        | 0
jobbytes        | 0
readbytes       | 0
joberrors       | 2
jobmissingfiles | 0
poolid          | 3
filesetid       | 14
priorjobid      | 0
purgedfiles     | 0
hasbase         | 0
hascache        | 1
reviewed        | 0
comment         | 
-[ RECORD 5 ]---+---------------------------------------------------
jobid           | 242
job             | backup-devdb2-postgresql.2021-07-15_10.00.18_21
name            | backup-devdb2-postgresql
type            | B
level           | F
clientid        | 4
jobstatus       | f
schedtime       | 2021-07-15 10:00:18
starttime       | 2021-07-15 10:00:21
endtime         | 2021-07-15 10:00:21
realendtime     | 2021-07-15 10:00:21
jobtdate        | 1626343221
volsessionid    | 204
volsessiontime  | 1625060238
jobfiles        | 0
jobbytes        | 0
readbytes       | 0
joberrors       | 1
jobmissingfiles | 0
poolid          | 3
filesetid       | 14
priorjobid      | 0
purgedfiles     | 0
hasbase         | 0
hascache        | 1
reviewed        | 0
comment         | 
-[ RECORD 6 ]---+---------------------------------------------------
jobid           | 248
job             | backup-devdb2-postgresql.2021-07-15_14.25.03_05
name            | backup-devdb2-postgresql
type            | B
level           | F
clientid        | 4
jobstatus       | f
schedtime       | 2021-07-15 14:25:03
starttime       | 2021-07-15 14:25:06
endtime         | 2021-07-15 14:25:06
realendtime     | 2021-07-15 14:25:06
jobtdate        | 1626359106
volsessionid    | 210
volsessiontime  | 1625060238
jobfiles        | 0
jobbytes        | 0
readbytes       | 0
joberrors       | 1
jobmissingfiles | 0
poolid          | 3
filesetid       | 14
priorjobid      | 0
purgedfiles     | 0
hasbase         | 0
hascache        | 1
reviewed        | 0
comment         | 
-[ RECORD 7 ]---+---------------------------------------------------
jobid           | 243
job             | backup-devdb2-postgresql.2021-07-15_10.07.54_05
name            | backup-devdb2-postgresql
type            | B
level           | F
clientid        | 4
jobstatus       | f
schedtime       | 2021-07-15 10:07:54
starttime       | 2021-07-15 10:07:57
endtime         | 2021-07-15 10:07:57
realendtime     | 2021-07-15 10:07:57
jobtdate        | 1626343677
volsessionid    | 205
volsessiontime  | 1625060238
jobfiles        | 0
jobbytes        | 0
readbytes       | 0
joberrors       | 1
jobmissingfiles | 0
poolid          | 3
filesetid       | 15
priorjobid      | 0
purgedfiles     | 0
hasbase         | 0
hascache        | 1
reviewed        | 0
comment         | 
-[ RECORD 8 ]---+---------------------------------------------------
jobid           | 252
job             | backup-devdb2-postgresql.2021-07-15_15.17.23_04
name            | backup-devdb2-postgresql
type            | B
level           | F
clientid        | 4
jobstatus       | f
schedtime       | 2021-07-15 15:17:23
starttime       | 2021-07-15 15:17:26
endtime         | 2021-07-15 15:17:26
realendtime     | 2021-07-15 15:17:26
jobtdate        | 1626362246
volsessionid    | 214
volsessiontime  | 1625060238
jobfiles        | 0
jobbytes        | 0
readbytes       | 0
joberrors       | 1
jobmissingfiles | 0
poolid          | 3
filesetid       | 16
priorjobid      | 0
purgedfiles     | 0
hasbase         | 0
hascache        | 1
reviewed        | 0
comment         | 
-[ RECORD 9 ]---+---------------------------------------------------
jobid           | 246
job             | backup-devdb2-postgresql.2021-07-15_14.06.32_39
name            | backup-devdb2-postgresql
type            | B
level           | F
clientid        | 4
jobstatus       | f
schedtime       | 2021-07-15 14:06:32
starttime       | 2021-07-15 14:06:34
endtime         | 2021-07-15 14:06:35
realendtime     | 2021-07-15 14:06:35
jobtdate        | 1626357995
volsessionid    | 208
volsessiontime  | 1625060238
jobfiles        | 0
jobbytes        | 0
readbytes       | 0
joberrors       | 1
jobmissingfiles | 0
poolid          | 3
filesetid       | 14
priorjobid      | 0
purgedfiles     | 0
hasbase         | 0
hascache        | 1
reviewed        | 0
comment         | 

Judging by Prometheus up metric, I can see that exporter stopped working around 10:08, thus I conclude that this failure was triggered by jobid 243. I'm using BareOS 20.0.1 and PostgreSQL 13 backend database.

DSN is handled incorrectly

Hello,

There is an issue with DSN string handling, let me show you an example:

$ ./bareos_exporter -dsn=postgres://bareos:bareospw@localhost/bareos
panic: missing "=" after "bareos:bareospw@localhost/bareos" in connection info string"

goroutine 1 [running]:
main.main()
	/github/workspace/main.go:52 +0x46d

It is perfectly valid URL, but bareos_exporter expects it to have = symbol in it. If I add additional connection parameters, it is working fine (the system is not running PostgreSQL locally, so connection refused is fine in this case):

$ ./bareos_exporter -dsn=postgres://bareos:bareospw@localhost/bareos?readOnly=true
panic: dial tcp [::1]:5432: connect: connection refused

Lots of sql: Scan error in logs

I'm running BareOS exporter with BareOS 20.0.1 and PostgreSQL 13 and BareOS exporter produces lots of following errors:

Jun 30 23:29:24 backup1 bareos_exporter[21509]: time="2021-06-30T23:29:24Z" level=error msg="sql: Scan error on column index 4, name \"expired\": sql/driver: couldn't convert <nil> (<nil>) into type bool" method=PoolInfo
Jun 30 23:29:42 backup1 bareos_exporter[21509]: time="2021-06-30T23:29:42Z" level=error msg="sql: Scan error on column index 4, name \"expired\": sql/driver: couldn't convert <nil> (<nil>) into type bool" method=PoolInfo

These errors only appear in logs when there are active backup jobs running.

Latest BareOS exporter is used with following flags:

/usr/bin/bareos_exporter -dsn=postgres://user bareos password=XXX host=127.0.0.1 dbname=bareos sslmode=disable

posrgres dosent work

i have been trying to get the postgres lookup to work.
and get at
ERRO[0002] pq: password authentication failed for user "root" args="[2020-10-05]" query="SELECT DISTINCT Name FROM job WHERE SchedTime >= $1"
panic: runtime error: invalid memory address or nil pointer dereference

But i have created a small test program to test the connection and run the query

package main

import (
"database/sql"
"fmt"
"time"
_ "github.com/lib/pq"
)

const (
host = "10.1.79.41"
port = 5432
user = "bareos"
password = "<>"
dbname = "bareos_catalog"
)

func main() {
psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+
"password=%s dbname=%s sslmode=disable",
host, port, user, password, dbname)
db, err := sql.Open("postgres", psqlInfo)
if err != nil {
panic(err)
}
date := time.Now().AddDate(0, 0, -7).Format("2006-01-02")
rows, err := db.Query("SELECT DISTINCT Name FROM job WHERE SchedTime >= $1",date)
//rows, err := db.Query("SELECT DISTINCT Name FROM job")
checkErr(err)
for rows.Next() {
var name string
err = rows.Scan(&name)
checkErr(err)
fmt.Println(name)
}

defer db.Close()

err = db.Ping()
if err != nil {
panic(err)
}

fmt.Println("Successfully connected!")
}

func checkErr(err error) {
if err != nil {
panic(err)
}
}

and that works ?
i cant seem to find the error, but i stops in the collector.go
with
var servers, getServerListErr = collector.connection.GetServerList()

cant you please help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.