Network Device Detail Fetcher Actor
Pricing
from $0.01 / 1,000 results
Network Device Detail Fetcher Actor
An Apify Actor that fetches detailed information about network devices via SSH. This Actor is designed to efficiently retrieve device data from multiple hosts while maintaining robust error handling and minimal resource usage.
Pricing
from $0.01 / 1,000 results
Rating
0.0
(0)
Developer

Sriniketh J
Actor stats
0
Bookmarked
2
Total users
1
Monthly active users
16 days ago
Last modified
Categories
Share
An Apify Actor that fetches detailed information about network devices via SSH. This Actor is designed to efficiently retrieve device data from multiple hosts while maintaining robust error handling and minimal resource usage.
Features
- SSH-based device connectivity - Connect to multiple network devices securely using SSH
- Command execution - Execute arbitrary commands on remote devices with optional sudo support
- CSV-based device management - Load device configuration from CSV files
- Structured output - Organize command outputs in a structured JSON format for easy analysis
- Error handling - Graceful error handling with detailed logging for failed connections and commands
- Async support - Leverages async/await for efficient cloud execution on Apify platform
Input
The Actor accepts the following input configuration:
{"csvFilePath": "path/to/devices.csv"}
CSV Format
Create a CSV file with device details in the following format:
Serial Number,IP,Port,Hostname,Password2,192.168.215.2,22,root,root3,192.168.215.3,22,admin,password123
Required fields:
Serial Number- Unique device identifierIP- Device IP addressHostname- SSH username for authentication
Optional fields:
Port- SSH port (default: 22)Password- SSH password for authentication
Output
The Actor pushes structured JSON data to the dataset for each device:
{"device_ip": "192.168.215.2","device_name": "N/A","commands_executed": [{"command": "ip -j addr show","output": "...","error": ""},{"command": "uname -a","output": "...","error": ""}]}
In case of errors:
{"device_ip": "192.168.215.2","error": "SSH connection failed: [Errno -2] Name or service not known"}
Configuration
Devices CSV
- Path:
data/input.csv(default) - Format: CSV with headers matching Device model fields
Commands
Edit src/constants.py to customize which commands execute on each device:
COMMANDS = ["ip -j addr show","ip -j link show","uname -a","lscpu -J",]
SSH Settings
Configure SSH connection timeout in src/constants.py:
SSH_CONNECTION_TIMEOUT = 10 # seconds
Local Development
Prerequisites
- Python 3.13+
- Paramiko (SSH client library)
- Pydantic (data validation)
- Apify SDK
Installation
# Install dependenciespip install -r requirements.txt# Run locallyapify run
Testing
Run the test script to verify device connectivity:
$python test.py
Deployment
Prerequisites
- Apify account
- Apify CLI installed (
npm install -g apify-cli)
Steps
- Authenticate with Apify:
$apify login
- Deploy the Actor:
$apify push
- Run on Apify platform through the web console or API
Project Structure
.├── .actor/│ ├── actor.json # Actor configuration│ └── INPUT_SCHEMA.json # Input validation schema├── src/│ ├── __main__.py # Entry point│ ├── main.py # Actor logic│ ├── models.py # Pydantic data models│ ├── constants.py # Configuration constants│ └── actor/│ ├── connect.py # SSH connection handler│ └── device.py # Device CSV loader├── data/│ └── input.csv # Device configuration file├── storage/ # Local Apify storage (ignored in git)├── Dockerfile # Container configuration├── requirements.txt # Python dependencies└── README.md # This file
Device Model
The src/models.py defines the structure for device configuration:
class Device(BaseModel):serial_number: str = Field(alias="Serial Number")ip: str = Field(alias="IP")port: Optional[int] = Field(alias="Port", default=22)hostname: Optional[str] = Field(alias="Hostname", default=None)password: Optional[str] = Field(alias="Password", default=None)
Error Handling
The Actor implements comprehensive error handling:
- CSV parsing errors - Logged and skipped, allowing other devices to process
- SSH connection failures - Caught and stored in output dataset
- Command execution errors - Captured and included in command output
- Timeout handling - Configurable SSH timeout with proper cleanup
Security Considerations
⚠️ Important: This Actor handles sensitive data (passwords, device IP addresses, command outputs).
- Store credentials securely using Apify's Secrets feature
- Use SSH keys instead of passwords when possible
- Avoid logging sensitive data
- Review device access policies before deployment
- Ensure CSV files are stored securely
Troubleshooting
Connection Refused
- Verify device IP address and port are correct
- Ensure SSH service is running on the device
- Check firewall rules allow SSH access
Authentication Failed
- Verify username (Hostname field) is correct
- Confirm password is accurate
- Check if device uses key-based authentication (not yet supported)
Command Execution Timeout
- Increase
SSH_CONNECTION_TIMEOUTinsrc/constants.py - Verify device is responsive
- Check if commands are hanging waiting for input
Future Enhancements
- Support SSH key-based authentication
- Batch command execution with parallel processing
- Output schema for better Apify Console integration
- Dataset schema for structured data display
- Support for custom device properties
- Command output parsing and structured extraction
License
MIT
Author
Sriniketh J
Support
For issues or questions, please refer to the Apify documentation.


