I recently created a script that I run on all of our celerras and VNX’s that reports on NAS pool size. The output from each array is then converted to HTML and combined on a single intranet page to provide a quick at-a-glance view of our global NAS capacity and disk space consumption.
The default command unfortunately outputs in Megabytes with no option to change to GB or TB. This script performs the MB to GB conversion and adds a comma as the numerical separator (what we use in the USA) to make the output much more readable.
First, identify the ID number for each of your NAS pools. You’ll need to insert the ID numbers into the script itself.
[nasadmin@celerra]$ nas_pool -listid inuse acl name storage system
10 y 0 NAS_Pool0_SPA AKM00111000000
18 y 0 NAS_Pool1_SPB AKM00111000000
Note that the default output of the command that provides the size of each pool is in a very hard to read format. I wanted to clean it up to make it easier to read on our reporting page. Here’s the default output:
[nasadmin@celerra]$ nas_pool -size -all id = 10 name = NAS_Pool0_SPA used_mb = 3437536 avail_mb = 658459 total_mb = 4095995 potential_mb = 0 id = 18 name = NAS_Pool1_SPB used_mb = 2697600 avail_mb = 374396 total_mb = 3071996 potential_mb = 1023998My script changes the output to look like the example below.
Name (Site) ; Total GB ; Used GB ; Avail GBNAS_Pool0_SPA ; 4,000 ; 3,356.97 ; 643.03
NAS_Pool1_SPB ; 3,000 ; 2,634.38 ; 365.62
In this example there are two NAS pools and this script is set up to report on both. It could be easily expanded or reduced depending on the number of pools on your array. The variable names I used include the Pool ID number from the output above, that should be changed to match your ID’s. You’ll also need to update the ‘id=<xx>’ portion of each command to match your Pool ID’s.
Here’s the script:
#!/bin/bash NAS_DB=”/nas” export NAS_DB # Set the Locale to English/US, used for adding the comma as a separator in a cron job export LC_NUMERIC=”en_US.UTF-8″ TODAY=$(date) # Gather Pool Name, Used MB, Avaialble MB, and Total MB for First Pool # Set variable to pull the Name of the pool from the output of ‘nas_pool -size’. name18=`/nas/bin/nas_pool -size id=18 | /bin/grep name | /bin/awk ‘{print $3}’` # Set variable to pull the Used MB of the pool from the output of ‘nas_pool -size’. usedmb18=`/nas/bin/nas_pool -size id=18 | /bin/grep used_mb | /bin/awk ‘{print $3}’` # Set variable to pull the Available MB of the pool from the output of ‘nas_pool -size’. availmb18=`/nas/bin/nas_pool -size id=18 | /bin/grep avail_mb | /bin/awk ‘{print $3}’` # Set variable to pull the Total MB of the pool from the output of ‘nas_pool -size’. totalmb18=`/nas/bin/nas_pool -size id=18 | /bin/grep total_mb | /bin/awk ‘{print $3}’` # Convert MB to GB, Add Comma as separator in output # Remove ‘…b’ variables if you don’t want commas as a separator # Convert Used MB to Used GB usedgb18=`/bin/echo $usedmb18/1024 | /usr/bin/bc -l | /bin/sed ‘s/^\./0./;s/0*$//;s/0*$//;s/\.$//’` # Add comma separator usedgb18b=`/usr/bin/printf “%’.2f\n” “$usedgb18″ | /bin/sed ‘s/\.00$// ; s/\(\.[1-9]\)0$/\1/’` # Convert Available MB to Available GB availgb18=`/bin/echo $availmb18/1024 | /usr/bin/bc -l | /bin/sed ‘s/^\./0./;s/0*$//;s/0*$//;s/\.$//’` # Add comma separator availgb18b=`/usr/bin/printf “%’.2f\n” “$availgb18″ | /bin/sed ‘s/\.00$// ; s/\(\.[1-9]\)0$/\1/’` # Convert Total MB to Total GB totalgb18=`/bin/echo $totalmb18/1024 | /usr/bin/bc -l | /bin/sed ‘s/^\./0./;s/0*$//;s/0*$//;s/\.$//’` # Add comma separator totalgb18b=`/usr/bin/printf “%’.2f\n” “$totalgb18″ | /bin/sed ‘s/\.00$// ; s/\(\.[1-9]\)0$/\1/’` # Gather Pool Name, Used MB, Avaialble MB, and Total MB for Second Pool # Set variable to pull the Name of the pool from the output of ‘nas_pool -size’. name10=`/nas/bin/nas_pool -size id=10 | /bin/grep name | /bin/awk ‘{print $3}’` # Set variable to pull the Used MB of the pool from the output of ‘nas_pool -size’. usedmb10=`/nas/bin/nas_pool -size id=10 | /bin/grep used_mb | /bin/awk ‘{print $3}’` # Set variable to pull the Available MB of the pool from the output of ‘nas_pool -size’. availmb10=`/nas/bin/nas_pool -size id=10 | /bin/grep avail_mb | /bin/awk ‘{print $3}’` # Set variable to pull the Total MB of the pool from the output of ‘nas_pool -size’. totalmb10=`/nas/bin/nas_pool -size id=10 | /bin/grep total_mb | /bin/awk ‘{print $3}’` # Convert MB to GB, Add Comma as separator in output # Remove ‘…b’ variables if you don’t want commas as a separator # Convert Used MB to Used GB usedgb10=`/bin/echo $usedmb10/1024 | /usr/bin/bc -l | /bin/sed ‘s/^\./0./;s/0*$//;s/0*$//;s/\.$//’` # Add comma separator usedgb10b=`/usr/bin/printf “%’.2f\n” “$usedgb10″ | /bin/sed ‘s/\.00$// ; s/\(\.[1-9]\)0$/\1/’` # Convert Available MB to Available GB availgb10=`/bin/echo $availmb10/1024 | /usr/bin/bc -l | /bin/sed ‘s/^\./0./;s/0*$//;s/0*$//;s/\.$//’` # Add comma separator availgb10b=`/usr/bin/printf “%’.2f\n” “$availgb10″ | /bin/sed ‘s/\.00$// ; s/\(\.[1-9]\)0$/\1/’` # Convert Total MB to Total GB totalgb10=`/bin/echo $totalmb10/1024 | /usr/bin/bc -l | /bin/sed ‘s/^\./0./;s/0*$//;s/0*$//;s/\.$//’` # Add comma separator totalgb10b=`/usr/bin/printf “%’.2f\n” “$totalgb10″ | /bin/sed ‘s/\.00$// ; s/\(\.[1-9]\)0$/\1/’` # Create Output File # If you don’t want the comma separator in the output file, substitute the variable without the ‘b’ at the end. # I use the semicolon rather than the comma as a separator due to the fact that I’m using the comma as a numerical separator. # The comma could be substituted here if desired. /bin/echo $TODAY > /scripts/NasPool.txt /bin/echo “Name” “;” “Total GB” “;” “Used GB” “;” “Avail GB” >> /scripts/NasPool.txt /bin/echo $name18 “;” $totalgb18b “;” $usedgb18b “;” $availgb18b >> /scripts/NasPool.txt /bin/echo $name10 “;” $totalgb10b “;” $usedgb10b “;” $availgb10b >> /scripts/NasPool.txtHere’s what the Output looks like:
Wed Jul 17 23:56:29 JST 2013Name (Site) ; Total GB ; Used GB ; Avail GB
NAS_Pool0_SPA ; 4,000 ; 3,356.97 ; 643.03
NAS_Pool1_SPB ; 3,000 ; 2,634.38 ; 365.62
I use a cron job to schedule the report daily and copy it to our internal web server. I then run the csv2html.pl perl script (from http://www.jpsdomain.org/source/perl.html) to convert it to an HTML output file to add to our intranet report page.
Note that I had to modify the csv2html.pl command to accomodate the use of a semicolon instead of the default comma in a csv file. Here is the command I use to do the conversion:
./csv2htm.pl -e -T -D “;” -i /reports/NasPool.txt -o /reports/NasPool.htmlBelow is what the output looks like after running the HTML conversion tool.