Last active
October 16, 2023 16:47
-
-
Save ejschaefer/5aadaa1c531de7b619015e6f33851166 to your computer and use it in GitHub Desktop.
Restart Websphere
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
| {"instanceId":"$.detail.configuration.metrics[0].metricStat.metric.dimensions.InstanceId"} |
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
| { | |
| "instanceId": "<instanceId>" | |
| } |
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
| { | |
| "source": ["aws.cloudwatch"], | |
| "detail-type": ["CloudWatch Alarm State Change"], | |
| "resources": ["arn:aws:cloudwatch:us-east-1:123456789012:alarm:ServerCpuTooHigh"], | |
| "detail": { | |
| "state": { | |
| "value": ["ALARM"] | |
| } | |
| } | |
| } |
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
| --- | |
| schemaVersion: "2.2" | |
| description: "Restart WebSphere" | |
| mainSteps: | |
| - action: "aws:runShellScript" | |
| name: "RestartService" | |
| inputs: | |
| maxAttempts: 1 | |
| timeoutSeconds: 30 | |
| runCommand: | |
| - | | |
| #!/bin/bash | |
| echo "Stopping WebSphere..." | |
| /home/admin2/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/stopServer.sh server1 | |
| echo "Starting WebSphere..." | |
| /home/admin2/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startServer.sh server1 |
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 boto3 | |
| import os | |
| import logging | |
| logger = logging.getLogger() | |
| logger.setLevel(logging.INFO) | |
| ssm_client = None | |
| def lambda_handler(event, context): | |
| global ssm_client | |
| logging.info(f"Event Received: {event}") | |
| if ssm_client is None: | |
| ssm_client = boto3.client('ssm') | |
| instance_id = event['instanceId'] | |
| cmd_id = ssm_client.send_command( | |
| InstanceIds=[instance_id], | |
| DocumentName="restart_websphere", | |
| CloudWatchOutputConfig={"CloudWatchOutputEnabled": True} | |
| ) | |
| logger.info(f"Command Id: {cmd_id}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment