Wednesday, November 2, 2011

Monitoring disk space usage on Sun Fishworks (7000) ZFS Storage Appliances

We needed a way to have our existing monitoring system alert us if a project was running out of space. There's not a single CLI command that will show all projects, but this bit of ECMAscript 3will output an easily parsed table:


 script  
 //  
 // jwasilko@gmail.com  
 // fishworks' cli user interface doesn't provide a good way to monitor  
 // disk space of all projects. This is an attempt to make up for that.   
 //  
 run('shares');  
 projects = list();  
 printf('%-40s %-10s %-10s %-10s\n', 'SHARE', 'AVAIL', 'USED', 'SNAPUSED');  
 for (i = 0; i < projects.length; i++) {  
     run('select ' + projects[i]);  
     shares = list();  
         for (j = 0; j < shares.length; j++) {  
         run('select ' + shares[j]);  
         share = projects[i] + '/' + shares[j];  
         used = run('get space_data').split(/\s+/)[3];  
         avail = run('get space_available').split(/\s+/)[3];  
         snap = run('get space_snapshots').split(/\s+/)[3];  
         printf('%-40s %-10s %-10s %-10s\n', share, avail, used, snap);  
         run('cd ..');  
     }  
     run('cd ..');  
 }  

No comments:

Post a Comment