Starting tactic script for CPU allocation calculations on POWER9/10

Based on Earl Jew’s presentation on the 6th of October 2022, “Simplest starting tactic for Power10 AIX exploitation V1.2″. Excellent IBM POWER VUG materials can be found here:

https://ibm.ent.box.com/s/6hn2orvig4r2peu6e39owmp07ewyyf4x

And the meeting presentation replay here:

https://ibm.ent.box.com/s/5atsp26sxup1ob04c3urbkiovj8epbax

This is an analytic way to calculate the virtual processors (vCPU) and entitlement (eCPU) on IBM POWER LPARs based on actual load during busy periods of the system. It is a starting tactic, so rinse-and-repeat.

The script below crunches the numbers for Earl’s eCPU/vCPU calculations. To gather data, as it says at the beginning of the script, setup a cron job to run:

uptime | awk '{ print $(NF-2),$(NF-1),$NF }' | tr -d ',' >>/tmp/uptime.out

every twenty minutes or so, for three weeks (give or take), then run this script.

The script finds the highest 5-minute number, which gives the peak number of threads requesting CPU time, and rounds up to nearest vCPU * SMT# to go above that.

It also does a running calculation of the busiest 5 runs, equaling 1h40m, and calculates the eCPU needed based on the average of all 1-, 5- & 15-minute loads divided by the SMT# for the LPAR.

#!/bin/ksh93

###############################################
#
# eCPU/vCPU planning script
#
# 2022-10-26 Henrik Morsing     1.0     Initial
#

ver=1.0

# Run:
# uptime | awk '{ print $(NF-2),${NF-1),$NF }' | tr -d ',' >>/tmp/uptime.out
# every twenty minutes for three weeks

sum5=0
sum5_max=0
sum5_avg_max=0
max5=0
# DBG=1 # Uncomment for running calculation output

# Find SMT#?

if [[ "$(uname)" == "AIX" ]]
then
   smt="$(smtctl | grep "SMT threads per processor" | awk '{ print $6 }')"
else
   smt_temp="$(dmesg | grep "CPU maps initialized for" | awk '{ print $7 }')"
   smt=${smt_temp:-8}
fi

echo
echo "Running on $(uname -n), ${smt} SMT system. Current load:"
uptime
echo
echo "Analysing $(wc -l /tmp/uptime.out) load entries."

[[ $(wc -l /tmp/uptime.out | cut -f 1 -d " ") -lt 1000 ]] && echo "(Is that enough?)"
echo

typeset -A last

while read m1 m5 m15
do

   # Firstly store last five values

   last[5][5]=${last[5][4]:-0}
   last[5][4]=${last[5][3]:-0}
   last[5][3]=${last[5][2]:-0}
   last[5][2]=${last[5][1]:-0}
   last[5][1]=${m5}

   last[15][5]=${last[15][4]:-0}
   last[15][4]=${last[15][3]:-0}
   last[15][3]=${last[15][2]:-0}
   last[15][2]=${last[15][1]:-0}
   last[15][1]=${m15}

   last[1][5]=${last[1][4]:-0}
   last[1][4]=${last[1][3]:-0}
   last[1][3]=${last[1][2]:-0}
   last[1][2]=${last[1][1]:-0}
   last[1][1]=${m1}


   ########
   # vCPU #
   ########

   # Store max for vCPU calculation and calculate new vCPU when new max is found

   if [[ ${m5} -gt ${max5} ]]
   then
      max5=${m5}

      # Highest 5 minute load, rounded up as per SMT#, to next number of logical processors. Divide by SMT# gives vCPUs
      # Sadly, AIX and Linux ksh93 does arithmetic differently, so will have to split this up

      vCPU=$(echo "scale=0;${max5} / ${smt} + 1" | bc -l)

      [[ -n ${DBG} ]] && echo "vCPU: "${vCPU} "based on max5: "${max5}

   fi

   ########
   # eCPU #
   ########

   # Now, sum up the last five five minute values. This is used to determine the busiest period.

   sum5=$(( ${last[5][1]}+${last[5][2]}+${last[5][3]}+${last[5][4]}+${last[5][5]} ))

   # And sum up all values, this is used for the actual calculation.

   sum_all=$(( ${last[1][1]}+${last[1][2]}+${last[1][3]}+${last[1][4]}+${last[1][5]}+${last[5][1]}+${last[5][2]}+${last[5][3]}+${last[5]
[4]}+${last[5][5]}+${last[15][1]}+${last[15][2]}+${last[15][3]}+${last[15][4]}+${last[15][5]} ))


   # Keep track of max. When we hit a new max, calculate new eCPU/vCPU pair

   if [[ ${sum5} -gt ${sum5_avg_max} ]]
   then
      # Store max value
      sum5_avg_max=${sum5}

      # Rather than storing all values, just calculate eCPU straight away

      eCPU_temp=$(echo "scale=2;${sum_all} / 15 / ${smt}" | bc -l)

      # We don't want to discard previous higher values of eCPU
      if [[ "${eCPU_temp}" -gt "${eCPU}" ]]
      then
         eCPU=${eCPU_temp}
      else
         [[ -n ${DBG} ]] && echo "eCPU calculation discarded"
      fi

      [[ -n ${DBG} ]] && echo "eCPU: "${eCPU}

   fi


done </tmp/uptime.out

echo "Final calculation:"
echo "eCPU / vCPU: "${eCPU}" / "${vCPU}" - Ratio: "$(( ${vCPU} / ${eCPU} ))

exit 0

Posted in AIX, IBM POWER, Linux, Performance tuning, Scripting | Tagged , , , , , , , | 1 Comment

NIM certificate issues?

NIM is great, right up to the point where it stops working!

Getting this error:

0042-404 nconn: Error connecting to SSL object.
0042-406 nconn: Error verifying SSL object after connection.
405 nconn: Error with certificate at depth .

This means the client certificate for nimsh isn’t working. You might have been Googling and be told nimclient -c or niminit might fix the problem, but it didn’t for me. Here is what did:

  • Move /ssl_nimsh/certs/.0 out of the way on the client
  • Copy /ssl_nimsh/certs/client.pem from the master in place of the moved file
  • Restart nimsh – stop/startsrc -s nimsh

Fixed it for me…

Posted in AIX | Tagged , , , | Leave a comment

Growing SAN LUN on Linux

This procedure works on SLES 15, should work on RHEL, but not yet tested.

This script is for growing SAN LUNs running via multipath on Linux. Makes it look like AIX and just as easy!

Growing SAN LUNs in Linux is a rather frustrating affair, as Googling the subject will tell you. As many different methods as Google hits. This script, ‘chvg’, combines the tools needed, and targets only the volume group you have extended LUNs for.

#!/bin/bash

####################################
# chvg script to increase disk in VG
####################################

# Version history
#
# 2022-09-14    HM      1.0     Initial
#

ver=1.0

# Set variables
today="$(date +%Y-%m-%d)"

# Setup a little usage function
helpFunction()
{
   echo ""
   echo "Usage: $0 -g <Volume Group>"
   echo -e "\t-g Update size of disks in volume group"
   exit 1 # Exit script after printing help
}

# Set a bogus VG to pick up running script with no arguments
VG="Gobbledegook"

# Pick out options
while getopts "g:" opt
do
   case "$opt" in
      g ) VG="$OPTARG" ;;
      ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent
   esac
done

# If VG isn't right, exit with help text
vgs ${VG} >/dev/null 2>&1 || helpFunction

# Save a copy of the current multipathed disks
multipath -ll > /tmp/multipath.before.out.${today}

# Find disks in VG
disks="$(pvs | grep -w ${VG} | awk '{ print $1 }' | awk -F/ '{ print $NF }' | tr '\n' '
')"

# Find paths
for disk in ${disks}
do
   # Find first set of paths
   paths1="$(multipath -ll ${disk} | grep -v -- "-+-" | grep "| |-" | awk '{ print $4 }')"

   # Find second set of paths
   paths2="$(multipath -ll ${disk} | grep -v -- "-+-" | grep -v "| |-" | grep "|-" | awk '{ print $3 }')"

   # Find last disk in first set
   paths3="$(multipath -ll ${disk} | grep -- "| \`-" | awk '{ print $4 }')"

   # Find last disk in second set
   paths4="$(multipath -ll ${disk} | grep -- "  \`-" | awk '{ print $3 }')"

   # Add to full list of paths
   allpaths=${allpaths}" "${paths1}" "${paths2}" "${paths3}" "${paths4}
done

# Now set the paths to rescan
for path in ${allpaths}
do
   # Write a true to the rescan parameter for the device
   echo 1 > /sys/block/${path}/device/rescan
done

# Now restart multipathd to rescan ("Linux" magic)
systemctl restart multipathd

# And save the new multipath output
multipath -ll > /tmp/multipath.after.out.${today}

# Resize the PVs in the VG
for pv in ${disks}
do
   pvresize /dev/mapper/${pv}
done

exit 0
Posted in Linux, Scripting | Tagged , , , , | Leave a comment

Adding applications to Gnome’s favourites

Having pushed out an application to a stack of workstations, I was looking for an easy command line way to programmatically add it to the favourite / side-bar in Gnome. Annoyingly, the only method I found (the one Google finds with “00-favorite-apps” doesn’t work) has to be run as the actual user and only does one user at a time.

dbus-launch gsettings set org.gnome.shell favorite-apps "['google-chrome.desktop', 'nautilus.desktop', 'gnome-terminal.desktop', 'blender.desktop', 'Autodesk-Maya2022.desktop']"

Posted in Linux | Tagged , , , | Leave a comment

Maya and Houdini headless install

Starting a job in the animation industry, I looked into automating the tools Maya and Houdini, Maya apparently being a must for most people (No, I’d never heard of either).

Maya consists of an RPM for the application plus three RPMs for the licence system (this is for the 2022 version), interspersed with running some licence server initialisation scripts. Run the below steps from my Org section as root:

  • Start by un-packing downloaded file
    tar xzf Autodesk_Maya_2022_1_ML_Linux_64bit.tgz
  • Install some OS libraries
    yum -y install libpng15 compat-openssl10 libXp libnsl libGLU
  • Install licence server components
    cd Packages; yum -y install adlmapps23-23.0.21-0.x86_64.rpm adsklicensing11.0.0.4854-0-0.x86_64.rpm adlmflexnetclient-23.0.21-0.x86_64.rpm
  • Check licence server status
    systemctl status adsklicensing
  • Install lsb core
    dnf -y install redhat-lsb-core
  • The magic step, install Maya non-interactively
    yes | rpm -ivh Maya2022_64-2022.1-579.x86_64.rpm --nodigest --nofiledigest
  • I think the following steps are licence server related
    cd /opt/Autodesk/Adlm/FLEXnet/bin
    /opt/Autodesk/Adlm/FLEXnet/bin/toolkitinstall.sh
    ./FNPLicensingService -r
    /opt/Autodesk/AdskLicensing/11.0.0.4854/helper/AdskLicensingInstHelper register -pk 657N1 -pv 2022.0.0.F -el EN_US -cf /var/opt/Autodesk/Adlm/Maya2022/MayaConfig.pit

And that’s it, easy to script/Ansibly as well. Houdini is almost simpler:

  • Install some screen saver library?
    yum -y install libXScrnSaver
  • Un-pack downloaded file
    tar xzf houdini-19.0.531-linux_x86_64_gcc9.3.tar.gz
  • cd in to un-packed directory
    cd houdini-19.0.531-linux_x86_64_gcc9.3/
  • Install Houdini
    ./houdini.install --auto-install --accept-EULA 2021-10-13 --make-dir --menus --license --houdini --install-engine-maya --make-dir /opt/houdini

Download Houdini here:

https://www.sidefx.com/download/daily-builds/

Posted in Automation, Software, VFX | Tagged , , , , , , , , | Leave a comment

Adding a Gmail account to your Mutt

Adding a Gmail IMAP inbox along-side your local mailbox can be useful to have easy access to both personal and work emails. It took a bit of fiddling around, but the recipe below worked for me.

In your standard .muttrc, at the top, just add these two lines:

unset folder
unset smtp_url

unset use_from

This ensures your personal setup does not try to contact Gmail after you have used your work profile.

Create a config for your work setup in .mutt/work.rc. Copy your standard .muttrc over, to get the same setup you are used to, then add the lines below at the top.

set imap_user = "your@work.com"
set imap_pass = "password"
set smtp_url = "smtp://your@work.com@smtp.gmail.com:587/"
set smtp_pass = "password"
set use_from=yes
set from = "your@work.com"
set realname = "Your Name"
set folder="imaps://imap.gmail.com:993"

set record="~/mail/other-sent-mail"
set postponed="=Drafts"
set spoolfile="+INBOX"
set signature="~/.mutt/signature.work"

bind index G imap-fetch-mail

The bind statement allows you to refresh the IMAP mailbox by hitting ‘G’. In your standard .muttrc, set your personal signature file:

set signature="~/.mutt/signature.personal"

Now, in both files, set folders and macros to switch between them.

# Folder hooks
mbox-hook 'mailbox' 'source ~/.muttrc'
folder-hook 'imaps://imap.gmail.com:993' 'source ~/.mutt/work.rc'
macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt.rc<enter><change-folder>/var/mail/<name><enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/work.rc<enter><change-folder>imaps://imap.gmail.com:993<enter>'

To be honest, I’m not 100% sure on the mbox-hook line, but nothing is broken, so I have left it like that. With the above lines, you can now hit <f2> and <f3> to switch between mail boxes.

Remember, with Gmail, you both need to enable IMAP and setup 2-factor authentication, or it won’t work. Then you need to “Add app password” to get the password to use in your work.rc configuration.

Have fun!

Posted in Software | Tagged , , , , | 1 Comment

Roundcube php7.4 after Debian Bullseye upgrade

I upgraded Debian Buster to Bullseye carefully following the procedure. Part of the procedure includes removing old or no longer used packages, which I think deleted something that was actually needed.

Not to worry, I managed to fix it. I think php-fpm was missing/deleted. After running ‘apt -y install php-fpm’ it started working again.

Oddly, I received these messages installing php-fpm:

NOTICE: Not enabling PHP 7.4 FPM by default.
NOTICE: To enable PHP 7.4 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.4-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Created symlink /etc/systemd/system/multi-user.target.wants/php7.4-fpm.service -> /lib/systemd/system/php7.4-fpm.service.
Setting up php-fpm (2:7.4+76) …
Processing triggers for man-db (2.9.4-2) …
Processing triggers for php7.4-fpm (7.4.21-1+deb11u1) …
NOTICE: Not enabling PHP 7.4 FPM by default.
NOTICE: To enable PHP 7.4 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.4-fpm
NOTICE: You are seeing this message because you have apache2 package installed.

Yet, despite not running the enabling or configuration commands listed, it still worked.

Posted in Linux, Software | Tagged , , , , , | Leave a comment

Concurrent/parallel or sequential LPAR migrations

When you run lslparmigr -r sys -m <system>, the value of “num_active_migr._supported” shows how many concurrent migrations are possible. For multiple partitions, LPAR names must be comma separated. The maximum number of partition names that can be specified is displayed by the “lslparmigr -r mc -F max_lpars_per_migrlpar_cmd” command.

When trying to migrate multiple LPARs at the same time, the system attempts to migrate them in parallel but only for number of allowed parallel migrations. When you reach the limit of allowed parallel migrations, the next migration will start after one finished, and so on.

The allowed parallel migration is different from one system to another. You can get current value by cli command:

lslparmigr -r sys -m system1

The command will display all partitions migration information for a managed system.

So essentially, if num_active_migr._supported is ‘2’, and you specify six LPAR names on the migration command line, it will run two in parallel until all six have been migrated.

Posted in AIX, IBM POWER | Tagged , , , | Leave a comment

Removing Java 7 on VIO 3.1

I asked IBM if I could remove Java 7 on our new VIO 3.1 instalattions, and rather than answer the question, they pointed me to this brilliant command:

updateios -remove_outdated_filesets

It happily removed old Java versions and a few other filesets and it has not caused any problems. Just a great tip.

Posted in AIX | Tagged , , , , , | Leave a comment