zk-phi / symon

Tiny graphical system monitor
289 stars 26 forks source link

Mac OS X support #18

Closed pierre-lecocq closed 9 years ago

pierre-lecocq commented 9 years ago

Hey @zk-phi,

Here is the darwin support. It surely needs some refactoring, but it works.

Also, as I said on reddit, graphs did not work on my hand-compiled Emacs 25 (should have missed some libs at compile runtime). On a packages version, it works.

Genki-S commented 9 years ago

Hi, I've tried your branch and it worked :+1: (OS X 10.9.5)

However, it made my emacs unbearably slow... (actually, my emacs stopped responding with default symon-refresh-rate) Setting symon-refresh-rate larger alleviates the problem, but it still makes my emacs slow.

My guess is that emacs is blocked when symon.el is gathering system information, or when rendering. Is this a problem of this branch or symon.el in general? Any thoughts?: @zk-phi

pierre-lecocq commented 9 years ago

Hi @Genki-S ,

Thanks for the feedback. Can you try, in a shell to type those commands and tell me which one is slow (if there is) ?

sysctl hw
route get 0.0.0.0
netstat -bi -I en0 | tail -1

(replace "en0" by the name of your current network interface)

Thanks in advance

Genki-S commented 9 years ago

Hi @pierre-lecocq , thanks for your quick response. Here is the result of each command with time:

% time sysctl hw > /dev/null                                
sysctl hw > /dev/null  0.00s user 0.00s system 80% cpu 0.003 total

% time route get 0.0.0.0 > /dev/null
route get 0.0.0.0 > /dev/null  0.00s user 0.00s system 65% cpu 0.003 total

% time netstat -bi -I en0 | tail -1
en0   1500  192.168.1     192.168.1.23      657376     -  638198775   587092     -  152521626     -
netstat -bi -I en0  0.00s user 0.00s system 0% cpu 0.284 total
tail -1  0.00s user 0.00s system 0% cpu 0.283 total

I felt the last one was a bit slow.

pierre-lecocq commented 9 years ago

Thanks @Genki-S. I will try to find another method in order to fetch these info. Or try a way not to block the UI.

Just give me some time to work on it and I'll drop you a line here.

zk-phi commented 9 years ago

thanks @pierre-lecocq and @genki-s.

I had a similar problem when implementing windows monitors, and I decided to fork a subprocess that reports status values every symon-refresh-rate seconds (see symon-windows--maybe-start-wmi-process function).

pierre-lecocq commented 9 years ago

I will try this way, @zk-phi, thanks for the tip.

pierre-lecocq commented 9 years ago

Hello mates,

I just committed on the same branch a patch to change the method used to fetch the data, as @zk-phi indicated just above.

Works fine for me, here on a standard emacs build, nothing fancy, minimal config tweaks.

Therefore, I refactored a little bit the windows part as the darwin and windows part use the same kind of workflow.

Would you be kind enough to test ? @Genki-S for osx and @zk-phi for Windows (I do not have a windows box here, but tomorow I can use a VM to test if you do not have any time for this).

Thanks in advance for your feedback, and be sure that if there is somthing wrong, I can continue working on it (even if not full time).

pierre-lecocq commented 9 years ago

An additional note: what kind of theme do you use, @Genki-S ? Is it a dark theme ? I guess that @zk-phi use a light colored theme, as on the screenshots on the README file.

I noticed that if I use a dark color theme, the graphs are "invisible", but if I deactivate it, graphs are "visible".

I tested with some of light (dichromacy, light-blue, tango) and dark (deeper-blue, tango-dark, manoj-dark) themes loaded with `load-theme' and the problem seems common to dark themes. At least on Mac OS X.

If it is confirmed, I'll open another issue on the @zk-phi repository

Genki-S commented 9 years ago

Works perfectly :exclamation: It's completely unobtrusive, Great job @pierre-lecocq :+1:

I use solarized dark theme and it's true the graph is a bit tough to see. Mine looks like this:

Gyazo

It may be a good idea to make it possible to control graph color, if possible.

zk-phi commented 9 years ago

works fine on windows too, thanks!

I tested with some of light (dichromacy, light-blue, tango) and dark (deeper-blue, tango-dark, manoj-dark) themes loaded with `load-theme' and the problem seems common to dark themes. At least on Mac OS X.

I've tried solarized-dark and had no problems (color of sparklines inherits 'default face). It may be an environment-dependent problem.

We can probably fix that by just adding :foreground and :background properties to sparklines. can you try this ?

(defadvice symon--make-sparkline (after fix activate)
  (setq ad-return-value
        (nconc ad-return-value '(:foreground "#ffffff"))))
zk-phi commented 9 years ago

merged. thanks for your contribution!

pierre-lecocq commented 9 years ago

All right ! Great news !

Thank you very much, both of you, @Genki-S for our feedbacks and @zk-phi for your initial work.

PS: I'll try to manage the color theme problem today. Thanks for the hint.