You are not logged in.

#1 2008-06-22 14:13:21

Hiperi0n
Member
Registered: 2008-06-17
Posts: 49

[SOLVED]Writing a CPU usage daemon

Hi. I have a strange issue with my old CPU, it reboots when idle (<5% usage) so whenever I login I usually go to a tty and execute a top -d 0.05, enough to keep my P3 busy. It works but I'd like to make a small daemon for that, so I wrote a script that executes that top. I then copy it to /etc/rc.d and add it to rc.conf. However, it executes before I login and I am forced to quit top to be able to login. I have tried writing an @ before the script name in rc.conf but doesn't work. It doesn't work either top -d 0.05 > /dev/null. I have also tried with a & after the script, it executes in the background but doesn't use any cpu (maybe because it is not printing=)

Is there a way to do what I want? I guess there are many ways to keep the cpu usage at about 10% but can I achieve this with top? Is there any way to execute it at background and not to print anything and use cpu? Like an ordinary daemon.

Anyway, if it is not possible I'd write a simple C program with some loops and waits...

Thanks.

Last edited by Hiperi0n (2008-06-27 21:47:05)

Offline

#2 2008-06-22 14:24:23

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: [SOLVED]Writing a CPU usage daemon

But why does your CPU reboot when idle ?


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#3 2008-06-22 15:51:54

Hiperi0n
Member
Registered: 2008-06-17
Posts: 49

Re: [SOLVED]Writing a CPU usage daemon

Moljac024 That is the question of the millenium. I posted it in several forums. People can't give me a clue. It could be the motherboard, it is a bit old. However, the fact is that it reboots when idle, not when running at 100%. I have tried many programs, benchmarks, stressing, unplugging things, HD... the only thing I haven't tried is the power supply. It is a Pentium 3 coppermine 866mhz

Offline

#4 2008-06-22 20:18:34

tigrmesh
IRC Op
From: Florida, US
Registered: 2007-12-11
Posts: 794

Re: [SOLVED]Writing a CPU usage daemon

This is not really an answer to your question, but what about having it start when you start X?

Offline

#5 2008-06-23 00:44:21

carlocci
Member
From: Padova - Italy
Registered: 2008-02-12
Posts: 368

Re: [SOLVED]Writing a CPU usage daemon

moljac024 wrote:

But why does your CPU reboot when idle ?

maybe his energy saving policy is too aggressive!

Offline

#6 2008-06-23 13:21:58

Doc Angelo
Member
From: Germany
Registered: 2007-11-28
Posts: 52

Re: [SOLVED]Writing a CPU usage daemon

If you really want a cpu usage daemon, you should choose Boinc. It keeps your CPU at the usage level you want, and you are doing work for science too. There are many projects to work for.

But maybe its just your power supply. A broken one can be responsible for the wierdest errors.

Offline

#7 2008-06-23 13:46:35

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: [SOLVED]Writing a CPU usage daemon

+1 for Boinc


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#8 2008-06-24 14:16:20

Hiperi0n
Member
Registered: 2008-06-17
Posts: 49

Re: [SOLVED]Writing a CPU usage daemon

Thanks for your answers. I guess I will try boinc. However I was just wondering how to write a daemon on my own, I am sure there are many programs to achieve so. I can't init with X, as I haven't installed xorg yet. I have been googling a bit and I found I must fork the process so it becomes autonomous. After that I should be able to login (the problem I had with the top script).

Anyway I will give boinc a try. Thank you all

Offline

#9 2008-06-24 18:01:13

kingjorge
Member
Registered: 2008-03-05
Posts: 16

Re: [SOLVED]Writing a CPU usage daemon

As long as you are using CPU cycles, you might as well put them to good use::D

http://vspx27.stanford.edu/cgi-bin/main … mnum=45032

Offline

#10 2008-06-26 22:20:06

Hiperi0n
Member
Registered: 2008-06-17
Posts: 49

Re: [SOLVED]Writing a CPU usage daemon

I give up using Boinc. I can't find a tutorial of the command line mode of boinc. I guess it is a nice project but there is little or no help regarding its usage. Maybe the GUI versions are easy to use but not the CLI version. I might give it a try when I have more spare time but not right now...

Offline

#11 2008-06-27 09:08:49

smoon
Member
Registered: 2005-08-22
Posts: 468
Website

Re: [SOLVED]Writing a CPU usage daemon

Hiperi0n wrote:

I give up using Boinc. I can't find a tutorial of the command line mode of boinc. I guess it is a nice project but there is little or no help regarding its usage. Maybe the GUI versions are easy to use but not the CLI version. I might give it a try when I have more spare time but not right now...

Have you even tried looking for the documentation or some other help? Didn't even took me a minute to find plenty of howtos, tutorials and other documentation.
http://boinc.berkeley.edu/wiki/User_manual and http://www.xtremesystems.org/forums/sho … p?t=137278 are just two examples.

Offline

#12 2008-06-27 10:56:33

Doc Angelo
Member
From: Germany
Registered: 2007-11-28
Posts: 52

Re: [SOLVED]Writing a CPU usage daemon

I also didnt get the CLI-Version to work. Maybe we can help, if you tell us, where you got stuck?

Have you tried searching the arch forums for "boinc"?

Offline

#13 2008-06-27 11:14:30

Hiperi0n
Member
Registered: 2008-06-17
Posts: 49

Re: [SOLVED]Writing a CPU usage daemon

thanks, I fill kinda stupid now. I have been looking for this kind of help but I couldn't find it. I have been able to attach to a project. I now must limit the cpu usage of it and start it with the system. I guess rc.conf would do

thanks smoon

Offline

#14 2008-06-27 13:06:00

Doc Angelo
Member
From: Germany
Registered: 2007-11-28
Posts: 52

Re: [SOLVED]Writing a CPU usage daemon

Good to read that its working now. The CPU usage is configurable in the global settings of each project. There you can set up the settings for the project, and the settings for boinc (global settings, which apply for every project, every boinc project should have a site to do this).

Which project did you choose, if i may ask?

Offline

#15 2008-06-27 13:44:24

Hiperi0n
Member
Registered: 2008-06-17
Posts: 49

Re: [SOLVED]Writing a CPU usage daemon

I am at einstein@home. However I now have some more problems. I wrote 2 scripts, one for the client and the other for the boinc_cmd. I put them in /etc/rc.d/ and in rc.conf but it is not working, i have the authorization failure error and I end up with my / folder with some boinc files, which it is a mess. I don't know why as I am cd-ing to my boinc-workdir in the scripts. I know I should not be using boinc as root but step by step please...

These are my two scripts:
boinc-client-script:

#!/bin/bash
cd /root/boinc-workdir
boinc_client --daemon

boinc-cmd-script:

#!/bin/bash
cd /root/boinc-workdir/
nice -n 19 /usr/bin/boinc_cmd --project_attach http://einstein.phys.uwm.edu/ <my-key>

I fell like a bit stupid, I have been too long in desktop environments....

Offline

#16 2008-06-27 14:17:52

Hiperi0n
Member
Registered: 2008-06-17
Posts: 49

Re: [SOLVED]Writing a CPU usage daemon

Well, it seems I have partially solved my problems. The --dir option in boinc_client specifies the working directory. However, the client executes at startup, nice, but the boinc_cmd doesn't attach to the project, as if my boinc_cmd script doesn't wait its predecessor (boinc-client script) to end. But if I am not wrong, unless I writen an @ before the script name, they execute sequentialy, waiting to finish the previous script.
If I execute the boinc_cmd script myself after logging in it does attach and begin to work nicely, so I suppose it could be what I have said before...

Offline

#17 2008-06-27 18:03:47

Hiperi0n
Member
Registered: 2008-06-17
Posts: 49

Re: [SOLVED]Writing a CPU usage daemon

Now I am quite surprised, I have rebooted for the tenth time and it works. As soon as I login, I can see the einstein_S5R3...... process with a NICE of 19 eating my oldie cpu. I guess the only thing left is adjusting its cpu usage.

I am not expert in kernel scheduling methods, but what do you think about not limiting boinc and executing it with a NICE of 19 (lowest priority)? Should I limit its cpu usage (with cpu-limiter I think, there is no option implemented yet to throttle cpu in boinc software) or leave it that way? I am also worried about the memory usage, as I only have 384mb and I plan on installing a desktop environment...

Offline

#18 2008-06-27 19:34:27

Doc Angelo
Member
From: Germany
Registered: 2007-11-28
Posts: 52

Re: [SOLVED]Writing a CPU usage daemon

You can set up memory and cpu usage in every boinc project globaly. No need for extra tools. Set your settings here: "Your account" (link to einstein). Every project has different memory usages, some require quite large ammounts to work.

Einstein seems to use about ~70 MB (FAQ). Currently i am crunching work for a project of a german university, they are studying magnetic reactions. Only 24 resident MB are used.

Edit: Link to the german project: Spinhenge@home

Last edited by Doc Angelo (2008-06-27 19:43:04)

Offline

#19 2008-06-27 21:45:34

Hiperi0n
Member
Registered: 2008-06-17
Posts: 49

Re: [SOLVED]Writing a CPU usage daemon

Thanks Doc Angelo, I might try the spinhenge project. I have configured a 90% usage of CPU but what it does is to use 100% cpu 90% of the time, not 90% cpu all the time. It worries me as my cpu must be active all the time, a couple of seconds being idle are enough to make it reboot. I think cpu limiter is the only choice to get what I want. Thanks anyway smile

After having resolved the cpu usage issues I am now ready to tickle further into arch ^^ thank you all for your help :*

Offline

#20 2008-06-27 21:50:19

Hiperi0n
Member
Registered: 2008-06-17
Posts: 49

Re: [SOLVED]Writing a CPU usage daemon

Well but stay tuned for the next episode of Hiperi0n's bizarre hiperactive rebooting CPU

I still can't find an answer to the rebooting-when-idle problem, the mobo is old and some capacitors are leaking a little bit, but that shouldn't affect the cpu...

Offline

Board footer

Powered by FluxBB