Log timestamp compliance check and auto-remediation for Cisco IOS/IOS-XE devices using Cisco pyATS and Genie.
This utility validates that devices are configured with the expected syslog timestamp command:
service timestamps log datetime msec localtime show-timezone
It can run a safe dry-run audit, remediate non-compliant devices, optionally save the running configuration, and export CSV compliance reports for audit evidence.
This code base uses Python, Cisco pyATS, and Genie to connect to devices from a testbed file, inspect the current service timestamps log configuration, remediate failed devices, and write a structured CSV report.
The workflow is designed for network operations teams that need a repeatable way to confirm syslog timestamp standards across a fleet of routers and switches.
Accurate syslog timestamps are critical for troubleshooting, incident response, and event correlation across network infrastructure. This tool checks whether each device is using datetime-based local timestamps with milliseconds and timezone information, then applies the approved remediation command when required.
Oluyemi Oshunkoya (yemi_o@outlook.com)
Python
Cisco pyATS
Cisco Genie
Unicon
CSV reporting
log_timestamp_remediate.py Main CLI tool
requirements.txt Python runtime dependencies
pyproject.toml Project metadata and formatting/lint configuration
LICENSE Apache 2.0 license
NOTICE Project notice
examples/testbed.example.yaml Sanitized pyATS testbed template
testbed/ Local testbed folder used by the default command
files/ Generated report folder used by the script
.github/workflows/ci.yml Lightweight GitHub Actions checks
tests/ Unit tests for helper logic
CONTRIBUTING.md Contribution guidelines
SECURITY.md Security and responsible-use guidance
This can be done either by using Cisco's pyATS Docker image or by using a local Python virtual environment.
https://docs.docker.com/get-docker/
docker pull ciscotestautomation/pyats:latest
docker run -it ciscotestautomation/pyats:latest /bin/bash
git clone https://github.com/yzmar4real/syslog_remediation.git
cd syslog_remediationpip3 install -r requirements.txt
git clone https://github.com/yzmar4real/syslog_remediation.git
cd syslog_remediationpython3 -m venv .venv
source .venv/bin/activatepython3 -m pip install --upgrade pip python3 -m pip install -r requirements.txt
The script defaults to this testbed path:
testbed/testbed.yaml
Create it from the included sanitized example:
cp examples/testbed.example.yaml testbed/testbed.yaml
Edit testbed/testbed.yaml with your device hostnames, IP addresses, usernames, passwords, and connection settings.
Real testbed files are ignored by Git because they commonly contain sensitive operational data.
Run a dry-run audit first. This checks compliance and writes a CSV report without changing device configuration:
python3 log_timestamp_remediate.py --dry-run
Run remediation:
python3 log_timestamp_remediate.py
Run remediation and save configuration after a device is confirmed compliant:
python3 log_timestamp_remediate.py --save
python3 log_timestamp_remediate.py [testbed] [options]
Arguments:
testbed: Optional path to a pyATS testbed YAML file. Defaults to testbed/testbed.yaml.Options:
--workers <N>: Number of concurrent device workers. Default: 5.--dry-run: Check compliance only. No configuration changes are made.--save: Run write memory after a device is confirmed compliant.--from-csv <PATH>: Re-run only devices that need attention from a previous CSV report.--devices <NAME,...>: Process only the listed device names from the testbed.-v, --verbose: Enable debug logging.Examples:
# Check all devices without changes python3 log_timestamp_remediate.py --dry-run # Remediate all failed devices using 10 workers python3 log_timestamp_remediate.py --workers 10 # Use a custom testbed python3 log_timestamp_remediate.py testbed/production.yaml --dry-run # Process only selected devices python3 log_timestamp_remediate.py --devices router1,switch1 --dry-run # Follow up only failed/error devices from a previous report python3 log_timestamp_remediate.py --from-csv files/2026-06-22/log_timestamp_check/0_log_timestamp_compliance_20260622_120000.csv
--save only when you are ready to persist the running configuration.Example:
python3 log_timestamp_remediate.py --dry-run python3 log_timestamp_remediate.py --from-csv files/<date>/log_timestamp_check/0_log_timestamp_compliance_<timestamp>.csv --save python3 log_timestamp_remediate.py --dry-run
CSV reports are written to:
files/<YYYY-MM-DD>/log_timestamp_check/<run_number>_log_timestamp_compliance_<timestamp>.csv
The CSV includes:
This tool can modify network device configuration. Always run --dry-run first and verify the target testbed before remediation.
Use --save carefully. It persists successful remediation by issuing write memory after a device is confirmed compliant.
The repository intentionally ignores generated reports and local testbed files because they may contain hostnames, addresses, usernames, or other sensitive operational details.
This project is licensed under the Apache License, Version 2.0. See LICENSE for details.
Owner
Contributors
Categories
NetworkingObservabilityProducts
pyATSLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community