<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: vs_corexl_check: a tool for a quick overview of VSX CoreXL allocation in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/vs-corexl-check-a-tool-for-a-quick-overview-of-VSX-CoreXL/m-p/148590#M6813</link>
    <description>&lt;P&gt;Code has been updated to also provide connections peak/limit per VS and provide a ratio with percentage, below 75%: OK, green, between 75% and&amp;nbsp; 85% Warning, yellow, above 85% Critical, red, probably time to update that connections limit.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vs_corexl_check_conns.png" style="width: 853px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/16537iD997A4E86D07C953/image-size/large?v=v2&amp;amp;px=999" role="button" title="vs_corexl_check_conns.png" alt="vs_corexl_check_conns.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 13 May 2022 16:11:14 GMT</pubDate>
    <dc:creator>Alex-</dc:creator>
    <dc:date>2022-05-13T16:11:14Z</dc:date>
    <item>
      <title>vs_corexl_check: a tool for a quick overview of VSX CoreXL allocation</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/vs-corexl-check-a-tool-for-a-quick-overview-of-VSX-CoreXL/m-p/148211#M6810</link>
      <description>&lt;P&gt;Here's a tool to quickly check the CoreXL allocation of all your VS.&lt;/P&gt;&lt;P&gt;Copy it on your VSX gateway and chmod+x, make sure to run it on the standby unit first to ensure it doesn't interfere with your systems.&lt;/P&gt;&lt;P&gt;It will take into account that you can have non-contiguous Virtual System ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/bin/bash

#Functions
function display_help () {
echo "Displays VS CoreXL allocations and connections ratios."
echo "Options:"
echo "  -h: Display this help"
echo "  -v: Display version"
echo "  -w: Save output in web version to /var/tmp/vs_corexl_check.html"
echo "  -s: Display output to terminal"
exit $2
}


#Initialize global empy argument variables
version=''
web=''
screen=''
echo $version
while getopts 'hwvs' flag
do
    case "${flag}" in
        v) version=1;;
        h) help=1;;
        w) web=1;;
        s) screen=1;;
    esac
done

if [[ "$version" -eq 1 ]];then
echo "Version 1.0"
exit 2
fi

if [[ "$help" -eq 1 ]];then
display_help
fi

#Import the vsenv shell to run vsenv commands
source /etc/profile.d/vsenv.sh

#Check if this is a VSX system, if not exit with error code 1.
vsenv 2&amp;amp;&amp;gt; /dev/null
if [[ ! "$? -eq 0" ]]; then
echo "This is not a VSX system, exiting. Run with the -h flag to get all options."
exit 1
fi

#System variable definitions
#---------------------------

t=0             #Assigned CoreXL instance counter
array_offset=1  #Since arrays begin with an index of 0 but VS count starts at 1
array_index=0   #Base array index is 0
chassis_name=`hostname`

#Screen version
if [[ "$screen" -eq 1 ]];then
#Initialize display and arrays
clear
echo "VSX CoreXL allocation summary"
echo "-----------------------------"
echo "Chassis name: $chassis_name"
printf "\n"

#Read the output of vsx stat -v and search for virtual systems
readarray -t vs_index &amp;lt; &amp;lt;(vsx stat -v | awk '{if ($3 == "S") print $1}')
readarray -t vs_name &amp;lt; &amp;lt;(vsx stat -v | awk '{if ($3 == "S") print $4}')
declare -p vs_list &amp;amp;&amp;gt;/dev/null
declare -p vs_name &amp;amp;&amp;gt;/dev/null

#Initialize for loop and match array index

for i in ${vs_index[@]}
do
evaluator=$(($array_index+1))


#Verifiy if there is not a gap in VS index

if [[ ! " $evaluator -eq  $array_index " ]]; then
array_index=$(($array_index + 2))
fi

#Display results

corecount=(`cpwd_admin list -ctx $i | grep _wd | awk {'print $11'}`)
conns_count=(`vsx stat -l $i | grep peak | awk '{print $3}'`)
conns_limit=(`vsx stat -l $i | grep limit | awk '{print $3}'`)
conns_ratio=(`echo "scale=2; ($conns_count / $conns_limit) * 100" | bc`)
if (( $(bc &amp;lt;&amp;lt;&amp;lt; "$conns_ratio&amp;lt;=75") )); then conn_color=2; elif
 (( $(bc &amp;lt;&amp;lt;&amp;lt; "$conns_ratio&amp;gt;75 &amp;amp;&amp;amp; $conns_ratio&amp;lt;=85") )); then conn_color=3; else
 conn_color=1; fi
if [ "$corecount" -eq 1 ]; then
echo "Virtual system ID $i with name ${vs_name[$array_index]} has CoreXL disabled"
else
echo "Virtual System ID $i with name ${vs_name[$array_index]} has been assigned $corecount CoreXL instances"
fi
echo "Peak connections#: $conns_count"
echo "Connections limit#: $conns_limit"
echo "Connections ratio: $(tput setaf $conn_color) $conns_ratio% $(tput setaf 7)"
echo "--"
array_index=$(($array_index+$array_offset))
t=$(($t + $corecount))
done
printf "\n"
echo "A total of $t CoreXL instances have been assigned between all virtual systems."
exit 0
fi

#Web version
if [[ "$web" -eq 1 ]];then
#Initialize display and arrays
clear
echo "&amp;lt;html&amp;gt;&amp;lt;header&amp;gt;&amp;lt;title&amp;gt;vs_corexl_check&amp;lt;/title&amp;gt;&amp;lt;style&amp;gt;table, th, td {border: 1px solid black;border-collapse: collapse;padding: 5pt;align-items: center;} body {font-family: sans-serif;background-color: white;}&amp;lt;/style&amp;gt;&amp;lt;/header&amp;gt;&amp;lt;body&amp;gt;" &amp;gt; /var/tmp/vs_corexl_check.html
echo "&amp;lt;body&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html
echo "&amp;lt;img src=\"https://sc1.checkpoint.com/www/images/layout/duke/check-point-logo.png\"&amp;gt; &amp;lt;h1&amp;gt;VSX CoreXL and connections for $chassis_name&amp;lt;/h1&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html
echo "&amp;lt;table&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html
echo "&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;VS Index&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;VS name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;CoreXL Instances&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Connections max/limit&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Connections Ratio&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html

#Read the output of vsx stat -v and search for virtual systems
readarray -t vs_index &amp;lt; &amp;lt;(vsx stat -v | awk '{if ($3 == "S") print $1}')
readarray -t vs_name &amp;lt; &amp;lt;(vsx stat -v | awk '{if ($3 == "S") print $4}')
declare -p vs_list &amp;amp;&amp;gt;/dev/null
declare -p vs_name &amp;amp;&amp;gt;/dev/null

#Initialize for loop and match array index

for i in ${vs_index[@]}
do
evaluator=$(($array_index+1))


#Verifiy if there is not a gap in VS index

if [[ ! " $evaluator -eq  $array_index " ]]; then
array_index=$(($array_index + 2))
fi

#Display results
clear;
echo "Processing VS $i of ${vs_index[-1]}"
echo "&amp;lt;tr&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html
corecount=(`cpwd_admin list -ctx $i | grep _wd | awk {'print $11'}`)
conns_count=(`vsx stat -l $i | grep peak | awk '{print $3}'`)
conns_limit=(`vsx stat -l $i | grep limit | awk '{print $3}'`)
conns_ratio=(`echo "scale=2; ($conns_count / $conns_limit) * 100" | bc`)
if (( $(bc &amp;lt;&amp;lt;&amp;lt; "$conns_ratio&amp;lt;=75") )); then conn_color="lightgreen"; elif
 (( $(bc &amp;lt;&amp;lt;&amp;lt; "$conns_ratio&amp;gt;75 &amp;amp;&amp;amp; $conns_ratio&amp;lt;=85") )); then conn_color="lightsalmon"; else
 conn_color="lightcoral"; fi
if [ "$corecount" -eq 1 ]; then
echo "&amp;lt;td&amp;gt;$i&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;${vs_name[$array_index]}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Off&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$conns_count / $conns_limit&amp;lt;/td&amp;gt;&amp;lt;td style=\"background-color:$conn_color;\"&amp;gt;$conns_ratio&amp;lt;/td&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html
else
echo "&amp;lt;td&amp;gt;$i&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;${vs_name[$array_index]}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$corecount&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;$conns_count / $conns_limit&amp;lt;/td&amp;gt;&amp;lt;td style=\"background-color:$conn_color;\"&amp;gt;$conns_ratio&amp;lt;/td&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html
fi
array_index=$(($array_index+$array_offset))
t=$(($t + $corecount))
echo "&amp;lt;/tr&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html
done
echo "&amp;lt;tr&amp;gt;&amp;lt;td colspan=\"5\"&amp;gt;A total of $t CoreXL instances has been assigned.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html
echo "&amp;lt;/table&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html
echo "&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;" &amp;gt;&amp;gt; /var/tmp/vs_corexl_check.html
echo "Iteration done. Output can be found in /var/tmp/vs_corexl_check.html"
exit 0
fi

#By default, display help if no option was chosen
display_help&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 07:42:03 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/vs-corexl-check-a-tool-for-a-quick-overview-of-VSX-CoreXL/m-p/148211#M6810</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2022-07-05T07:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: vs_corexl_check: a tool for a quick overview of VSX CoreXL allocation</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/vs-corexl-check-a-tool-for-a-quick-overview-of-VSX-CoreXL/m-p/148590#M6813</link>
      <description>&lt;P&gt;Code has been updated to also provide connections peak/limit per VS and provide a ratio with percentage, below 75%: OK, green, between 75% and&amp;nbsp; 85% Warning, yellow, above 85% Critical, red, probably time to update that connections limit.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vs_corexl_check_conns.png" style="width: 853px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/16537iD997A4E86D07C953/image-size/large?v=v2&amp;amp;px=999" role="button" title="vs_corexl_check_conns.png" alt="vs_corexl_check_conns.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 16:11:14 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/vs-corexl-check-a-tool-for-a-quick-overview-of-VSX-CoreXL/m-p/148590#M6813</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2022-05-13T16:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: vs_corexl_check: a tool for a quick overview of VSX CoreXL allocation</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/vs-corexl-check-a-tool-for-a-quick-overview-of-VSX-CoreXL/m-p/148627#M6814</link>
      <description>&lt;P&gt;Can confirm this works on R81.10 with JHFA45 VSX system.&lt;/P&gt;</description>
      <pubDate>Sat, 14 May 2022 18:00:53 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/vs-corexl-check-a-tool-for-a-quick-overview-of-VSX-CoreXL/m-p/148627#M6814</guid>
      <dc:creator>genisis__</dc:creator>
      <dc:date>2022-05-14T18:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: vs_corexl_check: a tool for a quick overview of VSX CoreXL allocation</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/vs-corexl-check-a-tool-for-a-quick-overview-of-VSX-CoreXL/m-p/152307#M6942</link>
      <description>&lt;P&gt;Code has been updated. The script will now prompt the user for an option instead of starting as it can take some time on larger VSX environments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;./vs_corexl_check

Displays VS CoreXL allocations and connections ratios.
Options:
  -h: Display this help
  -v: Display version
  -w: Save output in web version to /var/tmp/vs_corexl_check.html
  -s: Display output to terminal&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A new option to save the output in an HTML page has been added and looks like this, with real chassis and VS names of course.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vs_corexl_check_html.png" style="width: 772px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/17102iB11740BA0380F759/image-size/large?v=v2&amp;amp;px=999" role="button" title="vs_corexl_check_html.png" alt="vs_corexl_check_html.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another approach is to use the script repository in Smart Console.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="script_repository_output.png" style="width: 789px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/17104iBBA8E8D42DED424B/image-size/large?v=v2&amp;amp;px=999" role="button" title="script_repository_output.png" alt="script_repository_output.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="script_repository.png" style="width: 914px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/17103i37213BA9ADEFAAD0/image-size/large?v=v2&amp;amp;px=999" role="button" title="script_repository.png" alt="script_repository.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Comments and suggestions are welcome.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 07:41:45 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/vs-corexl-check-a-tool-for-a-quick-overview-of-VSX-CoreXL/m-p/152307#M6942</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2022-07-05T07:41:45Z</dc:date>
    </item>
  </channel>
</rss>

