Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 May 2011 23:23:25 +0000 (UTC)
From:      "David E. O'Brien" <obrien@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r222331 - projects/jbuild/usr.bin/jbuild/filemon
Message-ID:  <201105262323.p4QNNP9s085175@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105262323.p4QNNP9s085175>