From: Dobrica Pavlinusic Date: Thu, 27 Jan 2011 21:29:43 +0000 (+0100) Subject: show status in ps output by modifing $0 X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=commitdiff_plain;h=c2282ed1a09c2c3fc6d4b538b144a54ed835acbc;hp=40df4417247e8b3ec4e35770adbe9da62593e0e5 show status in ps output by modifing $0 --- diff --git a/bin/BackupPC_ASA_SearchUpdate b/bin/BackupPC_ASA_SearchUpdate index 2ce01fc..5615abb 100755 --- a/bin/BackupPC_ASA_SearchUpdate +++ b/bin/BackupPC_ASA_SearchUpdate @@ -78,6 +78,19 @@ warn "hosts: ",dump( $opt->host ); #---- subs ---- +sub status { + my $text = shift; + $text =~ s{\s+$}{}; + my $new = $0; + $new =~ s{^[\w\/]+/(\w+) }{$1 }; # strip path from process name + if ( $text =~ m/^\|/ ) { + $new =~ s/\|.*/$text/ or $new .= " $text"; + } else { + $new =~ s/\s+.*/ $text/ or $new .= " $text"; + } + $0 = $new; +} + sub fmt_time { my $t = shift || return; my $out = ""; @@ -170,6 +183,7 @@ sub hest_update { } print "$added"; + status "| $added"; $offset += EST_CHUNK; @@ -440,7 +454,7 @@ INSERT INTO hosts (name, IP) VALUES (?,?) }); $sth->{hosts_by_name} = $dbh->prepare(qq{ -SELECT ID FROM hosts WHERE name=? +SELECT id FROM hosts WHERE name=? }); $sth->{backups_count} = $dbh->prepare(qq{ @@ -518,6 +532,7 @@ foreach my $host_key (@hosts) { fmt_time($backup->{endTime} - $backup->{startTime}) ); print $share_header unless $opt->quiet; + status "$hostname $backupNum $share_header"; my $files = BackupPC::View->new($bpc, $hostname, \@backups, { only_first => 1 }); @@ -572,14 +587,17 @@ foreach my $host_key (@hosts) { } my $dur = (time() - $t) || 1; - printf(" %d/%d files %d/%d dirs %0.2f MB [%.2f/s dur: %s]\n", + my $status = sprintf("%d/%d files %d/%d dirs %0.2f MB [%.2f/s dur: %s]", $nf, $f, $nd, $d, ($size / 1024 / 1024), ( ($f+$d) / $dur ), fmt_time($dur) ); + print " $status\n"; + status "$hostname $backupNum $status"; if ($nf + $nd > 0) { + status "$hostname $backupNum full-text | indexing"; eval { hest_update($hostID, $shareID, $backupNum) }; warn "ERROR: $@" if $@; }