This Python script fetches details from pfSense devices and updates a CSV file with the retrieved information. It logs into the pfSense devices using the provided credentials, retrieves version information, system type, and uptime, and then writes this data to the specified CSV file.
- Prompts user for credentials and choice of input method (manual IP entry or CSV file).
- Logs into pfSense devices to retrieve version information, system type, and uptime.
- Updates the provided CSV file with the fetched details.
- Displays log messages to keep track of the process.
- Python 3.6 or higher
requests
libraryBeautifulSoup4
library
You can install the required libraries using pip:
pip install requests beautifulsoup4
## Usage
-
Clone this repository to your local machine.
-
Navigate to the directory containing the script.
-
Prepare a CSV file with the following structure:
Store Name,pfSense IP,pfSense Version,pfSense System Type,pfSense Uptime Store1,192.168.1.1,,, Store2,192.168.2.1,,, Store3,192.168.3.1,,,
-
Run the script:
python pfsense_details_fetcher.py
-
Follow the on-screen prompts to enter your username and password.
-
Choose whether to enter the pfSense IP manually or use the CSV file.
Enter your username: admin
Enter your password:
Do you want to provide pfSense IP manually? (yes/no): yes
Enter pfSense IP: 192.168.1.1
('Logging in to the pfSense at IP:', '192.168.1.1', 'for store:', 'manual entry')
('Logged in to the pfSense at IP:', '192.168.1.1')
('Fetching details for pfSense IP:', '192.168.1.1', 'for store:', 'manual entry')
pfSense Version: 2.5.2-RELEASE
pfSense System Type: APU2
pfSense Uptime: 15 days, 3 hours, 22 minutes
Enter your username: admin
Enter your password:
Do you want to provide pfSense IP manually? (yes/no): no
Enter the path to the CSV file: /home/adm/scripts/pfsense-script/sample.csv
('Logging in to the pfSense at IP:', '192.168.1.1', 'for store:', 'Store1')
('Logged in to the pfSense at IP:', '192.168.1.1')
('Fetching details for pfSense IP:', '192.168.1.1', 'for store:', 'Store1')
('Logging in to the pfSense at IP:', '192.168.2.1', 'for store:', 'Store2')
('Logged in to the pfSense at IP:', '192.168.2.1')
('Fetching details for pfSense IP:', '192.168.2.1', 'for store:', 'Store2')
('Logging in to the pfSense at IP:', '192.168.3.1', 'for store:', 'Store3')
('Logged in to the pfSense at IP:', '192.168.3.1')
('Fetching details for pfSense IP:', '192.168.3.1', 'for store:', 'Store3')
('Details saved to the CSV file:', '/home/adm/scripts/pfsense-script/sample.csv')
Saved!