mirror of
https://github.com/shirou/gopsutil.git
synced 2025-05-04 22:17:34 +08:00
Merge branch 'master' of github.com:shirou/gopsutil
This commit is contained in:
commit
0e1af698cc
@ -10,8 +10,8 @@ Available archtectures
|
|||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
- FreeBSD/amd64
|
- FreeBSD/amd64
|
||||||
- Linux
|
- Linux/amd64
|
||||||
- Windows
|
- Windows/amd64
|
||||||
|
|
||||||
(I do not have a darwin machine)
|
(I do not have a darwin machine)
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ Current Status
|
|||||||
- swap_memory (linux)
|
- swap_memory (linux)
|
||||||
- disk_partitions (freebsd, windows)
|
- disk_partitions (freebsd, windows)
|
||||||
- disk_usage (linux, freebsd, windows)
|
- disk_usage (linux, freebsd, windows)
|
||||||
- boot_time (linux, freebsd)
|
- boot_time (linux, freebsd, windows(but little broken))
|
||||||
- users (linux, freebsd)
|
- users (linux, freebsd)
|
||||||
|
|
||||||
- not yet
|
- not yet
|
||||||
|
@ -35,12 +35,12 @@ func ReadLines(filename string) ([]string, error) {
|
|||||||
func byteToString(orig []byte) string {
|
func byteToString(orig []byte) string {
|
||||||
n := -1
|
n := -1
|
||||||
l := -1
|
l := -1
|
||||||
for i, b := range orig{
|
for i, b := range orig {
|
||||||
// skip left side null
|
// skip left side null
|
||||||
if l == -1 && b == 0{
|
if l == -1 && b == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if l == -1{
|
if l == -1 {
|
||||||
l = i
|
l = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,57 +7,6 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
MNT_WAIT = 1
|
|
||||||
MFSNAMELEN = 16 /* length of type name including null */
|
|
||||||
MNAMELEN = 88 /* size of on/from name bufs */
|
|
||||||
)
|
|
||||||
|
|
||||||
// sys/mount.h
|
|
||||||
const (
|
|
||||||
MNT_RDONLY = 0x00000001 /* read only filesystem */
|
|
||||||
MNT_SYNCHRONOUS = 0x00000002 /* filesystem written synchronously */
|
|
||||||
MNT_NOEXEC = 0x00000004 /* can't exec from filesystem */
|
|
||||||
MNT_NOSUID = 0x00000008 /* don't honor setuid bits on fs */
|
|
||||||
MNT_UNION = 0x00000020 /* union with underlying filesystem */
|
|
||||||
MNT_ASYNC = 0x00000040 /* filesystem written asynchronously */
|
|
||||||
MNT_SUIDDIR = 0x00100000 /* special handling of SUID on dirs */
|
|
||||||
MNT_SOFTDEP = 0x00200000 /* soft updates being done */
|
|
||||||
MNT_NOSYMFOLLOW = 0x00400000 /* do not follow symlinks */
|
|
||||||
MNT_GJOURNAL = 0x02000000 /* GEOM journal support enabled */
|
|
||||||
MNT_MULTILABEL = 0x04000000 /* MAC support for individual objects */
|
|
||||||
MNT_ACLS = 0x08000000 /* ACL support enabled */
|
|
||||||
MNT_NOATIME = 0x10000000 /* disable update of file access time */
|
|
||||||
MNT_NOCLUSTERR = 0x40000000 /* disable cluster read */
|
|
||||||
MNT_NOCLUSTERW = 0x80000000 /* disable cluster write */
|
|
||||||
MNT_NFS4ACLS = 0x00000010
|
|
||||||
)
|
|
||||||
|
|
||||||
type Statfs struct {
|
|
||||||
F_version uint32 /* structure version number */
|
|
||||||
F_type uint32 /* type of filesystem */
|
|
||||||
F_flags uint64 /* copy of mount exported flags */
|
|
||||||
F_bsize uint64 /* filesystem fragment size */
|
|
||||||
F_iosize uint64 /* optimal transfer block size */
|
|
||||||
F_blocks uint64 /* total data blocks in filesystem */
|
|
||||||
F_bfree uint64 /* free blocks in filesystem */
|
|
||||||
F_bavail int64 /* free blocks avail to non-superuser */
|
|
||||||
F_files uint64 /* total file nodes in filesystem */
|
|
||||||
F_ffree int64 /* free nodes avail to non-superuser */
|
|
||||||
F_syncwrites uint64 /* count of sync writes since mount */
|
|
||||||
F_asyncwrites uint64 /* count of async writes since mount */
|
|
||||||
F_syncreads uint64 /* count of sync reads since mount */
|
|
||||||
F_asyncreads uint64 /* count of async reads since mount */
|
|
||||||
F_spare [10]uint64 /* unused spare */
|
|
||||||
F_namemax uint32 /* maximum filename length */
|
|
||||||
F_owner uint32 /* user that mounted the filesystem */
|
|
||||||
F_fsid int32 /* filesystem id */
|
|
||||||
F_charspare [80]byte /* spare string space */
|
|
||||||
F_fstypename [MFSNAMELEN]byte /* filesystem type name */
|
|
||||||
F_mntfromname [MNAMELEN]byte /* mounted filesystem */
|
|
||||||
F_mntonname [MNAMELEN]byte /* directory on which mounted */
|
|
||||||
}
|
|
||||||
|
|
||||||
func Disk_partitions() ([]Disk_partitionStat, error) {
|
func Disk_partitions() ([]Disk_partitionStat, error) {
|
||||||
ret := make([]Disk_partitionStat, 0)
|
ret := make([]Disk_partitionStat, 0)
|
||||||
|
|
||||||
|
55
disk_freebsd_amd64.go
Normal file
55
disk_freebsd_amd64.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// +build freebsd
|
||||||
|
// +build amd64
|
||||||
|
|
||||||
|
package gopsutil
|
||||||
|
|
||||||
|
const (
|
||||||
|
MNT_WAIT = 1
|
||||||
|
MFSNAMELEN = 16 /* length of type name including null */
|
||||||
|
MNAMELEN = 88 /* size of on/from name bufs */
|
||||||
|
)
|
||||||
|
|
||||||
|
// sys/mount.h
|
||||||
|
const (
|
||||||
|
MNT_RDONLY = 0x00000001 /* read only filesystem */
|
||||||
|
MNT_SYNCHRONOUS = 0x00000002 /* filesystem written synchronously */
|
||||||
|
MNT_NOEXEC = 0x00000004 /* can't exec from filesystem */
|
||||||
|
MNT_NOSUID = 0x00000008 /* don't honor setuid bits on fs */
|
||||||
|
MNT_UNION = 0x00000020 /* union with underlying filesystem */
|
||||||
|
MNT_ASYNC = 0x00000040 /* filesystem written asynchronously */
|
||||||
|
MNT_SUIDDIR = 0x00100000 /* special handling of SUID on dirs */
|
||||||
|
MNT_SOFTDEP = 0x00200000 /* soft updates being done */
|
||||||
|
MNT_NOSYMFOLLOW = 0x00400000 /* do not follow symlinks */
|
||||||
|
MNT_GJOURNAL = 0x02000000 /* GEOM journal support enabled */
|
||||||
|
MNT_MULTILABEL = 0x04000000 /* MAC support for individual objects */
|
||||||
|
MNT_ACLS = 0x08000000 /* ACL support enabled */
|
||||||
|
MNT_NOATIME = 0x10000000 /* disable update of file access time */
|
||||||
|
MNT_NOCLUSTERR = 0x40000000 /* disable cluster read */
|
||||||
|
MNT_NOCLUSTERW = 0x80000000 /* disable cluster write */
|
||||||
|
MNT_NFS4ACLS = 0x00000010
|
||||||
|
)
|
||||||
|
|
||||||
|
type Statfs struct {
|
||||||
|
F_version uint32 /* structure version number */
|
||||||
|
F_type uint32 /* type of filesystem */
|
||||||
|
F_flags uint64 /* copy of mount exported flags */
|
||||||
|
F_bsize uint64 /* filesystem fragment size */
|
||||||
|
F_iosize uint64 /* optimal transfer block size */
|
||||||
|
F_blocks uint64 /* total data blocks in filesystem */
|
||||||
|
F_bfree uint64 /* free blocks in filesystem */
|
||||||
|
F_bavail int64 /* free blocks avail to non-superuser */
|
||||||
|
F_files uint64 /* total file nodes in filesystem */
|
||||||
|
F_ffree int64 /* free nodes avail to non-superuser */
|
||||||
|
F_syncwrites uint64 /* count of sync writes since mount */
|
||||||
|
F_asyncwrites uint64 /* count of async writes since mount */
|
||||||
|
F_syncreads uint64 /* count of sync reads since mount */
|
||||||
|
F_asyncreads uint64 /* count of async reads since mount */
|
||||||
|
F_spare [10]uint64 /* unused spare */
|
||||||
|
F_namemax uint32 /* maximum filename length */
|
||||||
|
F_owner uint32 /* user that mounted the filesystem */
|
||||||
|
F_fsid int32 /* filesystem id */
|
||||||
|
F_charspare [80]byte /* spare string space */
|
||||||
|
F_fstypename [MFSNAMELEN]byte /* filesystem type name */
|
||||||
|
F_mntfromname [MNAMELEN]byte /* mounted filesystem */
|
||||||
|
F_mntonname [MNAMELEN]byte /* directory on which mounted */
|
||||||
|
}
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
package gopsutil
|
package gopsutil
|
||||||
|
|
||||||
|
|
||||||
func Disk_partitions() ([]Disk_partitionStat, error) {
|
func Disk_partitions() ([]Disk_partitionStat, error) {
|
||||||
ret := make([]Disk_partitionStat, 0)
|
ret := make([]Disk_partitionStat, 0)
|
||||||
|
|
||||||
|
@ -12,19 +12,6 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
UT_NAMESIZE = 16 /* see MAXLOGNAME in <sys/param.h> */
|
|
||||||
UT_LINESIZE = 8
|
|
||||||
UT_HOSTSIZE = 16
|
|
||||||
)
|
|
||||||
|
|
||||||
type utmp struct {
|
|
||||||
Ut_line [UT_LINESIZE]byte
|
|
||||||
Ut_name [UT_NAMESIZE]byte
|
|
||||||
Ut_host [UT_HOSTSIZE]byte
|
|
||||||
Ut_time int32
|
|
||||||
}
|
|
||||||
|
|
||||||
func HostInfo() (HostInfoStat, error) {
|
func HostInfo() (HostInfoStat, error) {
|
||||||
ret := HostInfoStat{}
|
ret := HostInfoStat{}
|
||||||
|
|
||||||
|
17
host_freebsd_amd64.go
Normal file
17
host_freebsd_amd64.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// +build freebsd
|
||||||
|
// +build amd64
|
||||||
|
|
||||||
|
package gopsutil
|
||||||
|
|
||||||
|
const (
|
||||||
|
UT_NAMESIZE = 16 /* see MAXLOGNAME in <sys/param.h> */
|
||||||
|
UT_LINESIZE = 8
|
||||||
|
UT_HOSTSIZE = 16
|
||||||
|
)
|
||||||
|
|
||||||
|
type utmp struct {
|
||||||
|
Ut_line [UT_LINESIZE]byte
|
||||||
|
Ut_name [UT_NAMESIZE]byte
|
||||||
|
Ut_host [UT_HOSTSIZE]byte
|
||||||
|
Ut_time int32
|
||||||
|
}
|
@ -11,29 +11,6 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type exit_status struct {
|
|
||||||
E_termination int16 // Process termination status.
|
|
||||||
E_exit int16 // Process exit status.
|
|
||||||
}
|
|
||||||
type timeval struct {
|
|
||||||
Tv_sec uint32 // Seconds.
|
|
||||||
Tv_usec uint32 // Microseconds.
|
|
||||||
}
|
|
||||||
|
|
||||||
type utmp struct {
|
|
||||||
Ut_type int16 // Type of login.
|
|
||||||
Ut_pid int32 // Process ID of login process.
|
|
||||||
Ut_line [32]byte // Devicename.
|
|
||||||
Ut_id [4]byte // Inittab ID.
|
|
||||||
Ut_user [32]byte // Username.
|
|
||||||
Ut_host [256]byte // Hostname for remote login.
|
|
||||||
Ut_exit exit_status // Exit status of a process marked
|
|
||||||
Ut_session int32 // Session ID, used for windowing.
|
|
||||||
Ut_tv timeval // Time entry was made.
|
|
||||||
Ut_addr_v6 [16]byte // Internet address of remote host.
|
|
||||||
Unused [20]byte // Reserved for future use. // original is 20
|
|
||||||
}
|
|
||||||
|
|
||||||
func HostInfo() (HostInfoStat, error) {
|
func HostInfo() (HostInfoStat, error) {
|
||||||
ret := HostInfoStat{}
|
ret := HostInfoStat{}
|
||||||
|
|
||||||
|
27
host_linux_amd64.go
Normal file
27
host_linux_amd64.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// +build linux
|
||||||
|
// +build amd64
|
||||||
|
|
||||||
|
package gopsutil
|
||||||
|
|
||||||
|
type exit_status struct {
|
||||||
|
E_termination int16 // Process termination status.
|
||||||
|
E_exit int16 // Process exit status.
|
||||||
|
}
|
||||||
|
type timeval struct {
|
||||||
|
Tv_sec uint32 // Seconds.
|
||||||
|
Tv_usec uint32 // Microseconds.
|
||||||
|
}
|
||||||
|
|
||||||
|
type utmp struct {
|
||||||
|
Ut_type int16 // Type of login.
|
||||||
|
Ut_pid int32 // Process ID of login process.
|
||||||
|
Ut_line [32]byte // Devicename.
|
||||||
|
Ut_id [4]byte // Inittab ID.
|
||||||
|
Ut_user [32]byte // Username.
|
||||||
|
Ut_host [256]byte // Hostname for remote login.
|
||||||
|
Ut_exit exit_status // Exit status of a process marked
|
||||||
|
Ut_session int32 // Session ID, used for windowing.
|
||||||
|
Ut_tv timeval // Time entry was made.
|
||||||
|
Ut_addr_v6 [16]byte // Internet address of remote host.
|
||||||
|
Unused [20]byte // Reserved for future use. // original is 20
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user