Home » Posts tagged '#Monitoring'

Tag Archives: #Monitoring

Python Code to get EBS stats for SAP Systems

In this article, we have developed a Python script to simplify the process of retrieving AWS CloudWatch metrics for Elastic Block Store (EBS) volumes. The script takes input from a CSV file, containing metrics such as metric-name, VolumeId, START_TIME, and END_TIME, and uses the boto3 library to interact with AWS services.

By using this script, users can avoid manually executing individual AWS CLI commands for each metric and volume, making the process more efficient and less error-prone. The script iterates through the CSV file, calls AWS CloudWatch using boto3, and collects the required metric statistics, such as the Average value, for each metric and volume within the specified time range.

The output is then written back to a CSV file with the columns metric-name, VolumeId, Timestamp, and Average. This organized output allows users to easily analyze and further process the data for their specific use cases.

Users can customize the input CSV file with desired metrics and volumes, making it adaptable to various AWS environments and monitoring requirements.

SAMPLE - input.csv
metric-name,VolumeId,START_TIME,END_TIME
VolumeReadOps,vol-12345,2023-07-01T00:00:00,2023-07-02T00:00:00
VolumeWriteOps,vol-67890,2023-07-01T00:00:00,2023-07-02T00:00:00
BurstBalance,vol-54321,2023-07-01T00:00:00,2023-07-02T00:00:00
VolumeBytesRead,vol-98765,2023-07-01T00:00:00,2023-07-02T00:00:00
VolumeBytesWrite,vol-24680,2023-07-01T00:00:00,2023-07-02T00:00:00
CODE - sap_get_metric_statistics.py
import csv
import boto3

# Function to get CloudWatch metric statistics
def get_metric_statistics(metric_name, volume_id, start_time, end_time):
    cloudwatch = boto3.client('cloudwatch')
    response = cloudwatch.get_metric_statistics(
        Namespace='AWS/EBS',
        MetricName=metric_name,
        Dimensions=[
            {
                'Name': 'VolumeId',
                'Value': volume_id
            },
        ],
        StartTime=start_time,
        EndTime=end_time,
        Period=300,
        Statistics=['Average']
    )
    return response['Datapoints']

# Main function
def main():
    input_file = 'input.csv'
    output_file = 'output.csv'

    with open(input_file, 'r') as csvfile:
        csvreader = csv.DictReader(csvfile)
        next(csvreader)  # Skip the header row
        data = list(csvreader)

    with open(output_file, 'w', newline='') as file:
        csvwriter = csv.writer(file)
        csvwriter.writerow(['metric-name', 'VolumeId', 'Timestamp', 'Average'])

        for entry in data:
            metric_name = entry['metric-name']
            volume_id = entry['VolumeId']
            start_time = entry['START_TIME']
            end_time = entry['END_TIME']

            datapoints = get_metric_statistics(metric_name, volume_id, start_time, end_time)
            for datapoint in datapoints:
                csvwriter.writerow([metric_name, volume_id, datapoint['Timestamp'], datapoint['Average']])

if __name__ == "__main__":
    main()

SAMPLE - output.csv

metric-name,VolumeId,Timestamp,Average
VolumeReadOps,volume-1,2023-07-20 10:00:00,120.0
VolumeReadOps,volume-1,2023-07-20 10:05:00,130.0
VolumeReadOps,volume-1,2023-07-20 10:10:00,115.0
VolumeWriteOps,volume-1,2023-07-20 10:00:00,50.0
VolumeWriteOps,volume-1,2023-07-20 10:05:00,60.0
VolumeWriteOps,volume-1,2023-07-20 10:10:00,55.0
BurstBalance,volume-1,2023-07-20 10:00:00,75.0
BurstBalance,volume-1,2023-07-20 10:05:00,80.0
BurstBalance,volume-1,2023-07-20 10:10:00,70.0
VolumeBytesRead,volume-1,2023-07-20 10:00:00,2000.0
VolumeBytesRead,volume-1,2023-07-20 10:05:00,2200.0
VolumeBytesRead,volume-1,2023-07-20 10:10:00,1900.0
VolumeBytesWrite,volume-1,2023-07-20 10:00:00,1500.0
VolumeBytesWrite,volume-1,2023-07-20 10:05:00,1700.0
VolumeBytesWrite,volume-1,2023-07-20 10:10:00,1400.0


Overview of Configuring SAP HANA System Replication

Configuring SAP HANA System Replication between a primary and secondary site involves several steps. Here is an overview of the process:

  1. Prerequisites:
    • Ensure that you have a fully installed and configured SAP HANA system on both the primary and secondary sites.
    • Make sure the network connectivity is established between the primary and secondary sites, including the necessary ports for HANA communication.
  2. Enable System Replication:
    • On the primary site, open the SAP HANA Cockpit or SAP HANA Studio.
    • Connect to the primary HANA instance as a user with administrative privileges.
    • Navigate to the “System Replication” section and enable the system replication feature.
  3. Configure the Primary Site:
    • Set the replication mode to “sync” or “async” based on your requirements.
    • Define the secondary site and specify the connection details (IP address, port, etc.) of the secondary HANA instance.
    • Configure the replication parameters like the replication mode, log retention, etc.
    • Save the configuration and start the replication process on the primary site.
  4. Prepare the Secondary Site:
    • Install and configure a new SAP HANA system on the secondary site if it’s not already done.
    • Ensure that the secondary site has the same hardware resources and HANA version as the primary site.
    • Configure the network settings and ensure that the secondary site can communicate with the primary site.
  5. Establish the Initial Data Copy:
    • Initiate the initial data replication from the primary site to the secondary site.
    • This process involves copying the data from the primary database to the secondary database to synchronize them.
    • Monitor the data copy process and ensure it completes successfully.
  6. Test the Replication:
    • Once the initial data copy is complete, verify that the data is consistent between the primary and secondary sites.
    • Perform tests and checks to ensure that the replication is working as expected.
    • Validate that the secondary site is in a synchronized state with the primary site.
  7. Monitor and Maintain:
    • Set up monitoring tools to track the replication status and performance.
    • Regularly monitor the replication processes, log files, and system alerts.
    • Perform periodic checks to ensure the replication is functioning correctly.