pspy icon indicating copy to clipboard operation
pspy copied to clipboard

Strange behaviour on Centos 7 based system when monitoring dirs

Open AkikoOrenji opened this issue 3 years ago • 1 comments
trafficstars

_# ./pspy64 -p=false -f pspy - version: v1.2.0 - Commit SHA: 9c63e5d6c58f7bcdc235db663f5e3fe1c33b8855

Config: Printing events (colored=true): processes=false | file-system-events=true ||| Scannning for processes every 100ms and on inotify events ||| Watching directories: [/usr /tmp /etc /home /var /opt] (recursive) | [] (non-recursive) Draining file system events due to startup..._

Running the above just hangs. Assuming because Draining file system events due to startup never goes to 'done'. The only way i can recover from that point is with CTRL-Z to background the process and then kill it. If i change the directory manually to only /home or /opt or other systems dirs it works fine. Seems like only a problem with /usr /tmp /etc & /var. Tried these dirs with non-recursive mode and had the same problem.

Any ideas ?

AkikoOrenji avatar Aug 11 '22 07:08 AkikoOrenji

hmmm so this is really surprising. since it prints the message about draining events, we for sure got here during startup, and since "done" is not printed, we get stuck somewhere within drainEventsFor (code).

Other than allowing you to CTRL-z out of the program, it just waits for a fixed duration (1 sec, hardcoded), returns after that, and ignores all other events meanwhile.

Golang's time.After(1 * time.Second) is basically a nice way of writing NewTimer(1 * time.Second).C and the docs about this timer say that it "will send the current time on its channel after at least duration" 1 second. There is no guarantee for good accuracy and for sure things like CPU load may cause additional delay. Still, a delay so long that it's annoying for humans sounds pretty extreme to me.

Since pspy will walk the file system and place watchers everywhere, its conceivable that the system might be under stress. Maybe that's causing the problem. Wild theory, I know...

Do you still have access to the box? Can you run htop or something similar and check what the load is during startup?

DominicBreuker avatar Aug 16 '22 19:08 DominicBreuker

Was able to reproduce this problem on one of my systems and changed the draining logic a bit to make it go away. If you build from master it should be better now.

DominicBreuker avatar Oct 25 '22 21:10 DominicBreuker

Any chance you might be inclined to publish a new release with this fix? Master build solved this issue for me as well.

Sector95 avatar Jan 11 '23 08:01 Sector95

I will, I will :)

DominicBreuker avatar Jan 13 '23 22:01 DominicBreuker

and there it is: https://github.com/DominicBreuker/pspy/releases/tag/v1.2.1

DominicBreuker avatar Jan 17 '23 21:01 DominicBreuker

I assume it is gone. Please open new issues if not

DominicBreuker avatar Jun 14 '23 20:06 DominicBreuker