Hello!

Joshua M. Clulow wrote in
 <CAEwA5n+LAJU5pKB==vodiApr4DLV+t3s2D=w=h8_16za3d_...@mail.gmail.com>:
 |On Wed, 30 Oct 2024 at 16:20, Steffen Nurpmeso via austin-group-l at
 |The Open Group <[email protected]> wrote:
 |>   elif command -v kstat >/dev/null 2>&1; then
 |>           i=$(PERL5OPT= kstat -p cpu | awk '
 |>                   BEGIN{no=0; FS=":"}
 |>                   {if($2 > no) max = $2; next}
 |>                   END{print ++max}
 |>                   ')
 |>           [ $? -eq 0 ] && NPROC=$i
 |>   fi
 |>   export NPROC
 |
 |FWIW, you can just use "psrinfo -t" (for "totals") if you want the
 |online CPU count, at least on illumos systems:
 |
 |    $ uname -a
 |    SunOS vulcan 5.11 helios-2.0.22694 i86pc i386 i86pc
 |
 |    $ PERL5OPT= kstat -p cpu | awk 'BEGIN { no = 0; FS = ":"; }
 |        { if ($2 > no) max = $2; next; }
 |        END{ print ++max; }'
 |    48
 |
 |    $ psrinfo -t
 |    48

Thank you.  This does not seem to be portable to elder machines
of the OpenCSW cluster to which i thankfully have access to,
whereas the older thing -- Jörg Schilling gave me this hint in the
past, you know -- works also there:

  #?0|kent:steffen$ ssh [email protected]
  ...
  Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
  ...
  #?255|login:sdaoden$ ssh unstable9s
  Last login: Mon Sep 23 21:50:30 2024 from login.bo.opencs
  Sun Microsystems Inc.   SunOS 5.9       Generic May 2002
  ..
  #?0|unstable9s:sdaoden$ psrinfo -t
  /.SUNWnative/usr/sbin/psrinfo: illegal option -- t
  usage:
          psrinfo [-v] [-p] [processor_id ...]
          psrinfo -s [-p] processor_id
  #?2|unstable9s:sdaoden$ echo $NPROC
  32

But thanks, i think i could test this inside () and check $?, it
likely is still better than running a complete perl session.
Will do.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
|
|And in Fall, feel "The Dropbear Bard"s ball(s).
|
|The banded bear
|without a care,
|Banged on himself fore'er and e'er
|
|Farewell, dear collar bear

            • ... Steffen Nurpmeso via austin-group-l at The Open Group
    • Re: request: ma... Rob Landley via austin-group-l at The Open Group
      • Re: request... enh via austin-group-l at The Open Group
      • Re: request... Paul Smith via austin-group-l at The Open Group
        • Re: req... David A. Wheeler via austin-group-l at The Open Group
          • Re:... Steffen Nurpmeso via austin-group-l at The Open Group
  • Re: request: make [-... Steffen Nurpmeso via austin-group-l at The Open Group
    • Re: request: ma... Nick Stoughton via austin-group-l at The Open Group
      • Re: request... Steffen Nurpmeso via austin-group-l at The Open Group
        • Re: req... Joshua M. Clulow via austin-group-l at The Open Group
          • Re:... Steffen Nurpmeso via austin-group-l at The Open Group

Reply via email to