@Override public GetConsoleOutputResult consoleOutput( ResultCapture<GetConsoleOutputResult> extractor) { GetConsoleOutputRequest request = new GetConsoleOutputRequest(); return consoleOutput(request, extractor); }
@Override public GetConsoleOutputResult consoleOutput( ResultCapture<GetConsoleOutputResult> extractor) { GetConsoleOutputRequest request = new GetConsoleOutputRequest(); return consoleOutput(request, extractor); }
/** * Gets the EC2 console output. */ public String getConsoleOutput() throws AmazonClientException { AmazonEC2 ec2 = getCloud().connect(); GetConsoleOutputRequest request = new GetConsoleOutputRequest(getInstanceId()); return ec2.getConsoleOutput(request).getOutput(); }
/** * Gets the EC2 console output. */ public String getConsoleOutput() throws AmazonClientException { AmazonEC2 ec2 = getCloud().connect(); GetConsoleOutputRequest request = new GetConsoleOutputRequest(getInstanceId()); return ec2.getConsoleOutput(request).getOutput(); }
public static void logEC2InstanceOutputToCloudwatch(String t, ECSConfiguration configuration) { AwsLogs.Driver driver = AwsLogs.getAwsLogsDriver(configuration); if (driver != null && driver.getRegion() != null && driver.getLogGroupName() != null) { try { AmazonEC2 client = AmazonEC2ClientBuilder.defaultClient(); GetConsoleOutputResult result = client.getConsoleOutput(new GetConsoleOutputRequest(t)); AWSLogsClient logs = new AWSLogsClient().withRegion(Regions.fromName(driver.getRegion())); // t (ec2 instance id) should be unique within reason final String logStreamName = "pbc-ec2-instance-stale/" + t; logs.createLogStream(new CreateLogStreamRequest(driver.getLogGroupName(), logStreamName)); logs.putLogEvents(new PutLogEventsRequest().withLogGroupName(driver.getLogGroupName()).withLogStreamName(logStreamName).withLogEvents(new InputLogEvent().withMessage(result.getDecodedOutput()).withTimestamp(System.currentTimeMillis()))); } catch (Exception th) { //we are fine swallowing any errors, has no direct influence on proper function. logger.error("failed to retrieve ec2 instance logs or send them to cloudwatch", th); } } }