Compare commits
137 Commits
sigar-ruby
...
master
Author | SHA1 | Date | |
---|---|---|---|
2b713c3dd4 | |||
![]() |
af03ded75f | ||
![]() |
00760eebda | ||
![]() |
8b887b2380 | ||
![]() |
9f918d1ae9 | ||
![]() |
49a9aeeff5 | ||
![]() |
04754bdf48 | ||
![]() |
9691f4bbf7 | ||
![]() |
b78b558fb7 | ||
![]() |
01df5b7739 | ||
![]() |
d521805a2d | ||
![]() |
7898cebf27 | ||
![]() |
68ba944840 | ||
![]() |
ad39547629 | ||
![]() |
c5f71e36b7 | ||
![]() |
ad4ff7f83f | ||
![]() |
2bb67fa1bf | ||
![]() |
4aeac4dfe8 | ||
![]() |
2c5dd8b674 | ||
![]() |
d88f2121b8 | ||
![]() |
621764c13d | ||
![]() |
cd07923dd2 | ||
![]() |
0d4fe42927 | ||
![]() |
369e5b093e | ||
![]() |
9f05d47620 | ||
![]() |
9b60875c06 | ||
![]() |
163745ad5d | ||
![]() |
489de8187f | ||
![]() |
a2c67588d0 | ||
![]() |
2f7284cd4c | ||
![]() |
d07ba63c28 | ||
![]() |
0c11387456 | ||
![]() |
ced59e8ca6 | ||
![]() |
f46a9baeef | ||
![]() |
a971b9e8e1 | ||
![]() |
5478eb4be9 | ||
![]() |
cc726007b3 | ||
![]() |
e9897b25b4 | ||
![]() |
800076db97 | ||
![]() |
1e23251b5c | ||
![]() |
5cb14da077 | ||
![]() |
cd0e5bf315 | ||
![]() |
368efdcd05 | ||
![]() |
5245b8f3e3 | ||
![]() |
660259e572 | ||
![]() |
dfe8fece17 | ||
![]() |
c2a1af3c25 | ||
![]() |
ad47dc3b49 | ||
![]() |
9158290982 | ||
![]() |
0f0dbe34ce | ||
![]() |
7a6aefc7fb | ||
![]() |
48ba690dd4 | ||
![]() |
341e288e98 | ||
![]() |
0928a780f4 | ||
![]() |
706f352e56 | ||
![]() |
6d4ff51b9c | ||
![]() |
236006e02d | ||
![]() |
18c2856f75 | ||
![]() |
13bcf8ae45 | ||
![]() |
b89060c481 | ||
![]() |
4fcaa226bd | ||
![]() |
189843858e | ||
![]() |
47f01e0177 | ||
![]() |
6ed8f3c9b5 | ||
![]() |
924c4c7476 | ||
![]() |
07b221a253 | ||
![]() |
f2ba707d9f | ||
![]() |
6508b09304 | ||
![]() |
64f32dd125 | ||
![]() |
aee1d82fae | ||
![]() |
5a1d5e75f1 | ||
![]() |
f15aa84dfe | ||
![]() |
0d91f7d6a4 | ||
![]() |
b13b8dcbbb | ||
![]() |
273889f827 | ||
![]() |
a62558af50 | ||
![]() |
ec489fb336 | ||
![]() |
907fe7a87f | ||
![]() |
83fbcbeb4e | ||
![]() |
a20ec372b7 | ||
![]() |
91aead2fd3 | ||
![]() |
965051cdcf | ||
![]() |
67b476efe0 | ||
![]() |
edf041dc7a | ||
![]() |
a04f46a647 | ||
![]() |
d83284613b | ||
![]() |
012dcef75d | ||
![]() |
f21897f93b | ||
![]() |
710a3f791b | ||
![]() |
b88fb7c0c7 | ||
![]() |
510a4b5c89 | ||
![]() |
4c76ea27c5 | ||
![]() |
44a4062111 | ||
![]() |
8bd48cc477 | ||
![]() |
ce23dbeec7 | ||
![]() |
5619873f02 | ||
![]() |
73b0850a52 | ||
![]() |
129062d9cd | ||
![]() |
cb1e4f491d | ||
![]() |
de81b90497 | ||
![]() |
fde00170d7 | ||
![]() |
e0ef7a3616 | ||
![]() |
2f8090559e | ||
![]() |
1f15289d75 | ||
![]() |
7acf88a0bf | ||
![]() |
fcdf809ef5 | ||
![]() |
dd8d2355cc | ||
![]() |
c1ee0a18b9 | ||
![]() |
0a3f546638 | ||
![]() |
58097d9743 | ||
![]() |
b44692d8e6 | ||
![]() |
a693ebce90 | ||
![]() |
216a2df541 | ||
![]() |
2d2c4c996d | ||
![]() |
e09ad13a16 | ||
![]() |
59aeadaef2 | ||
![]() |
73c3c287f7 | ||
![]() |
4655d5e3df | ||
![]() |
cef810dafb | ||
![]() |
240649b925 | ||
![]() |
7041d070f1 | ||
![]() |
8337f13d6c | ||
![]() |
9b8ec6ec5a | ||
![]() |
639169e9cc | ||
![]() |
adfb6d4d0a | ||
![]() |
e0c289a34c | ||
![]() |
436ceb351a | ||
![]() |
8a4c9f6eb0 | ||
![]() |
87f0aa7f6f | ||
![]() |
692f5a43ea | ||
![]() |
f2aef38d02 | ||
![]() |
833ca18ecf | ||
![]() |
b8c6325123 | ||
![]() |
78f5683bfc | ||
![]() |
619e639eca | ||
![]() |
d20d75908d | ||
![]() |
642df76807 |
19
.gitignore
vendored
19
.gitignore
vendored
@ -22,3 +22,22 @@ missing
|
||||
src/sigar_version_autoconf.c
|
||||
examples/cpuinfo
|
||||
examples/sigar_ps
|
||||
debian/*.log
|
||||
debian/stamp-*
|
||||
debian/tmp
|
||||
m4/
|
||||
debian/python-sigar*
|
||||
debian/python-module-stampdir
|
||||
debian/*.debhelper
|
||||
debian/*.substvars
|
||||
debian/libsigar1/
|
||||
debian/libsigar1-dev/
|
||||
debian/libsigar-java-doc/
|
||||
debian/libsigar-java/
|
||||
debian/files
|
||||
config.sub*
|
||||
config.guess*
|
||||
bindings/java/${dist}
|
||||
bindings/python/build
|
||||
TODO*
|
||||
check*.rb
|
||||
|
90
NOTICE
90
NOTICE
@ -1,10 +1,29 @@
|
||||
Copyright (c) 2004-2011 VMware, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
ADDITIONAL LICENSE INFORMATION:
|
||||
|
||||
Hyperic SIGAR includes some third-party open source components
|
||||
in its distribution. The list below identifies the community or
|
||||
organization and links to their appropriate license terms.
|
||||
|
||||
The Hyperic team would like to thank all the communities
|
||||
of the projects listed below for their contributions.
|
||||
---------------------------------------------------------------------
|
||||
of the projects listed below for their contributions.
|
||||
|
||||
----------------------------------------------------------
|
||||
Components under the Apache License 2.0:
|
||||
----------------------------------------------------------
|
||||
|
||||
The following components are included without modification:
|
||||
|
||||
@ -16,20 +35,83 @@ The following components are included with modification:
|
||||
|
||||
- cpptasks -
|
||||
Information: http://ant-contrib.sourceforge.net/
|
||||
License: http://ant-contrib.sourceforge.net/LICENSE.txt
|
||||
License: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
- (portions of) APR -
|
||||
Information: http://apr.apache.org/
|
||||
License: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
----------------------------------------------------------
|
||||
Components under BSD/MIT Style Licenses:
|
||||
----------------------------------------------------------
|
||||
|
||||
The following components are included with modification:
|
||||
|
||||
- solaris get_mib2 -
|
||||
Information: ftp://vic.cc.purdue.edu/pub/tools/unix/solaris/get_mib2/
|
||||
License: within src/os/solaris/get_mib2.[ch]
|
||||
|
||||
Copyright 1995 Purdue Research Foundation, West Lafayette, Indiana
|
||||
47907. All rights reserved.
|
||||
|
||||
Written by Victor A. Abell <abe@cc.purdue.edu>
|
||||
|
||||
This software is not subject to any license of the American Telephone
|
||||
and Telegraph Company or the Regents of the University of California.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose on
|
||||
any computer system, and to alter it and redistribute it freely, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. Neither Victor A Abell nor Purdue University are responsible for
|
||||
any consequences of the use of this software.
|
||||
|
||||
2. The origin of this software must not be misrepresented, either by
|
||||
explicit claim or by omission. Credit to Victor A. Abell and Purdue
|
||||
University must appear in documentation and sources.
|
||||
|
||||
3. Altered versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
4. This notice may not be removed or altered.
|
||||
|
||||
- getline by Chris Thewalt -
|
||||
Information: http://tinyurl.com/r438r
|
||||
License: within src/sigar_getline.c
|
||||
|
||||
Copyright (C) 1991, 1992 by Chris Thewalt (thewalt@ce.berkeley.edu)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
for any purpose and without fee is hereby granted, provided
|
||||
that the above copyright notices appear in all copies and that both the
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation. This software is provided "as is" without express or
|
||||
implied warranty.
|
||||
|
||||
- PrintfFormat.java -
|
||||
Information: http://java.sun.com/developer/technicalArticles/Programming/sprintf/PrintfFormat.java
|
||||
License: within bindings/java/src/org/hyperic/sigar/util/PrintfFormat.java
|
||||
License: within bindings/java/src/org/hyperic/sigar/util/PrintfFormat.java
|
||||
|
||||
(c) 2000 Sun Microsystems, Inc.
|
||||
ALL RIGHTS RESERVED
|
||||
|
||||
License Grant-
|
||||
|
||||
Permission to use, copy, modify, and distribute this Software and its
|
||||
documentation for NON-COMMERCIAL or COMMERCIAL purposes and without fee is
|
||||
hereby granted.
|
||||
|
||||
This Software is provided "AS IS". All express warranties, including any
|
||||
implied warranty of merchantability, satisfactory quality, fitness for a
|
||||
particular purpose, or non-infringement, are disclaimed, except to the extent
|
||||
that such disclaimers are held to be legally invalid.
|
||||
|
||||
You acknowledge that Software is not designed, licensed or intended for use in
|
||||
the design, construction, operation or maintenance of any nuclear facility
|
||||
("High Risk Activities"). Sun disclaims any express or implied warranty of
|
||||
fitness for such uses.
|
||||
|
||||
Please refer to the file http://www.sun.com/policies/trademarks/ for further
|
||||
important trademark information and to
|
||||
http://java.sun.com/nav/business/index.html for further important licensing
|
||||
information for the Java Technology.
|
||||
|
2
README
2
README
@ -1,2 +0,0 @@
|
||||
Visit the SIGAR Wiki for documentation, bugs, support, etc.:
|
||||
http://sigar.hyperic.com/
|
42
README.md
Normal file
42
README.md
Normal file
@ -0,0 +1,42 @@
|
||||
# System Information Gatherer And Reporter.
|
||||
|
||||
Fork of hyperic/sigar with some fixes. Support only ruby binding. Part of [Eye gem](https://github.com/kostya/eye).
|
||||
|
||||
## Fixed:
|
||||
|
||||
### [2.0.11] 10-09-2024
|
||||
* Fixing build issue on newer linux and also issues with newer Ruby [#16](https://github.com/kostya/sigar/pull/16)([commit](https://github.com/kostya/sigar/pull/16/commits/8b887b2380c4aadea82402904d9c1131bbb9c521))
|
||||
|
||||
### [2.0.10] 31-10-2021
|
||||
* Fix compilation on MacOS 11.3.1 [#11](https://github.com/kostya/sigar/issues/11)([commit](https://github.com/kostya/sigar/commit/49a9aeeff54e97ac6f41d464c30ff6c8adf4bcf4))
|
||||
|
||||
### [2.0.9] 28-06-2021
|
||||
* Fix compilation on FreeBSD 13 [#10](https://github.com/kostya/sigar/issues/10)([commit](https://github.com/kostya/sigar/commit/b78b558fb756a75dc7d6cbf704423be3c7098ae5))
|
||||
|
||||
### [2.0.8] 02-10-2020
|
||||
* Fix compilation on MacOS [#8](https://github.com/kostya/sigar/issues/8)([commit](https://github.com/kostya/sigar/pull/9/commits/ad39547629fa328e115f7d7bc3c7c358247d1961))
|
||||
|
||||
### [2.0.6] 18-01-2019
|
||||
* Fix compilation on FreeBSD 12 [#6](https://github.com/kostya/sigar/issues/6)([commit](https://github.com/kostya/sigar/commit/2bb67fa1bf6f6f0ddc2626cf028bcc0e4a8cb377))
|
||||
|
||||
### [2.0.5] 02-12-2018
|
||||
* Fix compilation with musl libc [#4](https://github.com/kostya/sigar/pull/4)([commit](https://github.com/kostya/sigar/pull/4/commits/cd07923dd2ed34aca353dfd182f2f85c13853fd9))
|
||||
|
||||
### [2.0.4] 10-06-2018
|
||||
* fix compilation with glibc 2.26, major/minor functions [#2](https://github.com/kostya/sigar/issues/2)([commit](https://github.com/kostya/sigar/commit/a2c67588d0f686e0007dadcaf0e4bbb35c0e1e83))
|
||||
|
||||
### [2.0.2] 30-05-2018
|
||||
* Remove obsolete rpc usage (fix compilation fail with glibc 2.27) [#213](https://github.com/kostya/eye/issues/213)([commit](https://github.com/kostya/sigar/commit/a971b9e8e1443fdf236c5ffa199c1994c05fcd4b))
|
||||
|
||||
### [2.0.1] 10-04-2018
|
||||
* FreeBSD: don't use v_cache_min/max [#68](https://github.com/hyperic/sigar/pull/68)([commit](https://github.com/kostya/sigar/commit/800076db97bcacb1ba90805d740b4f9a5a1d3cca))
|
||||
|
||||
### [2.0.0] 22-01-2018
|
||||
* sigfaulted logger, [#28](https://github.com/hyperic/sigar/pull/28)([commit](https://github.com/kostya/sigar/commit/c2a1af))
|
||||
* bug undefined symbol: sigar_skip_token, [#60](https://github.com/hyperic/sigar/pull/60)([commit](https://github.com/kostya/sigar/commit/dfe8fe))
|
||||
* bug detection boot_time on linux (now it works like gnu ps, and fix some issues with process start_time) ([commit](https://github.com/kostya/sigar/commit/660259))
|
||||
|
||||
|
||||
## Installation:
|
||||
|
||||
$ gem install kostya-sigar
|
23
Rakefile
23
Rakefile
@ -1,5 +1,5 @@
|
||||
require 'rubygems'
|
||||
require 'rake/gempackagetask'
|
||||
require 'rubygems/package_task'
|
||||
require 'rake/testtask'
|
||||
|
||||
#so we can: ssh host rake -f $hudson_workspace/sigar/Rakefile
|
||||
@ -20,27 +20,24 @@ MAKE = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
|
||||
|
||||
spec = Gem::Specification.new do |s|
|
||||
s.name = GEM
|
||||
# s.version = props['version.major'] + '.' + props['version.minor'] + '.' + props['version.maint']
|
||||
# '0.7.x' until the sigar-1.7.0 release
|
||||
s.version = '0' + '.' + props['version.minor'] + '.' + '0'
|
||||
s.version = props['version.major'] + '.' + props['version.minor'] + '.' + props['version.maint']
|
||||
s.summary = props['project.summary']
|
||||
s.description = s.summary
|
||||
s.author = props['project.author']
|
||||
s.email = props['project.email']
|
||||
s.homepage = props['project.homepage']
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.has_rdoc = false
|
||||
s.extensions = 'bindings/ruby/extconf.rb'
|
||||
s.files =
|
||||
%w(COPYING EXCEPTIONS README Rakefile version.properties) +
|
||||
%w(LICENSE NOTICE README.md Rakefile version.properties) +
|
||||
%w(bindings/SigarWrapper.pm bindings/SigarBuild.pm) +
|
||||
Dir.glob("bindings/ruby/**/*") +
|
||||
`git ls-files -- bindings/ruby/*.*`.split("\n") +
|
||||
Dir.glob("include/*.h") +
|
||||
Dir.glob("src/**/*.[ch]") +
|
||||
Dir.glob("src/**/*.in")
|
||||
end
|
||||
|
||||
Rake::GemPackageTask.new(spec) do |pkg|
|
||||
Gem::PackageTask.new(spec) do |pkg|
|
||||
pkg.gem_spec = spec
|
||||
end
|
||||
|
||||
@ -54,15 +51,15 @@ end
|
||||
desc 'Build sigar extension'
|
||||
task :build do
|
||||
in_ext()
|
||||
unless File.exists? "Makefile"
|
||||
unless File.exist? "Makefile"
|
||||
unless system("ruby extconf.rb")
|
||||
STDERR.puts "Failed to configure"
|
||||
break
|
||||
next
|
||||
end
|
||||
end
|
||||
unless system(MAKE)
|
||||
STDERR.puts 'Failed to ' + MAKE
|
||||
break
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
@ -78,13 +75,13 @@ end
|
||||
desc 'Clean sigar extension'
|
||||
task :clean do
|
||||
in_ext()
|
||||
system(MAKE + ' clean') if File.exists? "Makefile"
|
||||
system(MAKE + ' clean') if File.exist? "Makefile"
|
||||
end
|
||||
|
||||
desc 'Dist Clean sigar extension'
|
||||
task :distclean do
|
||||
in_ext()
|
||||
system(MAKE + ' distclean') if File.exists? "Makefile"
|
||||
system(MAKE + ' distclean') if File.exist? "Makefile"
|
||||
end
|
||||
|
||||
desc 'Run sigar examples (test)'
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
set -x
|
||||
|
||||
rm -f INSTALL NEWS AUTHORS \
|
||||
rm -f INSTALL NEWS \
|
||||
&& rm -f -r m4 \
|
||||
&& rm -f aclocal.m4 \
|
||||
&& rm -f -r autom4te.cache \
|
||||
&& rm -f compile \
|
||||
|
@ -28,7 +28,7 @@ use POSIX ();
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(cppflags ldflags libs os src inline_src version_file);
|
||||
@EXPORT = qw(cppflags ldflags libs os src inline_src version_file resource_file);
|
||||
|
||||
sub archname {
|
||||
my $os = lc $^O;
|
||||
@ -108,22 +108,8 @@ sub flags {
|
||||
}
|
||||
elsif ($os =~ /(darwin)/) {
|
||||
$os = $1;
|
||||
my(@sdks) = reverse sort </Developer/SDKs/MacOSX10.*.sdk>;
|
||||
my $sdk;
|
||||
if (@sdks == 0) {
|
||||
die
|
||||
"Xcode Developer Tools not installed\n".
|
||||
"Download from http://developer.apple.com/technology/xcode.html";
|
||||
}
|
||||
else {
|
||||
#print "Available SDKs...\n(*) " . join("\n ", @sdks) . "\n";
|
||||
$sdk = $sdks[0];
|
||||
}
|
||||
@cppflags = ('-DDARWIN',
|
||||
"-I/Developer/Headers/FlatCarbon -isysroot $sdk");
|
||||
@ldflags = ("-Wl,-syslibroot,$sdk",
|
||||
'-framework CoreServices',
|
||||
'-framework IOKit');
|
||||
@cppflags = ('-DDARWIN');
|
||||
@ldflags = ('-framework CoreServices', '-framework IOKit');
|
||||
if (-e "/usr/local/libproc.h") {
|
||||
push @cppflags, '-DDARWIN_HAS_LIBPROC_H';
|
||||
}
|
||||
@ -261,6 +247,11 @@ sub version_properties {
|
||||
return $props;
|
||||
}
|
||||
|
||||
sub resource_file {
|
||||
my(@args) = @_ ? @_ : @ARGV;
|
||||
version_file(find_file("src/os/win32/sigar.rc.in"), "sigar.rc", @args);
|
||||
}
|
||||
|
||||
sub version_file {
|
||||
local $_;
|
||||
my($source, $dest, %filters);
|
||||
|
@ -43,6 +43,7 @@ my %has_name_arg = map { $_, 1 } qw(FileSystemUsage DiskUsage
|
||||
FileAttrs DirStat DirUsage
|
||||
NetInterfaceConfig NetInterfaceStat);
|
||||
|
||||
|
||||
my %proc_no_arg = map { $_, 1 } qw(stat);
|
||||
|
||||
my %get_not_impl = map { $_, 1 } qw(net_address net_route net_connection net_stat cpu_perc
|
||||
@ -527,6 +528,7 @@ use vars qw(%classes %cmds);
|
||||
plat => '*'
|
||||
},
|
||||
],
|
||||
|
||||
ProcMem => [
|
||||
{
|
||||
name => 'size', type => 'Long',
|
||||
@ -627,6 +629,51 @@ use vars qw(%classes %cmds);
|
||||
plat => '*'
|
||||
},
|
||||
],
|
||||
ProcDiskIO => [
|
||||
{
|
||||
name => 'bytes_read', type => 'Long',
|
||||
desc => 'Bytes Read',
|
||||
plat => 'LW'
|
||||
},
|
||||
{
|
||||
name => 'bytes_written', type => 'Long',
|
||||
desc => 'Bytes Written',
|
||||
plat => 'LW'
|
||||
},
|
||||
{
|
||||
name => 'bytes_total', type => 'Long',
|
||||
desc => 'Bytes Total',
|
||||
plat => 'LWAHS'
|
||||
}
|
||||
],
|
||||
|
||||
ProcCumulativeDiskIO => [
|
||||
{
|
||||
name => 'bytes_read', type => 'Long',
|
||||
desc => 'Bytes Read from Start',
|
||||
plat => 'LW'
|
||||
},
|
||||
{
|
||||
name => 'bytes_written', type => 'Long',
|
||||
desc => 'Bytes Written from Start',
|
||||
plat => 'LW'
|
||||
},
|
||||
{
|
||||
name => 'bytes_total', type => 'Long',
|
||||
desc => 'Bytes Total from Start',
|
||||
plat => 'LWAHS'
|
||||
}
|
||||
],
|
||||
|
||||
DumpPidCache => [
|
||||
{
|
||||
name => 'dummy', type => 'Long',
|
||||
desc => 'Dummy',
|
||||
plat => 'LWAHS'
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
ProcState => [
|
||||
{
|
||||
name => 'state', type => 'Char',
|
||||
|
@ -508,6 +508,7 @@
|
||||
<include name="bindings/java/**/*.java"/>
|
||||
<include name="bindings/java/**/*.java.in"/>
|
||||
<include name="bindings/java/**/*.c"/>
|
||||
<include name="bindings/java/**/*.cpp"/>
|
||||
<include name="bindings/java/**/*.h"/>
|
||||
<include name="bindings/java/**/*.pl"/>
|
||||
<include name="bindings/java/**/build.xml"/>
|
||||
|
@ -356,8 +356,6 @@
|
||||
<compilerarg value="${uni.arch}"/>
|
||||
<compilerarg value="-mmacosx-version-min=${osx.min}"/>
|
||||
|
||||
<sysincludepath location="/Developer/Headers/FlatCarbon"/>
|
||||
|
||||
<defineset>
|
||||
<define name="DARWIN"/>
|
||||
<define name="DARWIN_HAS_LIBPROC_H" if="libproc.h"/>
|
||||
|
@ -17,6 +17,7 @@
|
||||
package org.hyperic.jni;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.StringTokenizer;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
@ -315,7 +316,16 @@ public class ArchLoader {
|
||||
if ((file != null) &&
|
||||
((file = file.getParentFile()) != null))
|
||||
{
|
||||
String dir = URLDecoder.decode(file.toString());
|
||||
String dir;
|
||||
try {
|
||||
// Passing UTF-8 according to the recommendation in the URLDecoder.decode JavaDoc.
|
||||
dir = URLDecoder.decode(file.toString(), "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
String msg = "Unsupported encoding in file name: " + file.toString();
|
||||
ArchLoaderException archLoaderException = new ArchLoaderException(msg);
|
||||
archLoaderException.initCause(e);
|
||||
throw archLoaderException;
|
||||
}
|
||||
if (findNativeLibrary(dir, libName)) {
|
||||
return dir;
|
||||
}
|
||||
|
@ -90,8 +90,12 @@ public class ArchNameTask extends Task {
|
||||
if (ArchLoader.IS_DARWIN) {
|
||||
//default to most recent SDK
|
||||
//MacOSX10.3.9.sdk, MacOSX10.4u.sdk, MacOSX10.5.sdk,etc.
|
||||
File[] sdks =
|
||||
new File("/Developer/SDKs").listFiles(new FileFilter() {
|
||||
String sdkRoot = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs";
|
||||
if (new File(sdkRoot).exists() == false) {
|
||||
sdkRoot = "/Developer/SDKs";
|
||||
}
|
||||
File[] sdks =
|
||||
new File(sdkRoot).listFiles(new FileFilter() {
|
||||
public boolean accept(File file) {
|
||||
String name = file.getName();
|
||||
return
|
||||
@ -99,6 +103,7 @@ public class ArchNameTask extends Task {
|
||||
name.endsWith(".sdk");
|
||||
}
|
||||
});
|
||||
|
||||
if (sdks != null) {
|
||||
Arrays.sort(sdks);
|
||||
String prop = "uni.sdk";
|
||||
|
Binary file not shown.
@ -292,74 +292,58 @@ public class FileInfo extends FileAttrs implements java.io.Serializable {
|
||||
}
|
||||
|
||||
public String diff(FileInfo info) {
|
||||
ArrayList changes = new ArrayList();
|
||||
ArrayList changes = new ArrayList();
|
||||
|
||||
if (this.getMtime() != info.getMtime()) {
|
||||
changes.add(new Diff("Mtime",
|
||||
formatDate(info.getMtime()),
|
||||
formatDate(this.getMtime())));
|
||||
if (this.getMtime() != info.getMtime()) {
|
||||
changes.add(new Diff("Mtime", formatDate(info.getMtime()),
|
||||
formatDate(this.getMtime())));
|
||||
} else if (this.getCtime() != info.getCtime()) {
|
||||
changes.add(new Diff("Ctime", formatDate(info.getCtime()),
|
||||
formatDate(this.getCtime())));
|
||||
}
|
||||
|
||||
if (this.getPermissions() != info.getPermissions()) {
|
||||
changes.add(new Diff("Perms", info.getPermissionsString(), this
|
||||
.getPermissionsString()));
|
||||
}
|
||||
|
||||
if (this.getType() != info.getType()) {
|
||||
changes.add(new Diff("Type", info.getTypeString(), this
|
||||
.getTypeString()));
|
||||
}
|
||||
|
||||
if (this.getUid() != info.getUid()) {
|
||||
changes.add(new Diff("Uid", info.getUid(), this.getUid()));
|
||||
}
|
||||
|
||||
if (this.getGid() != info.getGid()) {
|
||||
changes.add(new Diff("Gid", info.getGid(), this.getGid()));
|
||||
}
|
||||
|
||||
if (this.getSize() != info.getSize()) {
|
||||
changes.add(new Diff("Size", info.getSize(), this.getSize()));
|
||||
}
|
||||
|
||||
if (!OperatingSystem.IS_WIN32) {
|
||||
if (this.getInode() != info.getInode()) {
|
||||
changes.add(new Diff("Inode", info.getInode(), this.getInode()));
|
||||
}
|
||||
|
||||
if (this.getDevice() != info.getDevice()) {
|
||||
changes.add(new Diff("Device", info.getDevice(), this
|
||||
.getDevice()));
|
||||
}
|
||||
|
||||
if (this.getNlink() != info.getNlink()) {
|
||||
changes.add(new Diff("Nlink", info.getNlink(), this.getNlink()));
|
||||
}
|
||||
}
|
||||
else if (this.getCtime() != info.getCtime()) {
|
||||
changes.add(new Diff("Ctime",
|
||||
formatDate(info.getCtime()),
|
||||
formatDate(this.getCtime())));
|
||||
}
|
||||
else {
|
||||
//no point in checking the rest if all times are the same.
|
||||
//or should we include atime in the diff?
|
||||
|
||||
/* if changes were not detected then return empty String */
|
||||
if (changes.isEmpty()){
|
||||
return "";
|
||||
}
|
||||
|
||||
if (this.getPermissions() != info.getPermissions()) {
|
||||
changes.add(new Diff("Perms",
|
||||
info.getPermissionsString(),
|
||||
this.getPermissionsString()));
|
||||
}
|
||||
|
||||
if (this.getType() != info.getType()) {
|
||||
changes.add(new Diff("Type",
|
||||
info.getTypeString(),
|
||||
this.getTypeString()));
|
||||
}
|
||||
|
||||
if (this.getUid() != info.getUid()) {
|
||||
changes.add(new Diff("Uid",
|
||||
info.getUid(),
|
||||
this.getUid()));
|
||||
}
|
||||
|
||||
if (this.getGid() != info.getGid()) {
|
||||
changes.add(new Diff("Gid",
|
||||
info.getGid(),
|
||||
this.getGid()));
|
||||
}
|
||||
|
||||
if (this.getSize() != info.getSize()) {
|
||||
changes.add(new Diff("Size",
|
||||
info.getSize(),
|
||||
this.getSize()));
|
||||
}
|
||||
|
||||
if (!OperatingSystem.IS_WIN32) {
|
||||
if (this.getInode() != info.getInode()) {
|
||||
changes.add(new Diff("Inode",
|
||||
info.getInode(),
|
||||
this.getInode()));
|
||||
}
|
||||
|
||||
if (this.getDevice() != info.getDevice()) {
|
||||
changes.add(new Diff("Device",
|
||||
info.getDevice(),
|
||||
this.getDevice()));
|
||||
}
|
||||
|
||||
if (this.getNlink() != info.getNlink()) {
|
||||
changes.add(new Diff("Nlink",
|
||||
info.getNlink(),
|
||||
this.getNlink()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StringBuffer sb = format(changes);
|
||||
if (this.dirStatEnabled) {
|
||||
sb.append(diff(info.stat));
|
||||
@ -389,7 +373,9 @@ public class FileInfo extends FileAttrs implements java.io.Serializable {
|
||||
|
||||
stat();
|
||||
|
||||
return this.mtime != oldInfo.mtime;
|
||||
boolean isModified = isModified(this.oldInfo);
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
public boolean changed()
|
||||
@ -455,4 +441,49 @@ public class FileInfo extends FileAttrs implements java.io.Serializable {
|
||||
|
||||
return fetchInfo(sigar, name, false);
|
||||
}
|
||||
|
||||
private boolean isModified(FileInfo info){
|
||||
/* Check modified time */
|
||||
if (this.getMtime() != info.getMtime()) {
|
||||
return true;
|
||||
} else if (this.getCtime() != info.getCtime()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.getPermissions() != info.getPermissions()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.getType() != info.getType()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.getUid() != info.getUid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.getGid() != info.getGid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.getSize() != info.getSize()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!OperatingSystem.IS_WIN32) {
|
||||
if (this.getInode() != info.getInode()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.getDevice() != info.getDevice()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.getNlink() != info.getNlink()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public abstract class FileWatcher {
|
||||
|
||||
private Sigar sigar;
|
||||
@ -31,6 +33,9 @@ public abstract class FileWatcher {
|
||||
private Set files =
|
||||
Collections.synchronizedSet(new HashSet());
|
||||
|
||||
private static final Logger log =
|
||||
SigarLog.getLogger(FileWatcher.class.getName());
|
||||
|
||||
public abstract void onChange(FileInfo info);
|
||||
|
||||
public void onNotFound(FileInfo info) {
|
||||
@ -66,14 +71,22 @@ public abstract class FileWatcher {
|
||||
public void add(File[] files)
|
||||
throws SigarException {
|
||||
for (int i=0; i<files.length; i++) {
|
||||
add(files[i]);
|
||||
try {
|
||||
add(files[i]);
|
||||
} catch (SigarFileNotFoundException e) {
|
||||
log.error("Cannot add file: " + files[i].getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String[] files)
|
||||
throws SigarException {
|
||||
for (int i=0; i<files.length; i++) {
|
||||
add(files[i]);
|
||||
try {
|
||||
add(files[i]);
|
||||
} catch (SigarFileNotFoundException e) {
|
||||
log.error("Cannot add file: " + files[i], e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,6 @@
|
||||
|
||||
package org.hyperic.sigar;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hyperic.sigar.ptql.ProcessFinder;
|
||||
|
||||
/**
|
||||
@ -28,64 +25,33 @@ public class MultiProcCpu extends ProcCpu {
|
||||
|
||||
private long pid;
|
||||
private int nproc = 0;
|
||||
private static Map ptable = new HashMap();
|
||||
|
||||
|
||||
static synchronized MultiProcCpu get(Sigar sigar, String query)
|
||||
throws SigarException {
|
||||
throws SigarException {
|
||||
|
||||
MultiProcCpu cpu;
|
||||
|
||||
cpu = (MultiProcCpu)ptable.get(query);
|
||||
|
||||
if (cpu == null) {
|
||||
cpu = new MultiProcCpu();
|
||||
cpu.pid = query.hashCode(); //for equals()
|
||||
ptable.put(query, cpu);
|
||||
}
|
||||
|
||||
long timeNow = System.currentTimeMillis();
|
||||
double diff = timeNow - cpu.lastTime;
|
||||
if (diff == 0) {
|
||||
return cpu; //we were just called within < 1 second ago.
|
||||
}
|
||||
|
||||
cpu.lastTime = timeNow;
|
||||
|
||||
long otime = cpu.total;
|
||||
MultiProcCpu cpu = new MultiProcCpu();
|
||||
cpu.pid = query.hashCode(); //for equals()
|
||||
|
||||
cpu.total = 0;
|
||||
cpu.user = 0;
|
||||
cpu.sys = 0;
|
||||
cpu.nproc = 0;
|
||||
cpu.percent = 0.0D;
|
||||
|
||||
long[] pids = ProcessFinder.find(sigar, query);
|
||||
cpu.nproc = pids.length;
|
||||
|
||||
for (int i=0; i<pids.length; i++) {
|
||||
ProcTime time;
|
||||
try {
|
||||
time = sigar.getProcTime(pids[i]);
|
||||
ProcCpu procCpu = sigar.getProcCpu(pids[i]);
|
||||
cpu.total += procCpu.getTotal();
|
||||
cpu.user += procCpu.getUser();
|
||||
cpu.sys += procCpu.getSys();
|
||||
cpu.percent += procCpu.getPercent();
|
||||
} catch (SigarException e) {
|
||||
//process may have gone away or EPERM
|
||||
continue;
|
||||
}
|
||||
cpu.total += time.total;
|
||||
cpu.user += time.user;
|
||||
cpu.sys += time.sys;
|
||||
}
|
||||
|
||||
if (otime == 0) {
|
||||
//XXX could/should pause first time called.
|
||||
return cpu;
|
||||
}
|
||||
|
||||
cpu.percent = ((cpu.total - otime) / diff);
|
||||
if (cpu.percent < 0.0) {
|
||||
//counter wrapped
|
||||
cpu.percent = (0.0 - cpu.percent);
|
||||
}
|
||||
if (cpu.percent >= 1.0) {
|
||||
cpu.percent = 0.99;
|
||||
}
|
||||
|
||||
return cpu;
|
||||
|
@ -31,7 +31,7 @@ public class ProcUtil {
|
||||
|
||||
for (int i=0; i<len; i++) {
|
||||
char c = name.charAt(i);
|
||||
if (!((c == '.') || Character.isLetter(c))) {
|
||||
if (!((c == '.') || Character.isJavaIdentifierPart(c))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ public class Sigar implements SigarProxy {
|
||||
private static String loadError = null;
|
||||
|
||||
public static final long FIELD_NOTIMPL = -1;
|
||||
public static final int PID_PROC_CPU_CACHE = 1;
|
||||
public static final int PID_PROC_IO_CACHE = 2;
|
||||
|
||||
/**
|
||||
* The Sigar java version.
|
||||
@ -440,7 +442,7 @@ public class Sigar implements SigarProxy {
|
||||
return this.processFinder.findSingleProcess(pid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get process memory info.
|
||||
* @param pid The process id.
|
||||
@ -638,6 +640,57 @@ public class Sigar implements SigarProxy {
|
||||
Integer.parseInt(port));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get process disk IO info.
|
||||
* @param pid THe process id.
|
||||
* @exception SigarException on failure.
|
||||
*/
|
||||
public ProcDiskIO getProcDiskIO(long pid) throws SigarException {
|
||||
try {
|
||||
return ProcDiskIO.fetch(this, pid);
|
||||
} catch (UnsatisfiedLinkError linkErrorException) {
|
||||
// We want to handle exceptions gracefully even if the linked
|
||||
// shared library is older and isn't compiled with the ProcDiskIO APIs.
|
||||
// The downside of this is that we throw SigarNotImplemented exception
|
||||
// also when the shared library can't be loaded.
|
||||
SigarException sigarException = new SigarNotImplementedException();
|
||||
sigarException.initCause(linkErrorException);
|
||||
throw sigarException;
|
||||
}
|
||||
}
|
||||
|
||||
public ProcDiskIO getProcDiskIO(String pid) throws SigarException {
|
||||
return getProcDiskIO(convertPid(pid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get process cumulative disk IO info.
|
||||
* @param pid THe process id.
|
||||
* @exception SigarException on failure.
|
||||
*/
|
||||
public ProcCumulativeDiskIO getProcCumulativeDiskIO(long pid) throws SigarException {
|
||||
try {
|
||||
return ProcCumulativeDiskIO.fetch(this, pid);
|
||||
} catch (UnsatisfiedLinkError linkErrorException) {
|
||||
// We want to handle exceptions gracefully even if the linked
|
||||
// shared library is older and isn't compiled with the ProcDiskIO APIs.
|
||||
// The downside of this is that we throw SigarNotImplemented exception
|
||||
// also when the shared library can't be loaded.
|
||||
SigarException sigarException = new SigarNotImplementedException();
|
||||
sigarException.initCause(linkErrorException);
|
||||
throw sigarException;
|
||||
}
|
||||
}
|
||||
|
||||
public ProcCumulativeDiskIO getProcCumulativeDiskIO(String pid) throws SigarException {
|
||||
return getProcCumulativeDiskIO(convertPid(pid));
|
||||
}
|
||||
|
||||
public DumpPidCache dumpPidCache() throws SigarException {
|
||||
return DumpPidCache.fetch(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the cumulative cpu time for the calling thread.
|
||||
*/
|
||||
|
@ -29,6 +29,8 @@ public class SigarLog {
|
||||
private static final int LOG_INFO = 3;
|
||||
private static final int LOG_DEBUG = 4;
|
||||
|
||||
private static final boolean enableLogFallbackConf = ! Boolean.getBoolean("sigar.noLog4jDefaultConfig");
|
||||
|
||||
private static native void setLogger(Sigar sigar, Logger log);
|
||||
|
||||
public static native void setLevel(Sigar sigar, int level);
|
||||
@ -46,7 +48,7 @@ public class SigarLog {
|
||||
|
||||
public static Logger getLogger(String name) {
|
||||
Logger log = Logger.getLogger(name);
|
||||
if (!isLogConfigured()) {
|
||||
if (enableLogFallbackConf && !isLogConfigured()) {
|
||||
BasicConfigurator.configure();
|
||||
}
|
||||
return log;
|
||||
|
@ -106,6 +106,16 @@ public interface SigarProxy {
|
||||
|
||||
public long getProcPort(String protocol, String port) throws SigarException;
|
||||
|
||||
public ProcDiskIO getProcDiskIO(long pid) throws SigarException;
|
||||
|
||||
public ProcDiskIO getProcDiskIO(String pid) throws SigarException;
|
||||
|
||||
public ProcCumulativeDiskIO getProcCumulativeDiskIO(long pid) throws SigarException;
|
||||
|
||||
public ProcCumulativeDiskIO getProcCumulativeDiskIO(String pid) throws SigarException;
|
||||
|
||||
public DumpPidCache dumpPidCache() throws SigarException;
|
||||
|
||||
public FileSystem[] getFileSystemList() throws SigarException;
|
||||
|
||||
public FileSystemMap getFileSystemMap() throws SigarException;
|
||||
|
51
bindings/java/src/org/hyperic/sigar/cmd/PidCacheInfo.java
Normal file
51
bindings/java/src/org/hyperic/sigar/cmd/PidCacheInfo.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Hyperic, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.hyperic.sigar.cmd;
|
||||
|
||||
import org.hyperic.sigar.SigarException;
|
||||
import org.hyperic.sigar.SigarPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Display all pid cache information.
|
||||
*/
|
||||
public class PidCacheInfo extends SigarCommandBase {
|
||||
|
||||
|
||||
public PidCacheInfo(Shell shell) {
|
||||
super(shell);
|
||||
}
|
||||
|
||||
public PidCacheInfo() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected boolean validateArgs(String[] args) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getUsageShort() {
|
||||
return "Display cache info for CPU cache and for IO cache";
|
||||
}
|
||||
|
||||
public boolean isPidCompleter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void output(String[] args) throws SigarException {
|
||||
sigar.dumpPidCache();
|
||||
}
|
||||
}
|
@ -100,6 +100,14 @@ public class ProcInfo extends SigarCommandBase {
|
||||
try {
|
||||
println("credname=" + sigar.getProcCredName(pid));
|
||||
} catch (SigarException e) {}
|
||||
try {
|
||||
println("diskio=" + sigar.getProcDiskIO(pid));
|
||||
} catch (SigarException e) {}
|
||||
|
||||
try {
|
||||
println("cumulative diskio=" + sigar.getProcCumulativeDiskIO(pid));
|
||||
} catch (SigarException e) {}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -103,6 +103,8 @@ public class Shell extends ShellBase {
|
||||
registerCommandHandler("time", new Time(this));
|
||||
registerCommandHandler("ulimit", new Ulimit(this));
|
||||
registerCommandHandler("who", new Who(this));
|
||||
registerCommandHandler("pid_cache_info", new PidCacheInfo(this));
|
||||
|
||||
if (SigarLoader.IS_WIN32) {
|
||||
registerCommandHandler("service", new Win32Service(this));
|
||||
registerCommandHandler("fversion", new FileVersionInfo(this));
|
||||
|
@ -20,6 +20,7 @@ import org.hyperic.sigar.ProcCpu;
|
||||
import org.hyperic.sigar.ProcFd;
|
||||
import org.hyperic.sigar.ProcMem;
|
||||
import org.hyperic.sigar.ProcUtil;
|
||||
import org.hyperic.sigar.ProcDiskIO;
|
||||
import org.hyperic.sigar.Sigar;
|
||||
import org.hyperic.sigar.SigarException;
|
||||
import org.hyperic.sigar.SigarProxy;
|
||||
@ -76,13 +77,23 @@ public class SigarProcess implements SigarProcessMBean {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized ProcDiskIO getDiskIO() {
|
||||
try {
|
||||
return this.sigar.getProcDiskIO(getPid());
|
||||
} catch (SigarException e) {
|
||||
throw unexpectedError("DiskIO", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized ProcFd getFd() throws SigarException {
|
||||
return this.sigar.getProcFd(getPid());
|
||||
}
|
||||
|
||||
public String getObjectName() throws SigarException {
|
||||
long pid = getPid();
|
||||
String name = this.sigar.getProcState(pid).getName();
|
||||
String name = this.sigar.getProcState(pid).getName().replaceAll(":", "_");
|
||||
String cls = "unknown";
|
||||
if (name.startsWith("java")) {
|
||||
try {
|
||||
@ -153,4 +164,9 @@ public class SigarProcess implements SigarProcessMBean {
|
||||
return NOTIMPL;
|
||||
}
|
||||
}
|
||||
|
||||
public Double getBytesReadWriteTotal() {
|
||||
return new Double(getDiskIO().getBytesTotal());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,4 +44,6 @@ public interface SigarProcessMBean {
|
||||
public Double getCpuUsage();
|
||||
|
||||
public Long getOpenFd();
|
||||
|
||||
public Double getBytesReadWriteTotal();
|
||||
}
|
||||
|
@ -133,11 +133,11 @@ public class TestFileInfo extends SigarTestCase {
|
||||
tmp.deleteOnExit();
|
||||
traceln("TMP=" + file);
|
||||
|
||||
try {
|
||||
// try {
|
||||
//stat() mtime is in seconds, this happens to quick to detect change.
|
||||
Thread.sleep(1000 * 1);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
//Thread.sleep(1000 * 1);
|
||||
// } catch (InterruptedException e) {
|
||||
// }
|
||||
|
||||
try {
|
||||
FileInfo info = sigar.getFileInfo(file);
|
||||
|
57
bindings/java/src/org/hyperic/sigar/test/TestProcDiskIO.java
Normal file
57
bindings/java/src/org/hyperic/sigar/test/TestProcDiskIO.java
Normal file
@ -0,0 +1,57 @@
|
||||
package org.hyperic.sigar.test;
|
||||
|
||||
import org.hyperic.sigar.ProcDiskIO;
|
||||
import org.hyperic.sigar.Sigar;
|
||||
import org.hyperic.sigar.SigarException;
|
||||
|
||||
public class TestProcDiskIO extends SigarTestCase {
|
||||
|
||||
public TestProcDiskIO(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
|
||||
private void traceDiskIO(Sigar sigar, long pid) throws Exception {
|
||||
ProcDiskIO procDiskIO;
|
||||
|
||||
try {
|
||||
procDiskIO = sigar.getProcDiskIO(pid);
|
||||
} catch (SigarException e) {
|
||||
traceln("pid " + pid + ": " + e.getMessage());
|
||||
// throw e;
|
||||
return;
|
||||
}
|
||||
|
||||
long bytesRead = procDiskIO.getBytesRead();
|
||||
long bytesWritten = procDiskIO.getBytesWritten();
|
||||
long bytesTotal = procDiskIO.getBytesTotal();
|
||||
|
||||
traceln("Pid=" + pid);
|
||||
traceln("Bytes Read=" + Sigar.formatSize(bytesRead));
|
||||
traceln("Bytes Written=" + Sigar.formatSize(bytesWritten));
|
||||
traceln("Bytes Total=" + Sigar.formatSize(bytesTotal));
|
||||
|
||||
if (bytesRead != -1 && bytesWritten != -1 && bytesTotal != -1) {
|
||||
assertTrue("Bytes total should equal bytesRead + bytesWritten",
|
||||
(bytesTotal == bytesRead + bytesWritten));
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreate() throws Exception {
|
||||
Sigar sigar = getSigar();
|
||||
|
||||
boolean caughtException = false;
|
||||
try {
|
||||
sigar.getProcDiskIO(getInvalidPid());
|
||||
} catch (SigarException e) {
|
||||
caughtException = true;
|
||||
}
|
||||
assertTrue("Test on invalid PID should have thrown an exception.", caughtException);
|
||||
|
||||
long[] pids = sigar.getProcList();
|
||||
for (int i=0; i<pids.length; i++) {
|
||||
traceDiskIO(sigar, pids[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -19,6 +19,7 @@ package org.hyperic.sigar.test;
|
||||
import java.util.Date;
|
||||
|
||||
import org.hyperic.sigar.SigarException;
|
||||
import org.hyperic.sigar.SigarLoader;
|
||||
import org.hyperic.sigar.Who;
|
||||
|
||||
public class TestWho extends SigarTestCase {
|
||||
@ -39,7 +40,9 @@ public class TestWho extends SigarTestCase {
|
||||
who[i].getDevice() + "\t" +
|
||||
new Date(who[i].getTime() * 1000) + "\t" +
|
||||
host);
|
||||
assertLengthTrace("user", who[i].getUser());
|
||||
if (!SigarLoader.IS_WIN32) {
|
||||
assertLengthTrace("user", who[i].getUser());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,6 +284,24 @@ public class Pdh extends Win32 {
|
||||
return trans.toString();
|
||||
}
|
||||
|
||||
private long addPdhCounter(String path, boolean format) throws Win32Exception {
|
||||
long counter;
|
||||
/*
|
||||
* Some metrics are missing the '/sec' suffix. This flow,
|
||||
* first tries to add the counter without the '/sec' and
|
||||
* if fails, try again with it. If the seconds call fails,
|
||||
* throw an exception.This issue must be addressed
|
||||
* at the java level (and not C code), since the counter
|
||||
* names must be translated before.
|
||||
*/
|
||||
try {
|
||||
counter = pdhAddCounter(this.query, translate(path));
|
||||
} catch (Win32Exception e) {
|
||||
counter = pdhAddCounter(this.query, translate(path + "/sec"));
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
private double getValue(String path, boolean format)
|
||||
throws Win32Exception {
|
||||
|
||||
@ -291,8 +309,8 @@ public class Pdh extends Win32 {
|
||||
pdhConnectMachine(this.hostname);
|
||||
}
|
||||
|
||||
long counter =
|
||||
pdhAddCounter(this.query, translate(path));
|
||||
long counter = addPdhCounter(path, format);
|
||||
|
||||
try {
|
||||
return pdhGetValue(this.query, counter, format);
|
||||
} finally {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Hyperic, Inc.
|
||||
* Copyright (c) 2010 VMware, Inc.
|
||||
* Copyright (c) 2010-2011 VMware, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -19,13 +19,14 @@
|
||||
#include "sigar.h"
|
||||
#include "sigar_fileinfo.h"
|
||||
#include "sigar_format.h"
|
||||
#include "sigar_ptql.h"
|
||||
|
||||
#define PySigarString_FromNetAddr(a) pysigar_net_address_to_string(&a)
|
||||
|
||||
#define PySigarInt_FromChar(c) PyInt_FromLong((int)c)
|
||||
|
||||
#define PySigar_ParsePID \
|
||||
if (!PyArg_ParseTuple(args, "i", &pid)) return NULL
|
||||
if (pysigar_parse_pid(sigar, args, &pid) != SIGAR_OK) return NULL
|
||||
|
||||
#define PySigar_ParseName \
|
||||
if (!PyArg_ParseTuple(args, "s", &name, &name_len)) return NULL
|
||||
@ -68,6 +69,103 @@ static void pysigar_free(PyObject *self)
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int pysigar_ptql_re_impl(void *data,
|
||||
char *haystack, char *needle)
|
||||
{
|
||||
PyObject *name = PyString_FromString("sigar");
|
||||
PyObject *module = PyImport_Import(name);
|
||||
PyObject *match, *args, *source, *regex, *result;
|
||||
int matches = 0;
|
||||
|
||||
match = PyObject_GetAttrString(module, "string_matches");
|
||||
|
||||
source = PyString_FromString(haystack);
|
||||
regex = PyString_FromString(needle);
|
||||
args = PyTuple_New(2);
|
||||
PyTuple_SetItem(args, 0, source); /* steals source reference */
|
||||
PyTuple_SetItem(args, 1, regex); /* steals regex reference */
|
||||
|
||||
result = PyObject_CallObject(match, args);
|
||||
|
||||
Py_DECREF(name);
|
||||
Py_DECREF(module);
|
||||
Py_DECREF(args);
|
||||
Py_DECREF(match);
|
||||
|
||||
if (result == NULL) {
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
}
|
||||
}
|
||||
else {
|
||||
matches = (result == Py_True);
|
||||
Py_DECREF(result);
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
#define sigar_isdigit(c) \
|
||||
(isdigit(((unsigned char)(c))))
|
||||
|
||||
static int pysigar_parse_pid(sigar_t *sigar, PyObject *args, long *pid)
|
||||
{
|
||||
if ((PyTuple_Size(args) >= 1) && PyString_Check(PyTuple_GetItem(args, 0))) {
|
||||
char *ptql;
|
||||
int ptql_len;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s#", &ptql, &ptql_len)) {
|
||||
return !SIGAR_OK;
|
||||
}
|
||||
|
||||
if (sigar_isdigit(*ptql)) {
|
||||
/* XXX pluck strtoull define from sigar_ptql.c */
|
||||
PyObject *obj = PyLong_FromString(ptql, &ptql, 10);
|
||||
*pid = PyLong_AsLong(obj);
|
||||
Py_DECREF(obj);
|
||||
return SIGAR_OK;
|
||||
}
|
||||
else if ((ptql_len == 2) &&
|
||||
(*ptql == '$') && (*(ptql + 1) == '$'))
|
||||
{
|
||||
*pid = sigar_pid_get(sigar);
|
||||
return SIGAR_OK;
|
||||
}
|
||||
else {
|
||||
/* XXX cache queries */
|
||||
sigar_ptql_query_t *query;
|
||||
sigar_ptql_error_t error;
|
||||
int status;
|
||||
|
||||
status = sigar_ptql_query_create(&query, ptql, &error);
|
||||
if (status == SIGAR_OK) {
|
||||
sigar_ptql_re_impl_set(sigar, NULL, pysigar_ptql_re_impl);
|
||||
status = sigar_ptql_query_find_process(sigar, query, (sigar_pid_t *)pid);
|
||||
sigar_ptql_re_impl_set(sigar, NULL, NULL);
|
||||
sigar_ptql_query_destroy(query);
|
||||
|
||||
if (status == SIGAR_OK) {
|
||||
return SIGAR_OK;
|
||||
}
|
||||
else {
|
||||
PySigar_Croak();
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError, error.message);
|
||||
return !SIGAR_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PyArg_ParseTuple(args, "i", pid)) {
|
||||
return SIGAR_OK;
|
||||
}
|
||||
else {
|
||||
return !SIGAR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *pysigar_net_address_to_string(sigar_net_address_t *address)
|
||||
{
|
||||
char addr_str[SIGAR_INET6_ADDRSTRLEN];
|
||||
@ -131,6 +229,38 @@ static PyObject *pysigar_new_strlist(char **data, unsigned long number)
|
||||
return av;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_new_doublelist(double *data, unsigned long number)
|
||||
{
|
||||
unsigned long i;
|
||||
PyObject *av;
|
||||
|
||||
if (!(av = PyTuple_New(number))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i=0; i<number; i++) {
|
||||
PyTuple_SET_ITEM(av, i, PyFloat_FromDouble(data[i]));
|
||||
}
|
||||
|
||||
return av;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_new_intlist(int *data, unsigned long number)
|
||||
{
|
||||
unsigned long i;
|
||||
PyObject *av;
|
||||
|
||||
if (!(av = PyTuple_New(number))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i=0; i<number; i++) {
|
||||
PyTuple_SET_ITEM(av, i, PyInt_FromLong(data[i]));
|
||||
}
|
||||
|
||||
return av;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_new_list(char *data, unsigned long number,
|
||||
int size, PyTypeObject *type)
|
||||
{
|
||||
@ -191,6 +321,57 @@ static PyObject *pysigar_net_interface_list(PyObject *self, PyObject *args)
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_net_connection_list(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status, flags;
|
||||
sigar_t *sigar = PySIGAR;
|
||||
sigar_net_connection_list_t connlist;
|
||||
PyObject *RETVAL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &flags)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = sigar_net_connection_list_get(sigar, &connlist, flags);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
PySigar_Croak();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RETVAL = pysigar_new_list((char *)&connlist.data[0],
|
||||
connlist.number,
|
||||
sizeof(*connlist.data),
|
||||
&pysigar_PySigarNetConnectionType);
|
||||
|
||||
sigar_net_connection_list_destroy(sigar, &connlist);
|
||||
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_net_route_list(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status;
|
||||
sigar_t *sigar = PySIGAR;
|
||||
sigar_net_route_list_t net_routelist;
|
||||
PyObject *RETVAL;
|
||||
|
||||
status = sigar_net_route_list_get(sigar, &net_routelist);
|
||||
if (status != SIGAR_OK) {
|
||||
PySigar_Croak();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RETVAL = pysigar_new_list((char *)&net_routelist.data[0],
|
||||
net_routelist.number,
|
||||
sizeof(*net_routelist.data),
|
||||
&pysigar_PySigarNetRouteType);
|
||||
|
||||
sigar_net_route_list_destroy(sigar, &net_routelist);
|
||||
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_arp_list(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status;
|
||||
@ -214,6 +395,222 @@ static PyObject *pysigar_arp_list(PyObject *self, PyObject *args)
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_net_stat(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status, flags;
|
||||
sigar_t *sigar = PySIGAR;
|
||||
sigar_net_stat_t *RETVAL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &flags)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RETVAL = malloc(sizeof(*RETVAL));
|
||||
if ((status = sigar_net_stat_get(sigar, RETVAL, flags)) != SIGAR_OK) {
|
||||
free(RETVAL);
|
||||
PySigar_Croak();
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
PyObject *self = PySigar_new(pysigar_PySigarNetStatType);
|
||||
PySIGAR_OBJ->ptr = RETVAL;
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *pysigar_cpu_list(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status;
|
||||
sigar_t *sigar = PySIGAR;
|
||||
sigar_cpu_list_t cpus;
|
||||
PyObject *RETVAL;
|
||||
|
||||
status = sigar_cpu_list_get(sigar, &cpus);
|
||||
if (status != SIGAR_OK) {
|
||||
PySigar_Croak();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RETVAL = pysigar_new_list((char *)&cpus.data[0],
|
||||
cpus.number,
|
||||
sizeof(*cpus.data),
|
||||
&pysigar_PySigarCpuType);
|
||||
|
||||
sigar_cpu_list_destroy(sigar, &cpus);
|
||||
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_cpu_info_list(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status;
|
||||
sigar_t *sigar = PySIGAR;
|
||||
sigar_cpu_info_list_t cpu_infos;
|
||||
PyObject *RETVAL;
|
||||
|
||||
status = sigar_cpu_info_list_get(sigar, &cpu_infos);
|
||||
if (status != SIGAR_OK) {
|
||||
PySigar_Croak();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RETVAL = pysigar_new_list((char *)&cpu_infos.data[0],
|
||||
cpu_infos.number,
|
||||
sizeof(*cpu_infos.data),
|
||||
&pysigar_PySigarCpuInfoType);
|
||||
|
||||
sigar_cpu_info_list_destroy(sigar, &cpu_infos);
|
||||
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_loadavg(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status;
|
||||
sigar_t *sigar = PySIGAR;
|
||||
sigar_loadavg_t loadavg;
|
||||
|
||||
status = sigar_loadavg_get(sigar, &loadavg);
|
||||
if (status != SIGAR_OK) {
|
||||
PySigar_Croak();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pysigar_new_doublelist(loadavg.loadavg, 3);
|
||||
}
|
||||
|
||||
static PyObject *pysigar_who_list(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status;
|
||||
sigar_t *sigar = PySIGAR;
|
||||
sigar_who_list_t wholist;
|
||||
PyObject *RETVAL;
|
||||
|
||||
status = sigar_who_list_get(sigar, &wholist);
|
||||
if (status != SIGAR_OK) {
|
||||
PySigar_Croak();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RETVAL = pysigar_new_list((char *)&wholist.data[0],
|
||||
wholist.number,
|
||||
sizeof(*wholist.data),
|
||||
&pysigar_PySigarWhoType);
|
||||
|
||||
sigar_who_list_destroy(sigar, &wholist);
|
||||
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_proc_list(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status;
|
||||
sigar_t *sigar = PySIGAR;
|
||||
sigar_proc_list_t list;
|
||||
|
||||
PyObject *RETVAL;
|
||||
|
||||
if (PyTuple_Size(args) == 0) {
|
||||
status = sigar_proc_list_get(sigar, &list);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
PySigar_Croak();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
sigar_ptql_query_t *query;
|
||||
sigar_ptql_error_t error;
|
||||
char *ptql;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &ptql)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = sigar_ptql_query_create(&query, ptql, &error);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
PyErr_SetString(PyExc_ValueError, error.message);
|
||||
return NULL;
|
||||
}
|
||||
sigar_ptql_re_impl_set(sigar, NULL, pysigar_ptql_re_impl);
|
||||
status = sigar_ptql_query_find(sigar, query, &list);
|
||||
sigar_ptql_re_impl_set(sigar, NULL, NULL);
|
||||
sigar_ptql_query_destroy(query);
|
||||
if (status != SIGAR_OK) {
|
||||
PySigar_Croak();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
RETVAL = pysigar_new_intlist(&list.data[0], list.number);
|
||||
|
||||
sigar_proc_list_destroy(sigar, &list);
|
||||
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_proc_args(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status;
|
||||
sigar_t *sigar = PySIGAR;
|
||||
sigar_proc_args_t proc_args;
|
||||
long pid;
|
||||
|
||||
PyObject *RETVAL;
|
||||
|
||||
PySigar_ParsePID;
|
||||
|
||||
status = sigar_proc_args_get(sigar, pid, &proc_args);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
PySigar_Croak();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RETVAL = pysigar_new_strlist(proc_args.data, proc_args.number);
|
||||
|
||||
sigar_proc_args_destroy(sigar, &proc_args);
|
||||
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static int pysigar_env_getall(void *data,
|
||||
const char *key, int klen,
|
||||
char *val, int vlen)
|
||||
{
|
||||
PyDict_SetItem((PyObject *)data,
|
||||
PyString_FromStringAndSize(key, klen),
|
||||
PyString_FromStringAndSize(val, vlen));
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_proc_env(PyObject *self, PyObject *args)
|
||||
{
|
||||
int status;
|
||||
sigar_t *sigar = PySIGAR;
|
||||
sigar_proc_env_t procenv;
|
||||
long pid;
|
||||
|
||||
PyObject *RETVAL;
|
||||
|
||||
PySigar_ParsePID;
|
||||
|
||||
RETVAL = PyDict_New();
|
||||
|
||||
procenv.type = SIGAR_PROC_ENV_ALL;
|
||||
procenv.env_getter = pysigar_env_getall;
|
||||
procenv.data = RETVAL;
|
||||
|
||||
status = sigar_proc_env_get(sigar, pid, &procenv);
|
||||
if (status != SIGAR_OK) {
|
||||
PySigar_Croak();
|
||||
}
|
||||
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static PyObject *pysigar_format_size(PyObject *self, PyObject *args)
|
||||
{
|
||||
char buffer[56];
|
||||
@ -230,8 +627,18 @@ static PyObject *pysigar_format_size(PyObject *self, PyObject *args)
|
||||
static PyMethodDef pysigar_methods[] = {
|
||||
{ "close", pysigar_close, METH_NOARGS, NULL },
|
||||
{ "net_interface_list", pysigar_net_interface_list, METH_NOARGS, NULL },
|
||||
{ "net_connection_list", pysigar_net_connection_list, METH_VARARGS, NULL },
|
||||
{ "net_route_list", pysigar_net_route_list, METH_NOARGS, NULL },
|
||||
{ "file_system_list", pysigar_file_system_list, METH_NOARGS, NULL },
|
||||
{ "arp_list", pysigar_arp_list, METH_NOARGS, NULL },
|
||||
{ "net_stat", pysigar_net_stat, METH_VARARGS, NULL },
|
||||
{ "cpu_list", pysigar_cpu_list, METH_NOARGS, NULL },
|
||||
{ "cpu_info_list", pysigar_cpu_info_list, METH_NOARGS, NULL },
|
||||
{ "loadavg", pysigar_loadavg, METH_NOARGS, NULL },
|
||||
{ "who_list", pysigar_who_list, METH_NOARGS, NULL },
|
||||
{ "proc_list", pysigar_proc_list, METH_VARARGS, NULL },
|
||||
{ "proc_args", pysigar_proc_args, METH_VARARGS, NULL },
|
||||
{ "proc_env", pysigar_proc_env, METH_VARARGS, NULL },
|
||||
PY_SIGAR_METHODS
|
||||
{NULL}
|
||||
};
|
||||
@ -290,10 +697,24 @@ static PyMethodDef pysigar_module_methods[] = {
|
||||
#define PY_SIGAR_CONST_STR(name) \
|
||||
PyDict_SetItemString(dict, #name, o=PyString_FromString(SIGAR_##name)); Py_DECREF(o)
|
||||
|
||||
#define PY_SIGAR_DEFINE_CONST_STR(name, value) \
|
||||
PyDict_SetItemString(dict, name, o=PyString_FromString(value)); Py_DECREF(o)
|
||||
|
||||
static void init_pysigar_version(PyObject *dict)
|
||||
{
|
||||
PyObject *o;
|
||||
sigar_version_t *sv = sigar_version_get();
|
||||
PY_SIGAR_DEFINE_CONST_STR("BUILD_DATE", sv->build_date);
|
||||
PY_SIGAR_DEFINE_CONST_STR("SCM_REVISION", sv->scm_revision);
|
||||
PY_SIGAR_DEFINE_CONST_STR("VERSION", sv->version);
|
||||
}
|
||||
|
||||
static void init_pysigar_constants(PyObject *dict)
|
||||
{
|
||||
PyObject *o;
|
||||
|
||||
init_pysigar_version(dict);
|
||||
|
||||
PY_SIGAR_CONST_INT(FIELD_NOTIMPL);
|
||||
|
||||
PY_SIGAR_CONST_INT(IFF_UP);
|
||||
|
@ -17,11 +17,14 @@
|
||||
#
|
||||
|
||||
from distutils.core import setup, Extension
|
||||
from os import system, mkdir, path, popen
|
||||
from distutils.util import get_platform
|
||||
from distutils.sysconfig import get_config_var, get_python_version
|
||||
from os import system, mkdir, path, popen, rename
|
||||
import sys
|
||||
|
||||
build = 'build'
|
||||
options = {'perl':'perl'}
|
||||
deps = [build + '/_sigar_generated.c']
|
||||
|
||||
def parse_args():
|
||||
global options
|
||||
@ -59,6 +62,7 @@ if 'sigar' in options:
|
||||
_sigar = Extension(
|
||||
"_sigar",
|
||||
["_sigar.c"],
|
||||
depends = deps,
|
||||
include_dirs = [sigar + '/include', build],
|
||||
extra_compile_args = ['-Wall'],
|
||||
libraries=['sigar'],
|
||||
@ -67,11 +71,24 @@ else :
|
||||
print "Inlining libsigar sources"
|
||||
src = sargs('inline_src -- ' + build)
|
||||
src.append('_sigar.c')
|
||||
|
||||
version_file = "sigar_version.c"
|
||||
build_version_file = build + "/" + version_file
|
||||
libname = "_sigar" + get_config_var("SO")
|
||||
filters = \
|
||||
'ARCHNAME=' + get_platform() + '-' + get_python_version() + ' ' + \
|
||||
'ARCHLIB=' + libname + ' ' + \
|
||||
'BINNAME=' + libname
|
||||
system(options['perl'] + ' -Mlib=.. -MSigarBuild -e version_file ' + filters)
|
||||
rename(version_file, build_version_file)
|
||||
src.append(build_version_file)
|
||||
|
||||
cppflags = sargs('cppflags')
|
||||
cppflags.append('-Wall')
|
||||
_sigar = Extension(
|
||||
"_sigar",
|
||||
src,
|
||||
depends = deps,
|
||||
include_dirs = [build],
|
||||
extra_compile_args = cppflags,
|
||||
extra_link_args = sargs('ldflags'),
|
||||
|
@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright (c) 2007 Hyperic, Inc.
|
||||
# Copyright (c) 2011 VMware, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -15,3 +16,8 @@
|
||||
#
|
||||
|
||||
from _sigar import *
|
||||
|
||||
import re
|
||||
#wrapper for pysigar_ptql_re_impl
|
||||
def string_matches(source, regex):
|
||||
return re.compile(regex).match(source) != None
|
||||
|
123
bindings/python/test/test_sigar.py
Executable file
123
bindings/python/test/test_sigar.py
Executable file
@ -0,0 +1,123 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2011 VMware, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
#prepend PYTHONPATH to find sigar in build/
|
||||
from distutils.util import get_platform
|
||||
from distutils.sysconfig import get_python_version
|
||||
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)) + \
|
||||
"/../build/lib." + get_platform() + "-" + get_python_version())
|
||||
|
||||
import sigar
|
||||
|
||||
class SigarTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.sigar = sigar.open()
|
||||
|
||||
def tearDown(self):
|
||||
self.sigar.close()
|
||||
self.sigar = None
|
||||
|
||||
def is_type(self, obj, cls):
|
||||
return obj.__class__.__name__ == cls
|
||||
|
||||
def testCpuList(self):
|
||||
retval = self.sigar.cpu_list()
|
||||
self.assertTrue(isinstance(retval, tuple))
|
||||
for cpu in retval:
|
||||
self.assertTrue(self.is_type(cpu, "Cpu"))
|
||||
|
||||
def testCpuInfoList(self):
|
||||
retval = self.sigar.cpu_info_list()
|
||||
self.assertTrue(isinstance(retval, tuple))
|
||||
for cpu in retval:
|
||||
self.assertTrue(self.is_type(cpu, "CpuInfo"))
|
||||
|
||||
def testWhoList(self):
|
||||
retval = self.sigar.who_list()
|
||||
self.assertTrue(isinstance(retval, tuple))
|
||||
for who in retval:
|
||||
self.assertTrue(self.is_type(who, "Who"))
|
||||
|
||||
def testNetRouteList(self):
|
||||
retval = self.sigar.net_connection_list(0)
|
||||
self.assertTrue(isinstance(retval, tuple))
|
||||
for conn in retval:
|
||||
self.assertTrue(self.is_type(conn, "NetConnection"))
|
||||
|
||||
def testNetStat(self):
|
||||
retval = self.sigar.net_stat(0)
|
||||
self.assertTrue(self.is_type(retval, "NetStat"))
|
||||
|
||||
def testNetRoute(self):
|
||||
retval = self.sigar.net_route_list()
|
||||
self.assertTrue(isinstance(retval, tuple))
|
||||
for route in retval:
|
||||
self.assertTrue(self.is_type(route, "NetRoute"))
|
||||
|
||||
def testProcArgs(self):
|
||||
retval = self.sigar.proc_args(os.getpid())
|
||||
self.assertTrue(isinstance(retval, tuple))
|
||||
self.assertTrue(retval > 1)
|
||||
for arg in retval:
|
||||
self.assertTrue(isinstance(arg, str))
|
||||
|
||||
self.assertEquals(retval, self.sigar.proc_args(str(os.getpid())))
|
||||
|
||||
self.assertEquals(retval, self.sigar.proc_args("$$"))
|
||||
|
||||
retval = self.sigar.proc_args("Pid.Pid.eq=" + str(os.getpid()))
|
||||
self.assertTrue(isinstance(retval, tuple))
|
||||
|
||||
def testProcEnv(self):
|
||||
retval = self.sigar.proc_env(os.getpid())
|
||||
for k, v in os.environ.items():
|
||||
self.assertEquals(v, retval[k])
|
||||
for pid in self.sigar.proc_list("State.Name.eq=python"):
|
||||
self.sigar.proc_env(pid)
|
||||
|
||||
def testProcList(self):
|
||||
retval = self.sigar.proc_list()
|
||||
self.assertTrue(isinstance(retval, tuple))
|
||||
self.assertTrue(len(retval) > 1)
|
||||
self.assertTrue(os.getpid() in retval)
|
||||
self.assertTrue(os.getpid() in self.sigar.proc_list("State.Name.eq=python"))
|
||||
self.assertTrue(os.getpid() in self.sigar.proc_list("State.Name.re=.*ython"))
|
||||
self.assertFalse(os.getpid() in self.sigar.proc_list("State.Name.eq=ruby"))
|
||||
try:
|
||||
self.sigar.proc_list("Invalid.Query.xe=.*ython")
|
||||
self.assertTrue(False)
|
||||
except ValueError:
|
||||
self.assertTrue(True)
|
||||
|
||||
def testPtql(self):
|
||||
try:
|
||||
self.sigar.proc_args("Invalid.Query.xe=.*ython")
|
||||
self.assertTrue(False)
|
||||
except ValueError:
|
||||
self.assertTrue(True)
|
||||
|
||||
def testConstants(self):
|
||||
self.assertEquals(sigar.IFF_UP, 0x1)
|
||||
self.assertTrue(len(sigar.VERSION) >= 7)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Copyright (c) 2007, 2009 Hyperic, Inc.
|
||||
# Copyright (c) 2009 SpringSource, Inc.
|
||||
# Copyright (c) 2010 VMware, Inc.
|
||||
# Copyright (c) 2010-2012 VMware, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -26,20 +26,11 @@ print 'Ruby platform=' + RUBY_PLATFORM + "\n"
|
||||
case RUBY_PLATFORM
|
||||
when /darwin/
|
||||
os = 'darwin'
|
||||
sdks = Dir.glob('/Developer/SDKs/MacOSX10.*.sdk').sort.reverse
|
||||
if sdks.length == 0
|
||||
print "Xcode Developer Tools not installed\n"
|
||||
print "Download from http://developer.apple.com/technology/xcode.html\n"
|
||||
exit 1
|
||||
else
|
||||
print "Available SDKs...\n(*) " + sdks.join("\n ") + "\n"
|
||||
sdk = sdks[0]
|
||||
end
|
||||
if File.file?("/usr/include/libproc.h")
|
||||
$CPPFLAGS += ' -DDARWIN_HAS_LIBPROC_H'
|
||||
end
|
||||
$CPPFLAGS += ' -DDARWIN -I/Developer/Headers/FlatCarbon -isysroot ' + sdk
|
||||
$LDFLAGS += ' -Wl,-syslibroot,' + sdk + ' -framework CoreServices -framework IOKit'
|
||||
$CPPFLAGS += ' -DDARWIN'
|
||||
$LDFLAGS += ' -framework CoreServices -framework IOKit'
|
||||
when /bsd/
|
||||
os = 'darwin'
|
||||
have_library("kvm")
|
||||
@ -58,6 +49,9 @@ when /mswin|mingw|cygwin|bccwin/
|
||||
have_library("version")
|
||||
when /linux/
|
||||
os = 'linux'
|
||||
if have_header("sys/sysmacros.h")
|
||||
$CPPFLAGS += ' -DLINUX_SYSMACROS'
|
||||
end
|
||||
when /solaris|sun/
|
||||
os = 'solaris'
|
||||
have_library("nsl")
|
||||
@ -79,6 +73,7 @@ end
|
||||
osdir = "../../src/os/#{os}"
|
||||
$CPPFLAGS += ' -I../../include' + ' -I' + osdir
|
||||
$CPPFLAGS += ' -U_FILE_OFFSET_BITS' unless is_win32
|
||||
$CPPFLAGS += ' -fgnu89-inline'
|
||||
|
||||
if RUBY_VERSION > '1.8.4'
|
||||
$CPPFLAGS += ' -DRB_HAS_RE_ERROR'
|
||||
@ -102,14 +97,26 @@ unless is_win32
|
||||
end
|
||||
end
|
||||
|
||||
$distcleanfiles = ['rbsigar_generated.rx','sigar_version.c']
|
||||
|
||||
system('perl -Mlib=.. -MSigarWrapper -e generate Ruby .')
|
||||
libname = extension_name + '.' + CONFIG['DLEXT']
|
||||
system('perl -Mlib=.. -MSigarBuild -e version_file ' +
|
||||
'ARCHNAME=' + RUBY_PLATFORM + ' ' +
|
||||
'ARCHLIB=' + libname + ' ' +
|
||||
'BINNAME=' + libname)
|
||||
filters =
|
||||
'ARCHNAME=' + RUBY_PLATFORM + ' ' +
|
||||
'ARCHLIB=' + libname + ' ' +
|
||||
'BINNAME=' + libname
|
||||
|
||||
system('perl -Mlib=.. -MSigarBuild -e version_file ' + filters)
|
||||
|
||||
if is_win32
|
||||
system('perl -Mlib=.. -MSigarBuild -e resource_file ' + filters)
|
||||
system('rc /r sigar.rc')
|
||||
$LDFLAGS += ' sigar.res'
|
||||
$distcleanfiles << ['sigar.rc', 'sigar.res']
|
||||
#do not want dynamic runtime else "MSVCR80.dll was not found"
|
||||
$CFLAGS = $CFLAGS.gsub('-MD', '')
|
||||
end
|
||||
|
||||
$distcleanfiles = ['rbsigar_generated.rx','sigar_version.c']
|
||||
#XXX seems mkmf forces basename on srcs
|
||||
#XXX should be linking against libsigar anyhow
|
||||
(Dir["../../src/*.c"] + Dir["#{osdir}/*.c"] + Dir["#{osdir}/*.cpp"]).each do |file|
|
||||
|
@ -24,9 +24,9 @@
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include "sigar.h"
|
||||
#include "sigar_fileinfo.h"
|
||||
#include "sigar_log.h"
|
||||
#include "sigar_format.h"
|
||||
#include "sigar_ptql.h"
|
||||
|
||||
@ -57,7 +57,6 @@
|
||||
|
||||
typedef struct {
|
||||
sigar_t *sigar;
|
||||
VALUE logger;
|
||||
} rb_sigar_t;
|
||||
|
||||
static rb_sigar_t *rb_sigar_get(VALUE obj)
|
||||
@ -155,7 +154,6 @@ static void rb_sigar_close(rb_sigar_t *rbsigar)
|
||||
|
||||
static void rb_sigar_mark(rb_sigar_t *rbsigar)
|
||||
{
|
||||
rb_gc_mark(rbsigar->logger);
|
||||
}
|
||||
|
||||
static VALUE rb_sigar_new(VALUE module)
|
||||
@ -637,93 +635,6 @@ static VALUE rb_sigar_proc_env(VALUE obj, VALUE pid)
|
||||
|
||||
VALUE rb = Qnil;
|
||||
|
||||
static const char *logger_consts[] = {
|
||||
"FATAL", /* SIGAR_LOG_FATAL */
|
||||
"ERROR", /* SIGAR_LOG_ERROR */
|
||||
"WARN", /* SIGAR_LOG_WARN */
|
||||
"INFO", /* SIGAR_LOG_INFO */
|
||||
"DEBUG", /* SIGAR_LOG_DEBUG */
|
||||
"DEBUG", /* SIGAR_LOG_TRACE */
|
||||
};
|
||||
|
||||
static void rb_sigar_logger_impl(sigar_t *sigar, void *data,
|
||||
int level, char *message)
|
||||
{
|
||||
rb_sigar_t *rbsigar = ((rb_sigar_t*)data);
|
||||
VALUE logger = rbsigar->logger;
|
||||
|
||||
/* XXX: cost of this, better way? */
|
||||
VALUE logger_const = rb_const_get(rb_cObject, rb_intern("Logger"));
|
||||
VALUE logger_level = rb_const_get(logger_const,
|
||||
rb_intern(logger_consts[level]));
|
||||
VALUE msg = rb_str_new2(message);
|
||||
|
||||
rb_funcall(logger, rb_intern ("add"), 2, logger_level, msg);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void rb_sigar_proc_impl(sigar_t *sigar, void *data,
|
||||
int level, char *message)
|
||||
{
|
||||
rb_sigar_t *rbsigar = ((rb_sigar_t*)data);
|
||||
VALUE logger = rbsigar->logger;
|
||||
|
||||
rb_funcall(logger, rb_intern("call"), 2, INT2FIX(level), rb_str_new2(message));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static VALUE rb_sigar_logger(VALUE obj)
|
||||
{
|
||||
rb_sigar_t *rbsigar = rb_sigar_get(obj);
|
||||
|
||||
return rbsigar->logger;
|
||||
}
|
||||
|
||||
static VALUE rb_sigar_set_logger(VALUE obj, VALUE logger)
|
||||
{
|
||||
SIGAR_GET;
|
||||
|
||||
if (rb_obj_is_kind_of(logger, rb_cProc) ||
|
||||
rb_respond_to(logger, rb_intern("call"))) {
|
||||
|
||||
sigar_log_impl_set(sigar, rbsigar, rb_sigar_proc_impl);
|
||||
rbsigar->logger = logger;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/* Have to load Logger to test for it properly */
|
||||
rb_require("logger");
|
||||
if (rb_obj_is_kind_of(logger, rb_path2class("Logger"))) {
|
||||
sigar_log_impl_set(sigar, rbsigar, rb_sigar_logger_impl);
|
||||
rbsigar->logger = logger;
|
||||
}
|
||||
else {
|
||||
rb_raise(rb_eArgError,
|
||||
"value is not a proc object or subclass of Logger");
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
static VALUE rb_sigar_log_level(VALUE obj)
|
||||
{
|
||||
SIGAR_GET;
|
||||
|
||||
return INT2FIX(sigar_log_level_get(sigar));
|
||||
}
|
||||
|
||||
static VALUE rb_sigar_set_log_level(VALUE obj, VALUE level)
|
||||
{
|
||||
SIGAR_GET;
|
||||
|
||||
sigar_log_level_set(sigar, NUM2INT(level));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
static VALUE rb_sigar_fqdn(VALUE obj)
|
||||
{
|
||||
SIGAR_GET;
|
||||
@ -823,13 +734,6 @@ static void Init_rbsigar_constants(VALUE rclass)
|
||||
RB_SIGAR_CONST_INT(RTF_HOST);
|
||||
|
||||
RB_SIGAR_CONST_STR(NULL_HWADDR);
|
||||
|
||||
RB_SIGAR_CONST_INT(LOG_FATAL);
|
||||
RB_SIGAR_CONST_INT(LOG_ERROR);
|
||||
RB_SIGAR_CONST_INT(LOG_WARN);
|
||||
RB_SIGAR_CONST_INT(LOG_INFO);
|
||||
RB_SIGAR_CONST_INT(LOG_DEBUG);
|
||||
RB_SIGAR_CONST_INT(LOG_TRACE);
|
||||
}
|
||||
|
||||
static void Init_rbsigar_version(VALUE rclass)
|
||||
@ -844,12 +748,6 @@ void Init_sigar(void)
|
||||
{
|
||||
VALUE rclass = rb_define_class("Sigar", rb_cObject);
|
||||
|
||||
rb_define_method(rclass, "logger", rb_sigar_logger, 0);
|
||||
rb_define_method(rclass, "logger=", rb_sigar_set_logger, 1);
|
||||
|
||||
rb_define_method(rclass, "log_level", rb_sigar_log_level, 0);
|
||||
rb_define_method(rclass, "log_level=", rb_sigar_set_log_level, 1);
|
||||
|
||||
rb_define_method(rclass, "cpu_info_list", rb_sigar_cpu_info_list, 0);
|
||||
rb_define_method(rclass, "cpu_list", rb_sigar_cpu_list, 0);
|
||||
rb_define_method(rclass, "loadavg", rb_sigar_loadavg, 0);
|
||||
|
@ -30,7 +30,7 @@ class FileSystemTest < Test::Unit::TestCase
|
||||
|
||||
begin
|
||||
usage = sigar.file_system_usage fs.dir_name
|
||||
rescue err
|
||||
rescue => err
|
||||
if fs.type == Sigar::FSTYPE_LOCAL_DISK
|
||||
raise err
|
||||
end
|
||||
|
@ -21,6 +21,7 @@ AC_PROG_LN_S
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_LIBTOOL
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AC_MSG_CHECKING([for os type ($host_os)])
|
||||
FRAMEWORK=
|
||||
@ -34,7 +35,6 @@ case $host_os in
|
||||
SRC_OS="darwin"
|
||||
AC_DEFINE(DARWIN,[],[running on MacOS X])
|
||||
AC_DEFINE(SIGAR_TEST_OS_DARWIN, [1], [for the tests])
|
||||
SIGAR_INCLUDES="-I /Developer/Headers/FlatCarbon/"
|
||||
SIGAR_LIBS="-framework IOKit -framework CoreServices"
|
||||
;;
|
||||
*netbsd*)
|
||||
@ -73,7 +73,7 @@ case $host_os in
|
||||
esac
|
||||
AC_MSG_RESULT([$SRC_OS])
|
||||
|
||||
AC_CHECK_HEADERS(libproc.h valgrind/valgrind.h)
|
||||
AC_CHECK_HEADERS(utmp.h utmpx.h libproc.h valgrind/valgrind.h)
|
||||
if test $ac_cv_header_libproc_h = yes; then
|
||||
AC_DEFINE(DARWIN_HAS_LIBPROC_H, [1], [sigar named them DARWIN_HAS_... instead of HAVE_])
|
||||
fi
|
||||
@ -148,10 +148,7 @@ src/os/darwin/Makefile
|
||||
src/os/freebsd/Makefile
|
||||
src/os/hpux/Makefile
|
||||
src/os/linux/Makefile
|
||||
src/os/netware/Makefile
|
||||
src/os/osf1/Makefile
|
||||
src/os/solaris/Makefile
|
||||
src/os/stub/Makefile
|
||||
src/os/win32/Makefile
|
||||
examples/Makefile
|
||||
src/sigar_version_autoconf.c
|
||||
|
BIN
go_bindings/Sigar/.vs/Sigar/v14/.suo
Normal file
BIN
go_bindings/Sigar/.vs/Sigar/v14/.suo
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Debug/Sigar.exp
Normal file
BIN
go_bindings/Sigar/Debug/Sigar.exp
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Debug/Sigar.ilk
Normal file
BIN
go_bindings/Sigar/Debug/Sigar.ilk
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Debug/Sigar.lib
Normal file
BIN
go_bindings/Sigar/Debug/Sigar.lib
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Debug/Sigar.pdb
Normal file
BIN
go_bindings/Sigar/Debug/Sigar.pdb
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar.sdf
Normal file
BIN
go_bindings/Sigar/Sigar.sdf
Normal file
Binary file not shown.
28
go_bindings/Sigar/Sigar.sln
Normal file
28
go_bindings/Sigar/Sigar.sln
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sigar", "Sigar\Sigar.vcxproj", "{BB39C6EE-CA93-4F77-9372-4767EAE8838C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BB39C6EE-CA93-4F77-9372-4767EAE8838C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BB39C6EE-CA93-4F77-9372-4767EAE8838C}.Debug|x64.Build.0 = Debug|x64
|
||||
{BB39C6EE-CA93-4F77-9372-4767EAE8838C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{BB39C6EE-CA93-4F77-9372-4767EAE8838C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{BB39C6EE-CA93-4F77-9372-4767EAE8838C}.Release|x64.ActiveCfg = Release|x64
|
||||
{BB39C6EE-CA93-4F77-9372-4767EAE8838C}.Release|x64.Build.0 = Release|x64
|
||||
{BB39C6EE-CA93-4F77-9372-4767EAE8838C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{BB39C6EE-CA93-4F77-9372-4767EAE8838C}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
7
go_bindings/Sigar/Sigar/Debug/Sigar.log
Normal file
7
go_bindings/Sigar/Sigar/Debug/Sigar.log
Normal file
@ -0,0 +1,7 @@
|
||||
peb.c
|
||||
wmi.cpp
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\wmi.cpp(202): warning C4244: 'argument': conversion from 'sigar_pid_t' to 'DWORD', possible loss of data
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\wmi.cpp(228): warning C4244: 'argument': conversion from 'sigar_pid_t' to 'DWORD', possible loss of data
|
||||
Creating library c:\users\iuriel\documents\visual studio 2015\Projects\Sigar\Debug\Sigar.lib and object c:\users\iuriel\documents\visual studio 2015\Projects\Sigar\Debug\Sigar.exp
|
||||
Sigar.vcxproj -> c:\users\iuriel\documents\visual studio 2015\Projects\Sigar\Debug\Sigar.dll
|
||||
Sigar.vcxproj -> c:\users\iuriel\documents\visual studio 2015\Projects\Sigar\Debug\Sigar.pdb (Partial PDB)
|
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/CL.command.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/CL.command.1.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/CL.read.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/CL.read.1.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/CL.write.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/CL.write.1.tlog
Normal file
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
|
||||
Debug|Win32|c:\users\iuriel\documents\visual studio 2015\Projects\Sigar\|
|
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/Sigar.write.1u.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/Sigar.write.1u.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/link.command.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/link.command.1.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/link.read.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/link.read.1.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/link.write.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/Sigar.tlog/link.write.1.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/peb.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/peb.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/sigar.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/sigar.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/sigar_cache.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/sigar_cache.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/sigar_fileinfo.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/sigar_fileinfo.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/sigar_format.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/sigar_format.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/sigar_getline.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/sigar_getline.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/sigar_ptql.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/sigar_ptql.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/sigar_signal.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/sigar_signal.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/sigar_util.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/sigar_util.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/vc140.idb
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/vc140.idb
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/vc140.pdb
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/vc140.pdb
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/win32_sigar.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/win32_sigar.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/Debug/wmi.obj
Normal file
BIN
go_bindings/Sigar/Sigar/Debug/wmi.obj
Normal file
Binary file not shown.
168
go_bindings/Sigar/Sigar/Sigar.vcxproj
Normal file
168
go_bindings/Sigar/Sigar/Sigar.vcxproj
Normal file
@ -0,0 +1,168 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{BB39C6EE-CA93-4F77-9372-4767EAE8838C}</ProjectGuid>
|
||||
<RootNamespace>Sigar</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetName>sigar-amd64-winnt</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>sigar-amd64-winnt</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetName>sigar-amd64-winnt</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetName>sigar-amd64-winnt</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<AdditionalIncludeDirectories>C:\Users\iuriel\Documents\Visual Studio 2015\Projects\Sigar\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;version.lib;netapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<AdditionalIncludeDirectories>C:\Users\iuriel\Documents\Visual Studio 2015\Projects\Sigar\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;version.lib;netapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<AdditionalIncludeDirectories>C:\Users\iuriel\Documents\Visual Studio 2015\Projects\Sigar\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ws2_32.lib;version.lib;netapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<AdditionalIncludeDirectories>C:\Users\iuriel\Documents\Visual Studio 2015\Projects\Sigar\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>ws2_32.lib;version.lib;netapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\sigar.h" />
|
||||
<ClInclude Include="..\include\sigar_fileinfo.h" />
|
||||
<ClInclude Include="..\include\sigar_format.h" />
|
||||
<ClInclude Include="..\include\sigar_getline.h" />
|
||||
<ClInclude Include="..\include\sigar_log.h" />
|
||||
<ClInclude Include="..\include\sigar_os.h" />
|
||||
<ClInclude Include="..\include\sigar_private.h" />
|
||||
<ClInclude Include="..\include\sigar_ptql.h" />
|
||||
<ClInclude Include="..\include\sigar_util.h" />
|
||||
<ClInclude Include="..\src\os\win32\sigar_pdh.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\os\win32\win32_sigar.c" />
|
||||
<ClCompile Include="..\src\peb.c" />
|
||||
<ClCompile Include="..\src\sigar.c" />
|
||||
<ClCompile Include="..\src\sigar_cache.c" />
|
||||
<ClCompile Include="..\src\sigar_fileinfo.c" />
|
||||
<ClCompile Include="..\src\sigar_format.c" />
|
||||
<ClCompile Include="..\src\sigar_getline.c" />
|
||||
<ClCompile Include="..\src\sigar_ptql.c" />
|
||||
<ClCompile Include="..\src\sigar_signal.c" />
|
||||
<ClCompile Include="..\src\sigar_util.c" />
|
||||
<ClCompile Include="..\src\wmi.cpp" />
|
||||
<ClCompile Include="sigar_version.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
87
go_bindings/Sigar/Sigar/Sigar.vcxproj.filters
Normal file
87
go_bindings/Sigar/Sigar/Sigar.vcxproj.filters
Normal file
@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\sigar.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\sigar_fileinfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\sigar_format.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\sigar_getline.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\sigar_log.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\sigar_private.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\sigar_ptql.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\sigar_util.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\os\win32\sigar_pdh.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\sigar_os.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\sigar.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\sigar_cache.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\sigar_fileinfo.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\sigar_format.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\sigar_getline.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\sigar_ptql.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\sigar_signal.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\sigar_util.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\os\win32\win32_sigar.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\peb.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\wmi.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sigar_version.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
4
go_bindings/Sigar/Sigar/Sigar.vcxproj.user
Normal file
4
go_bindings/Sigar/Sigar/Sigar.vcxproj.user
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
21
go_bindings/Sigar/Sigar/sigar_version.c
Normal file
21
go_bindings/Sigar/Sigar/sigar_version.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include "sigar.h"
|
||||
|
||||
static sigar_version_t sigar_version = {
|
||||
"2004-2011",
|
||||
"1",
|
||||
"7",
|
||||
"0",
|
||||
"0",
|
||||
"sigar",
|
||||
"1.66",
|
||||
2,
|
||||
17122014,
|
||||
1,
|
||||
6
|
||||
|
||||
};
|
||||
|
||||
SIGAR_DECLARE(sigar_version_t *) sigar_version_get(void)
|
||||
{
|
||||
return &sigar_version;
|
||||
}
|
30
go_bindings/Sigar/Sigar/x64/Debug/Sigar.log
Normal file
30
go_bindings/Sigar/Sigar/x64/Debug/Sigar.log
Normal file
@ -0,0 +1,30 @@
|
||||
sigar.c
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(52): warning C4996: 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\stdlib.h(1183): note: see declaration of 'getenv'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(114): warning C4013: 'getpid' undefined; assuming extern returning int
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(210): warning C4244: '=': conversion from 'double' to 'sigar_uint64_t', possible loss of data
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(299): warning C4018: '<': signed/unsigned mismatch
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(598): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(119): note: see declaration of 'strcpy'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(1249): warning C4311: 'type cast': pointer truncation from 'MEMORY_BASIC_INFORMATION *' to 'DWORD'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(1249): warning C4311: 'type cast': pointer truncation from 'PVOID' to 'DWORD'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(1251): warning C4311: 'type cast': pointer truncation from 'PVOID' to 'DWORD'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(1252): warning C4311: 'type cast': pointer truncation from 'PVOID' to 'DWORD'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(1978): warning C4018: '<': signed/unsigned mismatch
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(2064): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(2238): note: see declaration of 'gethostbyname'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(2096): warning C4996: 'gethostbyaddr': Use getnameinfo() or GetNameInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
c:\program files (x86)\windows kits\8.1\include\um\winsock2.h(2216): note: see declaration of 'gethostbyaddr'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(2155): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(2172): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(2219): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(2235): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy'
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(2117): warning C4101: 'domain': unreferenced local variable
|
||||
c:\users\iuriel\documents\visual studio 2015\projects\sigar\src\sigar.c(2301): warning C4013: '_getch' undefined; assuming extern returning int
|
||||
Creating library C:\Users\iuriel\documents\visual studio 2015\Projects\Sigar\x64\Debug\sigar-amd64-winnt.lib and object C:\Users\iuriel\documents\visual studio 2015\Projects\Sigar\x64\Debug\sigar-amd64-winnt.exp
|
||||
Sigar.vcxproj -> C:\Users\iuriel\documents\visual studio 2015\Projects\Sigar\x64\Debug\sigar-amd64-winnt.dll
|
||||
Sigar.vcxproj -> C:\Users\iuriel\documents\visual studio 2015\Projects\Sigar\x64\Debug\sigar-amd64-winnt.pdb (Partial PDB)
|
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/CL.command.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/CL.command.1.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/CL.read.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/CL.read.1.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/CL.write.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/CL.write.1.tlog
Normal file
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
|
||||
Debug|x64|C:\Users\iuriel\documents\visual studio 2015\Projects\Sigar\|
|
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/Sigar.write.1u.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/Sigar.write.1u.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/link.command.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/link.command.1.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/link.read.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/link.read.1.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/link.write.1.tlog
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/Sigar.tlog/link.write.1.tlog
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/peb.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/peb.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_cache.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_cache.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_fileinfo.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_fileinfo.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_format.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_format.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_getline.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_getline.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_ptql.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_ptql.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_signal.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_signal.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_util.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_util.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_version.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/sigar_version.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/vc140.idb
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/vc140.idb
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/vc140.pdb
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/vc140.pdb
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/win32_sigar.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/win32_sigar.obj
Normal file
Binary file not shown.
BIN
go_bindings/Sigar/Sigar/x64/Debug/wmi.obj
Normal file
BIN
go_bindings/Sigar/Sigar/x64/Debug/wmi.obj
Normal file
Binary file not shown.
985
go_bindings/Sigar/include/sigar.h
Normal file
985
go_bindings/Sigar/include/sigar.h
Normal file
@ -0,0 +1,985 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2008 Hyperic, Inc.
|
||||
* Copyright (c) 2009 SpringSource, Inc.
|
||||
* Copyright (c) 2009-2010 VMware, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SIGAR_H
|
||||
#define SIGAR_H
|
||||
|
||||
/* System Information Gatherer And Reporter */
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef MAX_INTERFACE_NAME_LEN
|
||||
#define MAX_INTERFACE_NAME_LEN 256
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_LP64) || \
|
||||
defined(__LP64__) || \
|
||||
defined(__64BIT__) || \
|
||||
defined(__powerpc64__) || \
|
||||
defined(__osf__)
|
||||
#define SIGAR_64BIT
|
||||
#endif
|
||||
|
||||
/* for printf sigar_uint64_t */
|
||||
#ifdef SIGAR_64BIT
|
||||
# define SIGAR_F_U64 "%lu"
|
||||
#else
|
||||
# define SIGAR_F_U64 "%Lu"
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
typedef unsigned __int32 sigar_uint32_t;
|
||||
|
||||
typedef unsigned __int64 sigar_uint64_t;
|
||||
|
||||
typedef __int32 sigar_int32_t;
|
||||
|
||||
typedef __int64 sigar_int64_t;
|
||||
|
||||
#elif ULONG_MAX > 4294967295UL
|
||||
|
||||
typedef unsigned int sigar_uint32_t;
|
||||
|
||||
typedef unsigned long sigar_uint64_t;
|
||||
|
||||
typedef int sigar_int32_t;
|
||||
|
||||
typedef long sigar_int64_t;
|
||||
|
||||
#else
|
||||
|
||||
typedef unsigned int sigar_uint32_t;
|
||||
|
||||
typedef unsigned long long sigar_uint64_t;
|
||||
|
||||
typedef int sigar_int32_t;
|
||||
|
||||
typedef long long sigar_int64_t;
|
||||
|
||||
#endif
|
||||
|
||||
#define SIGAR_FIELD_NOTIMPL -1
|
||||
|
||||
#define SIGAR_OK 0
|
||||
#define SIGAR_START_ERROR 20000
|
||||
#define SIGAR_ENOTIMPL (SIGAR_START_ERROR + 1)
|
||||
#define SIGAR_OS_START_ERROR (SIGAR_START_ERROR*2)
|
||||
|
||||
#ifdef WIN32
|
||||
# define SIGAR_ENOENT ERROR_FILE_NOT_FOUND
|
||||
# define SIGAR_EACCES ERROR_ACCESS_DENIED
|
||||
# define SIGAR_ENXIO ERROR_BAD_DRIVER_LEVEL
|
||||
#else
|
||||
# define SIGAR_ENOENT ENOENT
|
||||
# define SIGAR_EACCES EACCES
|
||||
# define SIGAR_ENXIO ENXIO
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# define SIGAR_DECLARE(type) \
|
||||
__declspec(dllexport) type __stdcall
|
||||
#else
|
||||
# define SIGAR_DECLARE(type) type
|
||||
#endif
|
||||
|
||||
#if defined(PATH_MAX)
|
||||
# define SIGAR_PATH_MAX PATH_MAX
|
||||
#elif defined(MAXPATHLEN)
|
||||
# define SIGAR_PATH_MAX MAXPATHLEN
|
||||
#else
|
||||
# define SIGAR_PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
typedef sigar_uint64_t sigar_pid_t;
|
||||
typedef unsigned long sigar_uid_t;
|
||||
typedef unsigned long sigar_gid_t;
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
typedef pid_t sigar_pid_t;
|
||||
typedef uid_t sigar_uid_t;
|
||||
typedef gid_t sigar_gid_t;
|
||||
#endif
|
||||
|
||||
typedef struct sigar_t sigar_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_open(sigar_t **sigar);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_close(sigar_t *sigar);
|
||||
|
||||
SIGAR_DECLARE(sigar_pid_t) sigar_pid_get(sigar_t *sigar);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_kill(sigar_pid_t pid, int signum);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_signum_get(char *name);
|
||||
|
||||
SIGAR_DECLARE(char *) sigar_strerror(sigar_t *sigar, int err);
|
||||
|
||||
/* system memory info */
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t
|
||||
ram,
|
||||
total,
|
||||
used,
|
||||
free,
|
||||
actual_used,
|
||||
actual_free;
|
||||
double used_percent;
|
||||
double free_percent;
|
||||
} sigar_mem_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t
|
||||
total,
|
||||
used,
|
||||
free,
|
||||
page_in,
|
||||
page_out;
|
||||
} sigar_swap_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t
|
||||
user,
|
||||
sys,
|
||||
nice,
|
||||
idle,
|
||||
wait,
|
||||
irq,
|
||||
soft_irq,
|
||||
stolen,
|
||||
total;
|
||||
} sigar_cpu_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu);
|
||||
|
||||
typedef struct {
|
||||
unsigned long number;
|
||||
unsigned long size;
|
||||
sigar_cpu_t *data;
|
||||
} sigar_cpu_list_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_cpu_list_destroy(sigar_t *sigar,
|
||||
sigar_cpu_list_t *cpulist);
|
||||
|
||||
typedef struct {
|
||||
char vendor[128];
|
||||
char model[128];
|
||||
int mhz;
|
||||
int mhz_max;
|
||||
int mhz_min;
|
||||
sigar_uint64_t cache_size;
|
||||
int total_sockets;
|
||||
int total_cores;
|
||||
int cores_per_socket;
|
||||
} sigar_cpu_info_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned long number;
|
||||
unsigned long size;
|
||||
sigar_cpu_info_t *data;
|
||||
} sigar_cpu_info_list_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_cpu_info_list_get(sigar_t *sigar,
|
||||
sigar_cpu_info_list_t *cpu_infos);
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_cpu_info_list_destroy(sigar_t *sigar,
|
||||
sigar_cpu_info_list_t *cpu_infos);
|
||||
|
||||
typedef struct {
|
||||
double uptime;
|
||||
} sigar_uptime_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_uptime_get(sigar_t *sigar,
|
||||
sigar_uptime_t *uptime);
|
||||
|
||||
typedef struct {
|
||||
double loadavg[3];
|
||||
} sigar_loadavg_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_loadavg_get(sigar_t *sigar,
|
||||
sigar_loadavg_t *loadavg);
|
||||
|
||||
typedef struct {
|
||||
unsigned long number;
|
||||
unsigned long size;
|
||||
sigar_pid_t *data;
|
||||
} sigar_proc_list_t;
|
||||
|
||||
typedef struct {
|
||||
/* RLIMIT_CPU */
|
||||
sigar_uint64_t cpu_cur, cpu_max;
|
||||
/* RLIMIT_FSIZE */
|
||||
sigar_uint64_t file_size_cur, file_size_max;
|
||||
/* PIPE_BUF */
|
||||
sigar_uint64_t pipe_size_cur, pipe_size_max;
|
||||
/* RLIMIT_DATA */
|
||||
sigar_uint64_t data_cur, data_max;
|
||||
/* RLIMIT_STACK */
|
||||
sigar_uint64_t stack_cur, stack_max;
|
||||
/* RLIMIT_CORE */
|
||||
sigar_uint64_t core_cur, core_max;
|
||||
/* RLIMIT_RSS */
|
||||
sigar_uint64_t memory_cur, memory_max;
|
||||
/* RLIMIT_NPROC */
|
||||
sigar_uint64_t processes_cur, processes_max;
|
||||
/* RLIMIT_NOFILE */
|
||||
sigar_uint64_t open_files_cur, open_files_max;
|
||||
/* RLIMIT_AS */
|
||||
sigar_uint64_t virtual_memory_cur, virtual_memory_max;
|
||||
} sigar_resource_limit_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar,
|
||||
sigar_resource_limit_t *rlimit);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_list_get(sigar_t *sigar,
|
||||
sigar_proc_list_t *proclist);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_list_destroy(sigar_t *sigar,
|
||||
sigar_proc_list_t *proclist);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t total;
|
||||
sigar_uint64_t sleeping;
|
||||
sigar_uint64_t running;
|
||||
sigar_uint64_t zombie;
|
||||
sigar_uint64_t stopped;
|
||||
sigar_uint64_t idle;
|
||||
sigar_uint64_t threads;
|
||||
} sigar_proc_stat_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_stat_get(sigar_t *sigar,
|
||||
sigar_proc_stat_t *procstat);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t
|
||||
size,
|
||||
resident,
|
||||
share,
|
||||
minor_faults,
|
||||
major_faults,
|
||||
page_faults;
|
||||
} sigar_proc_mem_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_mem_t *procmem);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t
|
||||
bytes_read,
|
||||
bytes_written,
|
||||
bytes_total;
|
||||
} sigar_proc_disk_io_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_disk_io_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_disk_io_t *proc_disk_io);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t
|
||||
bytes_read,
|
||||
bytes_written,
|
||||
bytes_total;
|
||||
sigar_uint64_t last_time;
|
||||
sigar_uint64_t
|
||||
bytes_read_diff,
|
||||
bytes_written_diff,
|
||||
bytes_total_diff;
|
||||
} sigar_cached_proc_disk_io_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t
|
||||
bytes_read,
|
||||
bytes_written,
|
||||
bytes_total;
|
||||
} sigar_proc_cumulative_disk_io_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_cumulative_disk_io_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_cumulative_disk_io_t *proc_cumulative_disk_io);
|
||||
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t dummy;
|
||||
}sigar_dump_pid_cache_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_dump_pid_cache_get(sigar_t *sigar, sigar_dump_pid_cache_t *info);
|
||||
|
||||
|
||||
typedef struct {
|
||||
sigar_uid_t uid;
|
||||
sigar_gid_t gid;
|
||||
sigar_uid_t euid;
|
||||
sigar_gid_t egid;
|
||||
} sigar_proc_cred_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_cred_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_cred_t *proccred);
|
||||
|
||||
#define SIGAR_CRED_NAME_MAX 512
|
||||
|
||||
typedef struct {
|
||||
char user[SIGAR_CRED_NAME_MAX];
|
||||
char group[SIGAR_CRED_NAME_MAX];
|
||||
} sigar_proc_cred_name_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_proc_cred_name_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_cred_name_t *proccredname);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t
|
||||
start_time,
|
||||
user,
|
||||
sys,
|
||||
total;
|
||||
} sigar_proc_time_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_time_t *proctime);
|
||||
|
||||
typedef struct {
|
||||
/* must match sigar_proc_time_t fields */
|
||||
sigar_uint64_t
|
||||
start_time,
|
||||
user,
|
||||
sys,
|
||||
total;
|
||||
sigar_uint64_t last_time;
|
||||
double percent;
|
||||
} sigar_proc_cpu_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_cpu_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_cpu_t *proccpu);
|
||||
|
||||
#define SIGAR_PROC_STATE_SLEEP 'S'
|
||||
#define SIGAR_PROC_STATE_RUN 'R'
|
||||
#define SIGAR_PROC_STATE_STOP 'T'
|
||||
#define SIGAR_PROC_STATE_ZOMBIE 'Z'
|
||||
#define SIGAR_PROC_STATE_IDLE 'D'
|
||||
|
||||
#define SIGAR_PROC_NAME_LEN 128
|
||||
|
||||
typedef struct {
|
||||
char name[SIGAR_PROC_NAME_LEN];
|
||||
char state;
|
||||
sigar_pid_t ppid;
|
||||
int tty;
|
||||
int priority;
|
||||
int nice;
|
||||
int processor;
|
||||
sigar_uint64_t threads;
|
||||
} sigar_proc_state_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_state_t *procstate);
|
||||
|
||||
typedef struct {
|
||||
unsigned long number;
|
||||
unsigned long size;
|
||||
char **data;
|
||||
} sigar_proc_args_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_args_t *procargs);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_args_destroy(sigar_t *sigar,
|
||||
sigar_proc_args_t *procargs);
|
||||
|
||||
typedef struct {
|
||||
void *data; /* user data */
|
||||
|
||||
enum {
|
||||
SIGAR_PROC_ENV_ALL,
|
||||
SIGAR_PROC_ENV_KEY
|
||||
} type;
|
||||
|
||||
/* used for SIGAR_PROC_ENV_KEY */
|
||||
const char *key;
|
||||
int klen;
|
||||
|
||||
int (*env_getter)(void *, const char *, int, char *, int);
|
||||
} sigar_proc_env_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_env_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_env_t *procenv);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t total;
|
||||
/* XXX - which are files, sockets, etc. */
|
||||
} sigar_proc_fd_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_fd_t *procfd);
|
||||
|
||||
typedef struct {
|
||||
char name[SIGAR_PATH_MAX+1];
|
||||
char cwd[SIGAR_PATH_MAX+1];
|
||||
char root[SIGAR_PATH_MAX+1];
|
||||
} sigar_proc_exe_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_exe_t *procexe);
|
||||
|
||||
typedef struct {
|
||||
void *data; /* user data */
|
||||
|
||||
int (*module_getter)(void *, char *, int);
|
||||
} sigar_proc_modules_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_modules_t *procmods);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t user;
|
||||
sigar_uint64_t sys;
|
||||
sigar_uint64_t total;
|
||||
} sigar_thread_cpu_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_thread_cpu_get(sigar_t *sigar,
|
||||
sigar_uint64_t id,
|
||||
sigar_thread_cpu_t *cpu);
|
||||
|
||||
typedef enum {
|
||||
SIGAR_FSTYPE_UNKNOWN,
|
||||
SIGAR_FSTYPE_NONE,
|
||||
SIGAR_FSTYPE_LOCAL_DISK,
|
||||
SIGAR_FSTYPE_NETWORK,
|
||||
SIGAR_FSTYPE_RAM_DISK,
|
||||
SIGAR_FSTYPE_CDROM,
|
||||
SIGAR_FSTYPE_SWAP,
|
||||
SIGAR_FSTYPE_MAX
|
||||
} sigar_file_system_type_e;
|
||||
|
||||
#define SIGAR_FS_NAME_LEN SIGAR_PATH_MAX
|
||||
#define SIGAR_FS_INFO_LEN 256
|
||||
|
||||
typedef struct {
|
||||
char dir_name[SIGAR_FS_NAME_LEN];
|
||||
char dev_name[SIGAR_FS_NAME_LEN];
|
||||
char type_name[SIGAR_FS_INFO_LEN]; /* e.g. "local" */
|
||||
char sys_type_name[SIGAR_FS_INFO_LEN]; /* e.g. "ext3" */
|
||||
char options[SIGAR_FS_INFO_LEN];
|
||||
sigar_file_system_type_e type;
|
||||
unsigned long flags;
|
||||
} sigar_file_system_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned long number;
|
||||
unsigned long size;
|
||||
sigar_file_system_t *data;
|
||||
} sigar_file_system_list_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_file_system_list_get(sigar_t *sigar,
|
||||
sigar_file_system_list_t *fslist);
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_file_system_list_destroy(sigar_t *sigar,
|
||||
sigar_file_system_list_t *fslist);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t reads;
|
||||
sigar_uint64_t writes;
|
||||
sigar_uint64_t write_bytes;
|
||||
sigar_uint64_t read_bytes;
|
||||
sigar_uint64_t rtime;
|
||||
sigar_uint64_t wtime;
|
||||
sigar_uint64_t qtime;
|
||||
sigar_uint64_t time;
|
||||
sigar_uint64_t snaptime;
|
||||
double service_time;
|
||||
double queue;
|
||||
} sigar_disk_usage_t;
|
||||
|
||||
/* XXX for sigar_file_system_usage_t compat */
|
||||
#define disk_reads disk.reads
|
||||
#define disk_writes disk.writes
|
||||
#define disk_write_bytes disk.write_bytes
|
||||
#define disk_read_bytes disk.read_bytes
|
||||
#define disk_queue disk.queue
|
||||
#define disk_service_time disk.service_time
|
||||
|
||||
typedef struct {
|
||||
sigar_disk_usage_t disk;
|
||||
double use_percent;
|
||||
sigar_uint64_t total;
|
||||
sigar_uint64_t free;
|
||||
sigar_uint64_t used;
|
||||
sigar_uint64_t avail;
|
||||
sigar_uint64_t files;
|
||||
sigar_uint64_t free_files;
|
||||
} sigar_file_system_usage_t;
|
||||
|
||||
#undef SIGAR_DISK_USAGE_T
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_file_system_usage_get(sigar_t *sigar,
|
||||
const char *dirname,
|
||||
sigar_file_system_usage_t *fsusage);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_disk_usage_get(sigar_t *sigar,
|
||||
const char *name,
|
||||
sigar_disk_usage_t *disk);
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_file_system_ping(sigar_t *sigar,
|
||||
sigar_file_system_t *fs);
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
SIGAR_AF_UNSPEC,
|
||||
SIGAR_AF_INET,
|
||||
SIGAR_AF_INET6,
|
||||
SIGAR_AF_LINK
|
||||
} family;
|
||||
union {
|
||||
sigar_uint32_t in;
|
||||
sigar_uint32_t in6[4];
|
||||
unsigned char mac[8];
|
||||
} addr;
|
||||
} sigar_net_address_t;
|
||||
|
||||
#define SIGAR_INET6_ADDRSTRLEN 46
|
||||
|
||||
#define SIGAR_MAXDOMAINNAMELEN 256
|
||||
#define SIGAR_MAXHOSTNAMELEN 256
|
||||
|
||||
typedef struct {
|
||||
char default_gateway[SIGAR_INET6_ADDRSTRLEN];
|
||||
char default_gateway_interface[MAX_INTERFACE_NAME_LEN];
|
||||
char host_name[SIGAR_MAXHOSTNAMELEN];
|
||||
char domain_name[SIGAR_MAXDOMAINNAMELEN];
|
||||
char primary_dns[SIGAR_INET6_ADDRSTRLEN];
|
||||
char secondary_dns[SIGAR_INET6_ADDRSTRLEN];
|
||||
} sigar_net_info_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_info_get(sigar_t *sigar,
|
||||
sigar_net_info_t *netinfo);
|
||||
|
||||
#define SIGAR_RTF_UP 0x1
|
||||
#define SIGAR_RTF_GATEWAY 0x2
|
||||
#define SIGAR_RTF_HOST 0x4
|
||||
|
||||
typedef struct {
|
||||
sigar_net_address_t destination;
|
||||
sigar_net_address_t gateway;
|
||||
sigar_net_address_t mask;
|
||||
sigar_uint64_t
|
||||
flags,
|
||||
refcnt,
|
||||
use,
|
||||
metric,
|
||||
mtu,
|
||||
window,
|
||||
irtt;
|
||||
char ifname[MAX_INTERFACE_NAME_LEN];
|
||||
} sigar_net_route_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned long number;
|
||||
unsigned long size;
|
||||
sigar_net_route_t *data;
|
||||
} sigar_net_route_list_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_net_route_list_get(sigar_t *sigar,
|
||||
sigar_net_route_list_t *routelist);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_net_route_list_destroy(sigar_t *sigar,
|
||||
sigar_net_route_list_t *routelist);
|
||||
|
||||
/*
|
||||
* platforms define most of these "standard" flags,
|
||||
* but of course, with different values in some cases.
|
||||
*/
|
||||
#define SIGAR_IFF_UP 0x1
|
||||
#define SIGAR_IFF_BROADCAST 0x2
|
||||
#define SIGAR_IFF_DEBUG 0x4
|
||||
#define SIGAR_IFF_LOOPBACK 0x8
|
||||
#define SIGAR_IFF_POINTOPOINT 0x10
|
||||
#define SIGAR_IFF_NOTRAILERS 0x20
|
||||
#define SIGAR_IFF_RUNNING 0x40
|
||||
#define SIGAR_IFF_NOARP 0x80
|
||||
#define SIGAR_IFF_PROMISC 0x100
|
||||
#define SIGAR_IFF_ALLMULTI 0x200
|
||||
#define SIGAR_IFF_MULTICAST 0x800
|
||||
#define SIGAR_IFF_SLAVE 0x1000
|
||||
#define SIGAR_IFF_MASTER 0x2000
|
||||
#define SIGAR_IFF_DYNAMIC 0x4000
|
||||
|
||||
#define SIGAR_NULL_HWADDR "00:00:00:00:00:00"
|
||||
|
||||
/* scope values from linux-2.6/include/net/ipv6.h */
|
||||
#define SIGAR_IPV6_ADDR_ANY 0x0000
|
||||
#define SIGAR_IPV6_ADDR_UNICAST 0x0001
|
||||
#define SIGAR_IPV6_ADDR_MULTICAST 0x0002
|
||||
#define SIGAR_IPV6_ADDR_LOOPBACK 0x0010
|
||||
#define SIGAR_IPV6_ADDR_LINKLOCAL 0x0020
|
||||
#define SIGAR_IPV6_ADDR_SITELOCAL 0x0040
|
||||
#define SIGAR_IPV6_ADDR_COMPATv4 0x0080
|
||||
|
||||
typedef struct {
|
||||
char name[MAX_INTERFACE_NAME_LEN];
|
||||
char type[64];
|
||||
char description[256];
|
||||
sigar_net_address_t hwaddr;
|
||||
sigar_net_address_t address;
|
||||
sigar_net_address_t destination;
|
||||
sigar_net_address_t broadcast;
|
||||
sigar_net_address_t netmask;
|
||||
sigar_net_address_t address6;
|
||||
int prefix6_length;
|
||||
int scope6;
|
||||
sigar_uint64_t
|
||||
flags,
|
||||
mtu,
|
||||
metric;
|
||||
int tx_queue_len;
|
||||
} sigar_net_interface_config_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_interface_config_get(sigar_t *sigar,
|
||||
const char *name,
|
||||
sigar_net_interface_config_t *ifconfig);
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_interface_config_primary_get(sigar_t *sigar,
|
||||
sigar_net_interface_config_t *ifconfig);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t
|
||||
/* received */
|
||||
rx_packets,
|
||||
rx_bytes,
|
||||
rx_errors,
|
||||
rx_dropped,
|
||||
rx_overruns,
|
||||
rx_frame,
|
||||
/* transmitted */
|
||||
tx_packets,
|
||||
tx_bytes,
|
||||
tx_errors,
|
||||
tx_dropped,
|
||||
tx_overruns,
|
||||
tx_collisions,
|
||||
tx_carrier,
|
||||
speed;
|
||||
} sigar_net_interface_stat_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_interface_stat_get(sigar_t *sigar,
|
||||
const char *name,
|
||||
sigar_net_interface_stat_t *ifstat);
|
||||
|
||||
typedef struct {
|
||||
unsigned long number;
|
||||
unsigned long size;
|
||||
char **data;
|
||||
} sigar_net_interface_list_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_interface_list_get(sigar_t *sigar,
|
||||
sigar_net_interface_list_t *iflist);
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_interface_list_destroy(sigar_t *sigar,
|
||||
sigar_net_interface_list_t *iflist);
|
||||
|
||||
#define SIGAR_NETCONN_CLIENT 0x01
|
||||
#define SIGAR_NETCONN_SERVER 0x02
|
||||
|
||||
#define SIGAR_NETCONN_TCP 0x10
|
||||
#define SIGAR_NETCONN_UDP 0x20
|
||||
#define SIGAR_NETCONN_RAW 0x40
|
||||
#define SIGAR_NETCONN_UNIX 0x80
|
||||
|
||||
enum {
|
||||
SIGAR_TCP_ESTABLISHED = 1,
|
||||
SIGAR_TCP_SYN_SENT,
|
||||
SIGAR_TCP_SYN_RECV,
|
||||
SIGAR_TCP_FIN_WAIT1,
|
||||
SIGAR_TCP_FIN_WAIT2,
|
||||
SIGAR_TCP_TIME_WAIT,
|
||||
SIGAR_TCP_CLOSE,
|
||||
SIGAR_TCP_CLOSE_WAIT,
|
||||
SIGAR_TCP_LAST_ACK,
|
||||
SIGAR_TCP_LISTEN,
|
||||
SIGAR_TCP_CLOSING,
|
||||
SIGAR_TCP_IDLE,
|
||||
SIGAR_TCP_BOUND,
|
||||
SIGAR_TCP_UNKNOWN
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
unsigned long local_port;
|
||||
sigar_net_address_t local_address;
|
||||
unsigned long remote_port;
|
||||
sigar_net_address_t remote_address;
|
||||
sigar_uid_t uid;
|
||||
unsigned long inode;
|
||||
int type;
|
||||
int state;
|
||||
unsigned long send_queue;
|
||||
unsigned long receive_queue;
|
||||
} sigar_net_connection_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned long number;
|
||||
unsigned long size;
|
||||
sigar_net_connection_t *data;
|
||||
} sigar_net_connection_list_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_connection_list_get(sigar_t *sigar,
|
||||
sigar_net_connection_list_t *connlist,
|
||||
int flags);
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_connection_list_destroy(sigar_t *sigar,
|
||||
sigar_net_connection_list_t *connlist);
|
||||
|
||||
typedef struct sigar_net_connection_walker_t sigar_net_connection_walker_t;
|
||||
|
||||
/* alternative to sigar_net_connection_list_get */
|
||||
struct sigar_net_connection_walker_t {
|
||||
sigar_t *sigar;
|
||||
int flags;
|
||||
void *data; /* user data */
|
||||
int (*add_connection)(sigar_net_connection_walker_t *walker,
|
||||
sigar_net_connection_t *connection);
|
||||
};
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_connection_walk(sigar_net_connection_walker_t *walker);
|
||||
|
||||
typedef struct {
|
||||
int tcp_states[SIGAR_TCP_UNKNOWN];
|
||||
sigar_uint32_t tcp_inbound_total;
|
||||
sigar_uint32_t tcp_outbound_total;
|
||||
sigar_uint32_t all_inbound_total;
|
||||
sigar_uint32_t all_outbound_total;
|
||||
} sigar_net_stat_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_stat_get(sigar_t *sigar,
|
||||
sigar_net_stat_t *netstat,
|
||||
int flags);
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_stat_port_get(sigar_t *sigar,
|
||||
sigar_net_stat_t *netstat,
|
||||
int flags,
|
||||
sigar_net_address_t *address,
|
||||
unsigned long port);
|
||||
|
||||
/* TCP-MIB */
|
||||
typedef struct {
|
||||
sigar_uint64_t active_opens;
|
||||
sigar_uint64_t passive_opens;
|
||||
sigar_uint64_t attempt_fails;
|
||||
sigar_uint64_t estab_resets;
|
||||
sigar_uint64_t curr_estab;
|
||||
sigar_uint64_t in_segs;
|
||||
sigar_uint64_t out_segs;
|
||||
sigar_uint64_t retrans_segs;
|
||||
sigar_uint64_t in_errs;
|
||||
sigar_uint64_t out_rsts;
|
||||
} sigar_tcp_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_tcp_get(sigar_t *sigar,
|
||||
sigar_tcp_t *tcp);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t null;
|
||||
sigar_uint64_t getattr;
|
||||
sigar_uint64_t setattr;
|
||||
sigar_uint64_t root;
|
||||
sigar_uint64_t lookup;
|
||||
sigar_uint64_t readlink;
|
||||
sigar_uint64_t read;
|
||||
sigar_uint64_t writecache;
|
||||
sigar_uint64_t write;
|
||||
sigar_uint64_t create;
|
||||
sigar_uint64_t remove;
|
||||
sigar_uint64_t rename;
|
||||
sigar_uint64_t link;
|
||||
sigar_uint64_t symlink;
|
||||
sigar_uint64_t mkdir;
|
||||
sigar_uint64_t rmdir;
|
||||
sigar_uint64_t readdir;
|
||||
sigar_uint64_t fsstat;
|
||||
} sigar_nfs_v2_t;
|
||||
|
||||
typedef sigar_nfs_v2_t sigar_nfs_client_v2_t;
|
||||
typedef sigar_nfs_v2_t sigar_nfs_server_v2_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_nfs_client_v2_get(sigar_t *sigar,
|
||||
sigar_nfs_client_v2_t *nfs);
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_nfs_server_v2_get(sigar_t *sigar,
|
||||
sigar_nfs_server_v2_t *nfs);
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t null;
|
||||
sigar_uint64_t getattr;
|
||||
sigar_uint64_t setattr;
|
||||
sigar_uint64_t lookup;
|
||||
sigar_uint64_t access;
|
||||
sigar_uint64_t readlink;
|
||||
sigar_uint64_t read;
|
||||
sigar_uint64_t write;
|
||||
sigar_uint64_t create;
|
||||
sigar_uint64_t mkdir;
|
||||
sigar_uint64_t symlink;
|
||||
sigar_uint64_t mknod;
|
||||
sigar_uint64_t remove;
|
||||
sigar_uint64_t rmdir;
|
||||
sigar_uint64_t rename;
|
||||
sigar_uint64_t link;
|
||||
sigar_uint64_t readdir;
|
||||
sigar_uint64_t readdirplus;
|
||||
sigar_uint64_t fsstat;
|
||||
sigar_uint64_t fsinfo;
|
||||
sigar_uint64_t pathconf;
|
||||
sigar_uint64_t commit;
|
||||
} sigar_nfs_v3_t;
|
||||
|
||||
typedef sigar_nfs_v3_t sigar_nfs_client_v3_t;
|
||||
typedef sigar_nfs_v3_t sigar_nfs_server_v3_t;
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_nfs_client_v3_get(sigar_t *sigar,
|
||||
sigar_nfs_client_v3_t *nfs);
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_nfs_server_v3_get(sigar_t *sigar,
|
||||
sigar_nfs_server_v3_t *nfs);
|
||||
|
||||
SIGAR_DECLARE(int)
|
||||
sigar_net_listen_address_get(sigar_t *sigar,
|
||||
unsigned long port,
|
||||
sigar_net_address_t *address);
|
||||
|
||||
typedef struct {
|
||||
char ifname[MAX_INTERFACE_NAME_LEN];
|
||||
char type[64];
|
||||
sigar_net_address_t hwaddr;
|
||||
sigar_net_address_t address;
|
||||
sigar_uint64_t flags;
|
||||
} sigar_arp_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned long number;
|
||||
unsigned long size;
|
||||
sigar_arp_t *data;
|
||||
} sigar_arp_list_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_arp_list_get(sigar_t *sigar,
|
||||
sigar_arp_list_t *arplist);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_arp_list_destroy(sigar_t *sigar,
|
||||
sigar_arp_list_t *arplist);
|
||||
|
||||
typedef struct {
|
||||
char user[32];
|
||||
char device[32];
|
||||
char host[256];
|
||||
sigar_uint64_t time;
|
||||
} sigar_who_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned long number;
|
||||
unsigned long size;
|
||||
sigar_who_t *data;
|
||||
} sigar_who_list_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_who_list_get(sigar_t *sigar,
|
||||
sigar_who_list_t *wholist);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_who_list_destroy(sigar_t *sigar,
|
||||
sigar_who_list_t *wholist);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_port_get(sigar_t *sigar,
|
||||
int protocol, unsigned long port,
|
||||
sigar_pid_t *pid);
|
||||
|
||||
typedef struct {
|
||||
const char *build_date;
|
||||
const char *scm_revision;
|
||||
const char *version;
|
||||
const char *archname;
|
||||
const char *archlib;
|
||||
const char *binname;
|
||||
const char *description;
|
||||
int major, minor, maint, build;
|
||||
} sigar_version_t;
|
||||
|
||||
SIGAR_DECLARE(sigar_version_t *) sigar_version_get(void);
|
||||
|
||||
#define SIGAR_SYS_INFO_LEN SIGAR_MAXHOSTNAMELEN /* more than enough */
|
||||
|
||||
typedef struct {
|
||||
char name[SIGAR_SYS_INFO_LEN]; /* canonicalized sysname */
|
||||
char version[SIGAR_SYS_INFO_LEN]; /* utsname.release */
|
||||
char arch[SIGAR_SYS_INFO_LEN];
|
||||
char machine[SIGAR_SYS_INFO_LEN];
|
||||
char description[SIGAR_SYS_INFO_LEN];
|
||||
char patch_level[SIGAR_SYS_INFO_LEN];
|
||||
char vendor[SIGAR_SYS_INFO_LEN];
|
||||
char vendor_version[SIGAR_SYS_INFO_LEN];
|
||||
char vendor_name[SIGAR_SYS_INFO_LEN]; /* utsname.sysname */
|
||||
char vendor_code_name[SIGAR_SYS_INFO_LEN];
|
||||
} sigar_sys_info_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_sys_info_get(sigar_t *sigar, sigar_sys_info_t *sysinfo);
|
||||
|
||||
#define SIGAR_FQDN_LEN 512
|
||||
|
||||
SIGAR_DECLARE(int) sigar_fqdn_get(sigar_t *sigar, char *name, int namelen);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_rpc_ping(char *hostname,
|
||||
int protocol,
|
||||
unsigned long program,
|
||||
unsigned long version);
|
||||
|
||||
SIGAR_DECLARE(char *) sigar_rpc_strerror(int err);
|
||||
|
||||
SIGAR_DECLARE(char *) sigar_password_get(const char *prompt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
157
go_bindings/Sigar/include/sigar_fileinfo.h
Normal file
157
go_bindings/Sigar/include/sigar_fileinfo.h
Normal file
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005 Hyperic, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Apache" and "Apache Software Foundation" must
|
||||
* not be used to endorse or promote products derived from this
|
||||
* software without prior written permission. For written
|
||||
* permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache",
|
||||
* nor may "Apache" appear in their name, without prior written
|
||||
* permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*/
|
||||
|
||||
#include "sigar.h"
|
||||
|
||||
typedef enum {
|
||||
SIGAR_FILETYPE_NOFILE = 0, /**< no file type determined */
|
||||
SIGAR_FILETYPE_REG, /**< a regular file */
|
||||
SIGAR_FILETYPE_DIR, /**< a directory */
|
||||
SIGAR_FILETYPE_CHR, /**< a character device */
|
||||
SIGAR_FILETYPE_BLK, /**< a block device */
|
||||
SIGAR_FILETYPE_PIPE, /**< a FIFO / pipe */
|
||||
SIGAR_FILETYPE_LNK, /**< a symbolic link */
|
||||
SIGAR_FILETYPE_SOCK, /**< a [unix domain] socket */
|
||||
SIGAR_FILETYPE_UNKFILE /**< a file of some other unknown type */
|
||||
} sigar_file_type_e;
|
||||
|
||||
#define SIGAR_UREAD 0x0400 /**< Read by user */
|
||||
#define SIGAR_UWRITE 0x0200 /**< Write by user */
|
||||
#define SIGAR_UEXECUTE 0x0100 /**< Execute by user */
|
||||
|
||||
#define SIGAR_GREAD 0x0040 /**< Read by group */
|
||||
#define SIGAR_GWRITE 0x0020 /**< Write by group */
|
||||
#define SIGAR_GEXECUTE 0x0010 /**< Execute by group */
|
||||
|
||||
#define SIGAR_WREAD 0x0004 /**< Read by others */
|
||||
#define SIGAR_WWRITE 0x0002 /**< Write by others */
|
||||
#define SIGAR_WEXECUTE 0x0001 /**< Execute by others */
|
||||
|
||||
typedef struct {
|
||||
/** The access permissions of the file. Mimics Unix access rights. */
|
||||
sigar_uint64_t permissions;
|
||||
sigar_file_type_e type;
|
||||
/** The user id that owns the file */
|
||||
sigar_uid_t uid;
|
||||
/** The group id that owns the file */
|
||||
sigar_gid_t gid;
|
||||
/** The inode of the file. */
|
||||
sigar_uint64_t inode;
|
||||
/** The id of the device the file is on. */
|
||||
sigar_uint64_t device;
|
||||
/** The number of hard links to the file. */
|
||||
sigar_uint64_t nlink;
|
||||
/** The size of the file */
|
||||
sigar_uint64_t size;
|
||||
/** The time the file was last accessed */
|
||||
sigar_uint64_t atime;
|
||||
/** The time the file was last modified */
|
||||
sigar_uint64_t mtime;
|
||||
/** The time the file was last changed */
|
||||
sigar_uint64_t ctime;
|
||||
} sigar_file_attrs_t;
|
||||
|
||||
typedef struct {
|
||||
sigar_uint64_t total;
|
||||
sigar_uint64_t files;
|
||||
sigar_uint64_t subdirs;
|
||||
sigar_uint64_t symlinks;
|
||||
sigar_uint64_t chrdevs;
|
||||
sigar_uint64_t blkdevs;
|
||||
sigar_uint64_t sockets;
|
||||
sigar_uint64_t disk_usage;
|
||||
} sigar_dir_stat_t;
|
||||
|
||||
typedef sigar_dir_stat_t sigar_dir_usage_t;
|
||||
|
||||
SIGAR_DECLARE(const char *)
|
||||
sigar_file_attrs_type_string_get(sigar_file_type_e type);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_file_attrs_get(sigar_t *sigar,
|
||||
const char *file,
|
||||
sigar_file_attrs_t *fileattrs);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_link_attrs_get(sigar_t *sigar,
|
||||
const char *file,
|
||||
sigar_file_attrs_t *fileattrs);
|
||||
|
||||
SIGAR_DECLARE(int)sigar_file_attrs_mode_get(sigar_uint64_t permissions);
|
||||
|
||||
SIGAR_DECLARE(char *)
|
||||
sigar_file_attrs_permissions_string_get(sigar_uint64_t permissions,
|
||||
char *str);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_dir_stat_get(sigar_t *sigar,
|
||||
const char *dir,
|
||||
sigar_dir_stat_t *dirstats);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_dir_usage_get(sigar_t *sigar,
|
||||
const char *dir,
|
||||
sigar_dir_usage_t *dirusage);
|
65
go_bindings/Sigar/include/sigar_format.h
Normal file
65
go_bindings/Sigar/include/sigar_format.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2007-2008 Hyperic, Inc.
|
||||
* Copyright (c) 2009 SpringSource, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SIGAR_FORMAT_H
|
||||
#define SIGAR_FORMAT_H
|
||||
|
||||
typedef struct {
|
||||
double user;
|
||||
double sys;
|
||||
double nice;
|
||||
double idle;
|
||||
double wait;
|
||||
double irq;
|
||||
double soft_irq;
|
||||
double stolen;
|
||||
double combined;
|
||||
} sigar_cpu_perc_t;
|
||||
|
||||
SIGAR_DECLARE(int) sigar_cpu_perc_calculate(sigar_cpu_t *prev,
|
||||
sigar_cpu_t *curr,
|
||||
sigar_cpu_perc_t *perc);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_uptime_string(sigar_t *sigar,
|
||||
sigar_uptime_t *uptime,
|
||||
char *buffer,
|
||||
int buflen);
|
||||
|
||||
SIGAR_DECLARE(char *) sigar_format_size(sigar_uint64_t size, char *buf);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_net_address_equals(sigar_net_address_t *addr1,
|
||||
sigar_net_address_t *addr2);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_net_address_to_string(sigar_t *sigar,
|
||||
sigar_net_address_t *address,
|
||||
char *addr_str);
|
||||
|
||||
SIGAR_DECLARE(const char *)sigar_net_scope_to_string(int type);
|
||||
|
||||
SIGAR_DECLARE(sigar_uint32_t) sigar_net_address_hash(sigar_net_address_t *address);
|
||||
|
||||
SIGAR_DECLARE(const char *)sigar_net_connection_type_get(int type);
|
||||
|
||||
SIGAR_DECLARE(const char *)sigar_net_connection_state_get(int state);
|
||||
|
||||
SIGAR_DECLARE(char *) sigar_net_interface_flags_to_string(sigar_uint64_t flags, char *buf);
|
||||
|
||||
SIGAR_DECLARE(char *)sigar_net_services_name_get(sigar_t *sigar,
|
||||
int protocol, unsigned long port);
|
||||
|
||||
#endif
|
||||
|
18
go_bindings/Sigar/include/sigar_getline.h
Normal file
18
go_bindings/Sigar/include/sigar_getline.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef SIGAR_GETLINE_H
|
||||
#define SIGAR_GETLINE_H
|
||||
|
||||
#include "sigar.h"
|
||||
|
||||
typedef int (*sigar_getline_completer_t)(char *, int, int *);
|
||||
|
||||
SIGAR_DECLARE(char *) sigar_getline(char *prompt);
|
||||
SIGAR_DECLARE(void) sigar_getline_setwidth(int width);
|
||||
SIGAR_DECLARE(void) sigar_getline_redraw(void);
|
||||
SIGAR_DECLARE(void) sigar_getline_reset(void);
|
||||
SIGAR_DECLARE(void) sigar_getline_windowchanged();
|
||||
SIGAR_DECLARE(void) sigar_getline_histinit(char *file);
|
||||
SIGAR_DECLARE(void) sigar_getline_histadd(char *buf);
|
||||
SIGAR_DECLARE(int) sigar_getline_eof();
|
||||
SIGAR_DECLARE(void) sigar_getline_completer_set(sigar_getline_completer_t func);
|
||||
|
||||
#endif /* SIGAR_GETLINE_H */
|
80
go_bindings/Sigar/include/sigar_log.h
Normal file
80
go_bindings/Sigar/include/sigar_log.h
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2006 Hyperic, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SIGAR_LOG_H
|
||||
#define SIGAR_LOG_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define SIGAR_LOG_FATAL 0
|
||||
#define SIGAR_LOG_ERROR 1
|
||||
#define SIGAR_LOG_WARN 2
|
||||
#define SIGAR_LOG_INFO 3
|
||||
#define SIGAR_LOG_DEBUG 4
|
||||
#define SIGAR_LOG_TRACE 5
|
||||
|
||||
#define SIGAR_LOG_IS_FATAL(sigar) \
|
||||
(sigar->log_level >= SIGAR_LOG_FATAL)
|
||||
|
||||
#define SIGAR_LOG_IS_ERROR(sigar) \
|
||||
(sigar->log_level >= SIGAR_LOG_ERROR)
|
||||
|
||||
#define SIGAR_LOG_IS_WARN(sigar) \
|
||||
(sigar->log_level >= SIGAR_LOG_WARN)
|
||||
|
||||
#define SIGAR_LOG_IS_INFO(sigar) \
|
||||
(sigar->log_level >= SIGAR_LOG_INFO)
|
||||
|
||||
#define SIGAR_LOG_IS_DEBUG(sigar) \
|
||||
(sigar->log_level >= SIGAR_LOG_DEBUG)
|
||||
|
||||
#define SIGAR_LOG_IS_TRACE(sigar) \
|
||||
(sigar->log_level >= SIGAR_LOG_TRACE)
|
||||
|
||||
#define SIGAR_STRINGIFY(n) #n
|
||||
|
||||
#define SIGAR_LOG_FILELINE \
|
||||
__FILE__ ":" SIGAR_STRINGIFY(__LINE__)
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ > 2)
|
||||
# define SIGAR_FUNC __func__
|
||||
# else
|
||||
# define SIGAR_FUNC __FUNCTION__
|
||||
# endif
|
||||
#else
|
||||
# define SIGAR_FUNC SIGAR_LOG_FILELINE
|
||||
#endif
|
||||
|
||||
typedef void (*sigar_log_impl_t)(sigar_t *, void *, int, char *);
|
||||
|
||||
SIGAR_DECLARE(void) sigar_log_printf(sigar_t *sigar, int level,
|
||||
const char *format, ...);
|
||||
|
||||
SIGAR_DECLARE(void) sigar_log(sigar_t *sigar, int level, char *message);
|
||||
|
||||
SIGAR_DECLARE(void) sigar_log_impl_set(sigar_t *sigar, void *data,
|
||||
sigar_log_impl_t impl);
|
||||
|
||||
SIGAR_DECLARE(void) sigar_log_impl_file(sigar_t *sigar, void *data,
|
||||
int level, char *message);
|
||||
|
||||
SIGAR_DECLARE(int) sigar_log_level_get(sigar_t *sigar);
|
||||
|
||||
SIGAR_DECLARE(void) sigar_log_level_set(sigar_t *sigar, int level);
|
||||
|
||||
|
||||
#endif /* SIGAR_LOG_H */
|
685
go_bindings/Sigar/include/sigar_os.h
Normal file
685
go_bindings/Sigar/include/sigar_os.h
Normal file
@ -0,0 +1,685 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2009 Hyperic, Inc.
|
||||
* Copyright (c) 2009 SpringSource, Inc.
|
||||
* Copyright (c) 2009-2010 VMware, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SIGAR_OS_H
|
||||
#define SIGAR_OS_H
|
||||
|
||||
#if !defined(MSVC) && defined(_MSC_VER)
|
||||
#define MSVC
|
||||
#endif
|
||||
|
||||
#ifdef MSVC
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
//#define snprintf _snprintf fixed by ilan
|
||||
#if _MSC_VER <= 1200
|
||||
#define SIGAR_USING_MSC6 /* Visual Studio version 6 */
|
||||
#define HAVE_MIB_IPADDRROW_WTYPE 0
|
||||
#else
|
||||
#define HAVE_MIB_IPADDRROW_WTYPE 1
|
||||
#endif
|
||||
#else
|
||||
/* Cross compiling */
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winreg.h>
|
||||
#include <winperf.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <tlhelp32.h>
|
||||
|
||||
#include "sigar_util.h"
|
||||
|
||||
#ifdef MSVC
|
||||
# define INT64_C(val) val##i64
|
||||
# define SIGAR_DLLFUNC(api, name) \
|
||||
struct { \
|
||||
const char *name; \
|
||||
##api##_##name func; \
|
||||
} ##name
|
||||
#else
|
||||
/* The GCC compiler doesn't require/accept the ## prefix */
|
||||
# define INT64_C(val) val##L
|
||||
# define SIGAR_DLLFUNC(api, name) \
|
||||
struct { \
|
||||
const char *name; \
|
||||
api##_##name func; \
|
||||
} name
|
||||
#endif
|
||||
|
||||
/* see apr/include/arch/win32/atime.h */
|
||||
#define EPOCH_DELTA INT64_C(11644473600000000)
|
||||
|
||||
#define SIGAR_CMDLINE_MAX 4096<<2
|
||||
|
||||
/* XXX: support CP_UTF8 ? */
|
||||
|
||||
#define SIGAR_A2W(lpa, lpw, bytes) \
|
||||
(lpw[0] = 0, MultiByteToWideChar(CP_ACP, 0, \
|
||||
lpa, -1, lpw, (bytes/sizeof(WCHAR))))
|
||||
|
||||
#define SIGAR_W2A(lpw, lpa, chars) \
|
||||
(lpa[0] = '\0', WideCharToMultiByte(CP_ACP, 0, \
|
||||
lpw, -1, (LPSTR)lpa, chars, \
|
||||
NULL, NULL))
|
||||
|
||||
/* iptypes.h from vc7, not available in vc6 */
|
||||
/* copy from PSDK if using vc6 */
|
||||
#include "iptypes.h"
|
||||
|
||||
/* from wtsapi32.h not in vs6.0 */
|
||||
typedef enum {
|
||||
WTSInitialProgram,
|
||||
WTSApplicationName,
|
||||
WTSWorkingDirectory,
|
||||
WTSOEMId,
|
||||
WTSSessionId,
|
||||
WTSUserName,
|
||||
WTSWinStationName,
|
||||
WTSDomainName,
|
||||
WTSConnectState,
|
||||
WTSClientBuildNumber,
|
||||
WTSClientName,
|
||||
WTSClientDirectory,
|
||||
WTSClientProductId,
|
||||
WTSClientHardwareId,
|
||||
WTSClientAddress,
|
||||
WTSClientDisplay,
|
||||
WTSClientProtocolType,
|
||||
} WTS_INFO_CLASS;
|
||||
|
||||
typedef enum _WTS_CONNECTSTATE_CLASS {
|
||||
WTSActive,
|
||||
WTSConnected,
|
||||
WTSConnectQuery,
|
||||
WTSShadow,
|
||||
WTSDisconnected,
|
||||
WTSIdle,
|
||||
WTSListen,
|
||||
WTSReset,
|
||||
WTSDown,
|
||||
WTSInit
|
||||
} WTS_CONNECTSTATE_CLASS;
|
||||
|
||||
#define WTS_PROTOCOL_TYPE_CONSOLE 0
|
||||
#define WTS_PROTOCOL_TYPE_ICA 1
|
||||
#define WTS_PROTOCOL_TYPE_RDP 2
|
||||
|
||||
typedef struct _WTS_SESSION_INFO {
|
||||
DWORD SessionId;
|
||||
LPTSTR pWinStationName;
|
||||
DWORD State;
|
||||
} WTS_SESSION_INFO, *PWTS_SESSION_INFO;
|
||||
|
||||
typedef struct _WTS_PROCESS_INFO {
|
||||
DWORD SessionId;
|
||||
DWORD ProcessId;
|
||||
LPSTR pProcessName;
|
||||
PSID pUserSid;
|
||||
} WTS_PROCESS_INFO, *PWTS_PROCESS_INFO;
|
||||
|
||||
typedef struct _WTS_CLIENT_ADDRESS {
|
||||
DWORD AddressFamily;
|
||||
BYTE Address[20];
|
||||
} WTS_CLIENT_ADDRESS, *PWTS_CLIENT_ADDRESS;
|
||||
|
||||
/* the WINSTATION_INFO stuff here is undocumented
|
||||
* got the howto from google groups:
|
||||
* http://redirx.com/?31gy
|
||||
*/
|
||||
typedef enum _WINSTATION_INFO_CLASS {
|
||||
WinStationInformation = 8
|
||||
} WINSTATION_INFO_CLASS;
|
||||
|
||||
typedef struct _WINSTATION_INFO {
|
||||
BYTE Reserved1[72];
|
||||
ULONG SessionId;
|
||||
BYTE Reserved2[4];
|
||||
FILETIME ConnectTime;
|
||||
FILETIME DisconnectTime;
|
||||
FILETIME LastInputTime;
|
||||
FILETIME LoginTime;
|
||||
BYTE Reserved3[1096];
|
||||
FILETIME CurrentTime;
|
||||
} WINSTATION_INFO, *PWINSTATION_INFO;
|
||||
|
||||
/* end wtsapi32.h */
|
||||
|
||||
#ifdef SIGAR_USING_MSC6
|
||||
|
||||
/* from winbase.h not in vs6.0 */
|
||||
typedef struct {
|
||||
DWORD dwLength;
|
||||
DWORD dwMemoryLoad;
|
||||
DWORDLONG ullTotalPhys;
|
||||
DWORDLONG ullAvailPhys;
|
||||
DWORDLONG ullTotalPageFile;
|
||||
DWORDLONG ullAvailPageFile;
|
||||
DWORDLONG ullTotalVirtual;
|
||||
DWORDLONG ullAvailVirtual;
|
||||
DWORDLONG ullAvailExtendedVirtual;
|
||||
} MEMORYSTATUSEX;
|
||||
|
||||
/* service manager stuff not in vs6.0 */
|
||||
typedef struct _SERVICE_STATUS_PROCESS {
|
||||
DWORD dwServiceType;
|
||||
DWORD dwCurrentState;
|
||||
DWORD dwControlsAccepted;
|
||||
DWORD dwWin32ExitCode;
|
||||
DWORD dwServiceSpecificExitCode;
|
||||
DWORD dwCheckPoint;
|
||||
DWORD dwWaitHint;
|
||||
DWORD dwProcessId;
|
||||
DWORD dwServiceFlags;
|
||||
} SERVICE_STATUS_PROCESS;
|
||||
|
||||
typedef enum {
|
||||
SC_STATUS_PROCESS_INFO = 0
|
||||
} SC_STATUS_TYPE;
|
||||
|
||||
#ifndef ERROR_DATATYPE_MISMATCH
|
||||
#define ERROR_DATATYPE_MISMATCH 1629L
|
||||
#endif
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#include <iprtrmib.h>
|
||||
|
||||
/* undocumented structures */
|
||||
typedef struct {
|
||||
DWORD dwState;
|
||||
DWORD dwLocalAddr;
|
||||
DWORD dwLocalPort;
|
||||
DWORD dwRemoteAddr;
|
||||
DWORD dwRemotePort;
|
||||
DWORD dwProcessId;
|
||||
} MIB_TCPEXROW, *PMIB_TCPEXROW;
|
||||
|
||||
typedef struct {
|
||||
DWORD dwNumEntries;
|
||||
MIB_TCPEXROW table[ANY_SIZE];
|
||||
} MIB_TCPEXTABLE, *PMIB_TCPEXTABLE;
|
||||
|
||||
typedef struct {
|
||||
DWORD dwLocalAddr;
|
||||
DWORD dwLocalPort;
|
||||
DWORD dwProcessId;
|
||||
} MIB_UDPEXROW, *PMIB_UDPEXROW;
|
||||
|
||||
typedef struct {
|
||||
DWORD dwNumEntries;
|
||||
MIB_UDPEXROW table[ANY_SIZE];
|
||||
} MIB_UDPEXTABLE, *PMIB_UDPEXTABLE;
|
||||
|
||||
/* end undocumented structures */
|
||||
|
||||
/* no longer in the standard header files */
|
||||
typedef struct {
|
||||
LARGE_INTEGER IdleTime;
|
||||
LARGE_INTEGER KernelTime;
|
||||
LARGE_INTEGER UserTime;
|
||||
LARGE_INTEGER DpcTime;
|
||||
LARGE_INTEGER InterruptTime;
|
||||
ULONG InterruptCount;
|
||||
} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
|
||||
|
||||
#define SystemProcessorPerformanceInformation 8
|
||||
|
||||
/* PEB decls from msdn docs w/ slight mods */
|
||||
#define ProcessBasicInformation 0
|
||||
|
||||
typedef struct _UNICODE_STRING {
|
||||
USHORT Length;
|
||||
USHORT MaximumLength;
|
||||
PWSTR Buffer;
|
||||
} UNICODE_STRING, *PUNICODE_STRING;
|
||||
|
||||
typedef struct _PEB_LDR_DATA {
|
||||
BYTE Reserved1[8];
|
||||
PVOID Reserved2[3];
|
||||
LIST_ENTRY InMemoryOrderModuleList;
|
||||
} PEB_LDR_DATA, *PPEB_LDR_DATA;
|
||||
|
||||
typedef struct RTL_DRIVE_LETTER_CURDIR {
|
||||
USHORT Flags;
|
||||
USHORT Length;
|
||||
ULONG TimeStamp;
|
||||
UNICODE_STRING DosPath;
|
||||
} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
|
||||
|
||||
/* from: http://source.winehq.org/source/include/winternl.h */
|
||||
typedef struct _RTL_USER_PROCESS_PARAMETERS {
|
||||
ULONG AllocationSize;
|
||||
ULONG Size;
|
||||
ULONG Flags;
|
||||
ULONG DebugFlags;
|
||||
HANDLE hConsole;
|
||||
ULONG ProcessGroup;
|
||||
HANDLE hStdInput;
|
||||
HANDLE hStdOutput;
|
||||
HANDLE hStdError;
|
||||
UNICODE_STRING CurrentDirectoryName;
|
||||
HANDLE CurrentDirectoryHandle;
|
||||
UNICODE_STRING DllPath;
|
||||
UNICODE_STRING ImagePathName;
|
||||
UNICODE_STRING CommandLine;
|
||||
PWSTR Environment;
|
||||
ULONG dwX;
|
||||
ULONG dwY;
|
||||
ULONG dwXSize;
|
||||
ULONG dwYSize;
|
||||
ULONG dwXCountChars;
|
||||
ULONG dwYCountChars;
|
||||
ULONG dwFillAttribute;
|
||||
ULONG dwFlags;
|
||||
ULONG wShowWindow;
|
||||
UNICODE_STRING WindowTitle;
|
||||
UNICODE_STRING Desktop;
|
||||
UNICODE_STRING ShellInfo;
|
||||
UNICODE_STRING RuntimeInfo;
|
||||
RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
|
||||
} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
|
||||
|
||||
/* from msdn docs
|
||||
typedef struct _RTL_USER_PROCESS_PARAMETERS {
|
||||
BYTE Reserved1[16];
|
||||
PVOID Reserved2[10];
|
||||
UNICODE_STRING ImagePathName;
|
||||
UNICODE_STRING CommandLine;
|
||||
} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
|
||||
*/
|
||||
|
||||
typedef struct _PEB {
|
||||
BYTE Reserved1[2];
|
||||
BYTE BeingDebugged;
|
||||
BYTE Reserved2[1];
|
||||
PVOID Reserved3[2];
|
||||
PPEB_LDR_DATA Ldr;
|
||||
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
|
||||
BYTE Reserved4[104];
|
||||
PVOID Reserved5[52];
|
||||
/*PPS_POST_PROCESS_INIT_ROUTINE*/ PVOID PostProcessInitRoutine;
|
||||
BYTE Reserved6[128];
|
||||
PVOID Reserved7[1];
|
||||
ULONG SessionId;
|
||||
} PEB, *PPEB;
|
||||
|
||||
typedef struct _PROCESS_BASIC_INFORMATION {
|
||||
PVOID Reserved1;
|
||||
PPEB PebBaseAddress;
|
||||
PVOID Reserved2[2];
|
||||
/*ULONG_PTR*/ UINT_PTR UniqueProcessId;
|
||||
PVOID Reserved3;
|
||||
} PROCESS_BASIC_INFORMATION;
|
||||
|
||||
typedef struct {
|
||||
sigar_pid_t pid;
|
||||
int ppid;
|
||||
int priority;
|
||||
time_t mtime;
|
||||
sigar_uint64_t size;
|
||||
sigar_uint64_t resident;
|
||||
char name[SIGAR_PROC_NAME_LEN];
|
||||
char state;
|
||||
sigar_uint64_t handles;
|
||||
sigar_uint64_t threads;
|
||||
sigar_uint64_t page_faults;
|
||||
sigar_uint64_t bytes_read;
|
||||
sigar_uint64_t bytes_written;
|
||||
} sigar_win32_pinfo_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
HINSTANCE handle;
|
||||
} sigar_dll_handle_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
FARPROC func;
|
||||
} sigar_dll_func_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
HINSTANCE handle;
|
||||
sigar_dll_func_t funcs[12];
|
||||
} sigar_dll_module_t;
|
||||
|
||||
/* wtsapi.dll */
|
||||
typedef BOOL (CALLBACK *wtsapi_enum_sessions)(HANDLE,
|
||||
DWORD,
|
||||
DWORD,
|
||||
PWTS_SESSION_INFO *,
|
||||
DWORD *);
|
||||
|
||||
typedef void (CALLBACK *wtsapi_free_mem)(PVOID);
|
||||
|
||||
typedef BOOL (CALLBACK *wtsapi_query_session)(HANDLE,
|
||||
DWORD,
|
||||
WTS_INFO_CLASS,
|
||||
LPSTR *, DWORD *);
|
||||
/* iphlpapi.dll */
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_ipforward_table)(PMIB_IPFORWARDTABLE,
|
||||
PULONG,
|
||||
BOOL);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_ipaddr_table)(PMIB_IPADDRTABLE,
|
||||
PULONG,
|
||||
BOOL);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_if_table)(PMIB_IFTABLE,
|
||||
PULONG,
|
||||
BOOL);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_if_entry)(PMIB_IFROW);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_num_if)(PDWORD);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_tcp_table)(PMIB_TCPTABLE,
|
||||
PDWORD,
|
||||
BOOL);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_udp_table)(PMIB_UDPTABLE,
|
||||
PDWORD,
|
||||
BOOL);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_tcpx_table)(PMIB_TCPEXTABLE *,
|
||||
BOOL,
|
||||
HANDLE,
|
||||
DWORD,
|
||||
DWORD);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_udpx_table)(PMIB_UDPEXTABLE *,
|
||||
BOOL,
|
||||
HANDLE,
|
||||
DWORD,
|
||||
DWORD);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_tcp_stats)(PMIB_TCPSTATS);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_net_params)(PFIXED_INFO,
|
||||
PULONG);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_adapters_info)(PIP_ADAPTER_INFO,
|
||||
PULONG);
|
||||
|
||||
typedef ULONG (CALLBACK *iphlpapi_get_adapters_addrs)(ULONG,
|
||||
ULONG,
|
||||
PVOID,
|
||||
PIP_ADAPTER_ADDRESSES,
|
||||
PULONG);
|
||||
|
||||
/* advapi32.dll */
|
||||
typedef BOOL (CALLBACK *advapi_convert_string_sid)(LPCSTR,
|
||||
PSID *);
|
||||
|
||||
typedef BOOL (CALLBACK *advapi_query_service_status)(SC_HANDLE,
|
||||
SC_STATUS_TYPE,
|
||||
LPBYTE,
|
||||
DWORD,
|
||||
LPDWORD);
|
||||
|
||||
typedef DWORD (CALLBACK *iphlpapi_get_ipnet_table)(PMIB_IPNETTABLE,
|
||||
PDWORD,
|
||||
BOOL);
|
||||
|
||||
/* ntdll.dll */
|
||||
typedef DWORD (CALLBACK *ntdll_query_sys_info)(DWORD,
|
||||
PVOID,
|
||||
ULONG,
|
||||
PULONG);
|
||||
|
||||
typedef DWORD (CALLBACK *ntdll_query_proc_info)(HANDLE,
|
||||
DWORD,
|
||||
PVOID,
|
||||
ULONG,
|
||||
PULONG);
|
||||
|
||||
/* psapi.dll */
|
||||
typedef BOOL (CALLBACK *psapi_enum_modules)(HANDLE,
|
||||
HMODULE *,
|
||||
DWORD,
|
||||
LPDWORD);
|
||||
|
||||
typedef DWORD (CALLBACK *psapi_get_module_name)(HANDLE,
|
||||
HMODULE,
|
||||
LPTSTR,
|
||||
DWORD);
|
||||
|
||||
typedef BOOL (CALLBACK *psapi_enum_processes)(DWORD *,
|
||||
DWORD,
|
||||
DWORD *);
|
||||
|
||||
/* winsta.dll */
|
||||
typedef BOOLEAN (CALLBACK *winsta_query_info)(HANDLE,
|
||||
ULONG,
|
||||
WINSTATION_INFO_CLASS,
|
||||
PVOID,
|
||||
ULONG,
|
||||
PULONG);
|
||||
|
||||
/* kernel32.dll */
|
||||
typedef BOOL (CALLBACK *kernel_memory_status)(MEMORYSTATUSEX *);
|
||||
|
||||
/* mpr.dll */
|
||||
typedef BOOL (CALLBACK *mpr_get_net_connection)(LPCTSTR,
|
||||
LPTSTR,
|
||||
LPDWORD);
|
||||
|
||||
typedef struct {
|
||||
sigar_dll_handle_t handle;
|
||||
|
||||
SIGAR_DLLFUNC(wtsapi, enum_sessions);
|
||||
SIGAR_DLLFUNC(wtsapi, free_mem);
|
||||
SIGAR_DLLFUNC(wtsapi, query_session);
|
||||
|
||||
sigar_dll_func_t end;
|
||||
} sigar_wtsapi_t;
|
||||
|
||||
typedef struct {
|
||||
sigar_dll_handle_t handle;
|
||||
|
||||
SIGAR_DLLFUNC(iphlpapi, get_ipforward_table);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_ipaddr_table);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_if_table);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_if_entry);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_num_if);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_tcp_table);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_udp_table);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_tcpx_table);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_udpx_table);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_tcp_stats);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_net_params);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_adapters_info);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_adapters_addrs);
|
||||
SIGAR_DLLFUNC(iphlpapi, get_ipnet_table);
|
||||
|
||||
sigar_dll_func_t end;
|
||||
} sigar_iphlpapi_t;
|
||||
|
||||
typedef struct {
|
||||
sigar_dll_handle_t handle;
|
||||
|
||||
SIGAR_DLLFUNC(advapi, convert_string_sid);
|
||||
SIGAR_DLLFUNC(advapi, query_service_status);
|
||||
|
||||
sigar_dll_func_t end;
|
||||
} sigar_advapi_t;
|
||||
|
||||
typedef struct {
|
||||
sigar_dll_handle_t handle;
|
||||
|
||||
SIGAR_DLLFUNC(ntdll, query_sys_info);
|
||||
SIGAR_DLLFUNC(ntdll, query_proc_info);
|
||||
|
||||
sigar_dll_func_t end;
|
||||
} sigar_ntdll_t;
|
||||
|
||||
typedef struct {
|
||||
sigar_dll_handle_t handle;
|
||||
|
||||
SIGAR_DLLFUNC(psapi, enum_modules);
|
||||
SIGAR_DLLFUNC(psapi, enum_processes);
|
||||
SIGAR_DLLFUNC(psapi, get_module_name);
|
||||
|
||||
sigar_dll_func_t end;
|
||||
} sigar_psapi_t;
|
||||
|
||||
typedef struct {
|
||||
sigar_dll_handle_t handle;
|
||||
|
||||
SIGAR_DLLFUNC(winsta, query_info);
|
||||
|
||||
sigar_dll_func_t end;
|
||||
} sigar_winsta_t;
|
||||
|
||||
typedef struct {
|
||||
sigar_dll_handle_t handle;
|
||||
|
||||
SIGAR_DLLFUNC(kernel, memory_status);
|
||||
|
||||
sigar_dll_func_t end;
|
||||
} sigar_kernel_t;
|
||||
|
||||
typedef struct {
|
||||
sigar_dll_handle_t handle;
|
||||
|
||||
SIGAR_DLLFUNC(mpr, get_net_connection);
|
||||
|
||||
sigar_dll_func_t end;
|
||||
} sigar_mpr_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *buffer;
|
||||
DWORD size;
|
||||
time_t create_time;
|
||||
} buffer_t;
|
||||
|
||||
struct sigar_t {
|
||||
SIGAR_T_BASE;
|
||||
char *machine;
|
||||
int using_wide;
|
||||
long pagesize;
|
||||
HKEY handle;
|
||||
buffer_t** performanceBuffers;
|
||||
buffer_t* processesBuffer;
|
||||
sigar_wtsapi_t wtsapi;
|
||||
sigar_iphlpapi_t iphlpapi;
|
||||
sigar_advapi_t advapi;
|
||||
sigar_ntdll_t ntdll;
|
||||
sigar_psapi_t psapi;
|
||||
sigar_winsta_t winsta;
|
||||
sigar_kernel_t kernel;
|
||||
sigar_mpr_t mpr;
|
||||
sigar_win32_pinfo_t pinfo;
|
||||
sigar_cache_t *netif_adapters;
|
||||
sigar_cache_t *netif_mib_rows;
|
||||
sigar_cache_t *netif_addr_rows;
|
||||
sigar_cache_t *netif_names; /* dwIndex -> net_interface_config.name */
|
||||
int netif_name_short;
|
||||
|
||||
WORD ws_version;
|
||||
int ws_error;
|
||||
int ht_enabled;
|
||||
int lcpu; //number of logical cpus
|
||||
int winnt;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
sigar_uint64_t sigar_FileTimeToTime(FILETIME *ft);
|
||||
|
||||
int sigar_wsa_init(sigar_t *sigar);
|
||||
|
||||
int sigar_proc_exe_peb_get(sigar_t *sigar, HANDLE proc,
|
||||
sigar_proc_exe_t *procexe);
|
||||
|
||||
int sigar_proc_args_peb_get(sigar_t *sigar, HANDLE proc,
|
||||
sigar_proc_args_t *procargs);
|
||||
|
||||
int sigar_proc_env_peb_get(sigar_t *sigar, HANDLE proc,
|
||||
WCHAR *env, DWORD envlen);
|
||||
|
||||
int sigar_proc_args_wmi_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_args_t *procargs);
|
||||
|
||||
int sigar_proc_exe_wmi_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_exe_t *procexe);
|
||||
|
||||
int sigar_parse_proc_args(sigar_t *sigar, WCHAR *buf,
|
||||
sigar_proc_args_t *procargs);
|
||||
|
||||
int sigar_service_pid_get(sigar_t *sigar, char *name, sigar_pid_t *pid);
|
||||
|
||||
typedef struct {
|
||||
DWORD size;
|
||||
DWORD count;
|
||||
ENUM_SERVICE_STATUS *services;
|
||||
SC_HANDLE handle;
|
||||
} sigar_services_status_t;
|
||||
|
||||
int sigar_services_status_get(sigar_services_status_t *ss, DWORD state);
|
||||
|
||||
void sigar_services_status_close(sigar_services_status_t *ss);
|
||||
|
||||
typedef struct sigar_services_walker_t sigar_services_walker_t;
|
||||
|
||||
struct sigar_services_walker_t {
|
||||
sigar_t *sigar;
|
||||
int flags;
|
||||
void *data; /* user data */
|
||||
int (*add_service)(sigar_services_walker_t *walker, char *name);
|
||||
};
|
||||
|
||||
int sigar_services_query(char *ptql,
|
||||
sigar_ptql_error_t *error,
|
||||
sigar_services_walker_t *walker);
|
||||
|
||||
char *sigar_service_exe_get(char *path, char *buffer, int basename);
|
||||
|
||||
typedef struct {
|
||||
WORD product_major;
|
||||
WORD product_minor;
|
||||
WORD product_build;
|
||||
WORD product_revision;
|
||||
WORD file_major;
|
||||
WORD file_minor;
|
||||
WORD file_build;
|
||||
WORD file_revision;
|
||||
} sigar_file_version_t;
|
||||
|
||||
int sigar_file_version_get(sigar_file_version_t *version,
|
||||
char *name,
|
||||
sigar_proc_env_t *infocb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SIGAR_NO_SUCH_PROCESS (SIGAR_OS_START_ERROR+1)
|
||||
|
||||
#endif /* SIGAR_OS_H */
|
47
go_bindings/Sigar/include/sigar_pdh.h
Normal file
47
go_bindings/Sigar/include/sigar_pdh.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2006 Hyperic, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SIGAR_PDH_H
|
||||
#define SIGAR_PDH_H
|
||||
|
||||
/* performance data helpers */
|
||||
|
||||
#define PdhFirstObject(block) \
|
||||
((PERF_OBJECT_TYPE *)((BYTE *) block + block->HeaderLength))
|
||||
|
||||
#define PdhNextObject(object) \
|
||||
((PERF_OBJECT_TYPE *)((BYTE *) object + object->TotalByteLength))
|
||||
|
||||
#define PdhFirstCounter(object) \
|
||||
((PERF_COUNTER_DEFINITION *)((BYTE *) object + object->HeaderLength))
|
||||
|
||||
#define PdhNextCounter(counter) \
|
||||
((PERF_COUNTER_DEFINITION *)((BYTE *) counter + counter->ByteLength))
|
||||
|
||||
#define PdhGetCounterBlock(inst) \
|
||||
((PERF_COUNTER_BLOCK *)((BYTE *) inst + inst->ByteLength))
|
||||
|
||||
#define PdhFirstInstance(object) \
|
||||
((PERF_INSTANCE_DEFINITION *)((BYTE *) object + object->DefinitionLength))
|
||||
|
||||
#define PdhNextInstance(inst) \
|
||||
((PERF_INSTANCE_DEFINITION *)((BYTE *)inst + inst->ByteLength + \
|
||||
PdhGetCounterBlock(inst)->ByteLength))
|
||||
|
||||
#define PdhInstanceName(inst) \
|
||||
((wchar_t *)((BYTE *)inst + inst->NameOffset))
|
||||
|
||||
#endif /* SIGAR_PDH_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user