Note: I have since moved my entire telemetry pipeline over to InfluxDB because it handles time series data and visualization a lot better. Because of that, the code here is completely frozen and I won't be updating or maintaining it.
This Bash script automates the retrieval of network telemetry from a local cable modem gateway using its native REST API. It handles nested JSON payloads, transforms the data into flattened structures, and simultaneously records the metrics into two distinct formats:
- Flat Logs: Appends metrics into timestamped CSV files.
- Relational Database: Dynamically streams data into a structured MySQL or MariaDB database configuration.
The logic dynamically scales to handle the precise number of active downstream and upstream channels present on the modem during execution.
- Downstream Data: Channel IDs, Frequency, Power, SNR, RxMer, Modulation profiles, Lock Status, and Pre or Post RS Error counts.
- Upstream Data: Channel IDs, Frequency, Power, Modulation, Symbol Rate, and T1 to T4 Timeout tracking.
- Modem State: System Uptime, DOCSIS version, Config boot filename, Access states, and Maximum CPE allocations.
- Service Flows: ID tracking, Directional mapping for Upload and Download, Traffic rates, Burst sizes, and Schedule types.
To protect sensitive data, all authentication credentials and local environment paths are entirely decoupled from the core script logic.
The pipeline looks for a local configuration file named dot env in the working directory to source variables on execution:
DB_NAME=cable_modem
DB_USER=your_secure_user
DB_PASS=your_secure_passwordFor historical context, running this legacy version required the following system utilities:
- Bash (
v4.0or higher) - jq (Command-line JSON processor)
- wget (Network retrieval tool)
- MySQL / MariaDB Client (Relational database engine)