Created
October 9, 2013 09:56
-
-
Save gochist/6898937 to your computer and use it in GitHub Desktop.
ex. cw desc alarms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import com.amazonaws.auth.PropertiesCredentials; | |
import com.amazonaws.services.cloudwatch.AmazonCloudWatch; | |
import com.amazonaws.services.cloudwatch.AmazonCloudWatchClient; | |
import com.amazonaws.services.cloudwatch.model.DescribeAlarmsRequest; | |
import com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult; | |
import com.amazonaws.services.cloudwatch.model.MetricAlarm; | |
public class CloudWatchSample { | |
public static void main(String[] args) throws IOException { | |
int items_per_page = 12; | |
AmazonCloudWatch cw = new AmazonCloudWatchClient( | |
new PropertiesCredentials(CloudWatchSample.class | |
.getResourceAsStream("CloudWatchSample.properties"))); | |
cw.setEndpoint("http://localhost:3776/monitor/"); | |
DescribeAlarmsRequest dar = new DescribeAlarmsRequest(); | |
dar.setMaxRecords(items_per_page); | |
String nexttoken = null; | |
do { | |
dar.setNextToken(nexttoken); | |
DescribeAlarmsResult ret = cw.describeAlarms(dar); | |
nexttoken = ret.getNextToken(); | |
System.out.println("Page start"); | |
for (MetricAlarm a : ret.getMetricAlarms()) { | |
System.out.println(a); | |
} | |
System.out.println("Page end, nexttoken: " + nexttoken); | |
} while (nexttoken != null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment