osctl
is a command-line interface (CLI) tool for administrating Linux operating systems like RHEL, Ubuntu, and SUSE. It provides easy access to system statistics like RAM usage, disk usage, service management, and more. Additionally, it can run as an API server with a Prometheus metrics endpoint.
- Show RAM usage
- Show disk usage
- Manage system services
- Show top processes by CPU usage
- Show the last 10 errors from the journal
- Show the last 20 logged-in users
- Show system uptime
- Show operating system name and kernel version
- Shutdown the system
- Reboot the system
- Show IP addresses of all interfaces
- Show active firewalld rules
- Update OS packages
- List all Docker containers
- List all Docker images
- Show CPU usage
- Show system load averages
- Show network statistics
- List all active network connections
- List all mounted filesystems
- Show kernel messages
- List all currently logged-in users
- Show status of all running services
- Run as an API server on port 12000 with a Prometheus metrics endpoint
osctl [command]
ram
: Show RAM usagedisk
: Show disk usageservice [start|stop|restart|status] [service_name]
: Manage system servicestop
: Show top processes by CPU usageerrors
: Show the last 10 errors from the journalusers
: Show the last 20 logged-in usersuptime
: Show system uptimeosinfo
: Show operating system name and kernel versionshutdown
: Shutdown the systemreboot
: Reboot the systemip
: Show IP addresses of all interfacesfirewall
: Show active firewalld rulesupdate
: Update OS packagescontainers
: List all Docker containersimages
: List all Docker imagescpu
: Show CPU usageload
: Show system load averagesnetwork
: Show network statisticsconnections
: List all active network connectionsfilesystems
: List all mounted filesystemsdmesg
: Show kernel messageswho
: List all currently logged-in usersservices
: Show status of all running servicesapi
: Run as an API server on port 12000--help
: Show this help message
-
Ensure you have Go 1.18 or later installed.
-
Clone the repository:
git clone https://github.com/yourusername/osctl.git cd osctl
-
Build the binary:
go build -o osctl main.go auth.go metrics.go handlers.go system_info.go services.go
-
Run the
osctl
binary:./osctl --help
To run osctl
as an API server on port 12000, use the api
command:
./osctl api
The API server provides the same functionalities as the CLI commands. Additionally, it includes a Prometheus metrics endpoint at /metrics
.
Basic authentication is used for the API server. The default credentials are:
- Username:
admin
- Password:
password
You can modify these credentials in the auth.go
file.
Show RAM usage:
./osctl ram
Show disk usage:
./osctl disk
Start a service:
./osctl service start apache2
Show top processes by CPU usage:
./osctl top
Update OS packages:
./osctl update
Feel free to submit issues, fork the repository, and send pull requests. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.