Status of jobs from the database

94 views
Skip to first unread message

Guy Van Sanden

unread,
Aug 21, 2023, 5:10:06 AM8/21/23
to bareos-users
Can I get the status of jobs from the database directly?
I'm rebuilding my Zabbix template to monitor bareos jobs, but that part is missing.

I have this currently

jobquery = "select distinct name from job where type = 'B' and clientid in (select clientid from client where jobretention <> 0);"
-> gets the jobs

for job in jobs:
  statusquery = ("select * from job where name = '%s' order by endtime desc" %(job['name']))

Bruno Friedmann

unread,
Aug 22, 2023, 4:58:57 AM8/22/23
to bareos-users
I'm not sure to have 100% understood what you're looking for, if it is about finished jobs (then search in the database is fine) or actually running, planned and so on, which are only known by the director and are lost if there's a crash.

Tihomir Vlahovski

unread,
Sep 1, 2023, 7:14:49 AM9/1/23
to bareos-users
I was planning the same and my idea was to use the API - https://docs.bareos.org/DeveloperGuide/api.html#
Still on my TODO list though

Cheers,
-Tiho

Work User

unread,
Sep 1, 2023, 10:40:06 AM9/1/23
to bareos-users
Here's what I use. It's more for showing me the date, duration, and backup size than backup status, but it can be modified to show all statuses:

SELECT jobid, name, s.jobstatuslong as status, to_char(endtime::date, 'YYYY-MM-DD') as last_successful, to_char(date_part('epoch', endtime - starttime) * interval '1 second', 'HH24:MI:SS') as duration, jobfiles, jobbytes::bigint as size
FROM job
JOIN status s USING (jobstatus)
WHERE level = 'F'
AND jobstatus IN ('T', 'W')
ORDER BY last_successful desc;

In the WHERE clause:

level = 'F' - only show full backups
jobstatus IN ('T', 'W') - only show me successful and warning jobs. Take this out to see all statuses

Hope that helps

stefa...@googlemail.com

unread,
Sep 18, 2024, 12:16:41 PM9/18/24
to bareos-users
any news about a zabbix template which use the API?
Reply all
Reply to author
Forward
0 new messages