aboutsummaryrefslogtreecommitdiff
path: root/sbin/dump/optr.c
diff options
context:
space:
mode:
authorIan Dowse <iedowse@FreeBSD.org>2002-02-16 21:05:16 +0000
committerIan Dowse <iedowse@FreeBSD.org>2002-02-16 21:05:16 +0000
commit2bb823d2b9013b29e374b2d6f57062c5a9886590 (patch)
tree0952f18a123759d5d1883d2adade1938f7269c0e /sbin/dump/optr.c
parent19f8080e634db77aef0d5a5757e92d072ccd4de5 (diff)
downloadsrc-2bb823d2b9013b29e374b2d6f57062c5a9886590.tar.gz
src-2bb823d2b9013b29e374b2d6f57062c5a9886590.zip
Supply progress information in dump's process title, which is useful
for monitoring automated backups. This is based on a patch by Mikhail Teterin, with some changes to make its operation clearer and to update the proctitle more frequently. PR: bin/32138
Notes
Notes: svn path=/head/; revision=90743
Diffstat (limited to 'sbin/dump/optr.c')
-rw-r--r--sbin/dump/optr.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sbin/dump/optr.c b/sbin/dump/optr.c
index a35b550a903f..f13e7d683f72 100644
--- a/sbin/dump/optr.c
+++ b/sbin/dump/optr.c
@@ -193,20 +193,25 @@ time_t tschedule = 0;
void
timeest()
{
+ double percent;
time_t tnow;
- int deltat;
+ int deltat, hours, mins;
(void) time(&tnow);
+ deltat = (blockswritten == 0) ? 0 : tstart_writing - tnow +
+ (double)(tnow - tstart_writing) / blockswritten * tapesize;
+ percent = (blockswritten * 100.0) / tapesize;
+ hours = deltat / 3600;
+ mins = (deltat % 3600) / 60;
+
+ setproctitle("%s: pass %d: %3.2f%% done, finished in %d:%02d",
+ disk, passno, percent, hours, mins);
if (tnow >= tschedule) {
tschedule = tnow + 300;
if (blockswritten < 500)
return;
- deltat = tstart_writing - tnow +
- (1.0 * (tnow - tstart_writing))
- / blockswritten * tapesize;
- msg("%3.2f%% done, finished in %d:%02d\n",
- (blockswritten * 100.0) / tapesize,
- deltat / 3600, (deltat % 3600) / 60);
+ msg("%3.2f%% done, finished in %d:%02d\n", percent, hours,
+ mins);
}
}