View Issue Details

IDProjectCategoryView StatusLast Update
0000885bareos-coredirectorpublic2018-01-29 12:31
ReporterShodan Assigned To 
PrioritylowSeverityminorReproducibilityrandom
Status closedResolutionfixed 
PlatformLinuxOSDebianOS Version8
Product Version17.2.4 
Summary0000885: Job status value for completed backup job is different in mail command variable "%e" and in catalog database
DescriptionJob status value for zabbix monitoring script (%e) and job status value in database are different for completed single backup job.
Steps To Reproduce1) Run backup job (for example JobId = 1111)
2) In bareos console: backup job completed with termination status OK
3) Job status value in catalog database is still R (Running) or C (created) for JobId 1111
4) Zabbix.sh script sends alert to zabbix server with status code 2 (status is not T or W)
5) After a couple of seconds job status in catalog database changed to T terminated) for JobId 1111
Additional Information1) definition of zabbix monitoring script for Bareos jobs

Messages {
  Name = Standard
  Mail Command = "/etc/bareos/zabbix/zabbix.sh %i %t %e %c %l"
  Mail = admin@admiralmarkets.com = all, !skipped
  Console = all, !skipped, !saved
  Append = "/var/log/bareos/bareos.log" = all, !skipped, !fatal, !error
  Append = "/var/log/bareos/bareos_err.log" = fatal, error
}

2) Catalog definition for bareos director
Catalog {
  Name = MyCatalog
  Reconnect = yes
  dbdriver = mysql
  dbname = bareos
  dbaddress = 10.1.1.1
  dbport = 3306
  dbuser = bareos
  dbpassword = "****"
}

3) Code block from zabbix.sh script to check bareos job status

JobType="$2"
JobExitCode="$3"
ClientName="$4"
JobLevel="$5"

sql="/usr/bin/mysql --defaults-file=$bareosDbPass -h$bareosDbAddr -P$bareosDbPort -u$bareosDbUser -D$bareosDbName -NB -e" ;;

# Get Job exit status from database
bareosJobStatus=$($sql "select JobStatus from Job where JobId=$bareosJobId;" 2>/dev/null)

case $bareosJobStatus in
        "T") status=0 ;;
        "W") status=1 ;;
        *) status=2 ;;
esac
TagsNo tags attached.

Activities

joergs

joergs

2018-01-27 20:21

developer   ~0002889

I understand, that the mail command shows the exit status before it is written to the database.

However, this is the first time I see the Mail Command being used to interact with a monitoring tool. Why is this required?

Some update has to be done at first. As the Mail Command may also send reports about a lost database connection, sending mails before updating the database makes sense.

I would have chosen an other option for communicating with a monitoring system.
How about:
  Run Script {
        Runs When = After
        Runs On Client = No
        ...
  }

or a plugin like
https://github.com/bareos/bareos-contrib/tree/master/dir-plugins/nagios_icinga
Shodan

Shodan

2018-01-29 12:28

reporter   ~0002892

For historical reason :)

Thank you, I've enabled Run Script command in JobDefs template and it works fine.

Issue History

Date Modified Username Field Change
2017-12-22 13:19 Shodan New Issue
2018-01-27 20:21 joergs Note Added: 0002889
2018-01-29 12:28 Shodan Note Added: 0002892
2018-01-29 12:31 joergs Status new => resolved
2018-01-29 12:31 joergs Resolution open => fixed
2018-01-29 12:31 joergs Assigned To => joergs
2018-01-29 12:31 joergs Status resolved => closed
2018-01-29 12:31 joergs Assigned To joergs =>