Jump to content


how many sync'd files for a set of clients? (vs locked clients)

client have locked

  • Please log in to reply
7 replies to this topic

#1 Miles O'Neal

Miles O'Neal

    Advanced Member

  • Members
  • PipPipPip
  • 214 posts
  • LocationAustin. Texas. Y'all.

Posted 11 June 2020 - 09:06 PM

Our db.have is huge. As part of the cleanup effort, I'm looking at how many files various sets of clients have. Most of our clients are locked to an owner, so

   p4 -c <client> have | wc -l

is going to fail.

We do not want to have to unlock (edit) each client to run the have, then relock (edit) the client again. We have lots of user-run and automated scripts that edit clients on the fly, and there's potential for problems if the two processes overlap. While the probability is not high, one of our priorities is that Everything Just Works.

Is there a better way to get this data? I'm somewhat frustrated that superusers don't have a way to universally override a locked client. The -f option is available for *some* commands, but not "p4 have".

Thanks.

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1192 posts

Posted 11 June 2020 - 09:44 PM

Do you want it for all the clients at once?  Perhaps sorted from greatest to least number of files synced?

p4 -F "sizes -s @%domainName%" clients | p4 -F "%fileCount% files %path%" -x - run | sort -n -r

If you're on Windows, beware the %path% expansion (and you might want to use the Cygwin sort instead of the native one because the CMD version doesn't have a "numeric" flag):


C:\Perforce\test>p4 -F "sizes -s @%domainName%" clients | p4 -F ^"%fileCount% files ^%path^%^" -x - run | sort /R
38 files @Samwise-dvcs-1509687817
0 files @Widget-COMPY386
0 files @Sprocket-COMPY386


#3 Miles O'Neal

Miles O'Neal

    Advanced Member

  • Members
  • PipPipPip
  • 214 posts
  • LocationAustin. Texas. Y'all.

Posted 11 June 2020 - 10:35 PM

That actually looks perfect. Where did you find out about -F? Thanks!

#4 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1192 posts

Posted 11 June 2020 - 11:11 PM

View PostMiles O, on 11 June 2020 - 10:35 PM, said:

Where did you find out about -F?

I wrote it.  :ph34r:

Here's the blog post explaining more about how it works and what you can do with it: https://web.archive..../fun-formatting

#5 Miles O'Neal

Miles O'Neal

    Advanced Member

  • Members
  • PipPipPip
  • 214 posts
  • LocationAustin. Texas. Y'all.

Posted 11 June 2020 - 11:14 PM

Awesome. I'll read that later; I'm pretty fried at the moment. But I ran a test of that vs the way I originally planned to do it, and the numbers were almost exact. (One client wouldn't work in my original plan, even unlocking clients, because it was locked to a host, which we don't normally allow.) Thanks again!

#6 Miles O'Neal

Miles O'Neal

    Advanced Member

  • Members
  • PipPipPip
  • 214 posts
  • LocationAustin. Texas. Y'all.

Posted 12 June 2020 - 03:26 PM

Any chance this will ever move out of undoc? Just curious.

#7 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1192 posts

Posted 12 June 2020 - 10:18 PM

View PostMiles O, on 12 June 2020 - 03:26 PM, said:

Any chance this will ever move out of undoc? Just curious.

Hard for me to guess at this point, but I'd doubt it.  

My thinking on having it be undoc in the first place was that it's impossible to "document" it to the standard of the rest of the end user documentation without going pretty deep into the specifics of the server messages -- how they're actually string dictionaries, how they get parsed and substituted, what specific values you'll get from all the specific messages that each command can produce (there are thousands of them!), lots of examples of usage with different commands, etc.  

It's a feature that the average end user is going to be very confused by (as in either asking "why is this something you'd ever want to do in the first place?" or worse yet, deciding that this is something you need to do as part of a normal workflow -- I've seen people do this with -Ztag and then wonder why Perforce doesn't bother to have human-readable output), but the power user who's already spent some time using regexes to script around CLI output will A. immediately grok the usefulness of being able to rewrite the message themselves without needing twenty pages of doc explaining it and B. probably not mind doing a bit of experimentation to figure out how to make it useful.  :)

#8 Matt Janulewicz

Matt Janulewicz

    Advanced Member

  • Members
  • PipPipPip
  • 230 posts
  • LocationSan Diego, CA

Posted 13 June 2020 - 10:41 PM

Just wanted to add two quick things to this discussion.

1. A less elegant way to do this but one that doesn't hammer a server with queries would be to just dump db.have and sort/grep/awk/wc what you need out of it. In my case, our db.have was only about half a TB so it was just barely manageable, but after the overhead of dumping and sorting, it was quicker over the medium term to get the data out of it that I needed. At the time I was more concerned with older clients, so the data didn't change or get stale over the few days I monkeyed around with it. It was also a one time assessment, not a continual process over a long period of time. Quick and dirty is my MO.

2. After I found out about -F, I eventually got to the point where the regular output of '-ztag' started to look weird and unfamiliar. I always have/had trouble processing around newlines in output so -F ended up cutting out a huge number of headaches for me. Your work on that is much appreciated!
-Matt Janulewicz
Currently unemployed, looking for work in Boise, ID!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users