As part of my job in Oracle ACS (Advanced Customer Services) I'm handling lots of different systems and customers. Among the recent systems I worked with have been Oracle's Exalogic engineered systems. One of the things I'd never had much exposure to as a system developer/architect/middleware guy/Java dude has been storage; outside of consuming it for my photography needs.. Well, I'm always ready for a new challenge...
I'd downloaded the 7000 series storage simulator when it was released in the good old Sun days, found it fun and instructive to play around with, but as I never touched storage in any way (besides consuming it..) I forgot about it. A couple of years ago when I started working with Exalogic engineered systems it again came into light as an invaluable learning and testing tool for the embedded storage in an Exalogic; Oracle's Sun ZFS Storage 7320 Appliance.
aaaanyway... I've been "booted" into a part-time role as the interim storage/system admin/middleware/Java guy for a
client and found I needed to create the occasional report or summary or whatever.. of what's using the storage in the 7320 (as default configured for an Exalogic, 40T of disk in a mirrored configuration, yielding 18T of actual space.)
Reading the nice documentation and some articles on the Oracle Technology Network I saw great possibilities with the embedded ECMAScript3/JavaScript engine in the 7000 series.
In my personal opinion anyone who's dealing with Exalogic administration, or exposed to any of the 7000 series of storage appliances and servers that Oracle offers should have a VirtualBox instance of it kicking around. For development and testing it's a fantastic tool. (It can save you from explaining (most) of the embarrassing FAILS you can do if you test something in a production system to your management...)
So download, and install.
A small sidestep, if after firing up the 7000 series simulator in VirtualBox you've forgotten what it's IP address is, the following will sort you out if you log in directly via the running VirtualBox VM.
So in my case I can ssh to 192.168.56.101 or point a browser to https://192.168.56.101:215 to log into the storage appliance.
One simple way of executing a script on the 7320 is to ssh to the device and redirecting a file with the script in it to ssh.
ssh
[email protected] < myscript.js
One question I got from my
client and the people who will take over the systems was: "how can we see the quotas and allocations for all projects/shares in one easy go so we don't have to go navigating around in the BUI for all the hundreds of shares the 7320 is hosting just to check if anything is running dry?"
Easy!
JavaScript time, VirtualBox and emacs!
//NOTE! this script is available 'as is' It has ben run on a couple of 7320's, (running 2010.08.17.3.0,1-1.25 &
// 2011.04.24.1.0,1-1.8) a 7420 and the VB image, but I personally
//offer no guarantee whatsoever that it won't make your server topple, catch fire or in any way go pear shaped..
//run at your own risk or learn from my code and or mistakes..
script
run('cd /');
run('shares');
//get all projects:
proj = list();
function spaceToGig(bytes){
return bytes/1073741824; //convert bytes to GB
}
function fullInPercent(quota, space_data){
tmp = (space_data/quota)*100;
return tmp;
}
//print header, slightly good looking
printf(" %s/%-15s %8s(GB) %7s(GB) %5s(GB) %7s(GB) %3s\n","Project", "Share","Quota","Ref", "Snap", "Total","%full");
printf("-------------------------------------------------------------------------------\n")
//for each project, get all shares. check for quota and calculate percentage and human readable figures..
for (i=0;i<proj.length;i++){
run('select ' + proj[i]);
//get all shares for a project
var pshares = list();
//for each share get quota properties
for (j=0;j<pshares.length;j++){
run('select ' + pshares[j]);
quota = get('quota');
//properties associated with a share or inherited from a project
spaceData = get('space_data');
spaceSnap = get('space_snapshots');
spaceTotal = get('space_total');
if(quota>0){ //has quota
printf(" %s/%-15s \t%4.2fGB\t%.2fGB\t%.2fGB\t%.2fGB\t%5.2f%%\n",proj[i], pshares[j],spaceToGig(quota),spaceToGig(spaceData),spaceToGig(spaceSnap),spaceToGig(spaceTotal),fullInPercent(quota,spaceTotal));
}else{ //no quota
printf(" %s/%-15s \t%8s\t%.2fGB\t%.2fGB\t%.2fGB\t%s\n",proj[i],pshares[j], "N/A", spaceToGig(spaceData),spaceToGig(spaceSnap),spaceToGig(spaceTotal),"N/A");
}
run('cd ..');
}
run('done');
}
The resulting output should look something like this:
Project/Share Quota(GB) Ref(GB) Snap(GB) Total(GB) %full
-------------------------------------------------------------------------------
ACSExalogicSystem/domains N/A 0.04GB 0.00GB 0.04GB N/A
ACSExalogicSystem/logs N/A 0.01GB 0.00GB 0.01GB N/A
ACSExalogicSystem/nodemgrs N/A 0.00GB 0.00GB 0.00GB N/A
ACSExalogicSystem/stores N/A 0.04GB 0.00GB 0.04GB N/A
***_dev/FMW_***_1 133GB 4.24GB 0.01GB 4.25GB 3.19%
***_dev/FMW_***_2 N/A 4.25GB 0.01GB 4.26GB N/A
***_dev/applications 10GB 0.00GB 0.00GB 0.00GB 0.00%
***_dev/domains 50GB 10.75GB 3.55GB 14.30GB 28.61%
***_dev/logs 20GB 0.32GB 0.01GB 0.33GB 1.66%
***_dev/softwaredepot 20GB 4.15GB 0.00GB 4.15GB 20.73%
***_dev/stores 20GB 0.01GB 0.00GB 0.01GB 0.05%
###_dev/FMW_###_1 400GB 17.63GB 0.12GB 17.75GB 4.44%
###_dev/applications N/A 0.00GB 0.00GB 0.00GB N/A
###_dev/domains 120GB 14.21GB 5.53GB 19.74GB 16.45%
###_dev/logs 15GB 0.00GB 0.00GB 0.00GB 0.00%
###_dev/softwaredepot 250GB 73.55GB 0.02GB 73.57GB 29.43%
…snip
My apologies if the output is a bit mis-aligned here and there, I only bothered making it look good, not perfect :/ I also removed some of the project names (*,#)