Forum Discussion

Joe_Williams's avatar
6 years ago

Custom ConfigSource Issues

I am having to write a custom configsource for Steelhead Riverbeds. There isn't a way to sftp a file off so I am having to write an expect script in groovy. I am trying to cobble together something using the Cisco Generic RunningConfig as a stepping stone, but I just can't get it off the ground. If I run it via the ConfigSources page with Test Script I get this.


Failed to execute the script - null
	at java.nio.channels.spi.AbstractInterruptibleChannel.end(


If I run it via collector debug and !groovy I get


$ !groovy
Waiting... This may take up to 10 minutes.
Waiting... This may take up to 10 minutes.
End of stream reached, no match found End of stream reached, no match found
    at com.santaba.agent.groovyapi.expect.expectj.Spawn._expect2(
    at com.santaba.agent.groovyapi.expect.expectj.Spawn._expect2(
    at com.santaba.agent.groovyapi.expect.expectj.Spawn.expect(
    at com.santaba.agent.groovyapi.expect.expectj.Spawn.expect(
    at com.santaba.agent.groovyapi.expect.Expect.expect(
    at com.santaba.agent.groovyapi.expect.Expect$expect$ Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(
    at com.santaba.agent.util.GroovyScriptShell.execute(
    at com.santaba.agent.util.GroovyScriptExecutor.execute(
    at com.santaba.agent.debugger.GroovyTask._executeInAgent(
    at com.santaba.agent.debugger.GroovyTask._handle(
    at java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.util.concurrent.ThreadPoolExecutor$


Any help would appreciated.

Oh yeah the formatting of the cli.


servername >
servername > enable
servername # show configuration
## Other IP configuration


And what I have so far.

import com.santaba.agent.groovyapi.expect.Expect;

host = hostProps.get("system.hostname");
user = hostProps.get("config.user");
pass = hostProps.get("config.pass");

// open an ssh connection and wait for the prompt, user, pass);

// ensure the page-by-page view doesn't foul the config output
cli.send("terminal length 0\n");

// display the config
cli.send("show configuration\n");

// logout from the device

// collect the output

// close the ssh connection handle then print the config
println config;

And now what I have so far

1 Reply

Replies have been turned off for this discussion
  • And of course I kept plugging away and go it. It isn't pretty but it works.

    // import the logicmonitor expect helper class
    import com.santaba.agent.groovyapi.expect.Expect;
    // get the hostname and credentials from the device property table
    hostname = hostProps.get("system.hostname");
    userid = hostProps.get("config.user");
    passwd = hostProps.get("config.pass");
    // initiate an ssh connection to the host using the provided credentials
    ssh_connection =, userid, passwd);
    // wait for the cli prompt, which indicates we've connected
    ssh_connection.expect("> ");
    // send a command to show the tomcat log file size, along with the newline [enter] character
    // wait for the cli prompt to return, which indicates the command has completed
    ssh_connection.expect("# ");
    ssh_connection.send("terminal length 0\n");
    ssh_connection.expect("# ");
    // capture all the text up to the expected string. this should look something like
    ssh_connection.send("show configuration\n");
    ssh_connection.expect(" # ");
    cmd_output = ssh_connection.before();
    // now that we've capture the data we care about lets exit from the cli
    // wait until the external process finishes then close the connection
    println cmd_output;