obihann / archey-osx

An archey script clone for OS X
http://obihann.github.io/archey-osx/
GNU General Public License v2.0
341 stars 124 forks source link

1.5 IP timeout & Battery #17

Closed jhersh closed 9 years ago

jhersh commented 9 years ago

Thanks for a really great utility! :+1: I wanted to report 2 issues with 1.5:

% archey -c

                 ###                  User: jh
               ####                   Hostname: jhmp
               ###                    Distro: OS X 10.11.1
       #######    #######             Kernel: Darwin
     ######################           Uptime: 16:44  up 8 days,  3:36, 4 users, load averages: 1.64 1.53 1.58
    #####################             Shell: /usr/local/bin/zsh
    ####################              Terminal: xterm-256color iTerm.app
    ####################              Packages: 7
    #####################             CPU: Intel Xeon CPU E5-1680 v2 @ 3.00GHz
     ######################           Memory: 32 GB
      ####################            Disk: 36%
        ################              Battery:
         ####     #####               IP Address: ;; connection timed out; no servers could be reached

:battery::no_entry_sign: I'm on a Mac Pro, which doesn't have a battery, so it seems peculiar to include a blank battery line here.

:hourglass: archey now takes about 10 seconds to execute because the IP fetch times out. I've verified that the underlying command archey is using (dig +short myip.opendns.com @resolver1.opendns.com) is the cause of this delay, and that command still times out and prints the above message when used alone. It may be that my current network is blocking or filtering opendns, but even if not, this network request is still likely to be the slowest part about running archey. Perhaps it's worth adding an optional switch to disable the IP address fetch?

obihann commented 9 years ago

Thanks for noticing this, I'll look into both and try to get them taken care of before 1.5.x is released into homebrew.

obihann commented 9 years ago

@jhersh Could you do me a favour and verify that 519456178a49e8a0d1740f4e4942c15ff4bc50a5 hides the battery field for you without causing any new issues? I don't have a machine without a battery so I can only make an assumption this will work. Thanks!

edit: changed to a different commit

jhersh commented 9 years ago

@obihann Thanks for checking into this! Unfortunately it's still there:

[0] % git rev-parse HEAD
fa463d4c9d3b213cb9b55c231c6eb3d090c278a6

[0] % gb
* master

[0] % bin/archey -o

                 ###                  User: jh
               ####                   Hostname: jhmp
               ###                    Distro: OS X 10.11.1
       #######    #######             Kernel: Darwin
     ######################           Uptime: 8 days
    #####################             Shell: /usr/local/bin/zsh
    ####################              Terminal: xterm-256color iTerm.app
    ####################              Packages: 7
    #####################             CPU: Intel Xeon CPU E5-1680 v2 @ 3.00GHz
     ######################           Memory: 32 GB
      ####################            Disk: 44%
        ################              Battery:
         ####     #####

One other minor thing I noticed:

[0] % bin/archey -co
Unknown argument: -co
For help, use: bin/archey --help

Looks like it wants archey -c -o instead.

obihann commented 9 years ago

:-1: thats too bad. Could you run ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%", $10/$5 * 100)}' and paste me the output? Then I should know exactly what users see when they have no battery, and I can filter it from there. Thanks.

jhersh commented 9 years ago

No output ("capacity" does not appear anywhere in ioreg -l)

obihann commented 9 years ago

I think I see it now! I should have this fixed shortly.

obihann commented 9 years ago

6050fbc99d999250f05e30ff17101f31726aaa94 should fix this, let me know if not :+1:

jhersh commented 9 years ago

:+1::cool::100:

obihann commented 9 years ago

Sweet! Thanks.

nilstgmd commented 9 years ago

thanks for resolving the battery issue, any news on the IP fetching? I have the exact problem when using the corporate wireless network. Thx

obihann commented 9 years ago

@nilstgmd I added two features that are now in master and 1.5.1 PR, one is the addition of a -o flag that disables the IP check, the other is caching of the IP. Basically we store your IP in ~/.archey-ip and next time we load if that file is less than 6 hours old we just read it instead of checking again.

nilstgmd commented 9 years ago

@obihann Great 👍🏿 Thanks for fixing this :shipit: