INTRO
We've developed a little tool to monitor NS2 server's memory usage and restart it when it exceeds some threshold.
You can download it in the .zip attached to this post.
If you don't want to run some random .exe on your server you can find the source code here:
http://lacop.pastebin.com/q25xvgbM
And if you don't want to run random .exe and neither compile it on your own, download a decompiler like
Reflector and see for yourself that the .exe and public source are identical
Note: This is quickly thrown together to avoid servers filling memory and requiring manual restart. There is no guarantee it'll work as expected or at all. Bug reports, suggestions etc. are welcome, complete code patches even more
USAGE GUIDE
Simply extract the files somewhere. Configure the utility using the
.config file. You can test it by simply starting the
.exe. Note that a console window will appear for a while. The program instantly closes but all the output is appended to the
.log file. To test if it works you can set the threshold to a low value, like 1MB and running it.
The program itself does only a single pass over all servers and quits. You probably want to automate this task, so you need a way to run it periodically. You can use any cron-like system, for example
windows task scheduler.
Locate it in control panel and add a new task.
As
trigger add a
scheduled trigger,
repeating for every x minutes,
indefinitely. Don't forget to check the
enabled checkbox, if it isn't already.
In the
actions tab add a
start a program action, specify the
path to the .exe, then copy the path to
start in field and delete the .exe name so that it points to the folder you extracted the files to.
In the
general tab, make sure the user you want the task to run as has rights to kill and start the server (eg. use the user running the server), and check
run only when user is logged on.
You can then test it by setting low memory limit and clicking the manual Run button in the right panel. Don't forget to increase the memory limit after that.
FEEDBACK
If you have any problems, bug reports or suggestions please post them here and I'll try to answer them when I can.