Arrrgh!

download

chmod +x fahcheck-2.0

./fahcheck-2.0

That's it. You lose the use of that particular terminal window. Also needs to be a finstall install of SMP client. Wont work otherwise.

Dead easy :D
 
Thats a very nice bit of scripting there :cool:

A few comments if I may:

Code:
clientRestart()
{
	./folding stop
	./folding start
}

can simply become

Code:
clientRestart()
{
	./folding restart
}

Your CPU usage check is good, except it could easily become confused if another process suddenly started using high CPU usage. For example if the smp client died on my machine at midnight, the script wouldn't work, as I run some very CPU intensive cron'd jobs at around that time.

With this in mind, you could use this addition, which filters the results of ps for anything containing "fahcore", so it will only show the CPU usage for fah related processes.

Code:
ps -eo pcpu,pid -o comm= | grep -Ei "fahcore" | sort -k1 -n -r | head -4 | awk '{ print $1 } '

I would recommend that you also don't use relative paths for calling the folding script, since finstall doesn't need to be in the local directory, running ~/foldingathome/folding restart is safer if you want to use this as a cron job. (Also remember cron runs as root, so you'll have to actually enter the real home location rather than just ~).

If you want any help with the other items on your todo list (like a non finstall capability) you have but to ask.
 
SiriusB said:
Dead easy :D

I agree the the script entry looks easy - but my personal experiance is if i 'play' with ubuntu I brake it. :D

Setting up Fahmon is 'surposed' to be easy - took me three weeks, 7 reinstalled and 45 mins of Uncles F's 1-2-1 time.

Maybe I can't follow instructions 'to the letter' that Linux needs, but losing 10h or even a WU is less hassle than being on standard units again.

Edit: that Fact that I even have two SMP cruncher is totally down to the hardwork you and UF have done (that and my 'I will make it work' mantra)
 
Last edited:
uncle_fungus said:
Thats a very nice bit of scripting there :cool:

A few comments if I may:

Code:
clientRestart()
{
	./folding stop
	./folding start
}

can simply become

Code:
clientRestart()
{
	./folding restart
}

Changed :)

Your CPU usage check is good, except it could easily become confused if another process suddenly started using high CPU usage. For example if the smp client died on my machine at midnight, the script wouldn't work, as I run some very CPU intensive cron'd jobs at around that time.

With this in mind, you could use this addition, which filters the results of ps for anything containing "fahcore", so it will only show the CPU usage for fah related processes.

Code:
ps -eo pcpu,pid -o comm= | grep -Ei "fahcore" | sort -k1 -n -r | head -4 | awk '{ print $1 } '

Also changed!

I would recommend that you also don't use relative paths for calling the folding script, since finstall doesn't need to be in the local directory, running ~/foldingathome/folding restart is safer if you want to use this as a cron job. (Also remember cron runs as root, so you'll have to actually enter the real home location rather than just ~).

Would using
Code:
$HOME/foldingathome/folding restart
be acceptable? This would then remove the need for the vast majority of people to edit the script.

Also, how do you get this script to work with cron? I spent an hour last night trying to get it working without any luck. All I did find out was that cron uses an sh shell and not bash... or something! I couldn't find a definitive answer to actually get around this/make it work.

If you want any help with the other items on your todo list (like a non finstall capability) you have but to ask.

I would welcome any help and advice! Since I am one for doing things myself - gotta learn these things, right? - could you just give me a clue as to how to safely stop and start a non-finstall SMP client. [I did try to find the answer in finstalls folding script but that thing is a beast]. :eek:

shadow said:
I agree the the script entry looks easy - but my personal experiance is if i 'play' with ubuntu I brake it.

Setting up Fahmon is 'surposed' to be easy - took me three weeks, 7 reinstalled and 45 mins of Uncles F's 1-2-1 time.

Maybe I can't follow instructions 'to the letter' that Linux needs, but losing 10h or even a WU is less hassle than being on standard units again.

Edit: that Fact that I even have two SMP cruncher is totally down to the hardwork you and UF have done (that and my 'I will make it work' mantra)

I want to make this script work right out the box, so to speak. So even you my friend will be able to make it go :D.

Although this script may ultimately be unnecessary in the future, I think anything that safe-guards your client while it is in BETA is a good thing.
 
Dare I tempt fate... when your 100% happy I'll do a test run - If I can get it working it must be 'dummy' proof :p :D

(might try it with the EE server install i was half way through setting up - that way if it does crash, I'm still crunching on FF desktop)
 
Last edited:
SiriusB said:
Would using
Code:
$HOME/foldingathome/folding restart
be acceptable? This would then remove the need for the vast majority of people to edit the script.

Well not really. $HOME does the equivalent of ~, so when a cron job runs, it'll have a value of "/root". All you really need to do is setup a user editable global variable right at the top of the script (so its obvious), in which people enter their real home directory.

SiriusB said:
Also, how do you get this script to work with cron? I spent an hour last night trying to get it working without any luck. All I did find out was that cron uses an sh shell and not bash... or something! I couldn't find a definitive answer to actually get around this/make it work.

Fire up the crontab editor with

Code:
crontab -e

Then add an entry like this

Code:
0 * * * *   root   /home/user/fahcheck

That will launch the /home/user/fahcheck script under the user "root" on every day of every month on every hour at minute 0.

You don't have to be root to do these modifications, since every user can have their own crontab. In actual fact, you could set the actual cron job to run as "user", which would eliminate the $HOME problem altogether if you really wanted.
(I normally use the global crontab and run the jobs as root, for this, just edit /etc/crontab as root)


SiriusB said:
I would welcome any help and advice! Since I am one for doing things myself - gotta learn these things, right? - could you just give me a clue as to how to safely stop and start a non-finstall SMP client. [I did try to find the answer in finstalls folding script but that thing is a beast]. :eek:

The simplest way to stop the SMP client outside of finstall is to run

Code:
killall -QUIT FahCore_a1.exe

This will tell the core(s) to exit and close the client.
You'd still need to do some sanity checking to make sure the client had closed, by grepping the output of ps for fahcores, mpiexec and fah5. Once you're sure everything is dead, you can go about restarting the client. For that you need to cd into the fah5 local directory, sanity check that using pwd, then fire her up.
 
It would appear something aint right with my cron :/

I used crontab -e like you said but it wont let me save the changes.

Did it using sudo crontab -e and set it up for every 20th minute of every hour of every day etc etc etc and told it to run as root. Didn't work apparantly.

25 * * * * root /home/aeternum/fahcheck-0.4

That's the line I used.

EDIT: Nevermind, I think it was working but I made an error in the code when I was twaking :o

Have edited the /etc/crontab file directly and stuck it in there. So far it appears to be working :)
 
Last edited:
OK Mr Fungus I have hit a mental block with stopping and starting a non-finstall SMP client.

I know that first of all I need to check that the fahcore_a1.exe processes aren't running before attempting to start the client up again. However, I also need to check that mpiexec, fah5 and err.. the other one isn't running either and kill them if they are.

Just can't seem to come up with code that isn't as convoluted as blind-folded quadruple heart bypass surgery!

I did come up with something along the lines of

Code:
if cpu usage is too low

     kill fahcore_a1.exe

fi

if fahcore_a1.exe or mpiexec or fah5 is running

     kill fahcore_a1.exe
     kill mpiexec
     kill fah5

fi

change to folding client directory

if fah5 exists

     run fah5

else

     uh oh

fi

Now in pseudocode form it is dead easy, but I am struggling to find the best way of finding out what processes are running. Do I use the "ps" command several times to see if any of the three processes are running and put the results in separate variables and check them:

Code:
fahcoreProcess="`ps -eo pid -o comm= | grep -iE "fahcore" | awk '{print $1}'`"
mpiexecProcess="blah blah | grep -iE "mpiexec" | blah blah"
fah5Process="blah blah | grep -iE "fah5" | blah blah

if [ fahcoreProcess != NULL || mpiexecProcess != NULL || fah5Process != NULL ]; then
     killall -QUIT fahcoreProcess
     etc
     etc
fi

Or would it be better to create an array and iterate through it, killing each process...

Or is there a whole new approach to this?

Also, is there anything I can use to confirm a process has been killed?

Gah... my brain is melting. I hope you understand that lot - it has been fueled by some rather good single malt :p
 
What I'd do is something like this

Code:
if CPU usage of fahcores is too low
killall -QUIT fahcore
fi
wait 20 seconds for cores to quit correctly

#if any processes are still running send them a nice end signal
fahprocesses="ps ax |grep -iEc "fahcore|mpiexec|fah5""
#normally this would give a value of either 7 or 8 (4xfahcore, 1xfah5, 1xmpiexec, 1xsh running mpiexec(sometimes), 1xgrep) if all the processes are still running. If none are running you'd get a value of 1 (grep).

if [ $fahprocesses -gt 1 ]
killall -QUIT fahcore
etc.
fi

wait another x seconds (possibly longer than 20 seconds)

#if there are still processes, kill them outright
fahprocesses="ps ax |grep -iEc "fahcore|mpiexec|fah5""

if [ $fahprocesses -gt 1 ]
killall -KILL fahcore
etc.
fi

launch fah5 again

Sorry for combining pseudo and real code in the same block there, should be obvious which is which though ;)
 
Ahh that looks so much better. Glad to see I was along the right lines :D I will start fiddling with that tomorrow and see how it goes.

Cheers for the help mate!

I will upload the finished script tomorrow afternoon if all goes to plan and you lot can test it :eek:

EDIT: OK so I didn't upload the script. And for good reason. I had work earlier than I remembered! I suppose I could have started doing the script earlier... but meh :p

Scripting has caused me to catch the programming bug again so I will be turning my attentions back on my webpage once I am done. I have decided to keep the design very simple [but professional] for now as I want the page to actually become useful. Tarting it up is something I can do when I feel creative. :D
 
Last edited:
Back
Top Bottom