Documentation
¶
Index ¶
- type CachedDetectionResult
- type CatalogDefault
- type CheckConfig
- type CollectItem
- type CollectStrategy
- type CollectedData
- type Condition
- type ConfigMatcher
- type ConfigMatcherConfig
- type ConnectivityCheckConfig
- type ConnectivityChecker
- type DetectionCache
- type DetectionRequest
- type DetectionResult
- type DetectionRule
- type DeviceDetector
- type DeviceInfoCollectConfig
- type FallbackItem
- type FallbackPath
- type InfoCollector
- type MatchConfig
- type MatchingStrategy
- type Pattern
- type ProtocolConfig
- type ProtocolResult
- type RuleLoader
- type SNMPItemConfig
- type SSHCredentials
- type SSHItemConfig
- type TelnetCredentials
- type VersionExtractRule
- type VersionExtractor
- type VersionMapping
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedDetectionResult ¶
type CachedDetectionResult struct {
Result *DetectionResult
DetectedAt time.Time
ExpiresAt time.Time
}
CachedDetectionResult 缓存的检测结果
type CatalogDefault ¶
type CatalogDefault struct {
Manufacturer string `yaml:"manufacturer"`
Platform string `yaml:"platform"`
}
CatalogDefault 分类默认值
type CheckConfig ¶
type CheckConfig struct {
Type string `yaml:"type"`
OID string `yaml:"oid,omitempty"`
Port int `yaml:"port,omitempty"`
Timeout string `yaml:"timeout"`
Retries int `yaml:"retries"`
}
CheckConfig 检测配置
type CollectItem ¶
type CollectItem struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
Method string `yaml:"method"`
Target string `yaml:"target"`
Timeout string `yaml:"timeout"`
Output string `yaml:"output"` // 可以是单个字段或多个字段(逗号分隔)
Required bool `yaml:"required"`
Fallback []FallbackItem `yaml:"fallback,omitempty"`
SNMPConfig *SNMPItemConfig `yaml:"snmpConfig,omitempty"` // SNMP特定配置
SSHConfig *SSHItemConfig `yaml:"sshConfig,omitempty"` // SSH特定配置
}
CollectItem 采集项
type CollectStrategy ¶
type CollectStrategy struct {
Name string `yaml:"name"`
Priority int `yaml:"priority"`
Conditions []Condition `yaml:"conditions"`
Collect []CollectItem `yaml:"collect"`
}
CollectStrategy 采集策略
type ConfigMatcher ¶
type ConfigMatcher struct {
// contains filtered or unexported fields
}
ConfigMatcher 配置匹配器
func NewConfigMatcher ¶
func NewConfigMatcher(templatePath string, pipelineService *ps.PipelineService) (*ConfigMatcher, error)
NewConfigMatcher 创建配置匹配器
func (*ConfigMatcher) Match ¶
func (cm *ConfigMatcher) Match(manufacturer, platform, version, catalog string) (*structs.DeviceConfig, error)
Match 匹配设备配置
type ConfigMatcherConfig ¶
type ConfigMatcherConfig struct {
Name string `yaml:"name"`
Strategies []MatchingStrategy `yaml:"strategies"`
VersionMappings []VersionMapping `yaml:"versionMappings,omitempty"`
DefaultConfigs map[string]string `yaml:"defaultConfigs,omitempty"`
}
ConfigMatcherConfig 配置匹配器配置
type ConnectivityCheckConfig ¶
type ConnectivityCheckConfig struct {
Name string `yaml:"name"`
Timeout string `yaml:"timeout"`
Protocols []ProtocolConfig `yaml:"protocols"`
}
ConnectivityCheckConfig 连接检测配置
type ConnectivityChecker ¶
type ConnectivityChecker struct {
// contains filtered or unexported fields
}
ConnectivityChecker 连接检测器 MVP: 基于配置文件的连接检测模块
func NewConnectivityChecker ¶
func NewConnectivityChecker(templatePath string) (*ConnectivityChecker, error)
NewConnectivityChecker 创建连接检测器
func (*ConnectivityChecker) Check ¶
func (cc *ConnectivityChecker) Check(req *DetectionRequest) (map[string]bool, error)
Check 检测设备连接性 基于配置文件中的协议配置进行检测
type DetectionCache ¶
type DetectionCache struct {
// contains filtered or unexported fields
}
DetectionCache 检测结果缓存
func NewDetectionCache ¶
func NewDetectionCache(ttl time.Duration) *DetectionCache
NewDetectionCache 创建检测缓存
func (*DetectionCache) CleanExpired ¶
func (dc *DetectionCache) CleanExpired()
CleanExpired 清理过期的缓存项
func (*DetectionCache) Get ¶
func (dc *DetectionCache) Get(ip string) (*DetectionResult, bool)
Get 获取缓存的检测结果
func (*DetectionCache) Set ¶
func (dc *DetectionCache) Set(ip string, result *DetectionResult)
Set 设置缓存的检测结果
type DetectionRequest ¶
type DetectionRequest struct {
IP string
SNMPCommunity string
SSHCredentials *SSHCredentials
TelnetCredentials *TelnetCredentials
}
DetectionRequest 检测请求
type DetectionResult ¶
type DetectionResult struct {
Manufacturer string `json:"manufacturer"`
Platform string `json:"platform"`
Version string `json:"version"`
Catalog string `json:"catalog"`
Confidence float64 `json:"confidence"`
DeviceConfig *structs.DeviceConfig `json:"device_config,omitempty"`
Errors []error `json:"errors,omitempty"`
DetectedAt time.Time `json:"detected_at"`
}
DetectionResult 检测结果
type DetectionRule ¶
type DetectionRule struct {
Name string `yaml:"name"`
Manufacturer string `yaml:"manufacturer"`
Platform string `yaml:"platform"`
Catalog string `yaml:"catalog"`
Priority int `yaml:"priority"`
Patterns []Pattern `yaml:"patterns"`
VersionExtract *VersionExtractRule `yaml:"versionExtract,omitempty"`
Score float64 // 运行时计算的匹配分数
}
DetectionRule 检测规则
type DeviceDetector ¶
type DeviceDetector struct {
// contains filtered or unexported fields
}
DeviceDetector 设备检测器 MVP: 模块化设计,配置驱动
func NewDeviceDetector ¶
func NewDeviceDetector(templatePath string) (*DeviceDetector, error)
NewDeviceDetector 创建设备检测器 MVP: 初始化所有模块化组件
func (*DeviceDetector) Detect ¶
func (dd *DeviceDetector) Detect(req *DetectionRequest) (*DetectionResult, error)
Detect 执行设备检测 MVP: 使用模块化组件,配置驱动的检测流程
func (*DeviceDetector) VerifyDetection ¶
func (dd *DeviceDetector) VerifyDetection(req *DetectionRequest, result *DetectionResult) error
VerifyDetection 验证检测结果
type DeviceInfoCollectConfig ¶
type DeviceInfoCollectConfig struct {
Name string `yaml:"name"`
Timeout string `yaml:"timeout"`
Retries int `yaml:"retries"`
Strategies []CollectStrategy `yaml:"strategies"`
}
DeviceInfoCollectConfig 设备信息采集配置
type FallbackPath ¶
type FallbackPath struct {
PathTemplate string `yaml:"pathTemplate"`
}
FallbackPath 备选路径
type InfoCollector ¶
type InfoCollector struct {
// contains filtered or unexported fields
}
InfoCollector 信息采集器 MVP: 基于配置文件的信息采集模块
func NewInfoCollector ¶
func NewInfoCollector(templatePath string) (*InfoCollector, error)
NewInfoCollector 创建信息采集器
func (*InfoCollector) Collect ¶
func (ic *InfoCollector) Collect(req *DetectionRequest, protocols map[string]bool) (CollectedData, error)
Collect 采集设备信息 基于配置文件中的策略和采集项进行采集
type MatchConfig ¶
type MatchConfig struct {
Manufacturer string `yaml:"manufacturer"`
Platform string `yaml:"platform"`
Version string `yaml:"version"`
Catalog string `yaml:"catalog"`
}
MatchConfig 匹配配置
type MatchingStrategy ¶
type MatchingStrategy struct {
Name string `yaml:"name"`
Priority int `yaml:"priority"`
Match MatchConfig `yaml:"match"`
PathTemplate string `yaml:"pathTemplate"`
Fallback []FallbackPath `yaml:"fallback,omitempty"`
DefaultPlatforms map[string]string `yaml:"defaultPlatforms,omitempty"`
CatalogDefaults map[string]CatalogDefault `yaml:"catalogDefaults,omitempty"`
}
MatchingStrategy 匹配策略
type Pattern ¶
type Pattern struct {
Source string `yaml:"source"`
Regex string `yaml:"regex"`
Confidence float64 `yaml:"confidence"`
Required bool `yaml:"required"`
}
Pattern 匹配模式
type ProtocolConfig ¶
type ProtocolConfig struct {
Name string `yaml:"name"`
Enabled bool `yaml:"enabled"`
Check CheckConfig `yaml:"check"`
Priority int `yaml:"priority"`
}
ProtocolConfig 协议配置
type ProtocolResult ¶
ProtocolResult 协议检测结果
type RuleLoader ¶
type RuleLoader struct {
// contains filtered or unexported fields
}
RuleLoader 规则加载器
func NewRuleLoader ¶
func NewRuleLoader(templatePath string) (*RuleLoader, error)
NewRuleLoader 创建规则加载器
func (*RuleLoader) GetMatchedRule ¶
func (rl *RuleLoader) GetMatchedRule(collectedData CollectedData) *DetectionRule
GetMatchedRule 获取匹配的规则(用于版本提取)
func (*RuleLoader) MatchRules ¶
func (rl *RuleLoader) MatchRules(collectedData CollectedData) (*DetectionResult, error)
MatchRules 匹配规则
type SNMPItemConfig ¶
type SNMPItemConfig struct {
IndexPositions []int `yaml:"indexPositions"`
ClassifierPositions []int `yaml:"classifierPositions"`
PrefixMap map[string]string `yaml:"prefixMap"`
}
SNMPItemConfig SNMP采集项配置
type SSHCredentials ¶
SSHCredentials SSH凭证
type SSHItemConfig ¶
type SSHItemConfig struct {
Port int `yaml:"port,omitempty"`
Timeout string `yaml:"timeout,omitempty"`
}
SSHItemConfig SSH采集项配置
type TelnetCredentials ¶
TelnetCredentials TELNET凭证
type VersionExtractRule ¶
type VersionExtractRule struct {
Source string `yaml:"source"`
Regex string `yaml:"regex"`
Groups []string `yaml:"groups"`
}
VersionExtractRule 版本提取规则
type VersionExtractor ¶
type VersionExtractor struct {
}
VersionExtractor 版本提取器 MVP: 基于规则的版本提取模块
func (*VersionExtractor) Extract ¶
func (ve *VersionExtractor) Extract(collectedData CollectedData, rule *DetectionRule) string
Extract 提取版本信息 基于规则中的versionExtract配置提取版本
type VersionMapping ¶
VersionMapping 版本映射