Documentation
¶
Overview ¶
Package agent pkg/agent/checker.go
Package agent pkg/agent/mapper_checker.go
Package agent is a generated GoMock package.
Package agent pkg/agent/registry.go
Package agent pkg/agent/server.go
Package agent pkg/agent/types.go
Index ¶
- Variables
- func NewSNMPChecker(ctx context.Context, address string, security *models.SecurityConfig, ...) (checker.Checker, error)
- func ResolveAgentID(configPath, current string) (string, error)
- func SeedCheckerConfigsFromDisk(ctx context.Context, kvMgr *config.KVManager, cfg *ServerConfig, ...) error
- type CheckerConfig
- type CheckerConnection
- type Duration
- type ExternalChecker
- type ICMPChecker
- type ICMPResponse
- type IPSorter
- type KVStore
- type MapperConfig
- type MapperDiscoveryChecker
- type MapperDiscoveryDetails
- type MockKVStore
- func (m *MockKVStore) Close() error
- func (m *MockKVStore) Create(arg0 context.Context, arg1 string, arg2 []byte, arg3 time.Duration) error
- func (m *MockKVStore) Delete(arg0 context.Context, arg1 string) error
- func (m *MockKVStore) EXPECT() *MockKVStoreMockRecorder
- func (m *MockKVStore) Get(arg0 context.Context, arg1 string) ([]byte, bool, error)
- func (m *MockKVStore) Put(arg0 context.Context, arg1 string, arg2 []byte, arg3 time.Duration) error
- func (m *MockKVStore) Watch(arg0 context.Context, arg1 string) (<-chan []byte, error)
- type MockKVStoreMockRecorder
- func (mr *MockKVStoreMockRecorder) Close() *gomock.Call
- func (mr *MockKVStoreMockRecorder) Create(arg0, arg1, arg2, arg3 any) *gomock.Call
- func (mr *MockKVStoreMockRecorder) Delete(arg0, arg1 any) *gomock.Call
- func (mr *MockKVStoreMockRecorder) Get(arg0, arg1 any) *gomock.Call
- func (mr *MockKVStoreMockRecorder) Put(arg0, arg1, arg2, arg3 any) *gomock.Call
- func (mr *MockKVStoreMockRecorder) Watch(arg0, arg1 any) *gomock.Call
- type MockObjectStore
- type MockObjectStoreMockRecorder
- type MockService
- type MockServiceMockRecorder
- type MockSweepStatusProvider
- type MockSweepStatusProviderMockRecorder
- type ObjectStore
- type PortChecker
- type ProcessChecker
- type SNMPChecker
- type ScanStats
- type Server
- func (s *Server) Close(ctx context.Context) error
- func (s *Server) GetResults(ctx context.Context, req *proto.ResultsRequest) (*proto.ResultsResponse, error)
- func (s *Server) GetStatus(ctx context.Context, req *proto.StatusRequest) (*proto.StatusResponse, error)
- func (s *Server) ListServices() []string
- func (s *Server) ListenAddr() string
- func (s *Server) RestartServices(ctx context.Context)
- func (s *Server) SecurityConfig() *models.SecurityConfig
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) Stop(_ context.Context) error
- func (s *Server) StreamResults(req *proto.ResultsRequest, stream proto.AgentService_StreamResultsServer) error
- func (s *Server) UpdateConfig(newCfg *ServerConfig)
- type ServerConfig
- type Service
- type ServiceError
- type SweepConfig
- type SweepService
- func (s *SweepService) Check(ctx context.Context, _ *proto.StatusRequest) (bool, json.RawMessage)
- func (s *SweepService) CheckICMP(ctx context.Context, host string) (*models.Result, error)
- func (s *SweepService) Close() error
- func (s *SweepService) GetStatus(ctx context.Context) (*proto.StatusResponse, error)
- func (s *SweepService) GetSweepResults(ctx context.Context, lastSequence string) (*proto.ResultsResponse, error)
- func (*SweepService) Name() string
- func (s *SweepService) Start(ctx context.Context) error
- func (s *SweepService) Stop(_ context.Context) error
- func (s *SweepService) UpdateConfig(config *models.Config) error
- type SweepStatusProvider
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAgentIDRequired indicates agent_id is required in configuration ErrAgentIDRequired = errors.New("agent_id is required in configuration") // ErrInvalidJSONResponse indicates invalid JSON response from checker ErrInvalidJSONResponse = errors.New("invalid JSON response from checker") // ErrDataServiceClientInit indicates the DataService client could not be created. ErrDataServiceClientInit = errors.New("failed to initialize DataService client") // ErrInvalidSweepMetadata signals that stored sweep metadata is malformed. ErrInvalidSweepMetadata = errors.New("invalid sweep metadata") ErrObjectStoreUnavailable = errors.New("object store unavailable") )
var ( // ErrDetailsRequiredMapperDiscovery indicates details field is required for mapper_discovery checks ErrDetailsRequiredMapperDiscovery = errors.New("details field is required for mapper_discovery checks") )
var ( // ErrMapperAddressEmpty indicates mapper address configuration is missing ErrMapperAddressEmpty = errors.New("mapper address cannot be empty") )
Functions ¶
func NewSNMPChecker ¶
func ResolveAgentID ¶ added in v1.0.55
ResolveAgentID determines the canonical agent_id by checking current config, env vars, and config files.
Types ¶
type CheckerConfig ¶
type CheckerConfig struct {
Name string `json:"name"`
Type string `json:"type"`
Address string `json:"address,omitempty"`
Port int `json:"port,omitempty"`
Timeout Duration `json:"timeout,omitempty"`
ListenAddr string `json:"listen_addr,omitempty"`
Additional json.RawMessage `json:"additional,omitempty"`
Details json.RawMessage `json:"details,omitempty"`
Security *models.SecurityConfig `json:"security,omitempty"`
}
CheckerConfig defines the configuration for individual checker services.
type CheckerConnection ¶
type CheckerConnection struct {
// contains filtered or unexported fields
}
CheckerConnection represents a connection to an external checker service.
func (*CheckerConnection) EnsureConnected ¶
EnsureConnected ensures the connection is healthy and returns the gRPC client.
type Duration ¶
Duration represents a time duration that can be unmarshaled from JSON.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface to allow parsing of a Duration from a JSON string or number.
type ExternalChecker ¶
type ExternalChecker struct {
// contains filtered or unexported fields
}
func NewExternalChecker ¶
func NewExternalChecker( ctx context.Context, serviceName, serviceType, address, grpcServiceCheckName string, security *models.SecurityConfig, log logger.Logger, ) (*ExternalChecker, error)
func (*ExternalChecker) Check ¶
func (e *ExternalChecker) Check(ctx context.Context, req *proto.StatusRequest) (healthy bool, details json.RawMessage)
func (*ExternalChecker) Close ¶
func (e *ExternalChecker) Close() error
type ICMPChecker ¶
ICMPChecker performs ICMP checks using a pre-configured scanner.
func NewICMPChecker ¶
func NewICMPChecker(host string, log logger.Logger) (*ICMPChecker, error)
func NewICMPCheckerWithDeviceID ¶
func NewICMPCheckerWithDeviceID(host, deviceID string, log logger.Logger) (*ICMPChecker, error)
func (*ICMPChecker) Check ¶
func (p *ICMPChecker) Check(ctx context.Context, req *proto.StatusRequest) (isAccessible bool, statusMsg json.RawMessage)
type ICMPResponse ¶
type ICMPResponse struct {
Host string `json:"host"`
ResponseTime int64 `json:"response_time"` // in nanoseconds
PacketLoss float64 `json:"packet_loss"`
Available bool `json:"available"`
AgentID string `json:"agent_id,omitempty"` // Optional agent ID for context
PollerID string `json:"poller_id,omitempty"` // Optional poller ID for context
DeviceID string `json:"device_id,omitempty"` // Device ID for proper correlation (partition:host_ip)
}
ICMPResponse defines the structure of the ICMP check result.
type KVStore ¶
KVStore defines the interface for key-value store operations. It embeds the shared configuration KV interface so agent stores remain compatible with the config loader while allowing optional extensions (e.g. PutIfAbsent).
type MapperConfig ¶
type MapperConfig struct {
Address string `json:"address"` // Address of the mapper service
}
MapperConfig represents the configuration for the mapper service
type MapperDiscoveryChecker ¶
type MapperDiscoveryChecker struct {
// contains filtered or unexported fields
}
MapperDiscoveryChecker implements checker.Checker for initiating and monitoring mapper discovery jobs.
func NewMapperDiscoveryChecker ¶
func NewMapperDiscoveryChecker( ctx context.Context, details string, security *models.SecurityConfig, log logger.Logger, ) (*MapperDiscoveryChecker, error)
NewMapperDiscoveryChecker creates a new instance of MapperDiscoveryChecker.
func (*MapperDiscoveryChecker) Check ¶
func (mdc *MapperDiscoveryChecker) Check(ctx context.Context, req *proto.StatusRequest) (bool, json.RawMessage)
Check parses the discovery parameters, optionally initiates a job, and returns the status/results
func (*MapperDiscoveryChecker) Close ¶
func (mdc *MapperDiscoveryChecker) Close() error
Close gracefully closes the gRPC client connection to the mapper.
type MapperDiscoveryDetails ¶
type MapperDiscoveryDetails struct {
IncludeRawData bool `json:"include_raw_data,omitempty"`
}
type MockKVStore ¶
type MockKVStore struct {
// contains filtered or unexported fields
}
MockKVStore is a mock of KVStore interface.
func NewMockKVStore ¶
func NewMockKVStore(ctrl *gomock.Controller) *MockKVStore
NewMockKVStore creates a new mock instance.
func (*MockKVStore) Create ¶ added in v1.0.55
func (m *MockKVStore) Create(arg0 context.Context, arg1 string, arg2 []byte, arg3 time.Duration) error
Create mocks base method.
func (*MockKVStore) Delete ¶
func (m *MockKVStore) Delete(arg0 context.Context, arg1 string) error
Delete mocks base method.
func (*MockKVStore) EXPECT ¶
func (m *MockKVStore) EXPECT() *MockKVStoreMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockKVStoreMockRecorder ¶
type MockKVStoreMockRecorder struct {
// contains filtered or unexported fields
}
MockKVStoreMockRecorder is the mock recorder for MockKVStore.
func (*MockKVStoreMockRecorder) Close ¶
func (mr *MockKVStoreMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockKVStoreMockRecorder) Create ¶ added in v1.0.55
func (mr *MockKVStoreMockRecorder) Create(arg0, arg1, arg2, arg3 any) *gomock.Call
Create indicates an expected call of Create.
func (*MockKVStoreMockRecorder) Delete ¶
func (mr *MockKVStoreMockRecorder) Delete(arg0, arg1 any) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockKVStoreMockRecorder) Get ¶
func (mr *MockKVStoreMockRecorder) Get(arg0, arg1 any) *gomock.Call
Get indicates an expected call of Get.
type MockObjectStore ¶ added in v1.0.55
type MockObjectStore struct {
// contains filtered or unexported fields
}
MockObjectStore is a mock of ObjectStore interface.
func NewMockObjectStore ¶ added in v1.0.55
func NewMockObjectStore(ctrl *gomock.Controller) *MockObjectStore
NewMockObjectStore creates a new mock instance.
func (*MockObjectStore) DownloadObject ¶ added in v1.0.55
DownloadObject mocks base method.
func (*MockObjectStore) EXPECT ¶ added in v1.0.55
func (m *MockObjectStore) EXPECT() *MockObjectStoreMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockObjectStoreMockRecorder ¶ added in v1.0.55
type MockObjectStoreMockRecorder struct {
// contains filtered or unexported fields
}
MockObjectStoreMockRecorder is the mock recorder for MockObjectStore.
func (*MockObjectStoreMockRecorder) DownloadObject ¶ added in v1.0.55
func (mr *MockObjectStoreMockRecorder) DownloadObject(arg0, arg1 any) *gomock.Call
DownloadObject indicates an expected call of DownloadObject.
type MockService ¶
type MockService struct {
// contains filtered or unexported fields
}
MockService is a mock of Service interface.
func NewMockService ¶
func NewMockService(ctrl *gomock.Controller) *MockService
NewMockService creates a new mock instance.
func (*MockService) EXPECT ¶
func (m *MockService) EXPECT() *MockServiceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockService) Start ¶
func (m *MockService) Start(arg0 context.Context) error
Start mocks base method.
func (*MockService) Stop ¶
func (m *MockService) Stop(arg0 context.Context) error
Stop mocks base method.
func (*MockService) UpdateConfig ¶
func (m *MockService) UpdateConfig(arg0 *models.Config) error
UpdateConfig mocks base method.
type MockServiceMockRecorder ¶
type MockServiceMockRecorder struct {
// contains filtered or unexported fields
}
MockServiceMockRecorder is the mock recorder for MockService.
func (*MockServiceMockRecorder) Name ¶
func (mr *MockServiceMockRecorder) Name() *gomock.Call
Name indicates an expected call of Name.
func (*MockServiceMockRecorder) Start ¶
func (mr *MockServiceMockRecorder) Start(arg0 any) *gomock.Call
Start indicates an expected call of Start.
func (*MockServiceMockRecorder) Stop ¶
func (mr *MockServiceMockRecorder) Stop(arg0 any) *gomock.Call
Stop indicates an expected call of Stop.
func (*MockServiceMockRecorder) UpdateConfig ¶
func (mr *MockServiceMockRecorder) UpdateConfig(arg0 any) *gomock.Call
UpdateConfig indicates an expected call of UpdateConfig.
type MockSweepStatusProvider ¶
type MockSweepStatusProvider struct {
// contains filtered or unexported fields
}
MockSweepStatusProvider is a mock of SweepStatusProvider interface.
func NewMockSweepStatusProvider ¶
func NewMockSweepStatusProvider(ctrl *gomock.Controller) *MockSweepStatusProvider
NewMockSweepStatusProvider creates a new mock instance.
func (*MockSweepStatusProvider) EXPECT ¶
func (m *MockSweepStatusProvider) EXPECT() *MockSweepStatusProviderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSweepStatusProvider) GetStatus ¶
func (m *MockSweepStatusProvider) GetStatus(arg0 context.Context) (*proto.StatusResponse, error)
GetStatus mocks base method.
type MockSweepStatusProviderMockRecorder ¶
type MockSweepStatusProviderMockRecorder struct {
// contains filtered or unexported fields
}
MockSweepStatusProviderMockRecorder is the mock recorder for MockSweepStatusProvider.
type ObjectStore ¶ added in v1.0.55
ObjectStore defines read access to the JetStream-backed object store.
type PortChecker ¶
func NewPortChecker ¶
func NewPortChecker(details string, log logger.Logger) (*PortChecker, error)
func (*PortChecker) Check ¶
func (p *PortChecker) Check(ctx context.Context, _ *proto.StatusRequest) (isAccessible bool, statusMsg json.RawMessage)
Check validates if a port is accessible.
func (*PortChecker) Close ¶
func (*PortChecker) Close() error
type ProcessChecker ¶
type ProcessChecker struct {
ProcessName string
// contains filtered or unexported fields
}
func (*ProcessChecker) Check ¶
func (p *ProcessChecker) Check(ctx context.Context, req *proto.StatusRequest) (isActive bool, statusMsg json.RawMessage)
Check validates if a process is running.
func (*ProcessChecker) Close ¶
func (*ProcessChecker) Close() error
type SNMPChecker ¶
type SNMPChecker struct {
// contains filtered or unexported fields
}
func (*SNMPChecker) Check ¶
func (c *SNMPChecker) Check(ctx context.Context, req *proto.StatusRequest) (available bool, msg json.RawMessage)
type ScanStats ¶
type ScanStats struct {
// contains filtered or unexported fields
}
ScanStats tracks scanning statistics.
type Server ¶
type Server struct {
proto.UnimplementedAgentServiceServer
// contains filtered or unexported fields
}
Server represents the main agent server that handles checker coordination and service management.
func NewServer ¶
func NewServer(ctx context.Context, configDir string, cfg *ServerConfig, log logger.Logger) (*Server, error)
NewServer initializes a new Server instance.
func (*Server) GetResults ¶
func (s *Server) GetResults(ctx context.Context, req *proto.ResultsRequest) (*proto.ResultsResponse, error)
GetResults implements the AgentService GetResults method. For grpc services, this forwards the call to the actual service. For sweep services, this calls the local sweep service. For other services, this returns a "not supported" response. GetResults handles results requests for various service types.
func (*Server) GetStatus ¶
func (s *Server) GetStatus(ctx context.Context, req *proto.StatusRequest) (*proto.StatusResponse, error)
GetStatus handles status requests for various service types.
func (*Server) ListServices ¶
ListServices returns a list of all configured service names.
func (*Server) ListenAddr ¶
ListenAddr returns the server's listening address.
func (*Server) RestartServices ¶ added in v1.0.55
RestartServices stops and starts all managed services using the current configuration.
func (*Server) SecurityConfig ¶
func (s *Server) SecurityConfig() *models.SecurityConfig
SecurityConfig returns the server's security configuration.
func (*Server) StreamResults ¶
func (s *Server) StreamResults(req *proto.ResultsRequest, stream proto.AgentService_StreamResultsServer) error
StreamResults implements the AgentService StreamResults method for large datasets. For sweep services, this calls the local sweep service and streams the results. For grpc services, this forwards the streaming call to the actual service. For other services, this returns a "not supported" response. StreamResults handles streaming results requests for large datasets.
func (*Server) UpdateConfig ¶ added in v1.0.55
func (s *Server) UpdateConfig(newCfg *ServerConfig)
UpdateConfig applies logging/security updates at runtime where possible. Security changes typically require a restart to fully apply to gRPC servers/clients.
type ServerConfig ¶
type ServerConfig struct {
AgentID string `json:"agent_id"` // Unique identifier for this agent
AgentName string `json:"agent_name,omitempty"` // Explicit name for KV namespacing
HostIP string `json:"host_ip,omitempty"` // Host IP address for device correlation
Partition string `json:"partition,omitempty"` // Partition for device correlation
ListenAddr string `json:"listen_addr"`
Security *models.SecurityConfig `json:"security" hot:"rebuild"`
KVAddress string `json:"kv_address,omitempty"` // Optional KV store address
KVSecurity *models.SecurityConfig `json:"kv_security,omitempty"` // Separate security config for KV
CheckersDir string `json:"checkers_dir"`
Logging *logger.Config `json:"logging,omitempty" hot:"reload"`
}
ServerConfig holds the configuration for the agent server.
type Service ¶
type Service interface {
Start(context.Context) error
Stop(ctx context.Context) error
Name() string
UpdateConfig(config *models.Config) error // Added for dynamic config updates
}
Service defines the interface for agent services that can be started, stopped, and configured.
type ServiceError ¶
ServiceError represents an error that occurred in a specific service.
func (*ServiceError) Error ¶
func (e *ServiceError) Error() string
Error implements the error interface for ServiceError.
type SweepConfig ¶
type SweepConfig struct {
MaxTargets int
MaxGoroutines int
BatchSize int
MemoryLimit int64
Networks []string `json:"networks"`
Ports []int `json:"ports"`
SweepModes []models.SweepMode `json:"sweep_modes"`
DeviceTargets []models.DeviceTarget `json:"device_targets,omitempty"` // Per-device sweep configuration
Interval Duration `json:"interval"`
Concurrency int `json:"concurrency"`
Timeout Duration `json:"timeout"`
}
SweepConfig defines configuration parameters for network sweep operations.
type SweepService ¶
type SweepService struct {
// contains filtered or unexported fields
}
SweepService implements Service for network scanning.
func (*SweepService) Check ¶
func (s *SweepService) Check(ctx context.Context, _ *proto.StatusRequest) (bool, json.RawMessage)
func (*SweepService) Close ¶
func (s *SweepService) Close() error
func (*SweepService) GetStatus ¶
func (s *SweepService) GetStatus(ctx context.Context) (*proto.StatusResponse, error)
GetStatus returns the current status of the sweep service (lightweight version without hosts).
func (*SweepService) GetSweepResults ¶
func (s *SweepService) GetSweepResults(ctx context.Context, lastSequence string) (*proto.ResultsResponse, error)
GetSweepResults returns sweep results with sequence tracking for change detection.
func (*SweepService) Start ¶
func (s *SweepService) Start(ctx context.Context) error
Start begins the sweep service.
func (*SweepService) Stop ¶
func (s *SweepService) Stop(_ context.Context) error
Stop gracefully stops the sweep service.
func (*SweepService) UpdateConfig ¶
func (s *SweepService) UpdateConfig(config *models.Config) error
UpdateConfig updates the service configuration.
type SweepStatusProvider ¶
type SweepStatusProvider interface {
GetStatus(context.Context) (*proto.StatusResponse, error)
}
SweepStatusProvider is an interface for services that can provide sweep status.