]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_status.c
- Back port changes to 1.38.5
[bacula/bacula] / bacula / src / dird / ua_status.c
index 314371659704476da1d2007a1f3f52792e28e6af..84138f31b0df4961d6ec14e8e0f355905b9fd9b9 100644 (file)
@@ -7,7 +7,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2001-2005 Kern Sibbald
+   Copyright (C) 2001-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -66,14 +66,14 @@ int qstatus_cmd(UAContext *ua, const char *cmd)
             bsendmsg(ua, DotStatusJob, edit_int64(njcr->JobId, ed1), 
                      njcr->JobStatus, njcr->JobErrors);
          }
-         free_jcr(njcr);
       }
+      endeach_jcr(njcr);
    } else if (strcasecmp(ua->argk[2], "last") == 0) {
       bsendmsg(ua, OKqstatus, ua->argk[2]);
       if ((last_jobs) && (last_jobs->size() > 0)) {
          job = (s_last_job*)last_jobs->last();
-         bsendmsg(ua, DotStatusJob, edit_int64(njcr->JobId, ed1), 
-                  njcr->JobStatus, njcr->JobErrors);
+         bsendmsg(ua, DotStatusJob, edit_int64(job->JobId, ed1), 
+                  job->JobStatus, job->Errors);
       }
    } else {
       bsendmsg(ua, "1900 Bad .status command, wrong argument.\n");
@@ -112,7 +112,7 @@ int status_cmd(UAContext *ua, const char *cmd)
          }
          return 1;
       } else {
-         store = get_storage_resource(ua, 0);
+         store = get_storage_resource(ua, false/*no default*/);
          if (store) {
             do_storage_status(ua, store);
          }
@@ -379,8 +379,8 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp)
          close_db = true;             /* new db opened, remember to close it */
       }
       if (ok) {
-         mr.PoolId = jcr->PoolId;
-         ok = find_next_volume_for_append(jcr, &mr, 0);
+         mr.PoolId = jcr->jr.PoolId;
+         ok = find_next_volume_for_append(jcr, &mr, 1, false/*no create*/);
       }
       if (!ok) {
          bstrncpy(mr.VolumeName, "*unknown*", sizeof(mr.VolumeName));
@@ -440,16 +440,27 @@ static void list_scheduled_jobs(UAContext *ua)
    bool hdr_printed = false;
    dlist sched;
    sched_pkt *sp;
+   int days, i;
 
    Dmsg0(200, "enter list_sched_jobs()\n");
 
+   days = 1;
+   i = find_arg_with_value(ua, N_("days"));
+   if (i >= 0) {
+     days = atoi(ua->argv[i]);
+     if ((days < 0) || (days > 50)) {
+       bsendmsg(ua, _("Ignoring illegal value for days.\n"));
+       days = 1;
+     }
+   }
+
    /* Loop through all jobs */
    LockRes();
    foreach_res(job, R_JOB) {
-      if (!acl_access_ok(ua, Job_ACL, job->hdr.name)) {
+      if (!acl_access_ok(ua, Job_ACL, job->hdr.name) || !job->enabled) {
          continue;
       }
-      for (run=NULL; (run = find_next_run(run, job, runtime)); ) {
+      for (run=NULL; (run = find_next_run(run, job, runtime, days)); ) {
          level = job->JobLevel;
          if (run->level) {
             level = run->level;
@@ -496,7 +507,6 @@ static void list_running_jobs(UAContext *ua)
    Dmsg0(200, "enter list_run_jobs()\n");
    bsendmsg(ua, _("\nRunning Jobs:\n"));
    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.
@@ -505,10 +515,12 @@ static void list_running_jobs(UAContext *ua)
             bstrftime_nc(dt, sizeof(dt), jcr->start_time);
             bsendmsg(ua, _("Console connected at %s\n"), dt);
          }
-         njobs--;
-      }
-      free_jcr(jcr);
+         continue;
+      }       
+      njobs++;
    }
+   endeach_jcr(jcr);
+
    if (njobs == 0) {
       /* Note the following message is used in regress -- don't change */
       bsendmsg(ua, _("No Jobs running.\n====\n"));
@@ -520,7 +532,6 @@ static void list_running_jobs(UAContext *ua)
    bsendmsg(ua, _("======================================================================\n"));
    foreach_jcr(jcr) {
       if (jcr->JobId == 0 || !acl_access_ok(ua, Job_ACL, jcr->job->hdr.name)) {
-         free_jcr(jcr);
          continue;
       }
       njobs++;
@@ -639,8 +650,8 @@ static void list_running_jobs(UAContext *ua)
          free_pool_memory(emsg);
          pool_mem = false;
       }
-      free_jcr(jcr);
    }
+   endeach_jcr(jcr);
    bsendmsg(ua, _("====\n"));
    Dmsg0(200, "leave list_run_jobs()\n");
 }