From owner-svn-src-projects@FreeBSD.ORG Thu May 26 23:23:25 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 766AF1065672; Thu, 26 May 2011 23:23:25 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5BBB08FC1A; Thu, 26 May 2011 23:23:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p4QNNPrP085178; Thu, 26 May 2011 23:23:25 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4QNNP9s085175; Thu, 26 May 2011 23:23:25 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201105262323.p4QNNP9s085175@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 26 May 2011 23:23:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222331 - projects/jbuild/usr.bin/jbuild/filemon X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2011 23:23:25 -0000 Author: obrien Date: Thu May 26 23:23:25 2011 New Revision: 222331 URL: http://svn.freebsd.org/changeset/base/222331 Log: Add Start / Stop timestamps. Obtained from: Juniper Networks Modified: projects/jbuild/usr.bin/jbuild/filemon/filemon.h projects/jbuild/usr.bin/jbuild/filemon/filemon_wrapper.c Modified: projects/jbuild/usr.bin/jbuild/filemon/filemon.h ============================================================================== --- projects/jbuild/usr.bin/jbuild/filemon/filemon.h Thu May 26 22:29:43 2011 (r222330) +++ projects/jbuild/usr.bin/jbuild/filemon/filemon.h Thu May 26 23:23:25 2011 (r222331) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009, 2010, Juniper Networks, Inc. + * Copyright (c) 2009-2011, Juniper Networks, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,3 +28,5 @@ #define FILEMON_SET_FD _IOWR('S', 1, int) #define FILEMON_SET_PID _IOWR('S', 2, pid_t) + +#define FILEMON_VERSION 2 /* output format */ Modified: projects/jbuild/usr.bin/jbuild/filemon/filemon_wrapper.c ============================================================================== --- projects/jbuild/usr.bin/jbuild/filemon/filemon_wrapper.c Thu May 26 22:29:43 2011 (r222330) +++ projects/jbuild/usr.bin/jbuild/filemon/filemon_wrapper.c Thu May 26 23:23:25 2011 (r222331) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009, 2010, Juniper Networks, Inc. + * Copyright (c) 2009-2011, Juniper Networks, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -70,8 +70,12 @@ filemon_pid_check(struct proc *p) static void filemon_comment(struct filemon *filemon) { + struct timeval now; int len; + /* Load timestamp before locking. Less accurate but less contention. */ + getmicrotime(&now); + /* Grab a read lock on the filemon inuse list. */ filemon_lock_read(); @@ -79,7 +83,9 @@ filemon_comment(struct filemon *filemon) filemon_filemon_lock(filemon); len = snprintf(filemon->msgbufr, sizeof(filemon->msgbufr), - "# buildmon version 2\n# Target pid %d\nV 2\n", curproc->p_pid); + "# buildmon version %d\n# Target pid %d\n# Start %ju.%06ju\nV %d\n", + FILEMON_VERSION, curproc->p_pid, (uintmax_t)now.tv_sec, + (uintmax_t)now.tv_usec, FILEMON_VERSION); filemon_output(filemon, filemon->msgbufr, len); @@ -479,9 +485,13 @@ filemon_wrapper_freebsd32_stat(struct th static void filemon_wrapper_sys_exit(struct thread *td, struct sys_exit_args *uap) { + struct timeval now; size_t len; struct filemon *filemon; + /* Get timestamp before locking. */ + getmicrotime(&now); + /* Grab a read lock on the filemon inuse list. */ filemon_lock_read(); @@ -496,7 +506,10 @@ filemon_wrapper_sys_exit(struct thread * /* Check if the monitored process is about to exit. */ if (filemon->pid == curproc->p_pid) { - len = snprintf(filemon->msgbufr, sizeof(filemon->msgbufr), "# Bye bye\n"); + len = snprintf(filemon->msgbufr, + sizeof(filemon->msgbufr), + "# Stop %ju.%06ju\n# Bye bye\n", + (uintmax_t)now.tv_sec, (uintmax_t)now.tv_usec); filemon_output(filemon, filemon->msgbufr, len); }