Skip to content

Instantly share code, notes, and snippets.

@CTalvio
CTalvio / nsloadmanager
Last active April 20, 2023 21:29
This script will monitor the system load average. When a set threshold is exceeded, it will pause inactive northstar server docker containers to prevent additional load being placed on the hardware by additional players populating more instances, ensuring good times are had on the ones that are already populated. Once the load lessens again, the…
#!/bin/bash
# This script will monitor system resource load, and pause any nortstar servers that are inactive when the system is at capacity.
# The goal is to enable running more servers than the system has resources for, but prevent overload caused by too many servers
# becoming populated simultaneously
# Usage: "nsloadmanager northstar 400"
# "northstar" should be replaced by a keyword contained in all the northstar docker container names, so the script can tell them apart
# "400" can be any number, and does not need to be included, by default the threadcount of the system *100 will be used
# You can set a higher or lower number, if you want the system to pause/unpause servers sooner/later
# Run "nsloadmanager install-daemon" to have this script self-install as a systemd service
@CTalvio
CTalvio / squirrel.xml
Last active February 16, 2023 20:18
Squirrel highlighting XML for the Kate text editor
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<language name="Squirrel" version="1.0" kateversion="2.5" section="Scripts" extensions="*.nut;*.gnut">
<highlighting>
<list name="keywords">
<item> break </item>
<item> case </item>
<item> catch </item>
<item> class </item>
@CTalvio
CTalvio / nscrashlogwatcher
Last active June 1, 2023 11:53
A script to save logs of nortstar server crashes, as well as notify about them via email.
#!/bin/bash
# Prerequisites: functioning mail command for email notifications, otherwise everything should work
# Run "nscrashlogwatcher install-daemon" to have this script self-install as a systemd service
if [ "$1" = "install-daemon" ]; then #Run installer and interactively get config details from user
echo "You are about to install this script as a systemd daemon."
echo "nscrashlogwatcher will be started after this installation, and will be set up to start automatically on boot."
echo "As what user should the logs be saved?"
read -p 'User: ' USER
echo "Logs will be saved as: $USER"