List of usage examples for com.amazonaws.services.ec2 AmazonEC2Client getConsoleScreenshot
@Override
public GetConsoleScreenshotResult getConsoleScreenshot(GetConsoleScreenshotRequest request)
Retrieve a JPG-format screenshot of a running instance to help with troubleshooting.
From source file:ec2watch.EC2Watch.java
License:Open Source License
public void run() { ImageViewer viewer = null;// w w w . j a v a 2s. c o m AmazonEC2Client ec2Client = new AmazonEC2Client(clientConfiguration); if (region != null) { ec2Client.setRegion(Region.getRegion(Regions.fromName(region))); } while (true) { try { GetConsoleScreenshotResult result = ec2Client.getConsoleScreenshot( new GetConsoleScreenshotRequest().withInstanceId(instanceId).withWakeUp(Boolean.TRUE)); byte[] imageData = Base64.getDecoder().decode(result.getImageData()); if (viewer == null) { viewer = new ImageViewer(instanceId, imageData); } else { viewer.setImageData(imageData); System.out.print("."); } Thread.sleep(interval * 1000); } catch (Exception e) { // Ignore it System.out.print("x"); } } }