4.7 KiB
4.7 KiB
GuruConnect Session Log - 2025-12-29
Session Summary
What Was Accomplished
- Cleaned up stale persistent sessions - Deleted 12 offline machines from PostgreSQL database
- Added machine deletion API with uninstall support - Implemented full machine management endpoints
- Added AdminCommand protobuf message - For server-to-agent commands (uninstall, restart, update)
- Implemented machine history export - Sessions and events can be exported before deletion
Key Decisions
- Machine deletion has two modes:
- Delete Only (
DELETE /api/machines/:agent_id) - Removes from DB, allows re-registration - Delete with Uninstall (
DELETE /api/machines/:agent_id?uninstall=true) - Sends uninstall command to agent if online
- Delete Only (
- History export available via
?export=truequery param or separate endpoint - AdminCommand message types: ADMIN_UNINSTALL, ADMIN_RESTART, ADMIN_UPDATE
Problems Encountered
- Server endpoint returning 404 - new binary may not have been properly deployed
- Cross-compilation issues with ring crate for Windows MSVC on Linux
Credentials
GuruConnect Database (PostgreSQL)
- Host: 172.16.3.30 (localhost from server)
- Database: guruconnect
- User: guruconnect
- Password: gc_a7f82d1e4b9c3f60
- DATABASE_URL:
postgres://guruconnect:gc_a7f82d1e4b9c3f60@localhost:5432/guruconnect
Build Server SSH
- Host: 172.16.3.30
- User: guru
- Password: Gptf*77ttb123!@#-rmm
- Sudo Password: Gptf*77ttb123!@#-rmm
Infrastructure
GuruConnect Server
- Host: 172.16.3.30
- Port: 3002
- Binary:
/home/guru/guru-connect/target/release/guruconnect-server - Service: guruconnect.service (systemd)
- Log: ~/gc-server.log
API Endpoints (NEW)
GET /api/machines - List all persistent machines
GET /api/machines/:agent_id - Get machine info
GET /api/machines/:agent_id/history - Get full session/event history
DELETE /api/machines/:agent_id - Delete machine
Query params:
?uninstall=true - Send uninstall command to agent
?export=true - Include history in response
Files Modified
Protobuf Schema
proto/guruconnect.proto- Added AdminCommand message and AdminCommandType enum
Server Changes
server/src/main.rs- Added machine API routes and handlersserver/src/api/mod.rs- Added MachineInfo, MachineHistory, DeleteMachineParams typesserver/src/db/machines.rs- Existing delete_machine function usedserver/src/db/sessions.rs- Added get_sessions_for_machine()server/src/db/events.rs- Added get_events_for_machine()server/src/session/mod.rs- Added send_admin_command() and remove_agent() methods
Agent Changes
agent/src/session/mod.rs- Added AdminCommand message handleragent/src/main.rs- Added ADMIN_UNINSTALL and ADMIN_RESTART error handlers
Important Commands
Query/Delete Machines from PostgreSQL
# Query all machines
ssh guru@172.16.3.30 'PGPASSWORD=gc_a7f82d1e4b9c3f60 psql -h localhost -U guruconnect -d guruconnect -c "SELECT agent_id, hostname, status FROM connect_machines;"'
# Delete all offline machines
ssh guru@172.16.3.30 'PGPASSWORD=gc_a7f82d1e4b9c3f60 psql -h localhost -U guruconnect -d guruconnect -c "DELETE FROM connect_machines WHERE status = '\''offline'\'';"'
Build Server
# Build for Linux
ssh guru@172.16.3.30 'cd ~/guru-connect && source ~/.cargo/env && cargo build -p guruconnect-server --release --target x86_64-unknown-linux-gnu'
# Restart server
ssh guru@172.16.3.30 'pkill -f guruconnect-server; cd ~/guru-connect/server && DATABASE_URL="postgres://guruconnect:gc_a7f82d1e4b9c3f60@localhost:5432/guruconnect" nohup ~/guru-connect/target/release/guruconnect-server > ~/gc-server.log 2>&1 &'
Pending Tasks
-
Debug 404 on /api/machines endpoint - The new routes aren't being recognized
- May need to verify the correct binary is being executed
- Check if old process is still running on port 3002
-
Test machine deletion flow end-to-end
- Connect an agent
- Delete with uninstall flag
- Verify agent receives command and uninstalls
-
Build Windows agent binary - Cross-compilation needs MSVC tools or use Windows build
Git Status
Committed and pushed:
commit dc7b742: Add machine deletion API with uninstall command support
- 8 files changed, 380 insertions(+), 6 deletions(-)
Next Steps for Future Sessions
- Investigate why
/api/machinesreturns 404 - likely old binary running - Use systemd properly for server management (need root access)
- Build and test Windows agent with uninstall command handling
- Add dashboard UI for machine management (list, delete with options)