]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_status.c
Prevent connecting with the Console::m_at_main_prompt member.
[bacula/bacula] / bacula / src / dird / ua_status.c
index 6cf7e3e8ac6ea3443758ab00f28d89eba9d5f43d..cf8e2fb95f9e2c893780d7e726dd61e8ee3e0c3d 100644 (file)
@@ -38,6 +38,8 @@
 #include "bacula.h"
 #include "dird.h"
 
+extern void *start_heap;
+
 static void list_scheduled_jobs(UAContext *ua);
 static void list_running_jobs(UAContext *ua);
 static void list_terminated_jobs(UAContext *ua);
@@ -253,10 +255,10 @@ static void do_all_status(UAContext *ua)
 
 }
 
-static void do_director_status(UAContext *ua)
+void list_dir_status_header(UAContext *ua)
 {
    char dt[MAX_TIME_LENGTH];
-   char b1[35], b2[35], b3[35], b4[35];
+   char b1[35], b2[35], b3[35], b4[35], b5[35];
 
    ua->send_msg(_("%s Version: %s (%s) %s %s %s\n"), my_name, VERSION, BDATE,
             HOST_OS, DISTNAME, DISTVER);
@@ -268,11 +270,17 @@ static void do_director_status(UAContext *ua)
       ua->send_msg(_("Daemon started %s, %d Jobs run since started.\n"),
         dt, num_jobs_run);
    }
-   ua->send_msg(_(" 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));
+   ua->send_msg(_(" Heap: heap=%s smbytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"),
+            edit_uint64_with_commas((char *)sbrk(0)-(char *)start_heap, b1),
+            edit_uint64_with_commas(sm_bytes, b2),
+            edit_uint64_with_commas(sm_max_bytes, b3),
+            edit_uint64_with_commas(sm_buffers, b4),
+            edit_uint64_with_commas(sm_max_buffers, b5));
+}
+
+static void do_director_status(UAContext *ua)
+{
+   list_dir_status_header(ua);
 
    /*
     * List scheduled Jobs
@@ -590,7 +598,11 @@ static void list_running_jobs(UAContext *ua)
          break;
       case JS_WaitFD:
          emsg = (char *) get_pool_memory(PM_FNAME);
-         Mmsg(emsg, _("is waiting on Client %s"), jcr->client->name());
+         if (!jcr->client) {
+            Mmsg(emsg, _("is waiting on Client"));
+         } else {
+            Mmsg(emsg, _("is waiting on Client %s"), jcr->client->name());
+         }
          pool_mem = true;
          msg = emsg;
          break;
@@ -598,8 +610,10 @@ static void list_running_jobs(UAContext *ua)
          emsg = (char *) get_pool_memory(PM_FNAME);
          if (jcr->wstore) {
             Mmsg(emsg, _("is waiting on Storage %s"), jcr->wstore->name());
-         } else {
+         } else if (jcr->rstore) {
             Mmsg(emsg, _("is waiting on Storage %s"), jcr->rstore->name());
+         } else {
+            Mmsg(emsg, _("is waiting on Storage"));
          }
          pool_mem = true;
          msg = emsg;
@@ -624,7 +638,7 @@ static void list_running_jobs(UAContext *ua)
          break;
 
       default:
-         emsg = (char *) get_pool_memory(PM_FNAME);
+         emsg = (char *)get_pool_memory(PM_FNAME);
          Mmsg(emsg, _("is in unknown state %c"), jcr->JobStatus);
          pool_mem = true;
          msg = emsg;
@@ -653,8 +667,12 @@ static void list_running_jobs(UAContext *ua)
             emsg = (char *)get_pool_memory(PM_FNAME);
             pool_mem = true;
          }
-         Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"),
-              jcr->client->name(), jcr->wstore->name());
+         if (!jcr->client || !jcr->wstore) {
+            Mmsg(emsg, _("is waiting for Client to connect to Storage daemon"));
+         } else {
+            Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"),
+                 jcr->client->name(), jcr->wstore->name());
+        }
          msg = emsg;
          break;
       }