サンプルコード
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.3.5') import org.apache.http.client.methods.* import org.apache.http.impl.client.* import org.apache.http.message.* import org.apache.http.auth.* import groovy.json.* def host = "192.168.1.240" // replace this def port = 7180 def user = "admin" def password = "admin" def clusterName = "cluster" def httpclient = new DefaultHttpClient() httpclient.getCredentialsProvider().setCredentials( new AuthScope(host, port), new UsernamePasswordCredentials(user, password) ) def method = new HttpGet("http://${host}:${port}/api/v7/clusters/${clusterName}/services") def response = httpclient.execute(method) println response.getStatusLine().getStatusCode() def json = new JsonSlurper().parseText(response.getEntity().getContent().text) for(item in json.items){ println "name:${item.name}" println "health summary:${item.healthSummary}" println "service state:${item.serviceState}" println "----" }参考情報
/clusters/{clusterName}/services - Cloudera Manager API v7
0 件のコメント:
コメントを投稿