EMC _DiskPerformance_NaviSecCli
This datasource was modified on 03/17/2017 to improve the efficiency of the script. It looks like it shaved about a half-second off of the collection time by narrowing the scope using CLI arguments. However, each time this script runs, it still outputs the performance data for each and every disk. I've modified the script even further to only target the disk matching wildvalue. This looks to shave off another half-second or so from the execution time. This should improve collector performance. Please update the official datasource to target each instance as highlighted below.
import com.santaba.agent.groovyapi.expect.Expect;
def hostname = hostProps.get("system.hostname");
def username = hostProps.get("naviseccli.user");
def pass = hostProps.get("naviseccli.pass");
def original = "##WILDVALUE##"
def wldvlu = original.replaceAll('Bus',"").replaceAll('Enclosure',"_").replaceAll('Disk',"_")
// Slow if just given getdisk command. Faster if targeting specific disk.
def cli_cmd = "getdisk " + wldvlu +
" -state -bytrd -bytwrt -capacity -idleticks" +
" -rds -wrts -usercapacity -busyticks -actualcapacity" +
" -arrivalswithnonzeroqueue -hr -hw -sr -sw -userlba" +
" -que -numluns -highsumofseeks";
// find the location of naviseccli
trailing_quote = '';
if (new File("C:\\Program Files (x86)\\EMC\\Navisphere CLI\\NaviSecCLI.exe").exists())
{
naviseccli = "cmd /c 'C:\\Program Files (x86)\\EMC\\Navisphere CLI\\NaviSecCLI.exe'";
}
else if (new File("C:\\Program Files\\EMC\\Navisphere CLI\\NaviSecCLI.exe").exists())
{
naviseccli = "cmd /c 'C:\\Program Files\\EMC\\Navisphere CLI\\NaviSecCLI.exe'";
}
else
{
naviseccli = '/bin/sh -c "/opt/Navisphere/bin/naviseccli';
trailing_quote = '"';
}
def cli_args = " -User " + username + " -Password " + pass + " -Address " + hostname + " -Scope 0 ";
def cli = Expect.open(naviseccli + cli_args + cli_cmd + trailing_quote);
cli.expectClose();
def output = cli.stdout();
def units = output.split("\r\n\r\n");
Map output_map = [:]
// iterate through each "unit" (instance) returned
units.each
{ unit ->
// iterate through each line in this unit
unit.eachLine
{ line ->
// does this line start with "Bus" and not contain "Empty"
if (line.startsWith("Bus "))
{
// yes. this is a line that contains the instance name.
// is this an empty disk slot?
if (line.contains("Empty"))
{
// yes. skip it
return;
}
else
{
// no. get the wildvalue and remove whitespace
wildvalue = line.replaceAll(' ', '');
}
}
else
{
// no. it's a data line. try to split key/value pairs on whitespace
try
{
// separate the keys and values
(key, value) = line.split(/:\s{2}\s+/);
// make sure the keys don't have any whitespace
key_no_spaces = key.replaceAll(' ','');
// is this the drive state datapoint?
if (key_no_spaces == "State")
{
if (value == "Empty")
{
drive_state_int = 4;
}
else if (value == "Unbound")
{
drive_state_int = 3;
}
else if (value == "Hot Spare Ready")
{
drive_state_int = 2;
}
else if (value == "Enabled")
{
drive_state_int = 1;
}
else
{
drive_state_int = 0;
}
println wildvalue + '.' + "DriveState=" + drive_state_int;
}
else
{
// no. it's a normal datapoint -- just print it
println wildvalue + '.' + key_no_spaces + '=' + value.findAll(/[\d\.]+/)[0];
}
}
catch (all)
{
// do nothing in the case that key/value separation fails
}
}
}
}
return 0;