Server for a mid term project for a Unix System Administration course
Create 3 servers and 1 dashboard api/agent that monitors the servers, displays performance statistics, reboots the servers when they fail, and includes basic notification support.
This server is designed to be cloned into a GCP Google Cloud Ubuntu VM instance, and connected to from a dashboard that has Surxe/UnixMidtermDashboard cloned. The get_metrics.sh script may not function as expected in other environments and may require alterations for other operating systems during the dependency installation stage.
- Within the GCP instance,
git clone https://github.com/MightBeRaptor/UnixMidtermServer.git cd UnixMidtermServerbash src/update_dependencies.sh- Installs dependencies for checking metrics and stressing the serverbash src/add_user_groups.sh- Creates user and groups for the server to be added tobash src/systemd_setup.sh- Creates systemd file for the stresser. This will cause it to always run stresser for a random amount of seconds.bash src/add_crontab.sh- Adds a crontab entry that runspython3 src/server.pyevery 5 minutes- Open the crontab with
crontab -eand editetg1717to your own username/path in both portions of the command
- Open the crontab with
- The crontab will start the server (if its not already up) with
python3 src/server.py - Every 5 minutes of the dashboard's runtime, it will request the server to run:
bash src/stresser.sh- Stresses the serverbash src/get_metrics.sh- Retrieve's metrics and writes them todata/metrics_<timestamp>.txtpython3 src/parse_metrics.py- Parses the metrics from the raw txt into a readable json format indata/metrics_<timestamp>.json- Sends
data/metrics_<timestamp.jsonback to the dashboard atdata/serverN/metrics_<timestamp>.json, where serverN is pulled from the hostname
- When the server is no longer connected to the dashboard, it will run
If the stresser.service becomes problematic, it can be disabled using the following commands:
sudo systemctl disable stresser.service- Prevents launch on bootsudo systemctl stop stresser.service- Stops the stresser.service from workingsystemctl status stresser.service- Displays the status of stresser.service to make sure it is disabledpkill -9 stress-ng- Ends the currently running stress process To renable this service, run the commandbash src/systemd_setup.sh