Forum Discussion

Brandon's avatar
7 years ago

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;

3 Replies

Replies have been turned off for this discussion
  • @Brandon I'm not sure that your script logic is correct here, as the cli command is only run one time to get the full output of all disks and then post processes it.

    Targeting the specific disk name inside the cli command, you are only getting that specific disks metrics, not all disks as the command is run only once.

    If you were using the OLD script collection method, then yes it would work as it would run that code of each instance discovered using the disk name inside the CLI command.

    P.S. : ensure all your disks are collecting data, as I'm certain your change may have broken collection.

  • So if I'm understanding this correctly, the script only runs one time and each instance associated with the device is updated from the single run - as opposed to running one time per instance?  That is extremely efficient!  I wasn't aware any datasources ran this way!  That is very good news!

  • 2 minutes ago, Brandon said:

    So if I'm understanding this correctly, the script only runs one time and each instance associated with the device is updated from the single run - as opposed to running one time per instance?  That is extremely efficient!  I wasn't aware any datasources ran this way!  That is very good news!

     

    Yes, thats why we created batchscript !!!! 

    The initial command may take a bit longer to run, but it only has to run 1 time as opposed to per instance. Stick to batchscript.