GetCommandDescription returns a user-friendly description for a command. If no description is found, returns a generic description based on the command.
(cmd string)
| 122 | // GetCommandDescription returns a user-friendly description for a command. |
| 123 | // If no description is found, returns a generic description based on the command. |
| 124 | func GetCommandDescription(cmd string) string { |
| 125 | // Map of command patterns to descriptions |
| 126 | descriptions := map[string]string{ |
| 127 | // System overview |
| 128 | "uptime": "Show system uptime and load average", |
| 129 | "df -Th": "Show disk space usage by filesystem", |
| 130 | "lsblk": "List all block devices", |
| 131 | "free -h": "Show memory usage (RAM and swap)", |
| 132 | |
| 133 | // Process and resource inspection |
| 134 | "ps aux": "Show all running processes", |
| 135 | "top -bn1 | head -20": "Show top 20 processes by resource usage", |
| 136 | "ps -eo pid,ppid,cmd,%cpu,%mem --sort=-%cpu | head -20": "Show top 20 CPU-consuming processes", |
| 137 | "ps -eo pid,ppid,cmd,%cpu,%mem --sort=-%mem | head -20": "Show top 20 memory-consuming processes", |
| 138 | |
| 139 | // Services, logs, packages |
| 140 | "systemctl list-units --type=service --state=running": "List all running systemd services", |
| 141 | "systemctl list-unit-files --state=enabled": "List enabled systemd services", |
| 142 | "systemctl status {service}": "Show status of a specific service", |
| 143 | "journalctl -n 100": "Show last 100 system log entries", |
| 144 | "journalctl -u {service} -n 50": "Show last 50 log entries for a service", |
| 145 | "dpkg -l | grep {package}": "Search for installed Debian package", |
| 146 | |
| 147 | // Networking & connectivity |
| 148 | "ip addr show": "Show network interfaces and IP addresses", |
| 149 | "ip route show": "Show routing table", |
| 150 | "ip link show": "Show network interface status", |
| 151 | "ss -tulpn": "Show listening TCP/UDP ports", |
| 152 | "ss -s": "Show socket statistics summary", |
| 153 | "netstat -tulpn": "Show listening ports (netstat)", |
| 154 | "cat /etc/resolv.conf": "Show DNS resolver configuration", |
| 155 | "resolvectl status 2>/dev/null || systemd-resolve --status 2>/dev/null": "Show DNS resolution status", |
| 156 | "curl https://ifconfig.me/all": "Check public IP and network info", |
| 157 | "nslookup {hostname}": "Look up DNS records for a hostname", |
| 158 | |
| 159 | // User activity |
| 160 | "who": "Show logged-in users", |
| 161 | "last -n 20": "Show last 20 user logins", |
| 162 | |
| 163 | // Proxmox host-specific |
| 164 | "pveversion -v": "Show Proxmox VE version and packages", |
| 165 | "iostat -x 1 5": "Show disk I/O statistics (5 samples)", |
| 166 | |
| 167 | // Windows PowerShell commands |
| 168 | "Get-ComputerInfo | Select-Object CsName, OsName, OsVersion, WindowsProductName": "Show Windows system information", |
| 169 | "Get-Process | Sort-Object CPU -Descending | Select-Object -First 15 Name, CPU, PM | Format-Table": "Show top 15 processes by CPU usage", |
| 170 | "Get-Process | Sort-Object PM -Descending | Select-Object -First 15 Name, CPU, PM | Format-Table": "Show top 15 processes by memory usage", |
| 171 | "Get-Service | Sort-Object Status, DisplayName | Format-Table -AutoSize -First 40": "List Windows services (first 40)", |
| 172 | "Get-EventLog -LogName System -Newest 50 | Format-Table TimeGenerated, EntryType, Source, Message -AutoSize": "Show last 50 system event log entries", |
| 173 | "Get-Volume | Select-Object DriveLetter, FileSystemLabel, FileSystem, SizeRemaining, Size | Format-Table -AutoSize": "Show disk volumes and space", |
| 174 | "Get-NetIPAddress | Select-Object InterfaceAlias, IPAddress, PrefixLength | Format-Table -AutoSize": "Show network IP addresses", |
| 175 | "Get-NetAdapter | Select-Object Name, InterfaceDescription, Status, LinkSpeed | Format-Table -AutoSize": "Show network adapters status", |
| 176 | "Get-NetIPConfiguration | Format-Table -AutoSize": "Show network configuration", |
| 177 | "Get-NetRoute | Sort-Object DestinationPrefix | Format-Table -AutoSize": "Show network routing table", |
| 178 | "Get-DnsClientServerAddress | Select-Object InterfaceAlias, ServerAddresses | Format-Table -AutoSize": "Show DNS server configuration", |
| 179 | "ipconfig /all": "Show detailed network configuration", |
| 180 | "netstat -ano | findstr LISTEN": "Show listening ports", |
| 181 | "Test-NetConnection -ComputerName {hostname} -InformationLevel Detailed": "Test network connection to a host", |