# GRSG Office Cloud Print Agent Securely monitor printers on your local network and send data to the GRSG Office cloud. ## Features - 🔍 Auto-discovers printers on your network via SNMP - 📊 Sends printer metrics (page counts, toner levels) - 🔒 Secure token-based authentication - 🏢 Multi-tenant support (each agent linked to a company) - 📡 Works behind firewalls - agent initiates outbound connection ## Quick Start ### 1. Get Your Agent Token 1. Log in to GRSG Office dashboard as admin 2. Go to **Cloud Agents** tab 3. Click **Add Agent** 4. Select your company and give the agent a name 5. **Copy the token** (it won't be shown again!) ### 2. Install the Agent #### Windows ```batch # Download the agent files # Run install_windows.bat # Then: python grgs_office_agent.py --token YOUR_TOKEN --url https://your-cloud-url.ngrok-free.app ``` #### Linux/Mac ```bash # Download the agent files chmod +x install.sh ./install.sh # Run the agent python3 grgs_office_agent.py --token YOUR_TOKEN --url https://your-cloud-url.ngrok-free.app ``` ### 3. Run as a Service (Linux) ```bash # Copy service file sudo cp grgs_office_agent.service /etc/systemd/system/ # Edit with your token and URL sudo nano /etc/systemd/system/grgs_office_agent.service # Enable and start sudo systemctl enable grgs_office_agent sudo systemctl start grgs_office_agent # Check status sudo systemctl status grgs_office_agent ``` ## Command Line Options ``` --token, -t Agent token (required) --url, -u Cloud backend URL (required) --network, -n Network range to scan (default: 192.168.1.0/24) --scan-only Only scan network, don't sync to cloud --debug, -d Enable debug logging --log-file, -l Log file path (default: grgs_office_agent.log) ``` ## Examples ```bash # Basic usage python3 grgs_office_agent.py -t abc123... -u https://mycompany.ngrok-free.app # Scan a different network python3 grgs_office_agent.py -t abc123... -u https://mycompany.ngrok-free.app -n 10.0.0.0/24 # Just scan and show printers (without syncing) python3 grgs_office_agent.py -t abc123... -u https://mycompany.ngrok-free.app --scan-only # Debug mode python3 grgs_office_agent.py -t abc123... -u https://mycompany.ngrok-free.app --debug ``` ## Requirements - Python 3.7+ - `requests` library - `pysnmp` library (optional, for full SNMP support) ## Firewall Requirements The agent only makes **outbound** HTTPS connections to your cloud backend. No inbound ports need to be opened. ## Troubleshooting ### Agent can't connect to cloud - Check your internet connection - Verify the cloud URL is correct - Ensure the token is valid and active ### No printers found - Verify the network range is correct - Ensure printers support SNMP or have open ports (9100, 515, 631) - Try running with `--debug` for more information ### SNMP not working - Install pysnmp: `pip install pysnmp` - Check SNMP community string (default: "public") - Verify printer has SNMP enabled ## Security - Tokens are 64-character cryptographic strings - All communication uses HTTPS - Agent only sends data outbound; no inbound connections required - Each token is linked to a specific company ## Support For help, contact your GRSG Office administrator. --- ## Installing with Python Environment & Running in Background ### 1. Set Up Python Environment ```bash # Create project directory mkdir ~/Desktop/UbuntuAgent cd ~/Desktop/UbuntuAgent # Set up Python virtual environment python3 -m venv venv source venv/bin/activate # Install required packages pip install requests pysnmp ``` ### 2. Run Agent in Background (Always-On) **Recommended: Use systemd service** 1. Create or copy the service file: ```bash sudo cp grgs_office_agent.service /etc/systemd/system/ sudo nano /etc/systemd/system/grgs_office_agent.service ``` Update `ExecStart` to: ``` ExecStart=/home/parallels/Desktop/UbuntuAgent/venv/bin/python /home/parallels/Desktop/UbuntuAgent/grgs_office_agent.py --token YOUR_TOKEN --url https://your-cloud-url.ngrok-free.app WorkingDirectory=/home/parallels/Desktop/UbuntuAgent ``` 2. Enable and start the service: ```bash sudo systemctl daemon-reload sudo systemctl enable grgs_office_agent sudo systemctl start grgs_office_agent sudo systemctl status grgs_office_agent ``` This ensures your agent runs in the background and restarts automatically. --- ## Installazione con ambiente Python & Esecuzione in background ### 1. Configura l’ambiente Python ```bash # Crea la directory del progetto mkdir ~/Desktop/UbuntuAgent cd ~/Desktop/UbuntuAgent # Crea l’ambiente virtuale Python python3 -m venv venv source venv/bin/activate # Installa i pacchetti necessari pip install requests pysnmp ``` ### 2. Esegui l’agente in background (Sempre attivo) **Consigliato: Usa il servizio systemd** 1. Crea o copia il file di servizio: ```bash sudo cp grgs_office_agent.service /etc/systemd/system/ sudo nano /etc/systemd/system/grgs_office_agent.service ``` Aggiorna `ExecStart` a: ``` ExecStart=/home/tuoutente/Desktop/UbuntuAgent/venv/bin/python grgs_office_agent.py --token TUO_TOKEN --url https://your-cloud-url.ngrok-free.app ``` 2. Abilita e avvia il servizio: ```bash sudo systemctl daemon-reload sudo systemctl enable grgs_office_agent sudo systemctl start grgs_office_agent sudo systemctl status grgs_office_agent ``` Questo garantisce che l’agente sia sempre attivo e si riavvii automaticamente. --- ## How to Configure an Agent To configure the agent during installation: 1. Run the installer script: ```bash sudo bash install.sh ``` 2. Enter your Agent Token when prompted. 3. Enter your Cloud URL (e.g., https://yourserver.com). 4. Enter the network range to scan (default: 192.168.1.0/24). 5. The installer will save your configuration to `agent_config.json` and set up everything automatically. You can find the configuration file at: ``` /home/parallels/Desktop/Ubutu Agent/agent_config.json ``` Modify this file if you need to change settings later. --- ## Come configurare un agente Per configurare l’agente durante l’installazione: 1. Esegui lo script di installazione: ```bash sudo bash install.sh ``` 2. Inserisci il tuo Token Agente quando richiesto. 3. Inserisci l’URL del Cloud (es. https://yourserver.com). 4. Inserisci l’intervallo di rete da scansionare (predefinito: 192.168.1.0/24). 5. Il programma installerà tutto automaticamente e salverà la configurazione in `agent_config.json`. Troverai il file di configurazione qui: ``` /home/parallels/Desktop/UbuntuAgent/agent_config.json ``` Modifica questo file se vuoi cambiare le impostazioni in seguito.