extern char my_name[];
extern time_t daemon_start_time;
-extern struct s_last_job last_job;
+extern int num_jobs_run;
static void list_scheduled_jobs(UAContext *ua);
static void list_running_jobs(UAContext *ua);
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 since started.\n"),
+ dt, num_jobs_run, num_jobs_run == 1 ? "" : "s");
/*
* List scheduled Jobs
*/
int level, num_jobs = 0;
bool hdr_printed = false;
- Dmsg0(200, "enter find_runs()\n");
+ Dmsg0(200, "enter list_sched_jobs()\n");
/* Loop through all jobs */
LockRes();
} else {
bsendmsg(ua, "\n");
}
- Dmsg0(200, "Leave find_runs()\n");
+ Dmsg0(200, "Leave list_sched_jobs_runs()\n");
}
static void list_running_jobs(UAContext *ua)
char level[10];
bool pool_mem = false;
+ 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.
if (njobs == 0) {
unlock_jcr_chain();
bsendmsg(ua, _("No Running Jobs.\n"));
+ Dmsg0(200, "leave list_run_jobs()\n");
return;
}
njobs = 0;
bsendmsg(ua, _("\nRunning Jobs:\n"));
- bsendmsg(ua, _("Level JobId Job Status\n"));
- bsendmsg(ua, _("====================================================================\n"));
- for (jcr=NULL; (jcr=get_next_jcr(jcr)); njobs++) {
- if (!acl_access_ok(ua, Job_ACL, jcr->job->hdr.name)) {
- continue;
- }
- if (jcr->JobId == 0) { /* this is us */
- njobs--;
+ bsendmsg(ua, _(" JobId Level Name Status\n"));
+ bsendmsg(ua, _("======================================================================\n"));
+ foreach_jcr(jcr) {
+ if (jcr->JobId == 0 || !acl_access_ok(ua, Job_ACL, jcr->job->hdr.name)) {
free_locked_jcr(jcr);
continue;
}
+ njobs++;
switch (jcr->JobStatus) {
case JS_Created:
msg = _("is waiting execution");
switch (jcr->JobType) {
case JT_ADMIN:
case JT_RESTORE:
- bstrncpy(level, " ", sizeof(level));
+ bstrncpy(level, " ", sizeof(level));
break;
default:
bstrncpy(level, level_to_str(jcr->JobLevel), sizeof(level));
- level[4] = 0;
+ level[7] = 0;
break;
}
- bsendmsg(ua, _("%-4s %6d %-20s %s\n"),
- level,
+ bsendmsg(ua, _("%6d %-6s %-20s %s\n"),
jcr->JobId,
+ level,
jcr->Job,
msg);
free_locked_jcr(jcr);
}
unlock_jcr_chain();
-
bsendmsg(ua, "\n");
+ Dmsg0(200, "leave list_run_jobs()\n");
}
static void list_terminated_jobs(UAContext *ua)
lock_last_jobs_list();
struct s_last_job *je;
bsendmsg(ua, _("\nTerminated Jobs:\n"));
- bsendmsg(ua, _(" JobId Level Files Bytes Status Finished Name \n"));
- bsendmsg(ua, _("======================================================================\n"));
+ bsendmsg(ua, _(" JobId Level Files Bytes Status Finished Name \n"));
+ bsendmsg(ua, _("========================================================================\n"));
foreach_dlist(je, last_jobs) {
char JobName[MAX_NAME_LENGTH];
char *termstat;
*p = 0;
}
}
- bsendmsg(ua, _("%6d %-4s %8s %14s %-7s %-8s %s\n"),
+ bsendmsg(ua, _("%6d %-6s %8s %14s %-7s %-8s %s\n"),
je->JobId,
level,
edit_uint64_with_commas(je->JobFiles, b1),