Author

Topic: A utility to automatically adjust miner intensity on detection of activity (Read 1715 times)

legendary
Activity: 1288
Merit: 1004
Pretty neat.
It seems to do what MultiMiner does with it's dynamic intensity setting.  It keeps the system running great while mining away.
Thanks for this utility I will try it out.
member
Activity: 63
Merit: 10
Across the Universe
Ok. Let's assume that some fearless dudes out there have plugged some Radeons into their colleagues' and secretaries' workstations. Let's also assume that those jail-defying dudes have forced their workmates to run some Linux flavour on those PCs (a long shot, but I know of at least one scumbag person who has).

Great. So far we have a mining rig running on free electricity, internet and OS, but those pesky colleagues keep bitching about how slow it is to switch tasks and their screens get messed up with artifacts and their Libreoffice Writer crashes and their shiny X session is insufferable and, and, and to no end.

The obvious solution is to set a cron job to stop cgminer at 08:00 and restart it at whenever the get-the-hell-outta-here hour is. But then, you've paid in preciousss gold for a GPU that's idling for hours between wordprocessors and spreadsheets and the very thought is killing you.

The next best solution is telling cron to just lower the intensity to 10-12 at 08:00 and reset it to 20 at get-the-hell-outta-here hour. Now, that's better.

But nooooooooooooo. Your hard-earned gold deserves even better. You demand a tool that detects when that sucker has stopped typing or touching the mouse, sets intensity to maximum and then waits until that sucker has hung up the phone and touched the mouse again. Then and only then it lowers intensity to levels undetectable.

Your demands have been met; this little tool squeezes the last MH/s out of your GPUs and turns it into profit. And keeps your workmates happy.

Code:
/*
Detect activity on X and act accordingly.
(c) nous at archlinux dot us
BTC: 1Ls3Ug9V2J83XLsg9EFXgLX7ebSwXc39ix

Compile with
gcc -L/usr/X11R6/lib/ -lX11 -lXext -lXss cgminer_watch_intensity.c -o cgminer_watch_intensity

Share and enjoy!
*/

#include
#include
#include
#include
#include
#include
#include

int GetIdleTime () {
        time_t idle_time;
        static XScreenSaverInfo *mit_info;
        Display *display;
        int screen;
        mit_info = XScreenSaverAllocInfo();
        if((display=XOpenDisplay(NULL)) == NULL) { return(-1); }
        screen = DefaultScreen(display);
        XScreenSaverQueryInfo(display, RootWindow(display,screen), mit_info);
        idle_time = (mit_info->idle)/1000;
        XFree(mit_info);
        XCloseDisplay(display);
        return idle_time;
}

int main() {
char halfint[]="echo -n 'gpuintensity|0,15' | nc 127.0.0.1 4028 >/dev/null";
char fullint[]="echo -n 'gpuintensity|0,20' | nc 127.0.0.1 4028 >/dev/null";
int intensity=0;
int idleseconds=0;

system(halfint);
while (1) {
   idleseconds=GetIdleTime();
        if (idleseconds>10 && intensity<20) {
     system(fullint);
     intensity=20;
        }
        if (idleseconds<2 && intensity>15) {
system(halfint);
intensity=15;
        }
        if (!(idleseconds%10)) {
     printf ("Idleseconds: %d - intensity: %d\n", idleseconds, intensity);
        }
        sleep(1);
}
}

A little tweaking is required on your side, namely the fullint and halfint strings. For example, this dude I know has found that his workmates' tolerance threshold was good even at 15 intensity. YMMV. The tool checks for activity every second; it doesn't make any sense to set it lower. It also prints relative information every 10 seconds, so you can (should) run it in a screen(1) and check it remotely. It doesn't check whether the miner is running; it just tries to set its intensity and assumes RPC port 4028. Compilation instructions are in the top comment.

If anyone finds it useful and profitable, show your appreciation to 1Ls3Ug9V2J83XLsg9EFXgLX7ebSwXc39ix

Share and enjoy and profit!

[EDIT] I forgot to mention, you need netcat(1) to pass the commands to cgminer.
Jump to: