]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/status.c
07Jan06
[bacula/bacula] / bacula / src / stored / status.c
index 156f5bd854c9b794676d9e4a0bfbb8ac579b74a5..3ad2076e06ad5abe38c65f4e6af5b06af8d33bb2 100644 (file)
@@ -4,25 +4,20 @@
  *     Kern Sibbald, May MMIII
  *
  *   Version $Id$
- *  
+ *
  */
 /*
-   Copyright (C) 2000-2004 Kern Sibbald and John Walker
+   Copyright (C) 2003-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 as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
@@ -39,34 +34,52 @@ extern char my_name[];
 extern time_t daemon_start_time;
 extern int num_jobs_run;
 
+
 /* Static variables */
+static char qstatus[] = ".status %127s\n";
+
+static char OKqstatus[]   = "3000 OK .status\n";
+static char DotStatusJob[] = "JobId=%d JobStatus=%c JobErrors=%d\n";
 
 
 /* Forward referenced functions */
 static void send_blocked_status(JCR *jcr, DEVICE *dev);
 static void list_terminated_jobs(void *arg);
 static void list_running_jobs(BSOCK *user);
-static void sendit(char *msg, int len, void *arg);
-static char *level_to_str(int level);
+static void sendit(const char *msg, int len, void *arg);
+static const char *level_to_str(int level);
 
 
 /*
  * Status command from Director
  */
-int status_cmd(JCR *jcr)
+bool status_cmd(JCR *jcr)
 {
    DEVRES *device;
+   AUTOCHANGER *changer;
    DEVICE *dev;
    BSOCK *user = jcr->dir_bsock;
    char dt[MAX_TIME_LENGTH];
    char b1[30], b2[30], b3[30];
    int bpb;
 
-   bnet_fsend(user, "\n%s Version: " VERSION " (" BDATE ") %s %s %s\n", my_name,
-             HOST_OS, DISTNAME, DISTVER);
+   bnet_fsend(user, _("\n%s Version: %s (%s) %s %s %s\n"), my_name,
+              VERSION, BDATE, HOST_OS, DISTNAME, DISTVER);
    bstrftime_nc(dt, sizeof(dt), daemon_start_time);
-   bnet_fsend(user, _("Daemon started %s, %d Job%s run since started.\n"), dt, num_jobs_run,
-        num_jobs_run == 1 ? "" : "s");
+   if (num_jobs_run == 1) {
+      bnet_fsend(user, _("Daemon started %s, 1 Job run since started.\n"), dt);
+   }
+   else {
+      bnet_fsend(user, _("Daemon started %s, %d Jobs run since started.\n"), dt, num_jobs_run);
+   }
+   if (debug_level > 0) {
+      char b1[35], b2[35], b3[35], b4[35];
+      bnet_fsend(user, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"),
+            edit_uint64_with_commas(sm_bytes, b1),
+            edit_uint64_with_commas(sm_max_bytes, b2),
+            edit_uint64_with_commas(sm_buffers, b3),
+            edit_uint64_with_commas(sm_max_buffers, b4));
+   }
 
    /*
     * List running jobs
@@ -82,71 +95,95 @@ int status_cmd(JCR *jcr)
     * List devices
     */
    bnet_fsend(user, _("\nDevice status:\n"));
-   LockRes();
-   foreach_res(device, R_DEVICE) {
-      for (dev=device->dev; dev; dev=dev->next) {
-        if (dev_state(dev, ST_OPENED)) {
-           if (dev_state(dev, ST_LABEL)) {
-               bnet_fsend(user, _("Device \"%s\" is mounted with Volume \"%s\"\n"), 
-                 dev_name(dev), dev->VolHdr.VolName);
-           } else {
-               bnet_fsend(user, _("Device \"%s\" open but no Bacula volume is mounted.\n"), dev_name(dev));
-           }
-           send_blocked_status(jcr, dev);
-           if (dev_state(dev, ST_APPEND)) {
-              bpb = dev->VolCatInfo.VolCatBlocks;
-              if (bpb <= 0) {
-                 bpb = 1;
-              }
-              bpb = dev->VolCatInfo.VolCatBytes / bpb;
-               bnet_fsend(user, _("    Total Bytes=%s Blocks=%s Bytes/block=%s\n"),
-                 edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
-                 edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2), 
-                 edit_uint64_with_commas(bpb, b3));
-           } else {  /* reading */
-              bpb = dev->VolCatInfo.VolCatReads;
-              if (bpb <= 0) {
-                 bpb = 1;
-              }
-              if (dev->VolCatInfo.VolCatRBytes > 0) {
-                 bpb = dev->VolCatInfo.VolCatRBytes / bpb;
-              } else {
-                 bpb = 0;
-              }
-               bnet_fsend(user, _("    Total Bytes Read=%s Blocks Read=%s Bytes/block=%s\n"),
-                 edit_uint64_with_commas(dev->VolCatInfo.VolCatRBytes, b1),
-                 edit_uint64_with_commas(dev->VolCatInfo.VolCatReads, b2), 
-                 edit_uint64_with_commas(bpb, b3));
-           }
-            bnet_fsend(user, _("    Positioned at File=%s Block=%s\n"), 
-              edit_uint64_with_commas(dev->file, b1),
-              edit_uint64_with_commas(dev->block_num, b2));
-
-        } else {
-            bnet_fsend(user, _("Device \"%s\" is not open.\n"), dev_name(dev));
-           send_blocked_status(jcr, dev);
-        }
+   foreach_res(changer, R_AUTOCHANGER) {
+      bnet_fsend(user, _("Autochanger \"%s\" with devices:\n"),
+         changer->hdr.name);
+      foreach_alist(device, changer->device) {
+         if (device->dev) {
+            bnet_fsend(user, "   %s\n", device->dev->print_name());
+         } else {
+            bnet_fsend(user, "   %s\n", device->hdr.name);
+         }
       }
    }
-   UnlockRes();
-
+   foreach_res(device, R_DEVICE) {
+      dev = device->dev;
+      if (dev && dev->is_open()) {
+         if (dev->is_labeled()) {
+            bnet_fsend(user, _("Device %s is mounted with Volume=\"%s\" Pool=\"%s\"\n"),
+               dev->print_name(), dev->VolHdr.VolumeName, 
+               dev->pool_name[0]?dev->pool_name:"*unknown*");
+         } else {
+            bnet_fsend(user, _("Device %s open but no Bacula volume is mounted.\n"), 
+               dev->print_name());
+         }
+         send_blocked_status(jcr, dev);
+         if (dev->can_append()) {
+            bpb = dev->VolCatInfo.VolCatBlocks;
+            if (bpb <= 0) {
+               bpb = 1;
+            }
+            bpb = dev->VolCatInfo.VolCatBytes / bpb;
+            bnet_fsend(user, _("    Total Bytes=%s Blocks=%s Bytes/block=%s\n"),
+               edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
+               edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2),
+               edit_uint64_with_commas(bpb, b3));
+         } else {  /* reading */
+            bpb = dev->VolCatInfo.VolCatReads;
+            if (bpb <= 0) {
+               bpb = 1;
+            }
+            if (dev->VolCatInfo.VolCatRBytes > 0) {
+               bpb = dev->VolCatInfo.VolCatRBytes / bpb;
+            } else {
+               bpb = 0;
+            }
+            bnet_fsend(user, _("    Total Bytes Read=%s Blocks Read=%s Bytes/block=%s\n"),
+               edit_uint64_with_commas(dev->VolCatInfo.VolCatRBytes, b1),
+               edit_uint64_with_commas(dev->VolCatInfo.VolCatReads, b2),
+               edit_uint64_with_commas(bpb, b3));
+         }
+         bnet_fsend(user, _("    Positioned at File=%s Block=%s\n"),
+            edit_uint64_with_commas(dev->file, b1),
+            edit_uint64_with_commas(dev->block_num, b2));
 
-#ifdef xfull_status
-   bnet_fsend(user, "\n\n");
-   dump_resource(R_DEVICE, resources[R_DEVICE-r_first].res_head, sendit, user);
+      } else {
+         if (dev) {
+            bnet_fsend(user, _("Device %s is not open or does not exist.\n"), dev->print_name());
+         } else {
+            bnet_fsend(user, _("Device \"%s\" is not open or does not exist.\n"), device->hdr.name);
+         }
+         send_blocked_status(jcr, dev);
+      }
+   }
+   bnet_fsend(user, _("====\n\n"));
+   bnet_fsend(user, _("In Use Volume status:\n"));
+   list_volumes(user);
+   bnet_fsend(user, _("====\n\n"));
+       
+#ifdef xxx
+   if (debug_level > 10) {
+      bnet_fsend(user, _("====\n\n"));
+      dump_resource(R_DEVICE, resources[R_DEVICE-r_first].res_head, sendit, user);
+      bnet_fsend(user, _("====\n\n"));
+   }
 #endif
-   bnet_fsend(user, "====\n\n");
 
    list_spool_stats(user);
 
    bnet_sig(user, BNET_EOD);
-   return 1;
+   return true;
 }
 
-static void send_blocked_status(JCR *jcr, DEVICE *dev) 
+static void send_blocked_status(JCR *jcr, DEVICE *dev)
 {
    BSOCK *user = jcr->dir_bsock;
+   DCR *dcr = jcr->dcr;
 
+   if (!dev) {
+      bnet_fsend(user, _("No DEVICE structure.\n\n"));
+      return;
+   }
    switch (dev->dev_blocked) {
    case BST_UNMOUNTED:
       bnet_fsend(user, _("    Device is BLOCKED. User unmounted.\n"));
@@ -157,9 +194,9 @@ static void send_blocked_status(JCR *jcr, DEVICE *dev)
    case BST_WAITING_FOR_SYSOP:
       if (jcr->JobStatus == JS_WaitMount) {
          bnet_fsend(user, _("    Device is BLOCKED waiting for mount of volume \"%s\".\n"),
-           jcr->VolumeName);
+            dcr->VolumeName);
       } else {
-         bnet_fsend(user, _("    Device is BLOCKED waiting for appendable media.\n"));
+         bnet_fsend(user, _("    Device is BLOCKED waiting for media.\n"));
       }
       break;
    case BST_DOING_ACQUIRE:
@@ -171,6 +208,15 @@ static void send_blocked_status(JCR *jcr, DEVICE *dev)
    default:
       break;
    }
+   /* Send autochanger slot status */
+   if (dev->is_autochanger()) {
+      if (dev->Slot) {
+         bnet_fsend(user, _("    Slot %d is loaded in drive %d.\n"), 
+            dev->Slot, dev->drive_index);
+      } else {
+         bnet_fsend(user, _("    Drive %d is not loaded.\n"), dev->drive_index);
+      }
+   }
    if (debug_level > 1) {
       bnet_fsend(user, _("Configured device capabilities:\n"));
       bnet_fsend(user, "%sEOF ", dev->capabilities & CAP_EOF ? "" : "!");
@@ -187,24 +233,28 @@ static void send_blocked_status(JCR *jcr, DEVICE *dev)
       bnet_fsend(user, "%sALWAYSOPEN ", dev->capabilities & CAP_ALWAYSOPEN ? "" : "!");
       bnet_fsend(user, "\n");
 
-      bnet_fsend(user, _("Device status:\n"));
-      bnet_fsend(user, "%sOPENED ", dev->state & ST_OPENED ? "" : "!");
-      bnet_fsend(user, "%sTAPE ", dev->state & ST_TAPE ? "" : "!");
-      bnet_fsend(user, "%sLABEL ", dev->state & ST_LABEL ? "" : "!");
+      bnet_fsend(user, _("Device state:\n"));
+      bnet_fsend(user, "%sOPENED ", dev->is_open() ? "" : "!");
+      bnet_fsend(user, "%sTAPE ", dev->is_tape() ? "" : "!");
+      bnet_fsend(user, "%sLABEL ", dev->is_labeled() ? "" : "!");
       bnet_fsend(user, "%sMALLOC ", dev->state & ST_MALLOC ? "" : "!");
-      bnet_fsend(user, "%sAPPEND ", dev->state & ST_APPEND ? "" : "!");
-      bnet_fsend(user, "%sREAD ", dev->state & ST_READ ? "" : "!");
-      bnet_fsend(user, "%sEOT ", dev->state & ST_EOT ? "" : "!");
+      bnet_fsend(user, "%sAPPEND ", dev->can_append() ? "" : "!");
+      bnet_fsend(user, "%sREAD ", dev->can_read() ? "" : "!");
+      bnet_fsend(user, "%sEOT ", dev->at_eot() ? "" : "!");
       bnet_fsend(user, "%sWEOT ", dev->state & ST_WEOT ? "" : "!");
-      bnet_fsend(user, "%sEOF ", dev->state & ST_EOF ? "" : "!");
+      bnet_fsend(user, "%sEOF ", dev->at_eof() ? "" : "!");
       bnet_fsend(user, "%sNEXTVOL ", dev->state & ST_NEXTVOL ? "" : "!");
       bnet_fsend(user, "%sSHORT ", dev->state & ST_SHORT ? "" : "!");
+      bnet_fsend(user, "%sMOUNTED ", dev->state & ST_MOUNTED ? "" : "!");
       bnet_fsend(user, "\n");
+      bnet_fsend(user, _("num_writers=%d JobStatus=%c block=%d\n\n"), dev->num_writers,
+         jcr->JobStatus, dev->dev_blocked);
 
       bnet_fsend(user, _("Device parameters:\n"));
-      bnet_fsend(user, "Device name: %s\n", dev->dev_name);
-      bnet_fsend(user, "File=%u block=%u\n", dev->file, dev->block_num);
-      bnet_fsend(user, "Min block=%u Max block=%u\n", dev->min_block_size, dev->max_block_size);
+      bnet_fsend(user, _("Archive name: %s Device name: %s\n"), dev->archive_name(),
+         dev->name());
+      bnet_fsend(user, _("File=%u block=%u\n"), dev->file, dev->block_num);
+      bnet_fsend(user, _("Min block=%u Max block=%u\n"), dev->min_block_size, dev->max_block_size);
    }
 
 }
@@ -214,60 +264,79 @@ static void list_running_jobs(BSOCK *user)
    bool found = false;
    int bps, sec;
    JCR *jcr;
+   DCR *dcr, *rdcr;
    char JobName[MAX_NAME_LENGTH];
    char b1[30], b2[30], b3[30];
-   
+
    bnet_fsend(user, _("\nRunning Jobs:\n"));
-   lock_jcr_chain();
    foreach_jcr(jcr) {
       if (jcr->JobStatus == JS_WaitFD) {
          bnet_fsend(user, _("%s Job %s waiting for Client connection.\n"),
-           job_type_to_str(jcr->JobType), jcr->Job);
+            job_type_to_str(jcr->JobType), jcr->Job);
       }
-      if (jcr->device) {
-        bstrncpy(JobName, jcr->Job, sizeof(JobName));
-        /* There are three periods after the Job name */
-        char *p;
-        for (int i=0; i<3; i++) {
+      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;
-           }
-        }
-         bnet_fsend(user, _("%s %s job %s JobId=%d Volume=\"%s\" device=\"%s\"\n"), 
-                  job_level_to_str(jcr->JobLevel),
-                  job_type_to_str(jcr->JobType),
-                  JobName,
-                  jcr->JobId,
-                  jcr->VolumeName,
-                  jcr->device->device_name);
-        sec = time(NULL) - jcr->run_time;
-        if (sec <= 0) {
-           sec = 1;
-        }
-        bps = jcr->JobBytes / sec;
-         bnet_fsend(user, _("    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));
-        found = true;
+               *p = 0;
+            }
+         }
+         if (rdcr && rdcr->device) {
+            bnet_fsend(user, _("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);
+         }
+         if (dcr && dcr->device) {
+            bnet_fsend(user, _("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);
+         }
+         sec = time(NULL) - jcr->run_time;
+         if (sec <= 0) {
+            sec = 1;
+         }
+         bps = jcr->JobBytes / sec;
+         bnet_fsend(user, _("    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));
+         found = true;
 #ifdef DEBUG
-        if (jcr->file_bsock) {
-            bnet_fsend(user, "    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);
-        } else {
-            bnet_fsend(user, "    FDSocket closed\n");
-        }
+         if (jcr->file_bsock) {
+            bnet_fsend(user, _("    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);
+         } else {
+            bnet_fsend(user, _("    FDSocket closed\n"));
+         }
 #endif
       }
-      free_locked_jcr(jcr);
    }
-   unlock_jcr_chain();
+   endeach_jcr(jcr);
+
    if (!found) {
       bnet_fsend(user, _("No Jobs running.\n"));
    }
-   bnet_fsend(user, "====\n");
+   bnet_fsend(user, _("====\n"));
 }
 
 static void list_terminated_jobs(void *arg)
@@ -275,23 +344,23 @@ static void list_terminated_jobs(void *arg)
    char dt[MAX_TIME_LENGTH], b1[30], b2[30];
    char level[10];
    struct s_last_job *je;
-   char *msg;
+   const char *msg;
 
    if (last_jobs->size() == 0) {
-      msg = _("No Terminated Jobs.\n"); 
+      msg = _("No Terminated Jobs.\n");
       sendit(msg, strlen(msg), arg);
       return;
    }
    lock_last_jobs_list();
-   msg =  _("\nTerminated Jobs:\n"); 
+   msg =  _("\nTerminated Jobs:\n");
    sendit(msg, strlen(msg), arg);
    msg =  _(" JobId  Level   Files          Bytes Status   Finished        Name \n");
    sendit(msg, strlen(msg), arg);
-   msg = _("======================================================================\n"); 
+   msg = _("======================================================================\n");
    sendit(msg, strlen(msg), arg);
    foreach_dlist(je, last_jobs) {
       char JobName[MAX_NAME_LENGTH];
-      char *termstat;
+      const char *termstat;
       char buf[1000];
 
       bstrftime_nc(dt, sizeof(dt), je->end_time);
@@ -299,60 +368,60 @@ static void list_terminated_jobs(void *arg)
       case JT_ADMIN:
       case JT_RESTORE:
          bstrncpy(level, "    ", sizeof(level));
-        break;
+         break;
       default:
-        bstrncpy(level, level_to_str(je->JobLevel), sizeof(level));
-        level[4] = 0;
-        break;
+         bstrncpy(level, level_to_str(je->JobLevel), sizeof(level));
+         level[4] = 0;
+         break;
       }
       switch (je->JobStatus) {
       case JS_Created:
-         termstat = "Created";
-        break;
+         termstat = _("Created");
+         break;
       case JS_FatalError:
       case JS_ErrorTerminated:
-         termstat = "Error";
-        break;
+         termstat = _("Error");
+         break;
       case JS_Differences:
-         termstat = "Diffs";
-        break;
+         termstat = _("Diffs");
+         break;
       case JS_Canceled:
-         termstat = "Cancel";
-        break;
+         termstat = _("Cancel");
+         break;
       case JS_Terminated:
-         termstat = "OK";
-        break;
+         termstat = _("OK");
+         break;
       default:
-         termstat = "Other";
-        break;
+         termstat = _("Other");
+         break;
       }
       bstrncpy(JobName, je->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;
-        }
+            *p = 0;
+         }
       }
-      bsnprintf(buf, sizeof(buf), _("%6d  %-6s %8s %14s %-7s  %-8s %s\n"), 
-        je->JobId,
-        level, 
-        edit_uint64_with_commas(je->JobFiles, b1),
-        edit_uint64_with_commas(je->JobBytes, b2), 
-        termstat,
-        dt, JobName);
+      bsnprintf(buf, sizeof(buf), _("%6d  %-6s %8s %14s %-7s  %-8s %s\n"),
+         je->JobId,
+         level,
+         edit_uint64_with_commas(je->JobFiles, b1),
+         edit_uint64_with_commas(je->JobBytes, b2),
+         termstat,
+         dt, JobName);
       sendit(buf, strlen(buf), arg);
    }
-   sendit("====\n", 5, arg);
+   sendit(_("====\n"), 5, arg);
    unlock_last_jobs_list();
 }
 
 /*
  * Convert Job Level into a string
  */
-static char *level_to_str(int level) 
+static const char *level_to_str(int level)
 {
-   char *str;
+   const char *str;
 
    switch (level) {
    case L_BASE:
@@ -395,9 +464,9 @@ static char *level_to_str(int level)
 }
 
 /*
- * Send to Director 
+ * Send to Director
  */
-static void sendit(char *msg, int len, void *arg)
+static void sendit(const char *msg, int len, void *arg)
 {
    BSOCK *user = (BSOCK *)arg;
 
@@ -405,3 +474,47 @@ static void sendit(char *msg, int len, void *arg)
    user->msglen = len+1;
    bnet_send(user);
 }
+
+/*
+ * .status command from Director
+ */
+bool qstatus_cmd(JCR *jcr)
+{
+   BSOCK *dir = jcr->dir_bsock;
+   POOL_MEM time;
+   JCR *njcr;
+   s_last_job* job;
+
+   if (sscanf(dir->msg, qstatus, time.c_str()) != 1) {
+      pm_strcpy(jcr->errmsg, dir->msg);
+      Jmsg1(jcr, M_FATAL, 0, _("Bad .status command: %s\n"), jcr->errmsg);
+      bnet_fsend(dir, _("3900 Bad .status command, missing argument.\n"));
+      bnet_sig(dir, BNET_EOD);
+      return false;
+   }
+   unbash_spaces(time);
+
+   if (strcmp(time.c_str(), "current") == 0) {
+      bnet_fsend(dir, OKqstatus, time.c_str());
+      foreach_jcr(njcr) {
+         if (njcr->JobId != 0) {
+            bnet_fsend(dir, DotStatusJob, njcr->JobId, njcr->JobStatus, njcr->JobErrors);
+         }
+      }
+      endeach_jcr(njcr);
+   } else if (strcmp(time.c_str(), "last") == 0) {
+      bnet_fsend(dir, OKqstatus, time.c_str());
+      if ((last_jobs) && (last_jobs->size() > 0)) {
+         job = (s_last_job*)last_jobs->last();
+         bnet_fsend(dir, DotStatusJob, job->JobId, job->JobStatus, job->Errors);
+      }
+   } else {
+      pm_strcpy(jcr->errmsg, dir->msg);
+      Jmsg1(jcr, M_FATAL, 0, _("Bad .status command: %s\n"), jcr->errmsg);
+      bnet_fsend(dir, _("3900 Bad .status command, wrong argument.\n"));
+      bnet_sig(dir, BNET_EOD);
+      return false;
+   }
+   bnet_sig(dir, BNET_EOD);
+   return true;
+}