- char dt[MAX_TIME_LENGTH], b1[30], b2[30];
- char level[10];
- struct s_last_job *je;
- char *msg;
-
- if (last_job.NumJobs == 0) {
- msg = _("No Terminated Jobs.\n");
- sendit(msg, strlen(msg), arg);
- return;
- }
- lock_last_jobs_list();
- sendit("\n", 1, arg); /* send separately */
- msg = _("Terminated Jobs:\n");
- sendit(msg, strlen(msg), arg);
- msg = _(" JobId Level Files Bytes Status Finished Name \n");
- sendit(msg, strlen(msg), arg);
- msg = _("======================================================================\n");
- sendit(msg, strlen(msg), arg);
- for (je=NULL; (je=(s_last_job *)last_jobs->next(je)); ) {
- char JobName[MAX_NAME_LENGTH];
- char *termstat;
- char buf[1000];
-
- bstrftime_nc(dt, sizeof(dt), je->end_time);
- switch (je->JobType) {
- case JT_ADMIN:
- case JT_RESTORE:
- bstrncpy(level, " ", sizeof(level));
- break;
- default:
- bstrncpy(level, level_to_str(je->JobLevel), sizeof(level));
- level[4] = 0;
- break;
+ OutputWriter ow(sp->api_opts);
+ int sec, bps;
+ char *p;
+ JCR *njcr;
+
+ /* API v1, edit with comma, space before the name, sometime ' ' as separator */
+
+ foreach_jcr(njcr) {
+ p = ow.get_output(OT_CLEAR, OT_START_OBJ, OT_END);
+
+ if (njcr->JobId == 0) {
+ ow.get_output(OT_UTIME, "DirectorConnected", njcr->start_time,
+ OT_INT, "DirTLS", (njcr->dir_bsock && njcr->dir_bsock->tls)?1:0,
+ OT_END);
+ } else {
+ ow.get_output(OT_INT32, "JobId", njcr->JobId,
+ OT_STRING, "Job", njcr->Job,
+ OT_JOBLEVEL,"Level", njcr->getJobLevel(),
+ OT_JOBTYPE, "Type", njcr->getJobType(),
+ OT_JOBSTATUS, "Status", njcr->getJobStatus(),
+ OT_UTIME, "StartTime", njcr->start_time,
+ OT_END);
+
+ }
+ sendit(p, strlen(p), sp);
+ if (njcr->JobId == 0) {
+ continue;
+ }
+ sec = time(NULL) - njcr->start_time;
+ if (sec <= 0) {
+ sec = 1;
+ }
+ bps = (int)(njcr->JobBytes / sec);
+ ow.get_output(OT_CLEAR,
+ OT_INT32, "JobFiles", njcr->JobFiles,
+ OT_SIZE, "JobBytes", njcr->JobBytes,
+ OT_INT, "Bytes/sec", bps,
+ OT_INT, "Errors", njcr->JobErrors,
+ OT_INT64, "Bwlimit", njcr->max_bandwidth,
+ OT_SIZE, "ReadBytes", njcr->ReadBytes,
+ OT_END);
+
+ ow.get_output(OT_INT32, "Files Examined", njcr->num_files_examined, OT_END);
+
+ if (njcr->is_JobType(JT_RESTORE) && njcr->ExpectedFiles > 0) {
+ ow.get_output(OT_INT32, "Expected Files", njcr->ExpectedFiles,
+ OT_INT32, "Percent Complete", 100*(njcr->num_files_examined/njcr->ExpectedFiles),
+ OT_END);