Пример #1
0
/*
 * !!! WARNING !!!
 *
 * This function should be used ONLY after a fatal signal. We walk through the
 * JCR chain without doing any lock, BAREOS should not be running.
 */
void dbg_print_jcr(FILE *fp)
{
    char buf1[128], buf2[128], buf3[128], buf4[128];
    if (!jcrs) {
        return;
    }

    fprintf(fp, "Attempt to dump current JCRs. njcrs=%d\n", jcrs->size());

    for (JCR *jcr = (JCR *)jcrs->first(); jcr ; jcr = (JCR *)jcrs->next(jcr)) {
#ifdef HAVE_WIN32
        fprintf(fp, "threadid=%p JobId=%d JobStatus=%c jcr=%p name=%s\n",
                (void *)&jcr->my_thread_id, (int)jcr->JobId,
                jcr->JobStatus, jcr, jcr->Job);
        fprintf(fp, "threadid=%p killable=%d JobId=%d JobStatus=%c "
                "jcr=%p name=%s\n",
                (void *)&jcr->my_thread_id, jcr->is_killable(),
                (int)jcr->JobId, jcr->JobStatus, jcr, jcr->Job);
#else
        fprintf(fp, "threadid=%p JobId=%d JobStatus=%c jcr=%p name=%s\n",
                (void *)jcr->my_thread_id, (int)jcr->JobId,
                jcr->JobStatus, jcr, jcr->Job);
        fprintf(fp, "threadid=%p killable=%d JobId=%d JobStatus=%c "
                "jcr=%p name=%s\n",
                (void *)jcr->my_thread_id, jcr->is_killable(),
                (int)jcr->JobId, jcr->JobStatus, jcr, jcr->Job);
#endif
        fprintf(fp, "\tuse_count=%i\n", jcr->use_count());
        fprintf(fp, "\tJobType=%c JobLevel=%c\n",
                jcr->getJobType(), jcr->getJobLevel());
        bstrftime(buf1, sizeof(buf1), jcr->sched_time);
        bstrftime(buf2, sizeof(buf2), jcr->start_time);
        bstrftime(buf3, sizeof(buf3), jcr->end_time);
        bstrftime(buf4, sizeof(buf4), jcr->wait_time);
        fprintf(fp, "\tsched_time=%s start_time=%s\n\tend_time=%s wait_time=%s\n",
                buf1, buf2, buf3, buf4);
        fprintf(fp, "\tdb=%p db_batch=%p batch_started=%i\n",
                jcr->db, jcr->db_batch, jcr->batch_started);

        /*
         * Call all the jcr debug hooks
         */
        for(int i=0; i < dbg_jcr_handler_count; i++) {
            dbg_jcr_hook_t *hook = dbg_jcr_hooks[i];
            hook(jcr, fp);
        }
    }
}
Пример #2
0
/*
 * !!! WARNING !!! 
 *
 * This function should be used ONLY after a fatal signal. We walk through the
 * JCR chain without doing any lock, bacula should not be running.
 */
void _dbg_print_jcr(FILE *fp)
{
   char buf1[128], buf2[128], buf3[128], buf4[128];
   if (!jcrs) {
      return;
   }

   fprintf(fp, "Attempt to dump current JCRs\n");

   for (JCR *jcr = (JCR *)jcrs->first(); jcr ; jcr = (JCR *)jcrs->next(jcr)) {
      if (!jcr) {               /* protect us against something ? */
         continue;
      }
      
      fprintf(fp, "JCR=%p JobId=%i name=%s JobStatus=%c\n", 
              jcr, jcr->JobId, jcr->Job, jcr->JobStatus);
#ifdef HAVE_WIN32
      fprintf(fp, "\tuse_count=%i\n",
              jcr->use_count());
#else
      fprintf(fp, "\tuse_count=%i threadid=0x%x\n",
              jcr->use_count(), (int)jcr->my_thread_id);
#endif
      fprintf(fp, "\tJobType=%c JobLevel=%c\n",
              jcr->get_JobType(), jcr->get_JobLevel());
      bstrftime(buf1, sizeof(buf1), jcr->sched_time);
      bstrftime(buf2, sizeof(buf2), jcr->start_time);
      bstrftime(buf3, sizeof(buf3), jcr->end_time);
      bstrftime(buf4, sizeof(buf4), jcr->wait_time);
      fprintf(fp, "\tsched_time=%s start_time=%s\n\tend_time=%s wait_time=%s\n",
              buf1, buf2, buf3, buf4);
      fprintf(fp, "\tdequeing=%i\n", jcr->dequeuing);
      fprintf(fp, "\tdb=%p db_batch=%p batch_started=%i\n", 
              jcr->db, jcr->db_batch, jcr->batch_started);
      
      for(int i=0; i < dbg_jcr_handler_count; i++) {
         dbg_jcr_hook_t *fct = dbg_jcr_hooks[i];
         fct(jcr, fp);
      }
   }
}
Пример #3
0
/*
 * Formatted time for user display: dd-Mon-yy hh:mm (no century)
 */
char *bstrftime_nc(char *dt, int maxlen, utime_t utime)
{
   char *p, *q;

   /*
    * NOTE! since the compiler complains about %y, I use %Y and cut the century
    */
   bstrftime(dt, maxlen, utime, "%d-%b-%Y %H:%M");

   /*
    * Overlay the century
    */
   p = dt+7;
   q = dt+9;
   while (*q) {
      *p++ = *q++;
   }
   *p = 0;
   return dt;
}
Пример #4
0
static void dump_session_label(DEV_RECORD *rec, const char *type)
{
   int dbl;
   struct date_time dt;
   struct tm tm;
   SESSION_LABEL label;
   char ec1[30], ec2[30], ec3[30], ec4[30], ec5[30], ec6[30], ec7[30];

   unser_session_label(&label, rec);
   dbl = debug_level;
   debug_level = 1;
   Pmsg7(-1, _("\n%s Record:\n"
"JobId             : %d\n"
"VerNum            : %d\n"
"PoolName          : %s\n"
"PoolType          : %s\n"
"JobName           : %s\n"
"ClientName        : %s\n"
""),    type, label.JobId, label.VerNum,
      label.PoolName, label.PoolType,
      label.JobName, label.ClientName);

   if (label.VerNum >= 10) {
      Pmsg4(-1, _(
"Job (unique name) : %s\n"
"FileSet           : %s\n"
"JobType           : %c\n"
"JobLevel          : %c\n"
""), label.Job, label.FileSetName, label.JobType, label.JobLevel);
   }

   if (rec->FileIndex == EOS_LABEL) {
      Pmsg8(-1, _(
"JobFiles          : %s\n"
"JobBytes          : %s\n"
"StartBlock        : %s\n"
"EndBlock          : %s\n"
"StartFile         : %s\n"
"EndFile           : %s\n"
"JobErrors         : %s\n"
"JobStatus         : %c\n"
""),
         edit_uint64_with_commas(label.JobFiles, ec1),
         edit_uint64_with_commas(label.JobBytes, ec2),
         edit_uint64_with_commas(label.StartBlock, ec3),
         edit_uint64_with_commas(label.EndBlock, ec4),
         edit_uint64_with_commas(label.StartFile, ec5),
         edit_uint64_with_commas(label.EndFile, ec6),
         edit_uint64_with_commas(label.JobErrors, ec7),
         label.JobStatus);
   }
   if (label.VerNum >= 11) {
      char dt[50];
      bstrftime(dt, sizeof(dt), btime_to_utime(label.write_btime));
      Pmsg1(-1, _("Date written      : %s\n"), dt);
   } else {
      dt.julian_day_number   = label.write_date;
      dt.julian_day_fraction = label.write_time;
      tm_decode(&dt, &tm);
      Pmsg5(-1, _("Date written      : %04d-%02d-%02d at %02d:%02d\n"),
      tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min);
   }

   debug_level = dbl;
}
Пример #5
0
void dump_volume_label(DEVICE *dev)
{
   int dbl = debug_level;
   uint32_t File;
   const char *LabelType;
   char buf[30];
   struct tm tm;
   struct date_time dt;

   debug_level = 1;
   File = dev->file;
   switch (dev->VolHdr.LabelType) {
   case PRE_LABEL:
      LabelType = "PRE_LABEL";
      break;
   case VOL_LABEL:
      LabelType = "VOL_LABEL";
      break;
   case EOM_LABEL:
      LabelType = "EOM_LABEL";
      break;
   case SOS_LABEL:
      LabelType = "SOS_LABEL";
      break;
   case EOS_LABEL:
      LabelType = "EOS_LABEL";
      break;
   case EOT_LABEL:
      goto bail_out;
   default:
      LabelType = buf;
      sprintf(buf, _("Unknown %d"), dev->VolHdr.LabelType);
      break;
   }

   Pmsg11(-1, _("\nVolume Label:\n"
"Id                : %s"
"VerNo             : %d\n"
"VolName           : %s\n"
"PrevVolName       : %s\n"
"VolFile           : %d\n"
"LabelType         : %s\n"
"LabelSize         : %d\n"
"PoolName          : %s\n"
"MediaType         : %s\n"
"PoolType          : %s\n"
"HostName          : %s\n"
""),
             dev->VolHdr.Id, dev->VolHdr.VerNum,
             dev->VolHdr.VolumeName, dev->VolHdr.PrevVolumeName,
             File, LabelType, dev->VolHdr.LabelSize,
             dev->VolHdr.PoolName, dev->VolHdr.MediaType,
             dev->VolHdr.PoolType, dev->VolHdr.HostName);

   if (dev->VolHdr.VerNum >= 11) {
      char dt[50];
      bstrftime(dt, sizeof(dt), btime_to_utime(dev->VolHdr.label_btime));
      Pmsg1(-1, _("Date label written: %s\n"), dt);
   } else {
      dt.julian_day_number   = dev->VolHdr.label_date;
      dt.julian_day_fraction = dev->VolHdr.label_time;
      tm_decode(&dt, &tm);
      Pmsg5(-1,
            _("Date label written: %04d-%02d-%02d at %02d:%02d\n"),
              tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min);
   }

bail_out:
   debug_level = dbl;
}
Пример #6
0
/*
 * Formatted time for user display with weekday: weekday dd-Mon hh:mm
 */
char *bstrftime_wd(char *dt, int maxlen, utime_t utime)
{
   return bstrftime(dt, maxlen, utime, "%a %d-%b-%Y %H:%M");
}
Пример #7
0
/*
 * Formatted time for user display: dd-Mon hh:mm
 */
char *bstrftime_ny(char *dt, int maxlen, utime_t utime)
{
   return bstrftime(dt, maxlen, utime, "%d-%b %H:%M");
}
Пример #8
0
/*
 * Formatted time for user display: dd-Mon-yyyy hh:mm:ss
 */
char *bstrftimes(char *dt, int maxlen, utime_t utime)
{
   return bstrftime(dt, maxlen, utime, "%d-%b-%Y %H:%M:%S");
}
Пример #9
0
/*
 * Unix time to standard time string yyyy-mm-dd hh:mm:ss
 */
char *bstrutime(char *dt, int maxlen, utime_t utime)
{
   return bstrftime(dt, maxlen, utime, "%Y-%m-%d %H:%M:%S");
}