View Single Post
Author Message
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 03-15-2019 , 00:49   How to use Bash script to automate server hang repair.
Reply With Quote #1

https://forums.alliedmods.net/showpo...9&postcount=25

Quote:
Originally Posted by DJEarthQuake View Post
Make sure logging is on modded server with:
Code:
log on
What this does is waits for file size to be zero. The last 30 or so minutes of the server's history log is found and saved. Once it is 0 we know the server is hung and needs to be killed so the server restart process can resume. I use a much simpler nmap the port approach for that matter. If port 27015 is closed the hlds or srcds process (your server) begins again no matter what with optional page/e-mail options.

I had a ball using PHP beforehand since there is no such thing as a UDP ping tester. PHP made me regret not learning it 20 years ago. I had a PHP script checking UDP latency. If over spec amount of so many thousand from momentary map change, it retested again to make sure it was just a map change. PHP was the only book not on my shelf. Scary what it can sniff on a single UDP packet. Paul's Home Page. Thanks Paul. Long forgotten author of PHP.


This is my busy or lazy admin script developed 5 years ago. Finding the bad plugin, which is almost always 3rd party bots, is the best method. IE| cs and cz. CZ has bots native. CS does not.

was added and removed in this example I am sharing to eliminate false positives. Then there is a separate process killer if port is not open I used with nmap every min or however you want. HLDSWatch in your case. There is nothing like being in a perfectly good game then, JANK, your own game, from your own script. Keep the cron times long so this does not happen.

PHP Code:

cat sizer
.sh


#!/bin/bash
sleep 7
myfilesize
=`stat -c %s ~/log_GTM.log`
if [ 
$myfilesize ]
then
#exec ~/retry.sh
else
echo 
"The file size is NOT zero it's" $myfilesize 
fi
exit 0



cat logger
.sh


#!/bin/bash
MOD="gearbox"
find ~/Steam/steamapps/common/Half-Life/$MOD/logs/* -mmin -30 >~/log_GTM.log && cat log_GTM.log && ls -la log_GTM.log 
I changed this as I pasted and initially grabbed the wrong script. This 2 different files. Name as you wish .sh. chmod +x thefile.sh of course. Enjoy no longer being exasperated.

There is a much noticeable load difference not having to run and maintain server with PHP to use the latency script which would also work but cost 5% or more on the core. That is literally money as it uses more electricity.

So cstrike users replace gearbox with cstrike and so on for other mods. Make the logger every minute to 7. The sizer @hourly. Anything less than 40 minutes without running a second script to do a double-check it will lead to disappointments

Oh to the fellow with the IP problem. inet addr: xxx.xxx.xxx.x P-t-P:168.95.98.254. I think you already know 168 is your PPPoE peer, as you put x on yours, mate.



This funny thing is, this wasn't even the post I was seeking, still haven't found it, found 1 similar and posted. Now I post here!

Best of luck everybody keeping the servers running well.
__________________

Last edited by DJEarthQuake; 03-20-2019 at 20:21. Reason: more descriptive title
DJEarthQuake is offline