- bps = (int)(njcr->JobBytes / sec);
- len = Mmsg(&msg, _(" Files=%s Bytes=%s Bytes/sec=%s\n"),
- edit_uint64_with_commas(njcr->JobFiles, b1),
- edit_uint64_with_commas(njcr->JobBytes, b2),
- edit_uint64_with_commas(bps, b3));
- sendit(msg, len, arg);
- len = Mmsg(&msg, _(" Files Examined=%s\n"),
- edit_uint64_with_commas(njcr->num_files_examined, b1));
- sendit(msg, len, arg);
+ total_sec = now - njcr->start_time;
+ inst_sec = now - njcr->last_time;
+ if (total_sec <= 0) {
+ total_sec = 1;
+ }
+ if (inst_sec <= 0) {
+ inst_sec = 1;
+ }
+ /* Instanteous bps not smoothed */
+ inst_bps = (njcr->JobBytes - njcr->LastJobBytes) / inst_sec;
+ if (njcr->LastRate <= 0) {
+ njcr->LastRate = inst_bps;
+ }
+ /* Smooth the instantaneous bps a bit */
+ inst_bps = (2 * njcr->LastRate + inst_bps) / 3;
+ /* total bps (AveBytes/sec) since start of job */
+ total_bps = njcr->JobBytes / total_sec;
+ len = Mmsg(msg, _(" Files=%s Bytes=%s AveBytes/sec=%s LastBytes/sec=%s Errors=%d\n"
+ " Bwlimit=%s ReadBytes=%s\n"),
+ edit_uint64_with_commas(njcr->JobFiles, b1),
+ edit_uint64_with_commas(njcr->JobBytes, b2),
+ edit_uint64_with_commas(total_bps, b3),
+ edit_uint64_with_commas(inst_bps, b4),
+ njcr->JobErrors, edit_uint64_with_commas(njcr->max_bandwidth, b5),
+ edit_uint64_with_commas(njcr->ReadBytes, b6));
+ sendit(msg.c_str(), len, sp);
+
+ if (njcr->is_JobType(JT_RESTORE) && njcr->ExpectedFiles > 0) {
+ len = Mmsg(msg, _(" Files: Restored=%s Expected=%s Completed=%d%%\n"),
+ edit_uint64_with_commas(njcr->num_files_examined, b1),
+ edit_uint64_with_commas(njcr->ExpectedFiles, b2),
+ (100*njcr->num_files_examined)/njcr->ExpectedFiles);
+ } else {
+ len = Mmsg(msg, _(" Files: Examined=%s Backed up=%s\n"),
+ edit_uint64_with_commas(njcr->num_files_examined, b1),
+ edit_uint64_with_commas(njcr->JobFiles, b2));
+ }
+ /* Update only every 10 seconds */
+ if (now - njcr->last_time > 10) {
+ njcr->LastRate = inst_bps;
+ njcr->LastJobBytes = njcr->JobBytes;
+ njcr->last_time = now;
+ }
+ sendit(msg.c_str(), len, sp);