-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[receiver/ciscoosreceiver] Add Cisco network device monitoring receiver #42742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
9ea32ae
71c30ed
9d5d329
c741e9d
a7d9b0d
11e3222
317b569
b10c473
c297c82
7ae4ebe
6207907
ba233b8
d7006dd
16bbc89
309e451
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
| change_type: new_component | ||
|
|
||
| # The name of the component (path or short name is acceptable) | ||
| component: receiver/ciscoosreceiver | ||
|
|
||
| # A brief description of the change | ||
| note: "Add initial skeleton of Cisco OS receiver (README, config, factory, metadata) with In Development stability." | ||
|
|
||
| # Mandatory: tracking issues (use PR number if no issue exists) | ||
| issues: [42647] | ||
|
|
||
| # Optional: additional lines shown under the main note | ||
| subtext: | | ||
| This PR adds structure only (no scraping implementation yet). | ||
| Scrapers and SSH-based collection logic (BGP, Environment, Facts, Interfaces, Optics) will be added in follow-up PRs. | ||
|
|
||
| # Change logs where this entry should appear | ||
| change_logs: [user] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1 @@ | ||
| KiranmayiB | ||
| jordivilaseca | ||
| MoreraAlejandro |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include ../../Makefile.Common |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # Cisco OS Receiver | ||
|
|
||
| <!-- status autogenerated section --> | ||
| | Status | | | ||
| | ------------- |-----------| | ||
| | Stability | [development]: metrics | | ||
| | Distributions | [] | | ||
| | Issues | [](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fciscoos) [](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fciscoos) | | ||
| | Code coverage | [](https://app.codecov.io/gh/open-telemetry/opentelemetry-collector-contrib/tree/main/?components%5B0%5D=receiver_ciscoosreceiver&displayType=list) | | ||
| | [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@dmitryax](https://www.github.com/dmitryax) | | ||
|
|
||
| [development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development | ||
| <!-- end autogenerated section --> | ||
|
|
||
| The Cisco OS Receiver is a modular receiver that collects metrics from Cisco network devices via SSH connections. It supports multiple scrapers for comprehensive network monitoring and provides native OpenTelemetry OTLP metrics generation. | ||
|
|
||
| ## Configuration | ||
|
|
||
| The following settings are available: | ||
|
|
||
| | Setting | Type | Required | Description | | ||
| |---------|------|----------|-------------| | ||
| | `devices` | []DeviceConfig | Yes | List of Cisco devices to monitor | | ||
| | `collection_interval` | duration | No | How often to collect metrics (default: 60s) | | ||
| | `timeout` | duration | No | SSH connection and command timeout (default: 30s) | | ||
| | `scrapers` | ScrapersConfig | Yes | Enable/disable specific scrapers | | ||
|
|
||
| ### Device Configuration | ||
|
|
||
| | Setting | Type | Required | Description | | ||
| |---------|------|----------|-------------| | ||
| | `host` | string | Yes | Device address in `host:port` format | | ||
| | `username` | string | Yes | SSH username for authentication | | ||
| | `password` | string | No* | Password for authentication | | ||
| | `key_file` | string | No* | Path to SSH private key file | | ||
|
|
||
| *Either `password` or `key_file` is required, but not both. | ||
|
|
||
| ### Scrapers Configuration | ||
|
|
||
| | Setting | Type | Description | | ||
| |---------|------|-------------| | ||
| | `bgp` | bool | BGP session metrics | | ||
| | `environment` | bool | Temperature and power metrics | | ||
| | `facts` | bool | System information metrics | | ||
| | `interfaces` | bool | Interface status and statistics | | ||
| | `optics` | bool | Optical transceiver metrics | | ||
|
|
||
| ## Scrapers | ||
|
|
||
| The receiver supports the following scrapers: | ||
|
|
||
| - **BGP**: Collects BGP session information and statistics | ||
| - **Environment**: Collects temperature and power consumption metrics | ||
| - **Facts**: Collects system information (OS version, memory, CPU utilization) | ||
| - **Interfaces**: Collects interface statistics (bytes, packets, errors) | ||
| - **Optics**: Collects optical signal strength information | ||
|
|
||
| ## Example Configuration | ||
|
|
||
| ```yaml | ||
| receivers: | ||
| ciscoosreceiver: | ||
| collection_interval: 60s | ||
| timeout: 30s | ||
| scrapers: | ||
| bgp: true | ||
| environment: true | ||
| facts: true | ||
| interfaces: true | ||
| optics: true | ||
| devices: | ||
| - host: "cisco-device:22" | ||
| username: "admin" | ||
| password: "password" | ||
|
|
||
| exporters: | ||
| debug: | ||
| verbosity: detailed | ||
|
|
||
| service: | ||
| pipelines: | ||
| metrics: | ||
| receivers: [ciscoosreceiver] | ||
| exporters: [debug] | ||
| ``` | ||
|
|
||
| ## Metrics | ||
dmitryax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| | Metric | Type | Description | Attributes | | ||
| |--------|------|-------------|------------| | ||
| | `cisco.device.connected` | Gauge | Device connectivity status (1=connected, 0=disconnected) | `host` | | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package ciscoosreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/ciscoosreceiver" | ||
|
|
||
| import ( | ||
| "errors" | ||
| "time" | ||
|
|
||
| "go.opentelemetry.io/collector/scraper/scraperhelper" | ||
|
|
||
| "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/ciscoosreceiver/internal/metadata" | ||
| ) | ||
|
|
||
| // Config represents the receiver configuration | ||
| type Config struct { | ||
| scraperhelper.ControllerConfig `mapstructure:",squash"` | ||
| metadata.MetricsBuilderConfig `mapstructure:",squash"` | ||
|
|
||
| CollectionInterval time.Duration `mapstructure:"collection_interval"` | ||
| Devices []DeviceConfig `mapstructure:"devices"` | ||
| Timeout time.Duration `mapstructure:"timeout"` | ||
dmitryax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Scrapers ScrapersConfig `mapstructure:"scrapers"` | ||
| } | ||
|
|
||
| // DeviceConfig represents configuration for a single Cisco device | ||
| type DeviceConfig struct { | ||
| Host string `mapstructure:"host"` | ||
| KeyFile string `mapstructure:"key_file"` | ||
| Username string `mapstructure:"username"` | ||
| Password string `mapstructure:"password"` | ||
| } | ||
|
|
||
| // ScrapersConfig represents which scrapers are enabled | ||
| type ScrapersConfig struct { | ||
| BGP bool `mapstructure:"bgp"` | ||
| Environment bool `mapstructure:"environment"` | ||
| Facts bool `mapstructure:"facts"` | ||
| Interfaces bool `mapstructure:"interfaces"` | ||
| Optics bool `mapstructure:"optics"` | ||
| } | ||
|
|
||
| // Validate checks if the receiver configuration is valid | ||
| func (cfg *Config) Validate() error { | ||
| if len(cfg.Devices) == 0 { | ||
| return errors.New("at least one device must be configured") | ||
| } | ||
|
|
||
| for _, device := range cfg.Devices { | ||
| if device.Host == "" { | ||
| return errors.New("device host cannot be empty") | ||
| } | ||
|
|
||
| // Authentication validation logic: | ||
| // 1. If using key file: username + key_file (password optional) | ||
| // 2. If not using key file: username + password required | ||
| if device.KeyFile != "" { | ||
| // Key file authentication: requires username | ||
| if device.Username == "" { | ||
| return errors.New("device username cannot be empty") | ||
| } | ||
| } else { | ||
| // Password authentication: requires both username and password | ||
| if device.Username == "" { | ||
| return errors.New("device username cannot be empty") | ||
| } | ||
| if device.Password == "" { | ||
| return errors.New("device password cannot be empty") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if cfg.Timeout <= 0 { | ||
| return errors.New("timeout must be greater than 0") | ||
| } | ||
|
|
||
| if cfg.CollectionInterval <= 0 { | ||
| return errors.New("collection_interval must be greater than 0") | ||
| } | ||
dmitryax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Check if at least one scraper is enabled | ||
| if !cfg.Scrapers.BGP && !cfg.Scrapers.Environment && !cfg.Scrapers.Facts && !cfg.Scrapers.Interfaces && !cfg.Scrapers.Optics { | ||
| return errors.New("at least one scraper must be enabled") | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.