X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fdird%2Fua_status.c;h=b3c85c9d72e482fad31c48ec5295e809355cc9a7;hb=2d33910ffe9a56d8d74223733bb828c60282022b;hp=2e24753f34522d00ea099af9bf7bde66ff3f90d9;hpb=5de4a23f6776e64872856fb86b18062128c52a0f;p=bacula%2Fbacula diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 2e24753f34..b3c85c9d72 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -7,28 +7,37 @@ * Version $Id$ */ /* - Copyright (C) 2001-2005 Kern Sibbald + Bacula® - The Network Backup Solution - 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. + Copyright (C) 2001-2006 Free Software Foundation Europe e.V. - 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. + 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 ofJohn Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ #include "bacula.h" #include "dird.h" -extern char my_name[]; -extern time_t daemon_start_time; -extern int num_jobs_run; - static void list_scheduled_jobs(UAContext *ua); static void list_running_jobs(UAContext *ua); static void list_terminated_jobs(UAContext *ua); @@ -66,8 +75,8 @@ int qstatus_cmd(UAContext *ua, const char *cmd) bsendmsg(ua, DotStatusJob, edit_int64(njcr->JobId, ed1), njcr->JobStatus, njcr->JobErrors); } - free_jcr(njcr); } + endeach_jcr(njcr); } else if (strcasecmp(ua->argk[2], "last") == 0) { bsendmsg(ua, OKqstatus, ua->argk[2]); if ((last_jobs) && (last_jobs->size() > 0)) { @@ -98,14 +107,14 @@ int status_cmd(UAContext *ua, const char *cmd) Dmsg1(20, "status:%s:\n", cmd); for (i=1; iargc; i++) { - if (strcasecmp(ua->argk[i], N_("all")) == 0) { + if (strcasecmp(ua->argk[i], NT_("all")) == 0) { do_all_status(ua); return 1; - } else if (strcasecmp(ua->argk[i], N_("dir")) == 0 || - strcasecmp(ua->argk[i], N_("director")) == 0) { + } else if (strcasecmp(ua->argk[i], NT_("dir")) == 0 || + strcasecmp(ua->argk[i], NT_("director")) == 0) { do_director_status(ua); return 1; - } else if (strcasecmp(ua->argk[i], N_("client")) == 0) { + } else if (strcasecmp(ua->argk[i], NT_("client")) == 0) { client = get_client_resource(ua); if (client) { do_client_status(ua, client); @@ -124,10 +133,10 @@ int status_cmd(UAContext *ua, const char *cmd) char prmt[MAX_NAME_LENGTH]; start_prompt(ua, _("Status available for:\n")); - add_prompt(ua, N_("Director")); - add_prompt(ua, N_("Storage")); - add_prompt(ua, N_("Client")); - add_prompt(ua, N_("All")); + add_prompt(ua, NT_("Director")); + add_prompt(ua, NT_("Storage")); + add_prompt(ua, NT_("Client")); + add_prompt(ua, NT_("All")); Dmsg0(20, "do_prompt: select daemon\n"); if ((item=do_prompt(ua, "", _("Select daemon type for status"), prmt, sizeof(prmt))) < 0) { return 1; @@ -179,7 +188,7 @@ static void do_all_status(UAContext *ua) i = 0; foreach_res(store, R_STORAGE) { found = false; - if (!acl_access_ok(ua, Storage_ACL, store->hdr.name)) { + if (!acl_access_ok(ua, Storage_ACL, store->name())) { continue; } for (j=0; jhdr.name)) { + if (!acl_access_ok(ua, Client_ACL, client->name())) { continue; } for (j=0; j 0) { - char b1[35], b2[35], b3[35], b4[35]; - bsendmsg(ua, _(" Heap: bytes=%s max_bytes=%s bufs=%s max_bufs=%s\n"), + bsendmsg(ua, _(" 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 scheduled Jobs */ @@ -281,13 +289,13 @@ static void do_storage_status(UAContext *ua, STORE *store) { BSOCK *sd; - set_storage(ua->jcr, store); + set_wstorage(ua->jcr, store); /* Try connecting for up to 15 seconds */ bsendmsg(ua, _("Connecting to Storage daemon %s at %s:%d\n"), - store->hdr.name, store->address, store->SDport); + store->name(), store->address, store->SDport); if (!connect_to_storage_daemon(ua->jcr, 1, 15, 0)) { bsendmsg(ua, _("\nFailed to connect to Storage daemon %s.\n====\n"), - store->hdr.name); + store->name()); if (ua->jcr->store_bsock) { bnet_close(ua->jcr->store_bsock); ua->jcr->store_bsock = NULL; @@ -322,10 +330,10 @@ static void do_client_status(UAContext *ua, CLIENT *client) /* Try to connect for 15 seconds */ bsendmsg(ua, _("Connecting to Client %s at %s:%d\n"), - client->hdr.name, client->address, client->FDport); + client->name(), client->address, client->FDport); if (!connect_to_file_daemon(ua->jcr, 1, 15, 0)) { bsendmsg(ua, _("Failed to connect to Client %s.\n====\n"), - client->hdr.name); + client->name()); if (ua->jcr->file_bsock) { bnet_close(ua->jcr->file_bsock); ua->jcr->file_bsock = NULL; @@ -360,6 +368,7 @@ struct sched_pkt { int priority; time_t runtime; POOL *pool; + STORE *store; }; static void prt_runtime(UAContext *ua, sched_pkt *sp) @@ -379,8 +388,10 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp) close_db = true; /* new db opened, remember to close it */ } if (ok) { - mr.PoolId = jcr->PoolId; - ok = find_next_volume_for_append(jcr, &mr, 0); + mr.PoolId = jcr->jr.PoolId; + mr.StorageId = sp->store->StorageId; + jcr->wstore = sp->store; + ok = find_next_volume_for_append(jcr, &mr, 1, false/*no create*/); } if (!ok) { bstrncpy(mr.VolumeName, "*unknown*", sizeof(mr.VolumeName)); @@ -398,12 +409,11 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp) } bsendmsg(ua, _("%-14s %-8s %3d %-18s %-18s %s\n"), level_ptr, job_type_to_str(sp->job->JobType), sp->priority, dt, - sp->job->hdr.name, mr.VolumeName); + sp->job->name(), mr.VolumeName); if (close_db) { db_close_database(jcr, jcr->db); } jcr->db = ua->db; /* restore ua db to jcr */ - } /* @@ -435,21 +445,33 @@ static void list_scheduled_jobs(UAContext *ua) time_t runtime; RUN *run; JOB *job; + STORE* store; int level, num_jobs = 0; int priority; bool hdr_printed = false; dlist sched; sched_pkt *sp; + int days, i; Dmsg0(200, "enter list_sched_jobs()\n"); + days = 1; + i = find_arg_with_value(ua, NT_("days")); + if (i >= 0) { + days = atoi(ua->argv[i]); + if ((days < 0) || (days > 50)) { + bsendmsg(ua, _("Ignoring illegal value for days.\n")); + days = 1; + } + } + /* Loop through all jobs */ LockRes(); foreach_res(job, R_JOB) { - if (!acl_access_ok(ua, Job_ACL, job->hdr.name)) { + if (!acl_access_ok(ua, Job_ACL, job->name()) || !job->enabled) { continue; } - for (run=NULL; (run = find_next_run(run, job, runtime)); ) { + for (run=NULL; (run = find_next_run(run, job, runtime, days)); ) { level = job->JobLevel; if (run->level) { level = run->level; @@ -458,6 +480,11 @@ static void list_scheduled_jobs(UAContext *ua) if (run->Priority) { priority = run->Priority; } + if (run->storage) { + store = run->storage; + } else { + store = (STORE *)job->storage->first(); + } if (!hdr_printed) { prt_runhdr(ua); hdr_printed = true; @@ -468,6 +495,7 @@ static void list_scheduled_jobs(UAContext *ua) sp->priority = priority; sp->runtime = runtime; sp->pool = run->pool; + sp->store = store; sched.binary_insert_multiple(sp, my_compare); num_jobs++; } @@ -496,7 +524,6 @@ static void list_running_jobs(UAContext *ua) Dmsg0(200, "enter list_run_jobs()\n"); bsendmsg(ua, _("\nRunning Jobs:\n")); foreach_jcr(jcr) { - njobs++; if (jcr->JobId == 0) { /* this is us */ /* this is a console or other control job. We only show console * jobs in the status output. @@ -505,10 +532,12 @@ static void list_running_jobs(UAContext *ua) bstrftime_nc(dt, sizeof(dt), jcr->start_time); bsendmsg(ua, _("Console connected at %s\n"), dt); } - njobs--; - } - free_jcr(jcr); + continue; + } + njobs++; } + endeach_jcr(jcr); + if (njobs == 0) { /* Note the following message is used in regress -- don't change */ bsendmsg(ua, _("No Jobs running.\n====\n")); @@ -519,8 +548,7 @@ static void list_running_jobs(UAContext *ua) bsendmsg(ua, _(" JobId Level Name Status\n")); bsendmsg(ua, _("======================================================================\n")); foreach_jcr(jcr) { - if (jcr->JobId == 0 || !acl_access_ok(ua, Job_ACL, jcr->job->hdr.name)) { - free_jcr(jcr); + if (jcr->JobId == 0 || !acl_access_ok(ua, Job_ACL, jcr->job->name())) { continue; } njobs++; @@ -554,13 +582,17 @@ 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->hdr.name); + Mmsg(emsg, _("is waiting on Client %s"), jcr->client->name()); pool_mem = true; msg = emsg; break; case JS_WaitSD: emsg = (char *) get_pool_memory(PM_FNAME); - Mmsg(emsg, _("is waiting on Storage %s"), jcr->store->hdr.name); + if (jcr->wstore) { + Mmsg(emsg, _("is waiting on Storage %s"), jcr->wstore->name()); + } else { + Mmsg(emsg, _("is waiting on Storage %s"), jcr->rstore->name()); + } pool_mem = true; msg = emsg; break; @@ -614,7 +646,7 @@ static void list_running_jobs(UAContext *ua) pool_mem = true; } Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"), - jcr->client->hdr.name, jcr->store->hdr.name); + jcr->client->name(), jcr->wstore->name()); msg = emsg; break; } @@ -639,8 +671,8 @@ static void list_running_jobs(UAContext *ua) free_pool_memory(emsg); pool_mem = false; } - free_jcr(jcr); } + endeach_jcr(jcr); bsendmsg(ua, _("====\n")); Dmsg0(200, "leave list_run_jobs()\n"); } @@ -657,8 +689,8 @@ static void list_terminated_jobs(UAContext *ua) lock_last_jobs_list(); struct s_last_job *je; bsendmsg(ua, _("\nTerminated Jobs:\n")); - bsendmsg(ua, _(" JobId Level Files Bytes Status Finished Name \n")); - bsendmsg(ua, _("========================================================================\n")); + bsendmsg(ua, _(" JobId Level Files Bytes Status Finished Name \n")); + bsendmsg(ua, _("====================================================================\n")); foreach_dlist(je, last_jobs) { char JobName[MAX_NAME_LENGTH]; const char *termstat; @@ -708,11 +740,11 @@ static void list_terminated_jobs(UAContext *ua) termstat = _("Other"); break; } - bsendmsg(ua, _("%6d %-6s %8s %14s %-7s %-8s %s\n"), + bsendmsg(ua, _("%6d %-6s %8s %10s %-7s %-8s %s\n"), je->JobId, level, edit_uint64_with_commas(je->JobFiles, b1), - edit_uint64_with_commas(je->JobBytes, b2), + edit_uint64_with_suffix(je->JobBytes, b2), termstat, dt, JobName); }