Hi,
I'm using nmon on my sytem to collect data in a csv file every second. I'm also using the NMON_SNAP enviroment variable to execute a script and record some extra information.
I'm facing a problem that happens sometimes when the child process, started by nmon, sends a SIGCHILD signal that interrupts the sleep() function. This leads to nmon taking more that one statistic in one second e.g.:
ZZZZ,T0020,11:05:02,01-JUL-2019
CPU001,T0020,24.0,2.0,0.0,74.0,0.0
...
ERROR,T0020, sleep interrupted, sleep(1 seconds), return value=0, errno=4
ZZZZ,T0021,11:05:02,01-JUL-2019
CPU001,T0021,100.0,0.0,0.0,0.0,0.0
...
ERROR,T0021, sleep interrupted, sleep(1 seconds), return value=0, errno=4
ZZZZ,T0022,11:05:02,01-JUL-2019
CPU001,T0022,0.0,0.0,0.0,100.0,0.0
...
ERROR,T0022, sleep interrupted, sleep(1 seconds), return value=0, errno=4
ZZZZ,T0023,11:05:02,01-JUL-2019
Woud it be possible to replace sleep() with nanosleep()? hence when nanosleep() gets interrupted it can sleep for the remaining time when it gets interrupted.
Thanks
Here the changes I did to try it out:
This is a good idea but has the potential of going horribly wrong with old and odd-ball Linux kernels. I thought nanoseconds was a "new fangles thing" but I find references to in back in 2001 so probaly older than that.
I will add this to the next major release as it is more than a simple bug fix.
That has no set date at the moment.
Good to know you are a capableC coder so you can have your nmon version fixed right now.
Question does: sleep_time = sleep_rem_time;
compile OK - these are two data structures?
Examples I have seen use just the one variable for both requested and remainer structures
Thanks for integrating it!
Question does: sleeptime = sleepremtime;
compile OK - these are two data structures?
Yes, it compiles fine and works fine. As
struct timespecdoes not contain any pointers it is possible to copy it just like that.Examples I have seen use just the one variable for both requested and remainer structures
This might work as well. Probably better as my proposed solution because there would be one less copy.