clbr / radeontop

GNU General Public License v3.0
804 stars 70 forks source link

Some posible new features? #21

Open DFOXpro opened 9 years ago

DFOXpro commented 9 years ago

Thank you for this program, this become the solution for amdoverdrive-data in radeon opensource ;)

clbr commented 9 years ago
  • Is possible to set this program like a daemon ? and get the data with a sysfile or netservice.

Yes: run it in the background using the -d (dump) option, then process the output as needed. Or for CGI use, dump with a limit of 1, so that it exits after one line. Simple scripts for either.

For example, you could pass it to a graphing program that refreshes a PNG image every second. Then your html page would also have instructions to refresh once per second, and you'd have a web page showing a realtime graph.

  • Is possible to this program get the clock of the card? like aticonfig & amdoverdrive.

No, that info is not exposed via any channels it can access. I tried to get such an interface back in 2012, but the radeon kernel devs weren't interested.

DFOXpro commented 9 years ago

thanks again, I will use your program to monitor within a Conky panel.

DFOXpro commented 9 years ago

Is posible with --dump option to write the file without adding more lines? or -d - (stdout option) to have an EOF for 1 data show. Why: If you use the --dump option, the dump file with the time will be bigger and bigger, and the -d - option, if you set a listener (my case via nc)(sudo radeontop -t 50 - | nc -l ) will not know how get the next data show, because is continuous and have no EOF.

ldsh commented 9 years ago

Hello @DFOXpro I once made some modifications of raddeontop in order to display some informations in my conky. I did change the source code to make it dump only one line in the file and replace it instead of adding it to the file. You can find it there: https://github.com/ldsh/radeonload Please be aware that I made it two years ago (no update since) with really basics skills.

I suggest you to take a look for inspiration and make a new one in order to have the latest advancement of the radeontop original repository (I do not maintain mine). The main modification I made was to change f = fopen(file, "a"); to f = fopen(file, "w+");, so that the file is erased between each writings.

I'll not work on this soon as I don't have radeon card any more (the motherboard were mine was soldered is dead).

Maybe @clbr would be interested to modify his own code to add this possibility to his dump command as it seems I'm not the only one that was interested in?

Hope it helps.

clbr commented 9 years ago

A --rewind argument would be ok to add, though this is the first I hear of the need for such. I'm a bit on the fence, as you can get the last line with a simple bash script. Writing it to a file, to network, or somewhere else after only parsing the desired numbers would be easy.

!/bin/sh

IFS=" " while read LINE; do echo got line $LINE done

ldsh commented 9 years ago

The idea is to benefit from your daemon feature but not having a file unnecessary growing as the goal is to have it running at startup (until shutdown) but only to have the last information.

Your daemon (at least what I remember from when I looked 2 years ago) is keeping all the data in the file, this is good to have if you want to see how this data have evolved in time, but not that much if you only wants to access the last data (in a memory point of view. I put the file in tmpfs to avoid disk writes, but having a file that don't stop growing is similar to a memory leak in the process).

The main modification I made was to change f = fopen(file, "a"); to f = fopen(file, "w+");, so that the file is erased between each writings.

Of course, there may be a more elegant way to pass the wanted data from radeontop to Conky, writing them in a file is still some kind of overhead. The thing is that reading data from a file is a basic Conky feature and do not need root access.

clbr commented 9 years ago

Yes, you can do that with a simple script like the one I pasted above? sudo radeontop -d- | myscript.sh

With the pipe, there is no unbound memory usage. Each line is passed to the script as a unit, which then does whatever is needed with it.

I don't use conky, but I'm willing to add a conky example under a contrib/ dir or similar, if a good one is sent to me.

ldsh commented 9 years ago

I remember now why I didn't use something like you suggest, that was to avoid giving root rights to Conky as some peoples says it is not recommended (maybe it would worth to know how far theses recommendations are usefull?) Thus the daemon at start-up was a workaround to give the rights only to the radeontop daemon, Conky having enough with user rights to read the file.

However, if this permission issue is not considered as a thread, piping the commends would indeed be a simple solution.

nckx commented 9 years ago

Why not just create a simple shell script wrapper (or use sh -c directly) to do this?

radeontop -d- | while read line; do echo "$line" > "$1"; done

or so. Teh unix way, and all that.

clbr commented 9 years ago

For permissions, I would recommend setting radeontop setuid root (chown root.root radeontop; chmod u+s radeontop), conky would not run as root then.

ldsh commented 9 years ago

May be a better workaround, @DFOXpro can you test it and report if the result satisfy you? (I can't test it myself, no working radeon card to test on)

myxal commented 8 years ago

Any plans for SIGWINCH support? (run-time terminal resizing)

clbr commented 8 years ago

On Thu, 14 Jan 2016 15:23:33 -0800 myxal notifications@github.com wrote:

Any plans for SIGWINCH support? (run-time terminal resizing)

Patches welcome.

ZeWebDev commented 6 years ago

I am currently using this as a daemon. I made a script like the one you posted. Problem is that 2 new lines are created every time it dumps new information, so i get 1 empty line and nothing gets written to the file.

Of course you go around this with just an 'if' but i think it would be preferable to not have any empty lines between dumps

clbr commented 6 years ago

I don't get any empty line? If you look at the output, "radeontop -d -", there is exactly one line per.

clbr commented 6 years ago

Oh, scratch that, I see it now. Fixed.