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
19f8080e63
commit
2bb823d2b9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=90743
@ -83,6 +83,7 @@ int blockswritten; /* number of blocks written on current tape */
|
|||||||
int tapeno; /* current tape number */
|
int tapeno; /* current tape number */
|
||||||
time_t tstart_writing; /* when started writing the first tape block */
|
time_t tstart_writing; /* when started writing the first tape block */
|
||||||
time_t tend_writing; /* after writing the last 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 */
|
struct fs *sblock; /* the file system super block */
|
||||||
char sblock_buf[MAXBSIZE];
|
char sblock_buf[MAXBSIZE];
|
||||||
long dev_bsize; /* block size of underlying disk device */
|
long dev_bsize; /* block size of underlying disk device */
|
||||||
|
@ -362,9 +362,13 @@ main(argc, argv)
|
|||||||
|
|
||||||
nonodump = spcl.c_level < honorlevel;
|
nonodump = spcl.c_level < honorlevel;
|
||||||
|
|
||||||
|
passno = 1;
|
||||||
|
setproctitle("%s: pass 1: regular files", disk);
|
||||||
msg("mapping (Pass I) [regular files]\n");
|
msg("mapping (Pass I) [regular files]\n");
|
||||||
anydirskipped = mapfiles(maxino, &tapesize);
|
anydirskipped = mapfiles(maxino, &tapesize);
|
||||||
|
|
||||||
|
passno = 2;
|
||||||
|
setproctitle("%s: pass 2: directories", disk);
|
||||||
msg("mapping (Pass II) [directories]\n");
|
msg("mapping (Pass II) [directories]\n");
|
||||||
while (anydirskipped) {
|
while (anydirskipped) {
|
||||||
anydirskipped = mapdirs(maxino, &tapesize);
|
anydirskipped = mapdirs(maxino, &tapesize);
|
||||||
@ -427,6 +431,8 @@ main(argc, argv)
|
|||||||
(void)time((time_t *)&(tstart_writing));
|
(void)time((time_t *)&(tstart_writing));
|
||||||
dumpmap(usedinomap, TS_CLRI, maxino - 1);
|
dumpmap(usedinomap, TS_CLRI, maxino - 1);
|
||||||
|
|
||||||
|
passno = 3;
|
||||||
|
setproctitle("%s: pass 3: directories", disk);
|
||||||
msg("dumping (Pass III) [directories]\n");
|
msg("dumping (Pass III) [directories]\n");
|
||||||
dirty = 0; /* XXX just to get gcc to shut up */
|
dirty = 0; /* XXX just to get gcc to shut up */
|
||||||
for (map = dumpdirmap, ino = 1; ino < maxino; ino++) {
|
for (map = dumpdirmap, ino = 1; ino < maxino; ino++) {
|
||||||
@ -445,6 +451,8 @@ main(argc, argv)
|
|||||||
(void)dumpino(dp, ino);
|
(void)dumpino(dp, ino);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
passno = 4;
|
||||||
|
setproctitle("%s: pass 4: regular files", disk);
|
||||||
msg("dumping (Pass IV) [regular files]\n");
|
msg("dumping (Pass IV) [regular files]\n");
|
||||||
for (map = dumpinomap, ino = 1; ino < maxino; ino++) {
|
for (map = dumpinomap, ino = 1; ino < maxino; ino++) {
|
||||||
int mode;
|
int mode;
|
||||||
|
@ -193,20 +193,25 @@ time_t tschedule = 0;
|
|||||||
void
|
void
|
||||||
timeest()
|
timeest()
|
||||||
{
|
{
|
||||||
|
double percent;
|
||||||
time_t tnow;
|
time_t tnow;
|
||||||
int deltat;
|
int deltat, hours, mins;
|
||||||
|
|
||||||
(void) time(&tnow);
|
(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) {
|
if (tnow >= tschedule) {
|
||||||
tschedule = tnow + 300;
|
tschedule = tnow + 300;
|
||||||
if (blockswritten < 500)
|
if (blockswritten < 500)
|
||||||
return;
|
return;
|
||||||
deltat = tstart_writing - tnow +
|
msg("%3.2f%% done, finished in %d:%02d\n", percent, hours,
|
||||||
(1.0 * (tnow - tstart_writing))
|
mins);
|
||||||
/ blockswritten * tapesize;
|
|
||||||
msg("%3.2f%% done, finished in %d:%02d\n",
|
|
||||||
(blockswritten * 100.0) / tapesize,
|
|
||||||
deltat / 3600, (deltat % 3600) / 60);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,6 +527,7 @@ startnewtape(top)
|
|||||||
/*
|
/*
|
||||||
* All signals are inherited...
|
* All signals are inherited...
|
||||||
*/
|
*/
|
||||||
|
setproctitle(NULL); /* Restore the proctitle. */
|
||||||
childpid = fork();
|
childpid = fork();
|
||||||
if (childpid < 0) {
|
if (childpid < 0) {
|
||||||
msg("Context save fork fails in parent %d\n", parentpid);
|
msg("Context save fork fails in parent %d\n", parentpid);
|
||||||
|
Loading…
Reference in New Issue
Block a user