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
This commit is contained in:
parent
3813d929a4
commit
c8b3c630ca
@ -83,6 +83,7 @@ int blockswritten; /* number of blocks written on current tape */
|
||||
int tapeno; /* current tape number */
|
||||
time_t tstart_writing; /* when started writing the first tape block */
|
||||
time_t tend_writing; /* after writing the last tape block */
|
||||
int passno; /* current dump pass number */
|
||||
struct fs *sblock; /* the file system super block */
|
||||
char sblock_buf[MAXBSIZE];
|
||||
long dev_bsize; /* block size of underlying disk device */
|
||||
|
@ -362,9 +362,13 @@ main(argc, argv)
|
||||
|
||||
nonodump = spcl.c_level < honorlevel;
|
||||
|
||||
passno = 1;
|
||||
setproctitle("%s: pass 1: regular files", disk);
|
||||
msg("mapping (Pass I) [regular files]\n");
|
||||
anydirskipped = mapfiles(maxino, &tapesize);
|
||||
|
||||
passno = 2;
|
||||
setproctitle("%s: pass 2: directories", disk);
|
||||
msg("mapping (Pass II) [directories]\n");
|
||||
while (anydirskipped) {
|
||||
anydirskipped = mapdirs(maxino, &tapesize);
|
||||
@ -427,6 +431,8 @@ main(argc, argv)
|
||||
(void)time((time_t *)&(tstart_writing));
|
||||
dumpmap(usedinomap, TS_CLRI, maxino - 1);
|
||||
|
||||
passno = 3;
|
||||
setproctitle("%s: pass 3: directories", disk);
|
||||
msg("dumping (Pass III) [directories]\n");
|
||||
dirty = 0; /* XXX just to get gcc to shut up */
|
||||
for (map = dumpdirmap, ino = 1; ino < maxino; ino++) {
|
||||
@ -445,6 +451,8 @@ main(argc, argv)
|
||||
(void)dumpino(dp, ino);
|
||||
}
|
||||
|
||||
passno = 4;
|
||||
setproctitle("%s: pass 4: regular files", disk);
|
||||
msg("dumping (Pass IV) [regular files]\n");
|
||||
for (map = dumpinomap, ino = 1; ino < maxino; ino++) {
|
||||
int mode;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,6 +527,7 @@ startnewtape(top)
|
||||
/*
|
||||
* All signals are inherited...
|
||||
*/
|
||||
setproctitle(NULL); /* Restore the proctitle. */
|
||||
childpid = fork();
|
||||
if (childpid < 0) {
|
||||
msg("Context save fork fails in parent %d\n", parentpid);
|
||||
|
Loading…
Reference in New Issue
Block a user