⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reporter.c

📁 开源备份软件源码 AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is a backup system that a
💻 C
📖 第 1 页 / 共 5 页
字号:
	}    }    tp = lookup_last_reusable_tape(skip);    run_tapes = getconf_int(CNF_RUNTAPES);    if (run_tapes == 1)	fputs(_("The next tape Amanda expects to use is: "), mailf);    else if(run_tapes > 1)	g_fprintf(mailf, _("The next %d tapes Amanda expects to use are: "),		run_tapes);        while(run_tapes > 0) {	if(tp != NULL) {	    g_fprintf(mailf, "%s", tp->label);	} else {	    if (run_tapes == 1)		g_fprintf(mailf, _("a new tape"));	    else		g_fprintf(mailf, _("%d new tapes"), run_tapes);	    run_tapes = 1;	}	if(run_tapes > 1) fputs(", ", mailf);	run_tapes -= 1;	skip++;	tp = lookup_last_reusable_tape(skip);    }    fputs(".\n", mailf);    lasttp = lookup_tapepos(lookup_nb_tape());    run_tapes = getconf_int(CNF_RUNTAPES);    if(lasttp && run_tapes > 0 && strcmp(lasttp->datestamp,"0") == 0) {	int c = 0;	while(lasttp && run_tapes > 0 && strcmp(lasttp->datestamp,"0") == 0) {	    c++;	    lasttp = lasttp->prev;	    run_tapes--;	}	lasttp = lookup_tapepos(lookup_nb_tape());	if(c == 1) {	    g_fprintf(mailf, _("The next new tape already labelled is: %s.\n"),		    lasttp->label);	}	else {	    g_fprintf(mailf, _("The next %d new tapes already labelled are: %s"), c,		    lasttp->label);	    lasttp = lasttp->prev;	    c--;	    while(lasttp && c > 0 && strcmp(lasttp->datestamp,"0") == 0) {		g_fprintf(mailf, ", %s", lasttp->label);		lasttp = lasttp->prev;		c--;	    }	    g_fprintf(mailf, ".\n");	}    }}/* ----- */static voidoutput_X_summary(    X_summary_t *first){    size_t len_host=0, len_disk=0;    X_summary_t *strange;    char *str = NULL;    for(strange=first; strange != NULL; strange = strange->next) {	if(strlen(strange->hostname) > len_host)	    len_host = strlen(strange->hostname);	if(strlen(strange->diskname) > len_disk)	    len_disk = strlen(strange->diskname);    }    for(strange=first; strange != NULL; strange = strange->next) {	str = vstralloc("  ", prefixstrange(strange->hostname, strange->diskname, strange->level, len_host, len_disk),			"  ", strange->str, NULL);	g_fprintf(mailf, "%s\n", str);	amfree(str);    }}static voidoutput_lines(    line_t *	lp,    FILE *	f){    line_t *next;    while(lp) {	fputs(lp->str, f);	amfree(lp->str);	fputc('\n', f);	next = lp->next;	amfree(lp);	lp = next;    }}/* ----- */static intsort_by_name(    disk_t *	a,    disk_t *	b){    int rc;    rc = strcmp(a->host->hostname, b->host->hostname);    if(rc == 0) rc = strcmp(a->name, b->name);    return rc;}static voidsort_disks(void){    disk_t *dp;    sortq.head = sortq.tail = NULL;    while(!empty(diskq)) {	dp = dequeue_disk(&diskq);	if(data(dp) == NULL) { /* create one */	    find_repdata(dp, run_datestamp, 0);	}	insert_disk(&sortq, dp, sort_by_name);    }}static voidCheckStringMax(    ColumnInfo *cd,    char *	s){    if (cd->MaxWidth) {	int l = (int)strlen(s);	if (cd->Width < l)	    cd->Width= l;    }}static voidCheckIntMax(    ColumnInfo *cd,    int		n){    if (cd->MaxWidth) {    	char testBuf[200];    	int l;	g_snprintf(testBuf, SIZEOF(testBuf),	  cd->Format, cd->Width, cd->Precision, n);	l = (int)strlen(testBuf);	if (cd->Width < l)	    cd->Width= l;    }}static voidCheckFloatMax(    ColumnInfo *cd,    double	d){    if (cd->MaxWidth) {    	char testBuf[200];	int l;	g_snprintf(testBuf, SIZEOF(testBuf),	  cd->Format, cd->Width, cd->Precision, d);	l = (int)strlen(testBuf);	if (cd->Width < l)	    cd->Width= l;    }}static int HostName;static int Disk;static int Level;static int OrigKB;static int OutKB;static int Compress;static int DumpTime;static int DumpRate;static int TapeTime;static int TapeRate;static voidCalcMaxWidth(void){    /* we have to look for columspec's, that require the recalculation.     * we do here the same loops over the sortq as is done in     * output_summary. So, if anything is changed there, we have to     * change this here also.     *							ElB, 1999-02-24.     */    disk_t *dp;    double f;    repdata_t *repdata;    char *qdevname;    int i, l;    for (i=0;ColumnData[i].Name != NULL; i++) {	if (ColumnData[i].MaxWidth) {	    l = (int)strlen(ColumnData[i].Title);	    if (ColumnData[i].Width < l)		ColumnData[i].Width= l;	}    }    for(dp = sortq.head; dp != NULL; dp = dp->next) {      if(dp->todo) {	for(repdata = data(dp); repdata != NULL; repdata = repdata->next) {	    char TimeRateBuffer[40];	    CheckStringMax(&ColumnData[HostName], dp->host->hostname);	    qdevname = quote_string(dp->name);	    CheckStringMax(&ColumnData[Disk], qdevname);	    amfree(qdevname);	    if (repdata->dumper.result == L_BOGUS && 		repdata->taper.result == L_BOGUS)		continue;	    CheckIntMax(&ColumnData[Level], repdata->level);            if(repdata->dumper.result == L_SUCCESS ||                    repdata->dumper.result == L_CHUNKSUCCESS) {		CheckFloatMax(&ColumnData[OrigKB],			      (double)du(repdata->dumper.origsize));		CheckFloatMax(&ColumnData[OutKB],			      (double)du(repdata->dumper.outsize));		if(abs(repdata->dumper.outsize - repdata->dumper.origsize)< 32)		    f = 0.0;		else 		    f = repdata->dumper.origsize;		CheckStringMax(&ColumnData[Compress], 			sDivZero(pct(repdata->dumper.outsize), f, Compress));		if(!amflush_run)		    g_snprintf(TimeRateBuffer, SIZEOF(TimeRateBuffer),				"%3d:%02d", mnsc(repdata->dumper.sec));		else		    g_snprintf(TimeRateBuffer, SIZEOF(TimeRateBuffer),				"N/A ");		CheckStringMax(&ColumnData[DumpTime], TimeRateBuffer);		CheckFloatMax(&ColumnData[DumpRate], repdata->dumper.kps); 	    }	    if(repdata->taper.result == L_FAIL) {		CheckStringMax(&ColumnData[TapeTime], "FAILED");		continue;	    }	    if(repdata->taper.result == L_SUCCESS ||	       repdata->taper.result == L_CHUNKSUCCESS)		g_snprintf(TimeRateBuffer, SIZEOF(TimeRateBuffer), 		  "%3d:%02d", mnsc(repdata->taper.sec));	    else		g_snprintf(TimeRateBuffer, SIZEOF(TimeRateBuffer),		  "N/A ");	    CheckStringMax(&ColumnData[TapeTime], TimeRateBuffer);	    if(repdata->taper.result == L_SUCCESS ||		    repdata->taper.result == L_CHUNKSUCCESS)		CheckFloatMax(&ColumnData[TapeRate], repdata->taper.kps);	    else		CheckStringMax(&ColumnData[TapeRate], "N/A ");	}      }    }}static voidoutput_summary(void){    disk_t *dp;    repdata_t *repdata;    char *ds="DUMPER STATS";    char *ts=" TAPER STATS";    char *tmp;    int i, h, w1, wDump, wTape;    double outsize, origsize;    double f;    HostName = StringToColumn("HostName");    Disk = StringToColumn("Disk");    Level = StringToColumn("Level");    OrigKB = StringToColumn("OrigKB");    OutKB = StringToColumn("OutKB");    Compress = StringToColumn("Compress");    DumpTime = StringToColumn("DumpTime");    DumpRate = StringToColumn("DumpRate");    TapeTime = StringToColumn("TapeTime");    TapeRate = StringToColumn("TapeRate");    /* at first determine if we have to recalculate our widths */    if (MaxWidthsRequested)	CalcMaxWidth();    /* title for Dumper-Stats */    w1= ColWidth(HostName, Level);    wDump= ColWidth(OrigKB, DumpRate);    wTape= ColWidth(TapeTime, TapeRate);    /* print centered top titles */    h = (int)strlen(ds);    if (h > wDump) {	h = 0;    } else {	h = (wDump-h)/2;    }    g_fprintf(mailf, "%*s", w1+h, "");    g_fprintf(mailf, "%-*s", wDump-h, ds);    h = (int)strlen(ts);    if (h > wTape) {	h = 0;    } else {	h = (wTape-h)/2;    }    g_fprintf(mailf, "%*s", h, "");    g_fprintf(mailf, "%-*s", wTape-h, ts);    fputc('\n', mailf);    /* print the titles */    for (i=0; ColumnData[i].Name != NULL; i++) {    	char *fmt;    	ColumnInfo *cd= &ColumnData[i];    	g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	if (cd->Format[1] == '-')	    fmt= "%-*s";	else	    fmt= "%*s";	if(strcmp(cd->Title,"ORIG-KB") == 0) {	    /* cd->Title must be re-allocated in write-memory */	    cd->Title = stralloc("ORIG-KB");	    cd->Title[5] = displayunit[0];	}	if(strcmp(cd->Title,"OUT-KB") == 0) {	    /* cd->Title must be re-allocated in write-memory */	    cd->Title = stralloc("OUT-KB");	    cd->Title[4] = displayunit[0];	}	g_fprintf(mailf, fmt, cd->Width, cd->Title);    }    fputc('\n', mailf);    /* print the rules */    fputs(tmp=Rule(HostName, Level), mailf); amfree(tmp);    fputs(tmp=Rule(OrigKB, DumpRate), mailf); amfree(tmp);    fputs(tmp=Rule(TapeTime, TapeRate), mailf); amfree(tmp);    fputc('\n', mailf);    for(dp = sortq.head; dp != NULL; dp = dp->next) {      if(dp->todo) {    	ColumnInfo *cd;	char TimeRateBuffer[40];	for(repdata = data(dp); repdata != NULL; repdata = repdata->next) {	    char *devname;	    char *qdevname;	    size_t devlen;	    cd= &ColumnData[HostName];	    g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	    g_fprintf(mailf, cd->Format, cd->Width, cd->Width, dp->host->hostname);	    cd= &ColumnData[Disk];	    g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	    devname = sanitize_string(dp->name);	    qdevname = quote_string(devname);	    devlen = strlen(qdevname);	    if (devlen > (size_t)cd->Width) {	   	fputc('-', mailf); 		g_fprintf(mailf, cd->Format, cd->Width-1, cd->Precision-1,			qdevname+devlen - (cd->Width-1) );	    }	    else		g_fprintf(mailf, cd->Format, cd->Width, cd->Width, qdevname);	    amfree(devname);	    amfree(qdevname);	    cd= &ColumnData[Level];	    if (repdata->dumper.result == L_BOGUS &&		repdata->taper.result  == L_BOGUS) {	      if(amflush_run){		g_fprintf(mailf, "%*s%s\n", cd->PrefixSpace+cd->Width, "",			tmp=TextRule(OrigKB, TapeRate, "NO FILE TO FLUSH"));	      } else {		g_fprintf(mailf, "%*s%s\n", cd->PrefixSpace+cd->Width, "",			tmp=TextRule(OrigKB, TapeRate, "MISSING"));	      }	      amfree(tmp);	      continue;	    }	    	    g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	    g_fprintf(mailf, cd->Format, cd->Width, cd->Precision,repdata->level);	    if (repdata->dumper.result == L_SKIPPED) {		g_fprintf(mailf, "%s\n",			tmp=TextRule(OrigKB, TapeRate, "SKIPPED"));		amfree(tmp);		continue;	    }	    if (repdata->dumper.result == L_FAIL && (repdata->chunker.result != L_PARTIAL && repdata->taper.result  != L_PARTIAL)) {		g_fprintf(mailf, "%s\n",			tmp=TextRule(OrigKB, TapeRate, "FAILED"));		amfree(tmp);		exit_status |= STATUS_FAILED;		continue;	    }	    if(repdata->dumper.result == L_SUCCESS ||	       repdata->dumper.result == L_CHUNKSUCCESS)		origsize = repdata->dumper.origsize;	    else if(repdata->taper.result == L_SUCCESS ||		    repdata->taper.result == L_PARTIAL)		origsize = repdata->taper.origsize;	    else		origsize = repdata->chunker.origsize;	    if(repdata->taper.result == L_SUCCESS ||	       repdata->taper.result == L_CHUNKSUCCESS)		outsize  = repdata->taper.outsize;	    else if(repdata->chunker.result == L_SUCCESS ||		    repdata->chunker.result == L_PARTIAL ||		    repdata->chunker.result == L_CHUNKSUCCESS)		outsize  = repdata->chunker.outsize;	    else if (repdata->taper.result == L_PARTIAL)		outsize  = repdata->taper.outsize;	    else		outsize  = repdata->dumper.outsize;	    cd= &ColumnData[OrigKB];	    g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	    if(isnormal(origsize))		g_fprintf(mailf, cd->Format, cd->Width, cd->Precision, du(origsize));	    else		g_fprintf(mailf, "%*.*s", cd->Width, cd->Width, "N/A");	    cd= &ColumnData[OutKB];	    g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	    g_fprintf(mailf, cd->Format, cd->Width, cd->Precision, du(outsize));	    		    cd= &ColumnData[Compress];	    g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	    if(abs(outsize - origsize) < 32)		f = 0.0;	    else if(origsize < 1.0)		f = 0.0;	    else		f = origsize;	    fputs(sDivZero(pct(outsize), f, Compress), mailf);	    cd= &ColumnData[DumpTime];	    g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	    if(repdata->dumper.result == L_SUCCESS ||	       repdata->dumper.result == L_CHUNKSUCCESS)		g_snprintf(TimeRateBuffer, SIZEOF(TimeRateBuffer),		  "%3d:%02d", mnsc(repdata->dumper.sec));	    else		g_snprintf(TimeRateBuffer, SIZEOF(TimeRateBuffer),		  "N/A ");	    g_fprintf(mailf, cd->Format, cd->Width, cd->Width, TimeRateBuffer);	    cd= &ColumnData[DumpRate];	    g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	    if(repdata->dumper.result == L_SUCCESS ||		    repdata->dumper.result == L_CHUNKSUCCESS)		g_fprintf(mailf, cd->Format, cd->Width, cd->Precision, repdata->dumper.kps);	    else		g_fprintf(mailf, "%*s", cd->Width, "N/A ");	    cd= &ColumnData[TapeTime];	    g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	    if(repdata->taper.result == L_FAIL) {		g_fprintf(mailf, "%s\n",			tmp=TextRule(TapeTime, TapeRate, "FAILED "));		amfree(tmp);		continue;	    }	    if(repdata->taper.result == L_SUCCESS || 	       repdata->taper.result == L_PARTIAL ||	       repdata->taper.result == L_CHUNKSUCCESS)		g_snprintf(TimeRateBuffer, SIZEOF(TimeRateBuffer),		  "%3d:%02d", mnsc(repdata->taper.sec));	    else		g_snprintf(TimeRateBuffer, SIZEOF(TimeRateBuffer),		  "N/A ");	    g_fprintf(mailf, cd->Format, cd->Width, cd->Width, TimeRateBuffer);	    cd= &ColumnData[TapeRate];	    g_fprintf(mailf, "%*s", cd->PrefixSpace, "");	    if(repdata->taper.result == L_SUCCESS || 	       repdata->taper.result == L_PARTIAL ||	       repdata->taper.result == L_CHUNKSUCCESS)		g_fprintf(mailf, cd->Format, cd->Width, cd->Precision, repdata->taper.kps);	    else		g_fprintf(mailf, "%*s", cd->Width, "N/A ");	    if (repdata->chunker.result == L_PARTIAL)		g_fprintf(mailf, " PARTIAL");	    else if(repdata->taper.result == L_PARTIAL)		g_fprintf(mailf, " TAPE-PARTIAL");	    fputc('\n', mailf);	}      }    }}static voidbogus_line(    const char *err_text){    char * s;    s = g_strdup_printf(_("line %d of log is bogus: <%s %s %s>\n"),                        curlinenum,                         logtype_str[curlog], program_str[curprog], curstr);    g_printf("%s\n", s);    g_printf(_("  Scan failed at: <%s>\n"), err_text);    addline(&errsum, s);    amfree(s);}/*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -