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

Provide a generic sysinfo function #720

Open
giampaolo opened this issue Dec 16, 2015 · 9 comments
Open

Provide a generic sysinfo function #720

giampaolo opened this issue Dec 16, 2015 · 9 comments

Comments

@giampaolo
Copy link
Owner

giampaolo commented Dec 16, 2015

This is supposed to be a function returning generic system wide info designed to host information which is not cross platform. As such, the returned namedtuple will have different attributes depending on what platform we're on. The new API should be called psutil.sysinfo(). Some ideas:

Linux

def sysinfo():

  • procs
  • procs_running
  • procs_blocked
  • open_files (cat /proc/sys/fs/file-nr)
  • max_files (sysctl -a | grep fs.file-max)
  • max_threads?
  • max_pids?

FreeBSD

PyObject *

  • openfiles
  • maxfiles?
  • maxprocs?
  • maxpid?

OpenBSD

PyObject *

  • open_files
  • num_threads
  • max_files?
  • max_procs?

NetBSD

https://github.com/giampaolo/psutil/blob/905030b052414e66bc065fc6dff14dbd875be77a/psutil/arch/bsd/netbsd.c#L801

  • max_files?
  • mac_proc?

OpenBSD

  • max_proc?
  • max_files?

Solaris

static PyObject *

  • num_threads

Windows

?

Debatable

  • last_pid
    • Linux: /proc/sys/kernel/ns_last_pid
    • FreeBSD: sysctl kern.lastpid
  • max_threads_perproc: (debatable because resource module can be used)
    • FreeBSD: sysctl kern.threads.max_threads_per_proc
  • max_files_perproc: (debatable because resource module can be used)
    • FreeBSD: sysctl kern.maxfilesperproc

Ideas are very welcome.

@AshishNamdev
Copy link

Would like to work on it.
Let met know if someone working on this.
Will support as I am a new with python.

BR,
Ashish Namdev
Software Engineer - I
AMD

-----Original Message-----
From: "giampaolo" notifications@github.com
Sent: ‎16-‎12-‎2015 22:20
To: "giampaolo/psutil" psutil@noreply.github.com
Subject: [psutil] Provide a generic sysinfo function (#720)

This is supposed to be a function returning generic system wide info designed to host information which is not cross platform As such, the returned namedtuple will have different attributes depending on what platform we're on Some ideas:
number of open files
number of threads
number of actively running processes
number of total ctx switches
number of open sockets (FreeBSD has this)
number of open sockets (FreeBSD has this)
max files per process
max threads per process (FreeBSD has this)

Reply to this email directly or view it on GitHub.

@giampaolo
Copy link
Owner Author

I'd rather ask people to come up with ideas about what else we might provide first. Of course any implementation help / PR is welcome.

giampaolo added a commit that referenced this issue Dec 18, 2015
giampaolo added a commit that referenced this issue Dec 19, 2015
giampaolo added a commit that referenced this issue Dec 20, 2015
@giampaolo
Copy link
Owner Author

As for Windows Process Hacker is able to determine number of context switches, interrupts and system calls. Hopefully psutil should be able to do the same.

@giampaolo
Copy link
Owner Author

@wj32

@wj32
Copy link

wj32 commented Dec 29, 2015

What you want is SYSTEM_PERFORMANCE_INFORMATION and SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, which you can get using NtQuerySystemInformation. See phlib/include/ntexapi.h and PhSipTickCpuDialog in ProcessHacker/sysinfo.c for details.

@giampaolo
Copy link
Owner Author

Note: for Linux testing we can use:

~/svn/psutil$ vmstat  -s
     10124368 K total memory
      8480240 K used memory
      4781932 K active memory
      2899572 K inactive memory
      1644128 K free memory
       325008 K buffer memory
      3143460 K swap cache
      2943996 K total swap
        23944 K used swap
      2920052 K free swap
      2064780 non-nice user cpu ticks
        27900 nice user cpu ticks
      1244258 system cpu ticks
      7665170 idle cpu ticks
       186416 IO-wait cpu ticks
           18 IRQ cpu ticks
         5434 softirq cpu ticks
            0 stolen cpu ticks
      5186699 pages paged in
     18304305 pages paged out
            7 pages swapped in
         5988 pages swapped out
     87182581 interrupts
    390691624 CPU context switches
   1455448832 boot time
        85420 forks

giampaolo added a commit that referenced this issue Mar 3, 2016
giampaolo added a commit that referenced this issue Mar 4, 2016
giampaolo added a commit that referenced this issue Mar 4, 2016
@giampaolo
Copy link
Owner Author

@nicolargo
Copy link
Contributor

Any head up concerning this development request ?

@giampaolo
Copy link
Owner Author

This is currently not on my radar for the immediate future.

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

4 participants