[Linux] - Detecting when SRCDS has locked up completely
5 replies, posted
Iv been running SRCDS servers for the good part of five years, four of which has been on a windows box using the amazing Server doc. Server doc could detect when SRCDS has actually locked up, which brings be to my question.
Does linux have anything similar? I use the autoupdate flag to auto restart from what I would call "soft crashes" but it doesn't do anything if SRCDS completly locks up in one if its "infinite loops", where the cpu maxes out at 100% and stays there untill I manually restart.
Cheers.
(Couldn't find any other suitable sections to post this in. As this will require shell / bash coding, I assume this is good enough)
Create a cronjob that runs a bash script every ~5 minutes or something that checks the cpu usage of SRCDS. You can kill it if the cpu usage exceeds a certain percentage or something.
Give me ~10 minutes and I'll write it for you.
That would be great if you could. Im just past the basics of shell. Most complicated thing iv done so far was to automatically go through my gmod folders and cope paste to my fastdl then auto bz2 them :3 Hopefully this script will help me learn even more, thanks!
[code]#!/bin/bash
process_name="srcds"
cpu_max="70"
#lazy but whatever
pid=`ps -C "mysqld" -o pid=`
cpuusage=`ps -C "mysqld" -o pcpu=`
if [[ $cpuusage -gt $cpu_max ]]; then
kill $pid -9
echo "put your launch script here for relaunching the srcds server or something"
fi[/code]
I did not test this yet tho. I'll do a proper test when I get home
Hello? Have you tested this?
[QUOTE=Xer0n;44708044]Hello? Have you tested this?[/QUOTE]
put this in a cronjob
[code]#!/bin/bash
process_name="srcds"
cpu_max="70"
#lazy but whatever
pid=`ps -C "$process_name" -o pid=`
cpuusage=$(echo "$(ps -C "$process_name" -o pcpu=)/1" | bc)
if [[ $cpuusage -gt $cpu_max ]]; then
kill $pid -9
echo "put your launch script here for relaunching the srcds server or something"
fi[/code]
[editline]3rd May 2014[/editline]
please note that it assumes that only one instance is running
Sorry, you need to Log In to post a reply to this thread.