+static void list_running_jobs(void sendit(const char *msg, int len, void *sarg), void *arg)
+{
+ bool found = false;
+ int bps, sec;
+ JCR *jcr;
+ DCR *dcr, *rdcr;
+ char JobName[MAX_NAME_LENGTH];
+ char *msg, b1[30], b2[30], b3[30];
+ int len;
+
+ msg = (char *)get_pool_memory(PM_MESSAGE);
+
+ len = Mmsg(msg, _("\nRunning Jobs:\n"));
+ sendit(msg, len, arg);
+
+ foreach_jcr(jcr) {
+ if (jcr->JobStatus == JS_WaitFD) {
+ len = Mmsg(msg, _("%s Job %s waiting for Client connection.\n"),
+ job_type_to_str(jcr->JobType), jcr->Job);
+ sendit(msg, len, arg);
+ }
+ dcr = jcr->dcr;
+ rdcr = jcr->read_dcr;
+ if ((dcr && dcr->device) || rdcr && rdcr->device) {
+ bstrncpy(JobName, jcr->Job, sizeof(JobName));
+ /* There are three periods after the Job name */
+ char *p;
+ for (int i=0; i<3; i++) {
+ if ((p=strrchr(JobName, '.')) != NULL) {
+ *p = 0;
+ }
+ }
+ if (rdcr && rdcr->device) {
+ len = Mmsg(msg, _("Reading: %s %s job %s JobId=%d Volume=\"%s\"\n"
+ " pool=\"%s\" device=\"%s\"\n"),
+ job_level_to_str(jcr->JobLevel),
+ job_type_to_str(jcr->JobType),
+ JobName,
+ jcr->JobId,
+ rdcr->VolumeName,
+ rdcr->pool_name,
+ rdcr->dev?rdcr->dev->print_name():
+ rdcr->device->device_name);
+ sendit(msg, len, arg);
+ }
+ if (dcr && dcr->device) {
+ len = Mmsg(msg, _("Writing: %s %s job %s JobId=%d Volume=\"%s\"\n"
+ " pool=\"%s\" device=\"%s\"\n"),
+ job_level_to_str(jcr->JobLevel),
+ job_type_to_str(jcr->JobType),
+ JobName,
+ jcr->JobId,
+ dcr->VolumeName,
+ dcr->pool_name,
+ dcr->dev?dcr->dev->print_name():
+ dcr->device->device_name);
+ sendit(msg, len, arg);
+ }
+ sec = time(NULL) - jcr->run_time;
+ if (sec <= 0) {
+ sec = 1;
+ }
+ bps = jcr->JobBytes / sec;
+ len = Mmsg(msg, _(" Files=%s Bytes=%s Bytes/sec=%s\n"),
+ edit_uint64_with_commas(jcr->JobFiles, b1),
+ edit_uint64_with_commas(jcr->JobBytes, b2),
+ edit_uint64_with_commas(bps, b3));
+ sendit(msg, len, arg);
+ found = true;
+#ifdef DEBUG
+ if (jcr->file_bsock) {
+ len = Mmsg(msg, _(" FDReadSeqNo=%s in_msg=%u out_msg=%d fd=%d\n"),
+ edit_uint64_with_commas(jcr->file_bsock->read_seqno, b1),
+ jcr->file_bsock->in_msg_no, jcr->file_bsock->out_msg_no,
+ jcr->file_bsock->fd);
+ sendit(msg, len, arg);
+ } else {
+ len = Mmsg(msg, _(" FDSocket closed\n"));
+ sendit(msg, len, arg);
+ }
+#endif
+ }
+ }
+ endeach_jcr(jcr);
+
+ sendit("====\n", 5, arg);
+
+ free_pool_memory(msg);
+}
+
+static void list_jobs_waiting_on_reservation(void sendit(const char *msg, int len, void *sarg), void *arg)
+{
+ JCR *jcr;
+ char *msg;
+
+ msg = _("\nJobs waiting to reserve a drive:\n");
+ sendit(msg, strlen(msg), arg);
+
+ foreach_jcr(jcr) {
+ if (!jcr->reserve_msgs) {
+ continue;
+ }
+ send_drive_reserve_messages(jcr, sendit, arg);
+ }
+ endeach_jcr(jcr);
+
+ sendit("====\n", 5, arg);
+}
+
+
+static void list_terminated_jobs(void sendit(const char *msg, int len, void *sarg), void *arg)