[p4] Monitoring

Robert Cowham robert at vaccaperna.co.uk
Fri Sep 21 08:01:01 PDT 2007


> One note of caution here.  If someone is executing a Perforce 
> task that locks the database, the "p4 monitor" task will wait 
> until the task that locks the database completes (at least, 
> that's what our 2006.2 version server does).  This can have 
> two unintended consequences:
>   * When someone is blocking you from accessing perforce, you 
> want to see what's going on.  Unfortunately, "p4 monitor" 
> will be blocked as well, so you can't see what that task is.
>   * If the HTML generator runs the "p4 monitor" and "vmstat" 
> serially, then the "vmstat" update will block as well, since 
> it can't run until the "p4 monitor" command completes.

As a way around this, if you are careful, you can create a secondary p4d
which shares only the db.monitor files with the live p4d

Assuming unix for ease (samething should work on Windows with hardlinks - I
have a simple python script to create these):

/p4root containts db.*

Server running in /p4root is on port 1666

/P4root/monitor contains its own set of db.*, but db.monitor is a soft link
to /p4root/db.monitor. Server in this directory is running on port 1777

Thus by running p4 monitor command on port 1777 you are accessing live info
on server in 1666, and yet the only file lock your 1999 server sees is that
on the db.monitor which doesn't happen (as far as I know).

Does that make sense?

This trick can also be used for some other nefarious situations... :)

See below for trace of this on Windows:

C:\temp\p4monitor>p4d -r . -p 1999
Perforce db files in '.' will be created if missing...
Perforce Server starting...

C:\temp\p4monitor>dir
 Volume in drive C is Main
 Volume Serial Number is 740F-93CE

 Directory of C:\temp\p4monitor

21/09/2007  15:50    <DIR>          .
21/09/2007  15:50    <DIR>          ..
21/09/2007  15:50            16,384 db.archmap
21/09/2007  15:50            16,384 db.change
21/09/2007  15:50            16,384 db.changex
21/09/2007  15:50            16,384 db.counters
21/09/2007  15:50            16,384 db.depot
21/09/2007  15:50            16,384 db.domain
21/09/2007  15:50            16,384 db.have
21/09/2007  15:50            16,384 db.integ
21/09/2007  15:50            16,384 db.integed
21/09/2007  15:50            16,384 db.label
21/09/2007  15:50            16,384 db.locks
21/09/2007  15:50            16,384 db.resolve
21/09/2007  15:50            16,384 db.rev
21/09/2007  15:50            16,384 db.revcx
21/09/2007  15:50            16,384 db.revdx
21/09/2007  15:50            16,384 db.revhx
21/09/2007  15:50            16,384 db.revsx
21/09/2007  15:50            16,384 db.trigger
21/09/2007  15:50            16,384 db.user
21/09/2007  15:50            16,384 db.view
21/09/2007  15:50            16,384 db.working
21/09/2007  15:50               956 journal
              22 File(s)        345,020 bytes
               2 Dir(s)  31,440,945,152 bytes free

C:\temp\p4monitor>

********* Note no db.monitor above

C:\temp\p4monitor>
C:\temp\p4monitor>p4d -r . -p 1999
Perforce Server starting...

******** Turn monitoring on and restart p4d

C:\temp\p4monitor>p4d -r . -p 1999
Perforce Server starting...

C:\temp\p4monitor>dir
 Volume in drive C is Main
 Volume Serial Number is 740F-93CE

 Directory of C:\temp\p4monitor

21/09/2007  15:51    <DIR>          .
21/09/2007  15:51    <DIR>          ..
21/09/2007  15:50            16,384 db.archmap
21/09/2007  15:50            16,384 db.change
21/09/2007  15:50            16,384 db.changex
21/09/2007  15:51            16,384 db.counters
21/09/2007  15:50            16,384 db.depot
21/09/2007  15:50            16,384 db.domain
21/09/2007  15:51            16,384 db.group
21/09/2007  15:50            16,384 db.have
21/09/2007  15:50            16,384 db.integ
21/09/2007  15:50            16,384 db.integed
21/09/2007  15:50            16,384 db.label
21/09/2007  15:50            16,384 db.locks
21/09/2007  15:51            16,384 db.monitor		<============
21/09/2007  15:51            16,384 db.protect
21/09/2007  15:50            16,384 db.resolve
21/09/2007  15:50            16,384 db.rev
21/09/2007  15:50            16,384 db.revcx
21/09/2007  15:50            16,384 db.revdx
21/09/2007  15:50            16,384 db.revhx
21/09/2007  15:50            16,384 db.revsx
21/09/2007  15:50            16,384 db.trigger
21/09/2007  15:51            16,384 db.user
21/09/2007  15:50            16,384 db.view
21/09/2007  15:50            16,384 db.working
21/09/2007  15:51             1,126 journal
              25 File(s)        394,342 bytes
               2 Dir(s)  31,440,891,904 bytes free

C:\temp\p4monitor>del db.monitor

C:\temp\p4monitor>hard_link
Usage: create_hard_link <new_link_name> <existing_file_name>

C:\temp\p4monitor>hard_link db.monitor c:\perforce\db.monitor

C:\temp\p4monitor>dir
 Volume in drive C is Main
 Volume Serial Number is 740F-93CE

 Directory of C:\temp\p4monitor

21/09/2007  15:52    <DIR>          .
21/09/2007  15:52    <DIR>          ..
21/09/2007  15:50            16,384 db.archmap
21/09/2007  15:50            16,384 db.change
21/09/2007  15:50            16,384 db.changex
21/09/2007  15:51            16,384 db.counters
21/09/2007  15:50            16,384 db.depot
21/09/2007  15:50            16,384 db.domain
21/09/2007  15:51            16,384 db.group
21/09/2007  15:50            16,384 db.have
21/09/2007  15:50            16,384 db.integ
21/09/2007  15:50            16,384 db.integed
21/09/2007  15:50            16,384 db.label
21/09/2007  15:50            16,384 db.locks
24/07/2007  09:02            16,384 db.monitor	 <==== note timestamp
21/09/2007  15:51            16,384 db.protect
21/09/2007  15:50            16,384 db.resolve
21/09/2007  15:50            16,384 db.rev
21/09/2007  15:50            16,384 db.revcx
21/09/2007  15:50            16,384 db.revdx
21/09/2007  15:50            16,384 db.revhx
21/09/2007  15:50            16,384 db.revsx
21/09/2007  15:50            16,384 db.trigger
21/09/2007  15:51            16,384 db.user
21/09/2007  15:50            16,384 db.view
21/09/2007  15:50            16,384 db.working
21/09/2007  15:51             1,126 journal
              25 File(s)        394,342 bytes
               2 Dir(s)  31,440,912,384 bytes free

C:\temp\p4monitor>p4d -r . -p 1999
Perforce Server starting...

C:\bruno_ws>p4 monitor show -ae
 6312 p4/2007.2 127.0.0.1      R bruno      bruno_ws   00:00:03 verify //...
 7524 p4/2007.2 127.0.0.1      R bruno      bruno_ws   00:00:00 monitor show
-ae

C:\bruno_ws>p4 -p 1999 monitor show -ae
 6312 p4/2007.2 127.0.0.1      R bruno      bruno_ws   00:00:08 verify //...
 7008 p4/2007.2 127.0.0.1      R bruno      bruno_ws   00:00:00 monitor show
-ae


Notice above that the verify PID is the same on the two different servers,
even if the monitor show PIDs are different.

Robert


More information about the perforce-user mailing list