Initial commit: loc_az_hci (smom-dbis-138 excluded via .gitignore)
Some checks failed
Test / test (push) Has been cancelled

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
defiQUG
2026-02-08 09:04:46 -08:00
commit c39465c2bd
386 changed files with 50649 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
#!/bin/bash
source ~/.bashrc
# Collect Metrics
# Collects system, application, network, and storage metrics
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
OUTPUT_DIR="${METRICS_OUTPUT_DIR:-$PROJECT_ROOT/metrics}"
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
collect_system_metrics() {
log_info "Collecting system metrics..."
mkdir -p "$OUTPUT_DIR/system"
# CPU metrics
top -bn1 | head -20 > "$OUTPUT_DIR/system/cpu.txt" 2>/dev/null || true
# Memory metrics
free -h > "$OUTPUT_DIR/system/memory.txt" 2>/dev/null || true
# Disk metrics
df -h > "$OUTPUT_DIR/system/disk.txt" 2>/dev/null || true
# Load average
uptime > "$OUTPUT_DIR/system/uptime.txt" 2>/dev/null || true
}
collect_kubernetes_metrics() {
log_info "Collecting Kubernetes metrics..."
if ! command -v kubectl &> /dev/null; then
log_warn "kubectl not found, skipping Kubernetes metrics"
return 0
fi
mkdir -p "$OUTPUT_DIR/kubernetes"
# Node metrics
kubectl top nodes > "$OUTPUT_DIR/kubernetes/nodes.txt" 2>/dev/null || true
# Pod metrics
kubectl top pods --all-namespaces > "$OUTPUT_DIR/kubernetes/pods.txt" 2>/dev/null || true
# Resource usage
kubectl get nodes -o json > "$OUTPUT_DIR/kubernetes/nodes.json" 2>/dev/null || true
}
collect_network_metrics() {
log_info "Collecting network metrics..."
mkdir -p "$OUTPUT_DIR/network"
# Interface statistics
ip -s link > "$OUTPUT_DIR/network/interfaces.txt" 2>/dev/null || true
# Network connections
ss -tunap > "$OUTPUT_DIR/network/connections.txt" 2>/dev/null || true
}
main() {
log_info "Collecting metrics..."
mkdir -p "$OUTPUT_DIR"
collect_system_metrics
collect_kubernetes_metrics
collect_network_metrics
log_info "Metrics collected to: $OUTPUT_DIR"
}
main "$@"

View File

@@ -0,0 +1,63 @@
#!/bin/bash
source ~/.bashrc
# Setup Alerts
# Configures alerting rules and notification channels
set -e
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
setup_prometheus_alerts() {
log_info "Setting up Prometheus alerts..."
if ! command -v kubectl &> /dev/null; then
log_warn "kubectl not found, skipping Prometheus alert setup"
return 0
fi
log_info "Prometheus alert rules should be configured via:"
log_info " - Prometheus Operator Alertmanager"
log_info " - Custom Resource Definitions (CRDs)"
log_info " - GitOps manifests"
log_warn "Manual configuration required for alert rules"
}
setup_azure_alerts() {
log_info "Setting up Azure alerts..."
if ! command -v az &> /dev/null; then
log_warn "Azure CLI not found, skipping Azure alert setup"
return 0
fi
log_info "Azure alerts should be configured via:"
log_info " - Azure Portal: Monitor > Alerts"
log_info " - Azure CLI: az monitor metrics alert create"
log_info " - Terraform: azurerm_monitor_metric_alert"
log_warn "Manual configuration required for Azure alerts"
}
main() {
log_info "Setting up alerting..."
setup_prometheus_alerts
setup_azure_alerts
log_info "Alert setup complete (manual configuration may be required)"
}
main "$@"