1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00
shirou_gopsutil/README.rst

201 lines
4.2 KiB
ReStructuredText
Raw Normal View History

2014-04-18 16:34:47 +09:00
gopsutil: psutil for golang
==============================
2014-04-24 21:48:51 +09:00
.. image:: https://drone.io/github.com/shirou/gopsutil/status.png
:target: https://drone.io/github.com/shirou/gopsutil
2014-04-25 14:38:26 +09:00
2014-05-11 17:06:53 +09:00
.. image:: https://coveralls.io/repos/shirou/gopsutil/badge.png?branch=master
:target: https://coveralls.io/r/shirou/gopsutil?branch=master
2014-04-22 12:31:36 +09:00
This is a port of psutil(http://pythonhosted.org/psutil/). This
2014-04-22 12:38:12 +09:00
challenges porting all psutil functions on some architectures.
2014-04-22 12:31:36 +09:00
Available archtectures
------------------------------------
2014-04-18 16:34:47 +09:00
2014-04-22 12:31:36 +09:00
- FreeBSD/amd64
2014-04-23 10:37:21 +09:00
- Linux/amd64
2014-05-14 00:12:17 +09:00
- Linux/arm (raspberry pi)
2014-04-23 10:37:21 +09:00
- Windows/amd64
2014-04-22 12:31:36 +09:00
(I do not have a darwin machine)
2014-04-23 12:53:27 +09:00
All works are implemented without cgo by porting c struct to golang struct.
2014-04-25 14:38:26 +09:00
Usage
2014-04-22 12:31:36 +09:00
---------
::
2014-04-30 23:17:33 +09:00
import (
"fmt"
"github.com/shirou/gopsutil"
)
func main() {
v, _ := gopsutil.VirtualMemory()
// almost every return value is struct
2014-04-30 23:17:33 +09:00
fmt.Printf("Total: %v, Free:%v, UsedPercent:%f%%\n", v.Total, v.Free, v.UsedPercent)
// convert to JSON. String() is also implemented
fmt.Println(d)
2014-04-30 23:17:33 +09:00
}
2014-04-22 12:31:36 +09:00
The output is below.
::
Total: 3179569152, Free:284233728, UsedPercent:84.508194%
{"total":3179569152,"available":492572672,"used":2895335424,"usedPercent":84.50819439828305, (snip)}
Document
----------
see http://godoc.org/github.com/shirou/gopsutil
2014-05-16 16:42:16 +09:00
More info
--------------------
To becomes more useful, add more information.
2014-05-16 19:03:15 +09:00
- Hostinfo() (linux)
2014-05-16 16:42:16 +09:00
- OS
2014-05-23 10:33:21 +09:00
- Platform (ex: ubuntu, arch)
- Platform family (ex: debian)
- Platform Version (ex: Ubuntu 13.10)
- VirtualizationSystem (ex: LXC)
- VirtualizationRole (ex: guest/host)
2014-05-16 16:42:16 +09:00
2014-05-16 19:03:15 +09:00
- CPUInfoStat() (linux, freebsd)
2014-05-16 18:12:18 +09:00
- Processer
- Vendor ID
- Model name
- cores
- Mhz
- etc...
2014-05-16 19:03:15 +09:00
- LoadAvg() (linux, freebsd)
- Load1
- Load5
- Load15
2014-05-16 16:42:16 +09:00
Some codes are ported some functions from Ohai. very thanks.
2014-04-22 12:38:12 +09:00
Current Status
------------------
- done
2014-04-23 11:37:00 +09:00
- cpu_times (linux, freebsd)
2014-04-22 12:38:12 +09:00
- cpu_count (linux, freebsd, windows)
- virtual_memory (linux, freebsd, windows)
- swap_memory (linux, freebsd)
- disk_partitions (linux, freebsd, windows)
2014-04-29 14:59:22 +09:00
- disk_io_counters (linux)
2014-04-22 19:25:28 +09:00
- disk_usage (linux, freebsd, windows)
2014-05-18 23:23:47 +09:00
- net_io_counters (linux, freebsd, windows)
2014-04-23 10:37:21 +09:00
- boot_time (linux, freebsd, windows(but little broken))
2014-04-22 17:51:58 +09:00
- users (linux, freebsd)
2014-04-24 00:31:57 +09:00
- pids (linux, freebsd)
- pid_exists (linux, freebsd)
2014-04-25 14:38:26 +09:00
- Process class
2014-04-30 16:29:16 +09:00
- pid (linux, freebsd, windows)
- ppid (linux, freebsd, windows)
2014-04-30 16:29:16 +09:00
- name (linux)
- cmdline (linux)
- create_time (linux)
- status (linux)
- cwd (linux)
2014-04-30 16:29:16 +09:00
- exe (linux, freebsd, windows)
- uids (linux, freebsd)
- gids (linux, freebsd)
- terminal (linux, freebsd)
- io_counters (linux)
2014-04-30 16:29:16 +09:00
- nice (linux)
- num_fds (linux)
- num_ctx_switches (linux)
- num_threads (linux, freebsd, windows)
2014-04-30 16:29:16 +09:00
- cpu_times (linux)
- memory_info (linux, freebsd)
2014-04-30 16:29:16 +09:00
- memory_info_ex (linux)
- memory_maps() (linux)
- open_files (linux)
- send_signal (linux, freebsd)
- suspend (linux, freebsd)
- resume (linux, freebsd)
- terminate (linux, freebsd)
- kill (linux, freebsd)
2014-04-22 12:38:12 +09:00
- not yet
- cpu_percent
- cpu_times_percent
- net_connections
- Process class
2014-04-25 14:38:26 +09:00
- username
- ionice
- rlimit
- num_handlers
- threads
- cpu_percent
- cpu_affinity
- memory_percent
- children
- connections
- is_running
- future work
2014-04-22 12:38:12 +09:00
- process_iter
- wait_procs
2014-04-25 14:38:26 +09:00
- Process class
- parent (use ppid instead)
2014-04-25 14:38:26 +09:00
- as_dict
- wait
2014-04-22 12:38:12 +09:00
2014-04-22 12:31:36 +09:00
License
------------
New BSD License (same as psutil)
Related works
-----------------------
2014-04-18 16:34:47 +09:00
- psutil: http://pythonhosted.org/psutil/
- dstat: https://github.com/dagwieers/dstat
- gosiger: https://github.com/cloudfoundry/gosigar/
- goprocinfo: https://github.com/c9s/goprocinfo
- go-ps: https://github.com/mitchellh/go-ps
2014-05-16 16:42:16 +09:00
- ohai: https://github.com/opscode/ohai/
2014-04-29 15:34:48 +09:00
I have referenced these great works.
How to Contributing
---------------------------
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create new Pull Request
My engilsh is terrible, documentation or correcting comments are also
welcome.