Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with network statistics on Solaris 10 #517

Closed
lymanepp opened this issue Jul 1, 2014 · 3 comments
Closed

Problems with network statistics on Solaris 10 #517

lymanepp opened this issue Jul 1, 2014 · 3 comments

Comments

@lymanepp
Copy link

lymanepp commented Jul 1, 2014

We’ve been evaluating psutil for suitability in a cross-platform machine statistic gathering application that we maintain for internal use. We’ve had several issues on Solaris and the attached patch file contains changes that made to get it working on Solaris 10.

  • We didn’t have any kstat network results where ks_module == “link”, so we hacked it to look for ks_name == “mac”. There is probably a better solution. The “kstat -c net” output from several of our servers is linked below for reference. Our servers have multi-port NIC cards, so we needed to mangle ks_name + ks_instance as the key of the returned dictionary.
  • The code was compiled as 32-bit code to match our Python installation. The #if code assumes that the kstat statistics will match the number of bits used to compile. That is not a valid assumption. A hack was made to check at runtime.

This patch is not ready to merge, but I would be happy to get feedback to make it acceptable.

Patch - https://gist.github.com/lymanepp/c5e403df4cbd73561d9a
Kstat output (server 1) - https://gist.github.com/lymanepp/2d105d01da798760f2c5
Kstat output (server 2) - https://gist.github.com/lymanepp/2b6c103ff97fdf5995f2

@lymanepp lymanepp changed the title Solaris issues Problems with network statistics on Solaris Jul 1, 2014
@lymanepp lymanepp changed the title Problems with network statistics on Solaris Problems with network statistics on Solaris 10 Jul 1, 2014
@wiggin15
Copy link
Collaborator

I think that instead of checking strcmp(ksp->ks_name, "mac") you could check strcmp(ksp->ks_module, "e1000g"). Then you'll get the e1000g# interfaces and the ks_name:ks_instance hack won't be needed. In fact, I think net_io_counters shouldn't be returning the mac interfaces at all, since those interfaces don't show in ifconfig -a.
In other words: in Solaris 10, ks_module is 'e1000g' and not 'link', that's all.

wiggin15 pushed a commit to Infinidat/psutil that referenced this issue Sep 5, 2015
instead of testing ksp->ks_module is 'link'
wiggin15 pushed a commit to Infinidat/psutil that referenced this issue Sep 6, 2015
and not system dependent

_INT64_TYPE may be defined but kstat may still return
the IO counters in 32-bit types.
In addition, on SunOS, sizeof(long)==sizeof(long long)==8
so using 'k' and 'K' means the same, and we need to ue 'I' for
unsigned 32 bit integers.
giampaolo added a commit that referenced this issue Sep 6, 2015
Fix #517 (net_io_counters on Solaris 10)
@giampaolo
Copy link
Owner

This was fixed in #680

@lymanepp
Copy link
Author

lymanepp commented Sep 6, 2015

Thank you!!

On 9/6/2015 4:52 AM, giampaolo wrote:

This was fixed in #680 #680


Reply to this email directly or view it on GitHub
#517 (comment).

mrjefftang added a commit to mrjefftang/psutil that referenced this issue Sep 8, 2015
* giampaolo/master: (33 commits)
  fix appveyor failure
  update TODO + GIT pre-commit script
  #678_ setup.py error on linux
  reverse change - don't call safe_remove on APPVEYOR
  fix review comments
  update history and credits
  giampaolo#517 The data type retrurned from kstat is interface dependent and not system dependent
  Fix giampaolo#517 by testing ksp->ks_name is a network interface instead of testing ksp->ks_module is 'link'
  avoid name cutoff in tests
  use os.path.normcase for Windows exe tests
  TestUnicode: Instead of using Python's executable, compile one if possible
  Fix test_memory_leaks
  Code review fixes
  fix test on Solaris
  fix test on Solaris
  fix test on Solaris
  fix test on Solaris
  swap -k is not supported in Solaris 10
  Add ifaddrs.c for Solaris 10
  move DUPLEX_UNKOWN fix outside of #if PSUTIL_HAVE_IOPRIO
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants