]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/status.c
Extend idea of Prefer Mounted Volumes to mean a volume about
[bacula/bacula] / bacula / src / stored / status.c
index db3a2c4c5eb250a932551a6342f7c8a6164a7b8c..091cb6278fcb217a4641888c9eda4214989828d8 100644 (file)
@@ -1,3 +1,30 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
+
+   The main author of Bacula is Kern Sibbald, with contributions from
+   many others, a complete list can be found in the file AUTHORS.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation plus additions
+   that are listed in the file LICENSE.
+
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 /*
  *  This file handles the status command
  *
@@ -6,20 +33,6 @@
  *   Version $Id$
  *
  */
-/*
-   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
-   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 
-   the file LICENSE for additional details.
-
- */
 
 #include "bacula.h"
 #include "stored.h"
@@ -43,16 +56,13 @@ static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int le
 static void list_terminated_jobs(void sendit(const char *msg, int len, void *sarg), void *arg);
 static void list_running_jobs(void sendit(const char *msg, int len, void *sarg), void *arg);
 static void list_jobs_waiting_on_reservation(void sendit(const char *msg, int len, void *sarg), void *arg);
-#if defined(HAVE_WIN32)
-static void win32_sendit(const char *msg, int len, void *arg);
-#endif
 
 static const char *level_to_str(int level);
 
 /*
  * Status command from Director
  */
-bool do_status(void sendit(const char *msg, int len, void *sarg), void *arg)
+void output_status(void sendit(const char *msg, int len, void *sarg), void *arg)
 {
    DEVRES *device;
    AUTOCHANGER *changer;
@@ -127,7 +137,7 @@ bool do_status(void sendit(const char *msg, int len, void *sarg), void *arg)
                dev->pool_name[0]?dev->pool_name:"*unknown*");
             sendit(msg, len, arg);
          } else {
-            len = Mmsg(msg, _("Device %s open but no Bacula volume is mounted.\n"), 
+            len = Mmsg(msg, _("Device %s open but no Bacula volume is currently mounted.\n"), 
                dev->print_name());
             sendit(msg, len, arg);
          }
@@ -168,21 +178,19 @@ bool do_status(void sendit(const char *msg, int len, void *sarg), void *arg)
          if (dev) {
             len = Mmsg(msg, _("Device %s is not open.\n"), dev->print_name());
             sendit(msg, len, arg);
+            send_blocked_status(dev, sendit, arg);
         } else {
             len = Mmsg(msg, _("Device \"%s\" is not open or does not exist.\n"), device->hdr.name);
             sendit(msg, len, arg);
          }
-         send_blocked_status(dev, sendit, arg);
       }
    }
-   len = Mmsg(msg, _("====\n\n"));
-   sendit(msg, len, arg);
+   sendit("====\n\n", 6, arg);
    len = Mmsg(msg, _("In Use Volume status:\n"));
    sendit(msg, len, arg);
    list_volumes(sendit, arg);
-   len = Mmsg(msg, _("====\n\n"));
-   sendit(msg, len, arg);
-       
+   sendit("====\n\n", 6, arg);
+
 #ifdef xxx
    if (debug_level > 10) {
       bnet_fsend(user, _("====\n\n"));
@@ -194,7 +202,6 @@ bool do_status(void sendit(const char *msg, int len, void *sarg), void *arg)
    list_spool_stats(sendit, arg);
 
    free_pool_memory(msg);
-   return true;
 }
 
 static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int len, void *sarg), void *arg)
@@ -210,7 +217,7 @@ static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int le
       free_pool_memory(msg);
       return;
    }
-   switch (dev->dev_blocked) {
+   switch (dev->blocked()) {
    case BST_UNMOUNTED:
       len = Mmsg(msg, _("    Device is BLOCKED. User unmounted.\n"));
       sendit(msg, len, arg);
@@ -305,7 +312,7 @@ static void send_blocked_status(DEVICE *dev, void sendit(const char *msg, int le
          dev->state & ST_MOUNTED ? "" : "!");
       sendit(msg, len, arg);
 
-      len = Mmsg(msg, _("num_writers=%d block=%d\n\n"), dev->num_writers, dev->dev_blocked);
+      len = Mmsg(msg, _("num_writers=%d block=%d\n\n"), dev->num_writers, dev->blocked());
       sendit(msg, len, arg);
 
       len = Mmsg(msg, _("Device parameters:\n"));
@@ -359,7 +366,7 @@ static void list_running_jobs(void sendit(const char *msg, int len, void *sarg),
          }
          if (rdcr && rdcr->device) {
             len = Mmsg(msg, _("Reading: %s %s job %s JobId=%d Volume=\"%s\"\n"
-                            "    pool=\"%s\" device=\"%s\"\n"),
+                            "    pool=\"%s\" device=%s\n"),
                    job_level_to_str(jcr->JobLevel),
                    job_type_to_str(jcr->JobType),
                    JobName,
@@ -372,7 +379,7 @@ static void list_running_jobs(void sendit(const char *msg, int len, void *sarg),
          }
          if (dcr && dcr->device) {
             len = Mmsg(msg, _("Writing: %s %s job %s JobId=%d Volume=\"%s\"\n"
-                            "    pool=\"%s\" device=\"%s\"\n"),
+                            "    pool=\"%s\" device=%s\n"),
                    job_level_to_str(jcr->JobLevel),
                    job_type_to_str(jcr->JobType),
                    JobName,
@@ -382,6 +389,9 @@ static void list_running_jobs(void sendit(const char *msg, int len, void *sarg),
                    dcr->dev?dcr->dev->print_name(): 
                             dcr->device->device_name);
             sendit(msg, len, arg);
+            len= Mmsg(msg, _("    spooling=%d despooling=%d despool_wait=%d\n"),
+                   dcr->spooling, dcr->despooling, dcr->despool_wait);
+            sendit(msg, len, arg);
          }
          sec = time(NULL) - jcr->run_time;
          if (sec <= 0) {
@@ -414,8 +424,7 @@ static void list_running_jobs(void sendit(const char *msg, int len, void *sarg),
       len = Mmsg(msg, _("No Jobs running.\n"));
       sendit(msg, len, arg);
    }
-   len = Mmsg(msg, _("====\n"));
-   sendit(msg, len, arg);
+   sendit("====\n", 5, arg);
 
    free_pool_memory(msg);
 }
@@ -436,8 +445,7 @@ static void list_jobs_waiting_on_reservation(void sendit(const char *msg, int le
    }
    endeach_jcr(jcr);
 
-   msg = _("====\n");
-   sendit(msg, strlen(msg), arg);
+   sendit("====\n", 5, arg);
 }
 
 
@@ -448,14 +456,13 @@ static void list_terminated_jobs(void sendit(const char *msg, int len, void *sar
    struct s_last_job *je;
    const char *msg;
 
+   msg =  _("\nTerminated Jobs:\n");
+   sendit(msg, strlen(msg), arg);
    if (last_jobs->size() == 0) {
-      msg = _("No Terminated Jobs.\n");
-      sendit(msg, strlen(msg), arg);
+      sendit("====\n", 5, arg);
       return;
    }
    lock_last_jobs_list();
-   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");
@@ -514,8 +521,8 @@ static void list_terminated_jobs(void sendit(const char *msg, int len, void *sar
          dt, JobName);
       sendit(buf, strlen(buf), arg);
    }
-   sendit(_("====\n"), 5, arg);
    unlock_last_jobs_list();
+   sendit("====\n", 5, arg);
 }
 
 /*
@@ -585,7 +592,7 @@ bool status_cmd(JCR *jcr)
    BSOCK *user = jcr->dir_bsock;
 
    bnet_fsend(user, "\n");
-   do_status(bsock_sendit, (void *)user);
+   output_status(bsock_sendit, (void *)user);
 
    bnet_sig(user, BNET_EOD);
    return 1;
@@ -638,46 +645,10 @@ bool qstatus_cmd(JCR *jcr)
 #if defined(HAVE_WIN32)
 int bacstat = 0;
 
-struct s_win32_arg {
-   HWND hwnd;
-   int idlist;
-};
-
-/*
- * Put message in Window List Box
- */
-static void win32_sendit(const char *msg, int len, void *marg)
-{
-   struct s_win32_arg *arg = (struct s_win32_arg *)marg;
-
-   if (len > 0 && msg[len-1] == '\n') {
-       // when compiling with visual studio some strings are read-only
-       // and cause access violations.  So we creat a tmp copy.
-       char *_msg = (char *)alloca(len);
-       bstrncpy(_msg, msg, len);
-       msg = _msg;
-   }
-   SendDlgItemMessage(arg->hwnd, arg->idlist, LB_ADDSTRING, 0, (LONG)msg);
-
-}
-
-void FillStatusBox(HWND hwnd, int idlist)
-{
-   struct s_win32_arg arg;
-
-   arg.hwnd = hwnd;
-   arg.idlist = idlist;
-
-   /* Empty box */
-   for ( ; SendDlgItemMessage(hwnd, idlist, LB_DELETESTRING, 0, (LONG)0) > 0; )
-      { }
-   do_status(win32_sendit, (void *)&arg);
-}
-
 char *bac_status(char *buf, int buf_len)
 {
    JCR *njcr;
-   const char *termstat = _("Bacula Idle");
+   const char *termstat = _("Bacula Storage: Idle");
    struct s_last_job *job;
    int stat = 0;                      /* Idle */
 
@@ -688,7 +659,7 @@ char *bac_status(char *buf, int buf_len)
    foreach_jcr(njcr) {
       if (njcr->JobId != 0) {
          stat = JS_Running;
-         termstat = _("Bacula Running");
+         termstat = _("Bacula Storage: Running");
          break;
       }
    }
@@ -702,15 +673,15 @@ char *bac_status(char *buf, int buf_len)
       stat = job->JobStatus;
       switch (job->JobStatus) {
       case JS_Canceled:
-         termstat = _("Last Job Canceled");
+         termstat = _("Bacula Storage: Last Job Canceled");
          break;
       case JS_ErrorTerminated:
       case JS_FatalError:
-         termstat = _("Last Job Failed");
+         termstat = _("Bacula Storage: Last Job Failed");
          break;
       default:
          if (job->Errors) {
-            termstat = _("Last Job had Warnings");
+            termstat = _("Bacula Storage: Last Job had Warnings");
          }
          break;
       }