java.lang.NullPointerException on Groovy Collector Attribute script
The following script encounter NullPointerException. It seems hostProps.get() doesn’t work. Any advice will be appreciate.
import com.santaba.agent.groovyapi.expect.Expect;
import com.santaba.agent.groovyapi.snmp.Snmp;
import com.santaba.agent.groovyapi.http.*;
import com.santaba.agent.groovyapi.jmx.*;
import org.xbill.DNS.*;Boolean debug = true
String hostname = hostProps.get("system.hostname") ;
String user = hostProps.get("scc.user");
String pass = hostProps.get("scc.pass");
String port = (String)hostProps.get("scc.port");
httpClient = HTTP.open(hostname, port, true);
httpClient.setAuthentication(user,pass);
//url="https://"+hostname+"/exposed?action=ping";
url="https://" + hostname + ":" + port + "/api/monitoring/memory";
//url="https://"+hostname+"/api/monitoring/performance/backends";def getResponse=httpClient.get(url, ["Accept":"application/json"]);
if ( !(httpClient.getStatusCode() =~ /200/) )
{
httpClient.close();
return 1
}
println httpClient.getResponseBody();
httpClient.close();
return 0;