• 0
Sign in to follow this  
Joe Williams

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(AbstractInterruptibleChannel.java:202)
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:407)
	at sun.nio.ch.SourceChannelImpl.read(SourceChannelImpl.java:113)


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
java.io.IOException: End of stream reached, no match found
    at com.santaba.agent.groovyapi.expect.expectj.Spawn._expect2(Spawn.java:595)
    at com.santaba.agent.groovyapi.expect.expectj.Spawn._expect2(Spawn.java:511)
    at com.santaba.agent.groovyapi.expect.expectj.Spawn.expect(Spawn.java:647)
    at com.santaba.agent.groovyapi.expect.expectj.Spawn.expect(Spawn.java:617)
    at com.santaba.agent.groovyapi.expect.Expect.expect(Expect.java:193)
    at com.santaba.agent.groovyapi.expect.Expect$expect$1.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at Script69.run(Script69.groovy:22)
    at com.santaba.agent.util.GroovyScriptShell.execute(GroovyScriptShell.java:127)
    at com.santaba.agent.util.GroovyScriptExecutor.execute(GroovyScriptExecutor.java:119)
    at com.santaba.agent.debugger.GroovyTask._executeInAgent(GroovyTask.java:186)
    at com.santaba.agent.debugger.GroovyTask._handle(GroovyTask.java:165)
    at com.santaba.agent.debugger.DebugTask.run(DebugTask.java:106)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)


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
cli=Expect.open(host, 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

Share this post

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

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 = Expect.open(hostname, 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;


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this