#!/usr/bin/env node
import { EventEmitter } from 'events';
/**
 * Resource monitoring thresholds
 */
interface ResourceThresholds {
    /** Memory usage threshold in MB */
    memoryMB: number;
    /** CPU usage threshold as percentage */
    cpuPercent: number;
    /** Event loop lag threshold in milliseconds */
    eventLoopLagMs: number;
    /** Open file descriptor threshold */
    openFiles: number;
}
/**
 * Current resource usage metrics
 */
interface ResourceMetrics {
    /** Current memory usage in MB */
    memoryUsageMB: number;
    /** Current CPU usage percentage */
    cpuUsagePercent: number;
    /** Current event loop lag in milliseconds */
    eventLoopLagMs: number;
    /** Number of open file descriptors */
    openFiles: number;
    /** System uptime in seconds */
    uptimeSeconds: number;
    /** Free memory percentage */
    freeMemoryPercent: number;
    /** Load average */
    loadAverage: number[];
    /** Process uptime in seconds */
    processUptimeSeconds: number;
}
/**
 * ResourceMonitor provides comprehensive monitoring of system resources
 * to detect potential issues before they cause crashes.
 *
 * Features:
 * - Memory usage monitoring with leak detection
 * - CPU usage tracking
 * - Event loop lag measurement
 * - File descriptor monitoring
 * - System health metrics
 * - Predictive alerting
 *
 * @example
 * ```typescript
 * const monitor = new ResourceMonitor({
 *   memoryMB: 500,
 *   cpuPercent: 80,
 *   eventLoopLagMs: 100,
 *   openFiles: 1000
 * });
 *
 * monitor.on('warning', (metrics) => {
 *   // Handle resource warning
 * });
 *
 * monitor.start();
 * ```
 */
export declare class ResourceMonitor extends EventEmitter {
    private thresholds;
    private monitoringInterval;
    private eventLoopStartTime;
    private lastCpuUsage;
    private lastCpuCheck;
    private memoryHistory;
    private cpuHistory;
    private isMonitoring;
    private logger;
    private readonly DEFAULT_THRESHOLDS;
    constructor(thresholds?: Partial<ResourceThresholds>);
    /**
     * Start resource monitoring
     *
     * @param intervalMs - Monitoring interval in milliseconds (default: 30000)
     */
    start(intervalMs?: number): void;
    /**
     * Stop resource monitoring
     */
    stop(): void;
    /**
     * Get current resource metrics
     *
     * @returns Current resource usage metrics
     */
    getCurrentMetrics(): Promise<ResourceMetrics>;
    /**
     * Measure and analyze current resource usage
     */
    private measureResources;
    /**
     * Log current metrics to console
     *
     * @param metrics - Current resource metrics
     */
    private logMetrics;
    /**
     * Check if metrics exceed thresholds and emit warnings
     *
     * @param metrics - Current resource metrics
     */
    private checkThresholds;
    /**
     * Analyze resource usage trends
     *
     * @param metrics - Current resource metrics
     */
    private analyzeTrends;
    /**
     * Calculate average growth rate from a series of measurements
     *
     * @param measurements - Array of measurements
     * @returns Average growth rate per measurement
     */
    private calculateAverageGrowth;
    /**
     * Calculate CPU usage percentage
     *
     * @returns CPU usage percentage
     */
    private calculateCpuUsage;
    /**
     * Measure event loop lag
     *
     * @returns Promise that resolves to event loop lag in milliseconds
     */
    private measureEventLoopLag;
    /**
     * Get the number of open file descriptors
     *
     * @returns Number of open file descriptors
     */
    private getOpenFileCount;
    /**
     * Get system information
     *
     * @returns System information object
     */
    private getSystemInfo;
    /**
     * Start monitoring event loop lag
     */
    private startEventLoopMonitoring;
    /**
     * Generate a comprehensive health report
     *
     * @returns Promise that resolves to a health report
     */
    generateHealthReport(): Promise<{
        status: 'healthy' | 'warning' | 'critical';
        metrics: ResourceMetrics;
        recommendations: string[];
        trends: {
            memoryTrend: string;
            cpuTrend: string;
        };
    }>;
    /**
     * Update monitoring thresholds
     *
     * @param newThresholds - New threshold values
     */
    updateThresholds(newThresholds: Partial<ResourceThresholds>): void;
    /**
     * Get current thresholds
     *
     * @returns Current monitoring thresholds
     */
    getThresholds(): ResourceThresholds;
}
export type { ResourceThresholds, ResourceMetrics };
//# sourceMappingURL=resource-monitor.d.ts.map