Documentation
¶
Index ¶
- func CalculateDockerRequestRate(containerID string) (float64, int64, error)
- func DetectDockerNginx() (string, error)
- func DockerDisableSite(containerID, siteName string) error
- func DockerEnableSite(containerID, siteName string) error
- func DockerReload(containerID string) error
- func DockerTestConfig(containerID string) error
- func FormatLogEntry(entry LogEntry) string
- func GetDockerNginxPorts(containerID string) ([]string, error)
- func GetDockerNginxSites(containerID string) ([]model.Site, error)
- func IsDockerAvailable() bool
- func ParseLogLine(line string) string
- type LogEntry
- type LogStats
- type Metrics
- type MetricsHistory
- type Service
- func (s *Service) CreateSiteConfig(filename, content string) error
- func (s *Service) DisableSite(siteName string) error
- func (s *Service) EnableSite(siteName string) error
- func (s *Service) GetAccessLogs(maxLines int) ([]LogEntry, error)
- func (s *Service) GetConfigErrors() ([]string, error)
- func (s *Service) GetErrorLogs(maxLines int) ([]string, error)
- func (s *Service) GetListeningPorts() ([]string, error)
- func (s *Service) GetLogStats() (*LogStats, error)
- func (s *Service) GetMetrics() (*Metrics, error)
- func (s *Service) GetServerNames() (map[string][]string, error)
- func (s *Service) GetSiteConfigPath() (string, error)
- func (s *Service) GetStats() (*Stats, error)
- func (s *Service) GetSystemMetrics() (*SystemMetrics, error)
- func (s *Service) ListSites() ([]model.Site, error)
- func (s *Service) Reload() error
- func (s *Service) TestConfig() error
- type Stats
- type SystemMetrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateDockerRequestRate ¶
CalculateDockerRequestRate calculates request rate from Docker container logs
func DetectDockerNginx ¶
DetectDockerNginx checks if NGINX is running in Docker and returns container ID
func DockerDisableSite ¶
DockerDisableSite - Not applicable for Docker (sites are in config)
func DockerEnableSite ¶
DockerEnableSite - Not applicable for Docker (sites are in config)
func DockerReload ¶
DockerReload reloads NGINX in Docker container
func DockerTestConfig ¶
DockerTestConfig tests NGINX config in Docker container
func FormatLogEntry ¶
FormatLogEntry formats a log entry for display with colors and detailed information
func GetDockerNginxPorts ¶
GetDockerNginxPorts gets ports from Docker container
func GetDockerNginxSites ¶
GetDockerNginxSites gets sites from Docker NGINX container
func IsDockerAvailable ¶
func IsDockerAvailable() bool
IsDockerAvailable checks if docker command is available
func ParseLogLine ¶
ParseLogLine parses an NGINX access log line and returns a styled version
Types ¶
type LogEntry ¶
type LogEntry struct {
IP string
Timestamp time.Time
Method string
Path string
StatusCode int
BytesSent int
UserAgent string
Referer string
StatusClass string // "2xx", "3xx", "4xx", "5xx"
}
LogEntry represents a parsed NGINX log entry
type LogStats ¶
type LogStats struct {
TotalRequests int
UniqueIPs int
StatusCounts map[string]int // "2xx", "3xx", "4xx", "5xx"
MethodCounts map[string]int // "GET", "POST", etc.
TopPaths map[string]int
TotalBytes int64
AvgBytesPerRequest int64
}
LogStats represents aggregated log statistics
type Metrics ¶
type Metrics struct {
CPU float64
Memory float64
NetworkIn float64 // Total bytes in (cumulative)
NetworkOut float64 // Total bytes out (cumulative)
NetworkInRate float64 // MB/s
NetworkOutRate float64 // MB/s
RequestRate float64
ActiveConns int
TotalConns int64
Timestamp time.Time
}
Metrics represents real-time NGINX metrics
type MetricsHistory ¶
type MetricsHistory struct {
CPU []float64
Memory []float64
Network []float64
Requests []float64
Timestamps []time.Time
MaxPoints int
}
MetricsHistory stores historical metrics
func NewMetricsHistory ¶
func NewMetricsHistory(maxPoints int) *MetricsHistory
NewMetricsHistory creates a new metrics history tracker
func (*MetricsHistory) AddMetrics ¶
func (h *MetricsHistory) AddMetrics(m *Metrics)
AddMetrics adds a metrics snapshot to history
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles NGINX operations using crossplane for real config parsing
func (*Service) CreateSiteConfig ¶
CreateSiteConfig creates a new NGINX site configuration file
func (*Service) DisableSite ¶
DisableSite disables an NGINX site
func (*Service) EnableSite ¶
EnableSite enables an NGINX site
func (*Service) GetAccessLogs ¶
GetAccessLogs returns the last N lines of the access log
func (*Service) GetConfigErrors ¶
GetConfigErrors validates nginx configuration and returns errors
func (*Service) GetErrorLogs ¶
GetErrorLogs returns recent error log entries
func (*Service) GetListeningPorts ¶
GetListeningPorts returns all ports that NGINX is configured to listen on
func (*Service) GetLogStats ¶
GetLogStats returns statistics from access logs
func (*Service) GetMetrics ¶
GetMetrics collects current NGINX metrics
func (*Service) GetServerNames ¶
GetServerNames extracts all server names from configurations
func (*Service) GetSiteConfigPath ¶
GetSiteConfigPath returns the path where site configs are stored
func (*Service) GetSystemMetrics ¶
func (s *Service) GetSystemMetrics() (*SystemMetrics, error)
GetSystemMetrics gets overall system metrics
func (*Service) TestConfig ¶
TestConfig tests the NGINX configuration