bool pool_mem = false;
OutputWriter ow(ua->api_opts);
JobId_t jid = 0;
+ POOL_MEM msg_buf;
if ((i = find_arg_with_value(ua, "jobid")) >= 0) {
jid = str_to_int64(ua->argv[i]);
break;
}
+ uint32_t curr_op = jcr->job_task;
+ if (curr_op != 0) {
+ /* We can add some more descriptive message */
+ Mmsg(msg_buf, "%s (%s)", msg, get_job_task(curr_op));
+ } else {
+ pm_strcpy(msg_buf, msg);
+ }
+
if (ua->api == 1) {
bash_spaces(jcr->comment);
ua->send_msg(_("%6d\t%-6s\t%-20s\t%s\t%s\n"),
- jcr->JobId, level, jcr->Job, msg, jcr->comment);
+ jcr->JobId, level, jcr->Job, msg_buf.c_str(), jcr->comment);
unbash_spaces(jcr->comment);
} else if (ua->api > 1) {
OT_JOBLEVEL,"level", jcr->getJobLevel(),
OT_JOBTYPE, "type", jcr->getJobType(),
OT_JOBSTATUS,"status", status,
- OT_STRING, "status_desc",msg,
+ OT_STRING, "status_desc",msg_buf.c_str(),
OT_STRING, "comment", jcr->comment,
OT_SIZE, "jobbytes", jcr->JobBytes,
OT_INT32, "jobfiles", jcr->JobFiles,
jcr->JobId, b1, level,
edit_uint64_with_commas(jcr->JobFiles, b2),
edit_uint64_with_suffix(jcr->JobBytes, b3),
- jcr->job->name(), msg);
+ jcr->job->name(), msg_buf.c_str());
}
if (pool_mem) {
#define JS_CloudUpload 'u' /* Cloud upload */
#define JS_CloudDownload 'w' /* Cloud download */
+/* Helper for more descriptive job status */
+enum {
+ JOB_TASK_ZERO = 0,
+ JOB_TASK_BEFORE_SCRIPT = 100,
+ JOB_TASK_AFTER_SCRIPT
+};
+
+struct job_task {
+ const uint32_t op_code;
+ const char *op_message;
+};
+
+
+const char *get_job_task(uint32_t op_code);
+
+
/* Migration selection types. Do not change the order. */
enum {
MT_SMALLEST_VOL = 1,
char Job[MAX_NAME_LENGTH]; /* Unique name of this Job */
char event[MAX_NAME_LENGTH]; /* Current event (python) */
uint32_t eventType; /* Current event type (plugin) */
-
+ uint32_t job_task; /* Used to add description of current opearion being executed
+ (e.g. 'running AfterJob script').
+ If not 0, it can be used to make current job
+ status more descriptive. */
uint32_t JobId; /* Director's JobId */
uint32_t VolSessionId;
uint32_t VolSessionTime;
static char Job_status[] = "Status JobId=%ld JobStatus=%d\n";
+/* Mapping of operation code to operation description */
+const struct job_task job_task_map[] = {
+ { JOB_TASK_ZERO, "\0" },
+ { JOB_TASK_BEFORE_SCRIPT, "executing Before Job Scripts" },
+ { JOB_TASK_AFTER_SCRIPT, "executing After Job Scripts" }
+};
+
+const uint32_t job_task_map_size = sizeof(job_task_map) / sizeof(job_task);
+
void lock_jobs()
{
P(job_start_mutex);
jcr->setJobType(JT_SYSTEM); /* internal job until defined */
jcr->setJobLevel(L_NONE);
jcr->setJobStatus(JS_Created); /* ready to run */
+ jcr->job_task = JOB_TASK_ZERO;
#ifndef HAVE_WIN32
struct sigaction sigtimer;
sigtimer.sa_flags = 0;
return 1;
}
+/* Get description of operation by given job task code */
+const char *get_job_task(uint32_t op_code)
+{
+ for (uint32_t i=0; i<job_task_map_size; i++) {
+ if (job_task_map[i].op_code == op_code) {
+ return job_task_map[i].op_message;
+ }
+ }
+
+ return NULL;
+}
+
/*
* Timeout signal comes here
*/
Dmsg4(200, "runscript: Run it because SCRIPT_Before (%s,%i,%i,%c)\n",
script->command, script->on_success, script->on_failure,
jcr->JobStatus );
+ /* Set job task code */
+ jcr->job_task = JOB_TASK_BEFORE_SCRIPT;
runit = true;
}
}
Dmsg4(200, "runscript: Run it because SCRIPT_AfterVSS (%s,%i,%i,%c)\n",
script->command, script->on_success, script->on_failure,
jcr->JobStatus );
+ /* Set job task code */
+ jcr->job_task = JOB_TASK_AFTER_SCRIPT;
runit = true;
}
}
Dmsg4(200, "runscript: Run it because SCRIPT_After (%s,%i,%i,%c)\n",
script->command, script->on_success, script->on_failure,
jcr->JobStatus );
+ /* Set job task code */
+ jcr->job_task = JOB_TASK_AFTER_SCRIPT;
runit = true;
}
}
}
}
+ /* Script ended, reset operation code */
+ jcr->job_task = JOB_TASK_ZERO;
+
return ret;
}
int mode;
const char *volname = (relabel == 1) ? oldname : newname;
uint64_t volCatBytes;
- bool opened = false;
if (!obtain_device_block(dev,
&hold,