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
#!/usr/bin/env python | |
""" | |
Run a CloudWatch Insights query, then save the results as CSV | |
""" | |
from __future__ import print_function | |
import sys | |
import time | |
from datetime import datetime | |
import csv | |
import re |
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
def wait_for_all_queries_to_complete(query_ids, timeout=3600): | |
start_time = time.time() | |
sys.stdout.write('\tQuerying: ') | |
while True: | |
all_complete = True # This will only remain True if all queries are complete | |
try: | |
# Describe all active queries for the log group | |
response = LOG_CLIENT.describe_queries(logGroupName=LOG_GROUP) |
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
def run_segmented_queries(start, end, query_string, interval=86400): | |
""" Run queries over smaller time intervals if results exceed the limit """ | |
batch_query_results = [] | |
current_start = start | |
while current_start < end: | |
current_end = min(current_start + interval - 1, end) | |
query_id = start_query(current_start, current_end, query_string) | |
# Wait for the query to complete |
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
Name: extnp.CDNXHG.com.au | |
Type: SOA | |
Value: | |
ns-1849.awsdns-39.co.uk. | |
admin.CDNXHG.com.au. | |
1 ; Serial number | |
1800 ; Refresh interval (30 mins) | |
900 ; Retry interval (15 mins) | |
2592000 ; Expire interval (30 days) | |
300 ; Minimum TTL (5 mins) |
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 ipaddress | |
import pandas as pd | |
import sys | |
def check_ip_in_cidr(ip, cidr): | |
""" | |
Checks if a given IP address belongs to a specified CIDR range. | |
:param ip: IP address as a string. | |
:param cidr: CIDR range as a string. | |
:return: Boolean indicating if IP is within the CIDR range. |
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 ipaddress | |
import pandas as pd | |
import sys | |
def find_correct_cidr(ip, target_cidr): | |
""" | |
Finds the correct CIDR block with the same or larger netmask that contains the IP. | |
:param ip: The IP address to check. | |
:param target_cidr: The original CIDR block as a string. | |
:return: Correct CIDR block containing the IP or None if not found. |
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
def play_next_track(self): | |
if not self.playlist: | |
self.playing = False | |
return "No tracks available" | |
try: | |
self.current_track = self.playlist[0] # Always play the first track in the playlist | |
self.playlist.append(self.playlist.pop(0)) # Move it to the end of the playlist | |
pygame.mixer.music.load(self.current_track) | |
pygame.mixer.music.play() |
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
parse @message /^.*eni-\w+\s+(?<srcAddr>\d+\.\d+\.\d+\.\d+)\s+(?<destAddr>\d+\.\d+\.\d+\.\d+)\s+(?<srcPort>\d+)\s+(?<destPort>\d+)\s+(?<protocol>\d+)\s+(?<tcpFlag>\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+(?<action>\w+)\s+OK/ | |
| filter destPort="993" and isIpv4InSubnet(destAddr, "10.154.113.89/32") | |
| display srcAddr, destAddr, srcPort, destPort, tcpFlag, action |
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
AWS Network Monitoring Strategy: Summary Report | |
Overview | |
This report presents a comprehensive strategy for monitoring AWS Direct Connect (DX), Transit Gateway, and Virtual Private Cloud (VPC) connections, as well as DNS management with Amazon Route 53. The focus is on achieving a cost-effective monitoring solution to ensure efficient utilization of resources while preventing bandwidth saturation issues. AWS Network Manager is recommended as a centralized solution to oversee the entire network infrastructure. | |
Monitoring Components and Strategies | |
1. Direct Connect and Transit Gateway Monitoring |