Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple example to demonstrate using the Splunk Java SDK from Groovy
package com.splunk.dev.javasdk.examples
import com.splunk.Entity;
import com.splunk.Service;
import com.splunk.ServiceInfo;
/**
* Simple example to demonstrate using the Splunk Java SDK from Groovy
* @author ddallimore
*
*/
class SplunkJavaSDKWrapper {
static main(args) {
//connect and login
def connectionParameters = [host:"somehost",username:"admin",password:"foo"]
Service service = Service.connect(connectionParameters )
//get Splunk Server info
ServiceInfo info = service.getInfo()
def splunkInfo = [:]
for (key in info.keySet())
splunkInfo.put(key,info.get(key))
printSplunkInfo(splunkInfo)
}
/**
* print out Splunk Server info
* @param splunkInfo
* @return
*/
static printSplunkInfo(splunkInfo) {
println "Info"
splunkInfo.each { key, value ->
println key + " : " + value
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.