[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Clever way to find ALL files not owned by RPM?



Very nice... I havent used delete in awk for a long long time (if ever
:)). Can I use this in the class with the correct attribution?


On Tue, 2003-01-21 at 10:33, Matthew Callaway wrote:
> I just posted this to a different thread on this list.  You might find
> it useful.
> 
> #
> # rogue.awk - Find files that are not accounted for
> #
> # awk -f rogue.awk
> #
> # Rogue is called from a cron job on an hourly basis.
> # It parses files in the filesystem and checks to see
> # that they belong to an rpm.  Then it prints the
> # output of rpm -Va to verify those files that do
> # belong to an rpm.
> #
> BEGIN {
>   # Required commands
>   cmd1="/bin/rpm -qal";
>   cmd2="find / -path '/proc' -prune -o -print";
> 
>   # All rpms in rpm db
>   while ( cmd1 | getline ) {
>     rpmfiles[$0] = 1;
>   }
>   close(cmd1);
> 
>   # All files on system not in an rpm
>   while ( cmd2 | getline ) {
>     if (!($0 in rpmfiles)) {
>       orphans[$0] = 1;
>     }
>   }
>   close(cmd2);
>   delete rpmfiles;
>   exit 0; # hit 'END' right now
> }
> END {
>   for (file in orphans) {
>     print "R:orphaned",file | "sort"
>   }
>   while ("rpm -Va --noghost" | getline) {
>     print "R:" $0 | "sort"
>   }
> }
> 
> 
> 
> On Tue, 21 Jan 2003, Stephen Smoogen wrote:
> 
> >
> > Thankyou Valery and Nigel... I am an idiot to not have thought of rpm
> > -qal | sort
> >
> > On Tue, 2003-01-21 at 10:09, Nigel Metheringham wrote:
> > > On Tue, 2003-01-21 at 16:57, Stephen Smoogen wrote:
> > > > I am having to write a lecture on checking on 'open' machines, and have
> > > > the flu.. so am not thinking anywhere close to clever. My first pass at
> > > > the idea was to do something like
> > > >
> > > > find / -xdev -print0 | xargs -0 rpm -qf > /tmp/b
> > > >
> > > > which of course thrashed the machine pretty bad while going through the
> > > > /dev directories. I am guessing there is a quicker way of doing this
> > > > using a perl module and such, but couldnt find anything via google. Of
> > > > course, I am just going to blame the flu on my lameness :)
> > >
> > > As a first cut I'd do something on the lines of
> > >   find / -print | sort >/tmp/disk.list
> > >   rpm -qal | sort >/tmp/rpm.list
> > >   comm /tmp/disk.list /tmp/rpm.list
> > >
> > > and then make more sophisticated as required (skipping /tmp and /home
> > > would be a start)....
> > >
> 
> 
> 
> _______________________________________________
> Rpm-list mailing list
> Rpm-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/rpm-list
> 
-- 
Stephen John Smoogen		smoogen@lanl.gov
Los Alamos National Labrador  CCN-2 B-Schedule  PH: 
Ta-03 SM-261  MailStop P208 DP 17U  Los Alamos, NM 87545





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []