On Mon, Mar 19, 2012 at 12:50:12PM +0100, Marc Espie wrote:
> On Wed, Mar 07, 2012 at 12:31:48AM -0500, Lawrence Teo wrote:
> > This simple diff makes pkg_add and pkg_delete include their PID when
> > logging to syslog. This is useful when trying to determine whether
> > several packages were added (or removed) by the same pkg_add (or
> > pkg_delete) process.
> > 
> > Here is some sample output:
> > 
> > Mar  3 22:15:17 obsd-amd64 pkg_add[3530]: Added nano-2.2.6 
> > Mar  3 22:15:26 obsd-amd64 pkg_delete[21136]: Removed nano-2.2.6 
> > Mar  3 22:16:51 obsd-amd64 pkg_add[30666]: Added redland-1.0.8p1 
> > Mar  3 22:16:54 obsd-amd64 pkg_add[30666]: Added mozilla-dicts-en-GB-1.3 
> > Mar  3 22:16:56 obsd-amd64 pkg_add[30666]: Added hunspell-1.2.12 
> > Mar  3 22:23:22 obsd-amd64 pkg_add[30666]: Added libreoffice-3.4.5.2v0 
> > Mar  3 23:33:23 obsd-amd64 pkg_add[5948]: Added kdiff3-0.9.96p1 
> > 
> > Comments?
> 
> The more I think about it, the more I fail to see the value.
> Consider that any pkg_add/pkg_delete that actually changes installed
> packages *will* lock the database anyways, so by nature, all relevant
> runs of pkg_add/pkg_delete will happen in sequence.
> 
> Hence, there's totally no ambiguity in the log lines. If I remove the pids
> in there, I still have no trouble figuring out what happened.
> 
> When I look at those logs, I usually have to look at the time anyways,
> so in the above case, figuring out that libreoffice and kdiff3 are
> different runs of pkg_add is not that hard...

Thank you for your comments.

If I remove the PIDs from the above logs, part of it would look like
this:

Mar  3 22:16:51 obsd-amd64 pkg_add: Added redland-1.0.8p1 
Mar  3 22:16:54 obsd-amd64 pkg_add: Added mozilla-dicts-en-GB-1.3 
Mar  3 22:16:56 obsd-amd64 pkg_add: Added hunspell-1.2.12 
Mar  3 22:23:22 obsd-amd64 pkg_add: Added libreoffice-3.4.5.2v0 

Just relying on those timestamps alone without PIDs, it looks like
redland, mozilla-dicts, and hunspell are part of the same run, while
libreoffice is a different run.

However, with PIDs it is clear that they are part of the same run, where
it so happened that it took almost 6.5 minutes to install the
libreoffice package on this machine:

Mar  3 22:16:51 obsd-amd64 pkg_add[30666]: Added redland-1.0.8p1 
Mar  3 22:16:54 obsd-amd64 pkg_add[30666]: Added mozilla-dicts-en-GB-1.3 
Mar  3 22:16:56 obsd-amd64 pkg_add[30666]: Added hunspell-1.2.12 
Mar  3 22:23:22 obsd-amd64 pkg_add[30666]: Added libreoffice-3.4.5.2v0 

> I won't say I can't be swayed, but you'll have to give me a concrete case
> where the pid offers some actual advantage over no pid.

My goal is to help the bleary-eyed sysadmin figure out what in the world
s/he did after working on a project all night long. :)  I think the
PIDs would help them answer questions like, "Why did I install $PACKAGE
again?" (where $PACKAGE could be "hunspell" in the above example).

Please let me know if you have any further thoughts and if you're ok
with the diff.  Since a long time has passed since your post on this
thread and I only managed to reply now, I have included my diff again
below.

Thank you,
Lawrence


Index: AddDelete.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/AddDelete.pm,v
retrieving revision 1.53
diff -u -p -r1.53 AddDelete.pm
--- AddDelete.pm        9 Oct 2011 16:43:50 -0000       1.53
+++ AddDelete.pm        4 Mar 2012 04:37:04 -0000
@@ -185,7 +185,7 @@ sub handle_options
        $state->{loglevel} //= $state->config->value("loglevel") // 1;
        if ($state->{loglevel}) {
                require Sys::Syslog;
-               Sys::Syslog::openlog($state->{cmd}, "nofatal");
+               Sys::Syslog::openlog($state->{cmd}, "nofatal,pid");
        }
 }

Reply via email to