]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_status.c
Fix reporting jobs from state file + misc
[bacula/bacula] / bacula / src / dird / ua_status.c
index 754b0199f89bc932d990096be25433d81ff7a1b7..a33cd179bd97ec4dc35aecc76f04c47281e3cf63 100644 (file)
@@ -202,8 +202,8 @@ static void do_director_status(UAContext *ua, char *cmd)
    bsendmsg(ua, "%s Version: " VERSION " (" BDATE ") %s %s %s\n", my_name,
            HOST_OS, DISTNAME, DISTVER);
    bstrftime_nc(dt, sizeof(dt), daemon_start_time);
-   bsendmsg(ua, _("Daemon started %s, %d Job%s run.\n"), dt, last_job.NumJobs,
-        last_job.NumJobs == 1 ? "" : "s");
+   bsendmsg(ua, _("Daemon started %s, %d Job%s run.\n"), dt, last_jobs->size(),
+        last_jobs->size() == 1 ? "" : "s");
    /*
     * List scheduled Jobs
     */
@@ -391,7 +391,8 @@ static void list_running_jobs(UAContext *ua)
 
    Dmsg0(200, "enter list_run_jobs()\n");
    lock_jcr_chain();
-   for (jcr=NULL; (jcr=get_next_jcr(jcr)); njobs++) {
+   foreach_jcr(jcr) {
+      njobs++;
       if (jcr->JobId == 0) {     /* this is us */
         /* this is a console or other control job. We only show console
          * jobs in the status output.
@@ -414,12 +415,12 @@ static void list_running_jobs(UAContext *ua)
    bsendmsg(ua, _("\nRunning Jobs:\n"));
    bsendmsg(ua, _("Level JobId  Job                        Status\n"));
    bsendmsg(ua, _("====================================================================\n"));
-   for (jcr=NULL; (jcr=get_next_jcr(jcr)); njobs++) {
+   foreach_jcr(jcr) {
       if (jcr->JobId == 0 || !acl_access_ok(ua, Job_ACL, jcr->job->hdr.name)) {
-        njobs--;
         free_locked_jcr(jcr);
         continue;
       }
+      njobs++;
       switch (jcr->JobStatus) {
       case JS_Created:
          msg = _("is waiting execution");