From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id IJakNk6yrl/9VQAA0tVLHw (envelope-from ) for ; Fri, 13 Nov 2020 16:20:30 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id AEFVMk6yrl9RAQAAB5/wlQ (envelope-from ) for ; Fri, 13 Nov 2020 16:20:30 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 41B779401BD for ; Fri, 13 Nov 2020 16:20:30 +0000 (UTC) Received: from localhost ([::1]:49962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdboK-00076U-Em for larch@yhetil.org; Fri, 13 Nov 2020 11:20:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdbl0-00043f-OV for guix-patches@gnu.org; Fri, 13 Nov 2020 11:17:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:37662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kdbl0-000844-Dv for guix-patches@gnu.org; Fri, 13 Nov 2020 11:17:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kdbl0-0005W2-94 for guix-patches@gnu.org; Fri, 13 Nov 2020 11:17:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#44460] Add copyright lines Resent-From: John Soo Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 13 Nov 2020 16:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44460 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 44460@debbugs.gnu.org Received: via spool by 44460-submit@debbugs.gnu.org id=B44460.160528420121167 (code B ref 44460); Fri, 13 Nov 2020 16:17:02 +0000 Received: (at 44460) by debbugs.gnu.org; 13 Nov 2020 16:16:41 +0000 Received: from localhost ([127.0.0.1]:49208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdbke-0005VK-Vs for submit@debbugs.gnu.org; Fri, 13 Nov 2020 11:16:41 -0500 Received: from mail-pg1-f169.google.com ([209.85.215.169]:33487) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdbkc-0005V6-Sc for 44460@debbugs.gnu.org; Fri, 13 Nov 2020 11:16:39 -0500 Received: by mail-pg1-f169.google.com with SMTP id r186so7477686pgr.0 for <44460@debbugs.gnu.org>; Fri, 13 Nov 2020 08:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=eSnt4I7Y9KF3jyJMnLrB3s3PymPkEVvXX1SBmjHf31o=; b=XuQIMQpb5AUN+cjf6nGZqgMVokvhuVh7z9OLjoRSIo+7xHV/lSVCcRgbpEL+f7mi4Q cSM38E7TYRUB7AHjtXA++Y7F6y5RcSrdtrgnDMSFvyUZPuc/lHgUhFxr+R/iG1ZeZdRO U38ja3Y8VCXQfWh9/awzlPu+bT7jwSmJh9fYsg9mb+Hds4ZMNgyo9jI5lsw8TgXDyRvN DHzS3oNbvnNvP13URF7FmKpq70JJqFV7Q6NvLvYy5anTtHevU3xu8J0pEIdV6QFTosxB hvRF/CKUkOGHVv/emCGOxVnkrgBX+MMohCk3LNDlz7K7FUo9U1WyirIryeZljWsc9mTD vEbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=eSnt4I7Y9KF3jyJMnLrB3s3PymPkEVvXX1SBmjHf31o=; b=H5yalPnfz3aPwO/vS1+BRFfSPSDCViVnAIz6fwyPgi3O7YrbqkMNzn4SYFlKQhiQGt lEkd1ZxpJwTdHu9S1N4tvdKuk6JJy++INVzGaw/rU0zl7oWDy8l90fZuA5h6V2GI7nXQ T0d9CIC3qgeLUQzrMpLXrb3VBdWpe3UdczR4pRkuBcdGmqQBPW2jZi8RO9y8BvYbCi09 VpjvMqpWBJYizlQBgI7jXmyPSksRrfZ03JhYojevTLsJ/fcJlpRlrT24ajkplT7ArOan 0x3QvgaETmxF2d8voihYOYbYHc2dku739mXCjzKQLi0DqCVaxa1/o4+ZZEor5wj4vhSV +V/g== X-Gm-Message-State: AOAM532W4DmO0GGUKZpQ9zq9kMQU5ZHsJPLXZqeN2GGzOj/aFKfhYKZO RKTGZx/04bU61sAvM4+Ges26gQiWja490Wfx X-Google-Smtp-Source: ABdhPJykYRAAe5f4qMDJOQ/B8PVLqbXDdjz8MOHPUeN8cZuMSUI1svo/Lp9UEDWAtkwLatnlI4x+Mg== X-Received: by 2002:a17:90a:987:: with SMTP id 7mr3814606pjo.84.1605284187548; Fri, 13 Nov 2020 08:16:27 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id q14sm8695496pfl.163.2020.11.13.08.16.26 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Nov 2020 08:16:26 -0800 (PST) From: John Soo References: <87o8kcv30a.fsf@asu.edu> <878sbeoya2.fsf@asu.edu> <87k0usn9jk.fsf@gnu.org> <87imabok8j.fsf@asu.edu> <87ft5elu45.fsf@gnu.org> <87361eoabg.fsf@asu.edu> <871rgyiajk.fsf@gnu.org> <87pn4hn7lr.fsf@asu.edu> Date: Fri, 13 Nov 2020 08:16:25 -0800 In-Reply-To: <87pn4hn7lr.fsf@asu.edu> (John Soo's message of "Thu, 12 Nov 2020 21:33:52 -0800") Message-ID: <87eekxxmee.fsf@asu.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=asu-edu.20150623.gappssmtp.com header.s=20150623 header.b=XuQIMQpb; dmarc=fail reason="SPF not aligned (relaxed)" header.from=asu.edu (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: Re9ErTtlP4Ji --=-=-= Content-Type: text/plain Hello again, No big changes here, I just forgot to update the manual again. - John --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-processes-Put-ChildProcess-and-ChildPID-on-separate-.patch Content-Transfer-Encoding: quoted-printable >From 6082c559d1200e632b3fb45eb0633d28829667a1 Mon Sep 17 00:00:00 2001 From: John Soo Date: Thu, 12 Nov 2020 21:16:48 -0800 Subject: [PATCH 1/2] processes: Put ChildProcess and ChildPID on separate lines. * guix/scripts/processes.scm: Put child process information in separate fields. * doc/guix.texi: Document change in output of guix processes. --- doc/guix.texi | 22 +++++++++++++--------- guix/scripts/processes.scm | 6 ++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 5e3e0435b4..e8814c686c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -82,6 +82,7 @@ Copyright @copyright{} 2020 Pierre Langlois@* Copyright @copyright{} 2020 pinoaffe@* Copyright @copyright{} 2020 Andr=C3=A9 Batista@* Copyright @copyright{} 2020 Alexandru-Sergiu Marton@* +Copyright @copyright{} 2020 John Soo@* =20 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -12661,9 +12662,12 @@ ClientCommand: cuirass --cache-directory /var/cach= e/cuirass @dots{} LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock -ChildProcess: 20495: guix offload x86_64-linux 7200 1 28800 -ChildProcess: 27733: guix offload x86_64-linux 7200 1 28800 -ChildProcess: 27793: guix offload x86_64-linux 7200 1 28800 +ChildPID: 20495 +ChildCommand: guix offload x86_64-linux 7200 1 28800 +ChildPID: 27733 +ChildCommand: guix offload x86_64-linux 7200 1 28800 +ChildPID: 27793 +ChildCommand: guix offload x86_64-linux 7200 1 28800 @end example =20 In this example we see that @command{guix-daemon} has three clients: @@ -12672,12 +12676,12 @@ integration tool; their process identifier (PID) = is given by the @code{ClientPID} field. The @code{SessionPID} field gives the PID of the @command{guix-daemon} sub-process of this particular session. =20 -The @code{LockHeld} fields show which store items are currently locked by = this -session, which corresponds to store items being built or substituted (the -@code{LockHeld} field is not displayed when @command{guix processes} is not -running as root). Last, by looking at the @code{ChildProcess} field, we -understand that these three builds are being offloaded (@pxref{Daemon Offl= oad -Setup}). +The @code{LockHeld} fields show which store items are currently locked +by this session, which corresponds to store items being built or +substituted (the @code{LockHeld} field is not displayed when +@command{guix processes} is not running as root). Last, by looking at +the @code{ChildPID} and @code{ChildCommand} fields, we understand that +these three builds are being offloaded (@pxref{Daemon Offload Setup}). =20 The output is in Recutils format so we can use the handy @command{recsel} command to select sessions of interest (@pxref{Selection Expressions,,, diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index b4ca7b1687..3a7ea0b89c 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2018, 2019, 2020 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 John Soo ;;; ;;; This file is part of GNU Guix. ;;; @@ -188,8 +189,9 @@ active sessions, and the master 'guix-daemon' process." (format port "LockHeld: ~a~%" lock)) (daemon-session-locks-held session)) (for-each (lambda (process) - (format port "ChildProcess: ~a:~{ ~a~}~%" - (process-id process) + (format port "ChildPID: ~a~%" + (process-id process)) + (format port "ChildCommand: :~{ ~a~}~%" (process-command process))) (daemon-session-children session))) =20 --=20 2.29.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-processes-Optionally-normalize-recutils-output.patch >From becf3a8fee4aea0a49dde47f5728410b97d94fbf Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 4 Nov 2020 07:51:52 -0800 Subject: [PATCH 2/2] processes: Optionally normalize recutils output. * guix/scripts/processes.scm: Add "format" and "list-formats" flag. * doc/guix.texi: Document new flags. --- doc/guix.texi | 38 ++++++++++ guix/scripts/processes.scm | 144 ++++++++++++++++++++++++++++++++----- 2 files changed, 163 insertions(+), 19 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index e8814c686c..d67ccd8acc 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12695,6 +12695,44 @@ ClientPID: 19419 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{} @end example +Additional options are listed below. + +@table @code +@item --format=@var{format} +@itemx -f @var{format} +Produce output in the specified @var{format}, one of: + +@table @code +@item recutils +The default option. It outputs a set of Session recutils records +that include each ChildProcess as a field. + +@item normalized +Normalize the output records into record sets (@pxref{Record Sets,,, +recutils, GNU recutils manual}). Normalizing into record sets allows +joins across record types. The example below lists the PID of each +ChildProcess and the associated PID for Session that spawned the +ChildProcess where the Session was started using guix build. + +@example +$ guix processes --format=normalized | \ + recsel \ + -j Session \ + -t ChildProcess \ + -p Session.PID,PID \ + -e 'Session.ClientCommand ~ "guix build'" +PID: 4435 +Session_PID: 4278 + +PID: 4554 +Session_PID: 4278 + +PID: 4646 +Session_PID: 4278 +@end example +@end table +@end table + @node System Configuration @chapter System Configuration diff --git a/guix/scripts/processes.scm b/guix/scripts/processes.scm index 3a7ea0b89c..bcc541badb 100644 --- a/guix/scripts/processes.scm +++ b/guix/scripts/processes.scm @@ -177,6 +177,9 @@ active sessions, and the master 'guix-daemon' process." (values (filter-map child-process->session children) master))) +(define (lock->recutils lock port) + (format port "LockHeld: ~a~%" lock)) + (define (daemon-session->recutils session port) "Display SESSION information in recutils format on PORT." (format port "SessionPID: ~a~%" @@ -185,8 +188,7 @@ active sessions, and the master 'guix-daemon' process." (process-id (daemon-session-client session))) (format port "ClientCommand:~{ ~a~}~%" (process-command (daemon-session-client session))) - (for-each (lambda (lock) - (format port "LockHeld: ~a~%" lock)) + (for-each (lambda (lock) (lock->recutils lock port)) (daemon-session-locks-held session)) (for-each (lambda (process) (format port "ChildPID: ~a~%" @@ -195,19 +197,102 @@ active sessions, and the master 'guix-daemon' process." (process-command process))) (daemon-session-children session))) +(define (daemon-sessions->recutils port sessions) + "Display denormalized SESSIONS information to PORT." + (for-each (lambda (session) + (daemon-session->recutils session port) + (newline port)) + sessions)) + +(define session-rec-type + "%rec: Session +%type: PID int +%type: ClientPID int +%key: PID +%mandatory: ClientPID ClientCommand") + +(define lock-rec-type + "%rec: Lock +%mandatory: LockHeld +%type: Session rec Session") + +(define child-process-rec-type + "%rec: ChildProcess +%type: PID int +%type: Session rec Session +%key: PID +%mandatory: Command") + +(define (session-key->recutils session port) + "Display SESSION PID as a recutils field on PORT." + (format + port "Session: ~a" + (process-id (daemon-session-process session)))) + +(define (session-scalars->normalized-record session port) + "Display SESSION scalar fields to PORT in normalized form." + (format port "PID: ~a~%" + (process-id (daemon-session-process session))) + (format port "ClientPID: ~a~%" + (process-id (daemon-session-client session))) + (format port "ClientCommand:~{ ~a~}~%" + (process-command (daemon-session-client session)))) + +(define (child-process->normalized-record process port) + "Display PROCESS record on PORT in normalized form" + (format port "PID: ~a" (process-id process)) + (newline port) + (format port "Command:~{ ~a~}" (process-command process))) + +(define (daemon-sessions->normalized-record port sessions) + "Display SESSIONS recutils on PORT in normalized form" + (display session-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (session-scalars->normalized-record session port) + (newline port)) + sessions) + + (display lock-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (lock) + (lock->recutils "testing testing" port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-locks-held session))) + sessions) + + (display child-process-rec-type port) + (newline port) + (newline port) + (for-each (lambda (session) + (for-each (lambda (process) + (child-process->normalized-record process port) + (newline port) + (session-key->recutils session port) + (newline port) + (newline port)) + (daemon-session-children session))) + sessions)) + ;;; ;;; Options. ;;; -(define %options - (list (option '(#\h "help") #f #f - (lambda args - (show-help) - (exit 0))) - (option '(#\V "version") #f #f - (lambda args - (show-version-and-exit "guix processes"))))) +(define %available-formats + '("recutils" "normalized")) + +(define (list-formats) + (display (G_ "The available formats are:\n")) + (newline) + (for-each (lambda (f) + (format #t " - ~a~%" f)) + %available-formats)) (define (show-help) (display (G_ "Usage: guix processes @@ -218,8 +303,33 @@ List the current Guix sessions and their processes.")) (display (G_ " -V, --version display version information and exit")) (newline) + (display (G_ " + -f, --format=FORMAT display results as normalized record sets")) + (display (G_ " + --list-formats display available formats")) + (newline) (show-bug-report-information)) +(define %options + (list (option '(#\h "help") #f #f + (lambda args + (show-help) + (exit 0))) + (option '(#\V "version") #f #f + (lambda args + (show-version-and-exit "guix processes"))) + (option '(#\f "format") #t #f + (lambda (opt name arg result) + (unless (member arg %available-formats) + (leave (G_ "~a: unsupported output format~%") arg)) + (alist-cons 'format (string->symbol arg) result))) + (option '("list-formats") #f #f + (lambda (opt name arg result) + (list-formats) + (exit 0))))) + +(define %default-options '((format . recutils))) + ;;; ;;; Entry point. @@ -229,17 +339,13 @@ List the current Guix sessions and their processes.")) (category plumbing) (synopsis "list currently running sessions") (define options - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - cons - '())) + (parse-command-line args %options (list %default-options))) (with-paginated-output-port port - (for-each (lambda (session) - (daemon-session->recutils session port) - (newline port)) - (daemon-sessions)) + (match (assoc-ref options 'format) + ('normalized + (daemon-sessions->normalized-record port (daemon-sessions))) + (_ (daemon-sessions->recutils port (daemon-sessions)))) ;; Pass 'R' (instead of 'r') so 'less' correctly estimates line length. #:less-options "FRX")) -- 2.29.1 --=-=-=--