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.
QuoteFailed to execute the script - null java.nio.channels.ClosedByInterruptException 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
Quote$ !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.
Quoteservername >
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); cli.expect("#"); // ensure the page-by-page view doesn't foul the config output cli.send("terminal length 0\n"); cli.expect("#"); // display the config cli.send("show configuration\n"); cli.expect("##\n") // logout from the device cli.send("exit\n"); cli.expect("#exit"); // collect the output config=cli.before(); // close the ssh connection handle then print the config cli.expectClose(); println config;
And now what I have so far