From 9c1bc3d2dc5c2bd684808689f4c2ce815af7901a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 31 Mar 2010 14:40:58 +0200 Subject: [PATCH] Add jobs running to status of daemons --- bacula/src/dird/ua_status.c | 9 ++------- bacula/src/filed/status.c | 8 +++----- bacula/src/lib/jcr.c | 18 ++++++++++++++++++ bacula/src/lib/protos.h | 1 + bacula/src/stored/status.c | 7 +++---- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index deda34f742..9247d7d845 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -295,13 +295,8 @@ void list_dir_status_header(UAContext *ua) ua->send_msg(_("%s Version: %s (%s) %s %s %s\n"), my_name, VERSION, BDATE, HOST_OS, DISTNAME, DISTVER); bstrftime_nc(dt, sizeof(dt), daemon_start_time); - if (num_jobs_run == 1) { - ua->send_msg(_("Daemon started %s, 1 Job run since started.\n"), dt); - } - else { - ua->send_msg(_("Daemon started %s, %d Jobs run since started.\n"), - dt, num_jobs_run); - } + ua->send_msg(_("Daemon started %s. Jobs: run=%d, running=%d\n"), dt, + num_jobs_run, job_count()); ua->send_msg(_(" Heap: heap=%s smbytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), edit_uint64_with_commas((char *)sbrk(0)-(char *)start_heap, b1), edit_uint64_with_commas(sm_bytes, b2), diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index ce570b93d1..6c2f646cec 100644 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2009 Free Software Foundation Europe e.V. + Copyright (C) 2001-2010 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -30,8 +30,6 @@ * * Kern Sibbald, August MMI * - * Version $Id$ - * */ #include "bacula.h" @@ -85,8 +83,8 @@ static void list_status_header(STATUS_PKT *sp) my_name, VERSION, BDATE, VSS, HOST_OS, DISTNAME, DISTVER); sendit(msg.c_str(), len, sp); bstrftime_nc(dt, sizeof(dt), daemon_start_time); - len = Mmsg(msg, _("Daemon started %s, %d Job%s run since started.\n"), - dt, num_jobs_run, num_jobs_run == 1 ? "" : "s"); + len = Mmsg(msg, _("Daemon started %s. Jobs: run=%d running=%d.\n"), + dt, num_jobs_run, job_count()); sendit(msg.c_str(), len, sp); #if defined(HAVE_WIN32) if (debug_level > 0) { diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 4e5b4c06e8..0367bf0671 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -971,6 +971,24 @@ void jcr_walk_end(JCR *jcr) } } +/* + * Return number of Jobs + */ +int job_count() +{ + JCR *jcr; + int count = 0; + + lock_jcr_chain(); + for (jcr = (JCR *)jcrs->first(); jcr = (JCR *)jcrs->next(jcr); ) { + if (jcr->JobId > 0) { + count++; + } + } + unlock_jcr_chain(); + return count; +} + /* * Setup to call the timeout check routine every 30 seconds diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 7e700bdad7..9de59dc296 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -204,6 +204,7 @@ void unlock_jobs(); JCR *jcr_walk_start(); JCR *jcr_walk_next(JCR *prev_jcr); void jcr_walk_end(JCR *jcr); +int job_count(); JCR *get_jcr_from_tsd(); void set_jcr_in_tsd(JCR *jcr); void remove_jcr_from_tsd(JCR *jcr); diff --git a/bacula/src/stored/status.c b/bacula/src/stored/status.c index a1fa4ddee9..e5ef685ce5 100644 --- a/bacula/src/stored/status.c +++ b/bacula/src/stored/status.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2003-2009 Free Software Foundation Europe e.V. + Copyright (C) 2003-2010 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -30,7 +30,6 @@ * * Kern Sibbald, May MMIII * - * Version $Id$ * */ @@ -223,8 +222,8 @@ static void list_status_header(STATUS_PKT *sp) bstrftime_nc(dt, sizeof(dt), daemon_start_time); - len = Mmsg(msg, _("Daemon started %s, %d Job%s run since started.\n"), - dt, num_jobs_run, num_jobs_run == 1 ? "" : "s"); + len = Mmsg(msg, _("Daemon started %s. Jobs: run=%d, running=%d.\n"), + dt, num_jobs_run, job_count()); sendit(msg, len, sp); len = Mmsg(msg, _(" Heap: heap=%s smbytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), -- 2.39.5