Compare commits
99
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80016c67c7 | ||
|
|
de915ae0d1 | ||
|
|
4d0046fa25 | ||
|
|
4bffa314d2 | ||
|
|
9326fe4a99 | ||
|
|
b8d4a04dfe | ||
|
|
c8609e9e4a | ||
|
|
7d483e3982 | ||
|
|
ce39c1ad1e | ||
|
|
22e9e06b9d | ||
|
|
3f3a070045 | ||
|
|
e9e3dce323 | ||
|
|
d048e0ccdc | ||
|
|
89b0b68ece | ||
|
|
07941d4304 | ||
|
|
8866170e52 | ||
|
|
bc492c8945 | ||
|
|
0e0d7ea1f7 | ||
|
|
46427ad949 | ||
|
|
2b0c7f8205 | ||
|
|
a788e2b6e2 | ||
|
|
d29ef6d6ac | ||
|
|
2b00bad1c1 | ||
|
|
d3d35e937f | ||
|
|
621f9ccb61 | ||
|
|
3366588f85 | ||
|
|
4f223cc4d6 | ||
|
|
af75428ab6 | ||
|
|
bb5fec3790 | ||
|
|
b3abdd5a53 | ||
|
|
eeadfd104b | ||
|
|
bace63f710 | ||
|
|
91ba1a2c3d | ||
|
|
596bc2a522 | ||
|
|
a04e2db66f | ||
|
|
fb9a5f3357 | ||
|
|
64a6f41925 | ||
|
|
26872fdda0 | ||
|
|
cb8eb6b183 | ||
|
|
5ac96fb803 | ||
|
|
f1e3a4c37c | ||
|
|
3ab4e297a9 | ||
|
|
9fec04ad66 | ||
|
|
289f024956 | ||
|
|
5e4d11f6ce | ||
|
|
4c5873885e | ||
|
|
8c8d4cf814 | ||
|
|
039080f722 | ||
|
|
68cf08cf4d | ||
|
|
6d6b5577b1 | ||
|
|
880a24ad30 | ||
|
|
ae289d3d41 | ||
|
|
b64ebca57e | ||
|
|
bc3e8ed6d4 | ||
|
|
7ef48da327 | ||
|
|
7a5288278c | ||
|
|
2e3c302f4f | ||
|
|
93afe26132 | ||
|
|
22dec9316c | ||
|
|
9774d05e20 | ||
|
|
bca7314718 | ||
|
|
bf342bc9cf | ||
|
|
3a9d6b7024 | ||
|
|
95dcc68c57 | ||
|
|
5d50f402bb | ||
|
|
5df4c608b4 | ||
|
|
143e8fb6bd | ||
|
|
e787667e91 | ||
|
|
1cd800ff6e | ||
|
|
08cfdfef6e | ||
|
|
a7495637a9 | ||
|
|
bd2178d0cf | ||
|
|
6db07f1cba | ||
|
|
ede7b6c9de | ||
|
|
bf61ce78a9 | ||
|
|
0175e969e1 | ||
|
|
be5f4930a7 | ||
|
|
4c441a3ee2 | ||
|
|
06f4770bf0 | ||
|
|
1ccf48ca19 | ||
|
|
4867aeb235 | ||
|
|
d19ab5ae30 | ||
|
|
8e9ab74eee | ||
|
|
c2114a71e1 | ||
|
|
ec7d726a9d | ||
|
|
26f2977533 | ||
|
|
b3b194e97b | ||
|
|
f2c9cc9d61 | ||
|
|
b1890e438d | ||
|
|
4424c48981 | ||
|
|
a6b5f3f30b | ||
|
|
61327b9034 | ||
|
|
7ac30e778a | ||
|
|
9b4dd7b263 | ||
|
|
29d57da8a9 | ||
|
|
898e933070 | ||
|
|
19a76d5fa1 | ||
|
|
4f4805ffd1 | ||
|
|
5c905c8e64 |
No files matched your search
@@ -1,3 +1,141 @@
|
||||
2008-07-13 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* 1.6.3 release
|
||||
|
||||
2009-07-08 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-130) Use pstat(PSTAT_GETCOMMANDLINE,...) on HP-UX < 11iv2
|
||||
|
||||
* (SIGAR-130) Use pstat_getcommandline on HP-UX 11iv2+
|
||||
|
||||
* (SIGAR-131) switch to pst_fileinfo2 on all HPUX flavors
|
||||
|
||||
2009-07-08 Jon Travis <jtravis@p00p.org>
|
||||
|
||||
* (SIGAR-150) Wrapper class to synchronize Sigar method invocation
|
||||
|
||||
2009-07-07 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* add getNetServicesName to SigarProxy interface
|
||||
|
||||
2009-07-02 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-145) default to 'Irix mode' for proc_cpu.percent
|
||||
|
||||
* (SIGAR-144) Solaris net_interface_stat should use 64-bit kstats
|
||||
|
||||
2009-07-01 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-148) statfs usage compiled with LFS flags
|
||||
|
||||
2009-06-30 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-152) Add support for 31-bit s390 builds
|
||||
|
||||
2009-06-17 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* darwin sigar_dlinfo_modules impl
|
||||
|
||||
2009-06-06 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-151) Add Modules support to PTQL
|
||||
|
||||
2009-06-01 Kay Röpke <kroepke@classdump.local>
|
||||
|
||||
* (SIGAR-149) fix Darwin side of SIGAR-47: integer multlipcation overflow on
|
||||
32bit builds with more than 4GB available memory
|
||||
|
||||
2009-05-24 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-142) loosen net_interface_list filters on MacOSX
|
||||
|
||||
2009-05-15 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-150) make SigarProxyCached.invoke synchronized
|
||||
|
||||
2009-05-13 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* fix so SigarPermissionDeniedException is throw on open /dev/kmem EACCES
|
||||
|
||||
* add 64-bit compile/link flags for AIX
|
||||
|
||||
* require libperfstat on aix
|
||||
|
||||
2009-04-25 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* getrusage on NetBSD may not return monotonically increasing
|
||||
values for CPU time.
|
||||
|
||||
* (SIGAR-39) Use kern.cp_times in cpu_list on FreeBSD 7.x+
|
||||
|
||||
2009-03-27 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-141) sigar.jar location is not required to find native library
|
||||
|
||||
2009-03-25 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-140) interface aliases are valid in sigar_net_interface_config_primary_get
|
||||
|
||||
2008-02-13 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* 1.6.2 release
|
||||
|
||||
2009-02-12 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-134) use UNICODE in EventLog wrapper
|
||||
|
||||
2009-02-10 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-73) check for 'ocfs' in addition to 'ocfs2'
|
||||
|
||||
2009-02-08 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* (SIGAR-138) Recognize zfs as local filesystem type
|
||||
|
||||
2009-02-06 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* fix osx version on 64-bit platforms
|
||||
|
||||
* [SIGAR-133] use InputStream.skip (bytes) instead of Reader.skip (chars) in onChange
|
||||
|
||||
* [SIGAR-132] Fix possible memory leak in sigar_rpc_ping
|
||||
|
||||
* [SIGAR-129] fix possible integer overflow in time_now_millis
|
||||
|
||||
* [SIGAR-129] add another sanity check
|
||||
|
||||
* [SIGAR-129] prevent possible wrapping
|
||||
|
||||
* [SIGAR-129] prevent possible integer overflow
|
||||
|
||||
* [SIGAR-127] use KERN_ARGMAX for KERN_PROCARGS2 buffer size
|
||||
|
||||
* [SIGAR-126] /dev/kmem not usable in aix 6
|
||||
|
||||
* rid "warning: cast from pointer to integer of different size" on 64-bit builds
|
||||
|
||||
* [SIGAR-125] bring back /private/var/vm swap impl for osx 10.3
|
||||
|
||||
* [SIGAR-123] do not include global shared text+data region size
|
||||
|
||||
* [SIGAR-122] ARG_MAX undefined on glibc 2.8
|
||||
|
||||
2008-09-13 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* include ptql and log in dist headers
|
||||
|
||||
* dont include ant and mx4j jars in dist
|
||||
|
||||
* add cpu_perc typemap to bindings/perl
|
||||
|
||||
2008-09-11 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* [SIGAR-120] Support WoW registry reflection
|
||||
|
||||
2008-09-08 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* [SIGAR-119] Use 64-bit performance counter for uptime
|
||||
|
||||
2008-09-06 Doug MacEachern <dougm@hyperic.com>
|
||||
|
||||
* 1.6 released, change summary:
|
||||
|
||||
@@ -8,10 +8,6 @@ of the projects listed below for their contributions.
|
||||
|
||||
The following components are included without modification:
|
||||
|
||||
- BCEL -
|
||||
Information: http://jakarta.apache.org/bcel/index.html
|
||||
License: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
- log4j -
|
||||
Information: http://logging.apache.org/
|
||||
License: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
@@ -824,22 +824,22 @@ use vars qw(%classes %cmds);
|
||||
FileSystemUsage => [
|
||||
{
|
||||
name => 'total', type => 'Long',
|
||||
desc => 'Total bytes of filesystem',
|
||||
desc => 'Total Kbytes of filesystem',
|
||||
plat => '*'
|
||||
},
|
||||
{
|
||||
name => 'free', type => 'Long',
|
||||
desc => 'Total free bytes on filesystem',
|
||||
desc => 'Total free Kbytes on filesystem',
|
||||
plat => '*'
|
||||
},
|
||||
{
|
||||
name => 'used', type => 'Long',
|
||||
desc => 'Total used bytes on filesystem',
|
||||
desc => 'Total used Kbytes on filesystem',
|
||||
plat => '*'
|
||||
},
|
||||
{
|
||||
name => 'avail', type => 'Long',
|
||||
desc => 'Total free bytes on filesystem available to caller',
|
||||
desc => 'Total free Kbytes on filesystem available to caller',
|
||||
plat => '*'
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
build
|
||||
sigar-bin
|
||||
+36
-18
@@ -141,7 +141,7 @@
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="scm-revision" if="svn.available">
|
||||
<target name="svn-revision" if="svn.available">
|
||||
<exec executable="svnversion" dir="."
|
||||
outputproperty="sigar.scmrev"
|
||||
failifexecutionfails="false">
|
||||
@@ -150,7 +150,31 @@
|
||||
<echo message="SIGAR svn revision #${sigar.scmrev}"/>
|
||||
</target>
|
||||
|
||||
<target name="sigar-version" depends="check-svn,scm-revision">
|
||||
<target name="check-git">
|
||||
<condition property="git.available">
|
||||
<and>
|
||||
<available file="../../.git" type="dir"/>
|
||||
<available file="git" type="file">
|
||||
<filepath>
|
||||
<pathelement path="${env.PATH}"/>
|
||||
</filepath>
|
||||
</available>
|
||||
</and>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="git-revision" if="git.available">
|
||||
<exec executable="git" dir="."
|
||||
outputproperty="sigar.scmrev"
|
||||
failifexecutionfails="false">
|
||||
<arg value="rev-parse"/>
|
||||
<arg value="--short"/>
|
||||
<arg value="HEAD"/>
|
||||
</exec>
|
||||
<echo message="SIGAR git revision #${sigar.scmrev}"/>
|
||||
</target>
|
||||
|
||||
<target name="sigar-version" depends="check-svn,svn-revision,check-git,git-revision">
|
||||
<tstamp>
|
||||
<format property="BUILD_DATE" pattern="MM/dd/yyyy hh:mm aa"/>
|
||||
</tstamp>
|
||||
@@ -169,7 +193,7 @@
|
||||
<param name="version.file"
|
||||
value="src/sigar_version.c"/>
|
||||
<param name="version.tofile"
|
||||
value="${build}/src/sigar_version_${jni.libarch}.c"/>
|
||||
value="${build}/src/sigar_version.c"/>
|
||||
</antcall>
|
||||
|
||||
<antcall target="version-file">
|
||||
@@ -239,7 +263,7 @@
|
||||
<include name="bindings/java/src/${win32.jni}/*.cpp"/>
|
||||
<include name="bindings/java/src/${win32.jni}/*.c"/>
|
||||
<include name="bindings/java/src/${vmware.jni}/*.c"/>
|
||||
<include name="bindings/java/build/src/sigar_version_${jni.libarch}.c"/>
|
||||
<include name="bindings/java/build/src/sigar_version.c"/>
|
||||
</patternset>
|
||||
|
||||
<path id="jni.include.dirs">
|
||||
@@ -263,7 +287,7 @@
|
||||
<isset property="aix"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.libset.libs" value="odm,cfg">
|
||||
<condition property="jni.libset.libs" value="odm,cfg,perfstat,pthreads">
|
||||
<isset property="aix"/>
|
||||
</condition>
|
||||
|
||||
@@ -281,6 +305,8 @@
|
||||
<include name="sigar.h"/>
|
||||
<include name="sigar_fileinfo.h"/>
|
||||
<include name="sigar_format.h"/>
|
||||
<include name="sigar_ptql.h"/>
|
||||
<include name="sigar_log.h"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
@@ -328,15 +354,6 @@
|
||||
depends="jni-init,prepare-src,jni-compile,jni-lib-copy,copy-includes"
|
||||
if="jni.libarch"/>
|
||||
|
||||
<target name="build-perfstat" depends="jni-init" if="aix">
|
||||
<ant dir="../../src/os/aix/perfstat"/>
|
||||
<copy toDir="${sigar-bin}/lib" overwrite="true">
|
||||
<fileset dir="${build}">
|
||||
<include name="libsigar_aixperfstat.so"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="pack">
|
||||
<jar jarfile="${sigar-bin}/lib/${sigar.jar}"
|
||||
basedir="${build}/classes">
|
||||
@@ -348,7 +365,7 @@
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="build-jni,build-perfstat,compile,pack"/>
|
||||
<target name="build" depends="build-jni,compile,pack"/>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${build}"/>
|
||||
@@ -445,7 +462,8 @@
|
||||
<include name="lib/*.lib"/>
|
||||
</fileset>
|
||||
<fileset dir=".">
|
||||
<include name="lib/*.jar"/>
|
||||
<include name="lib/junit.jar"/>
|
||||
<include name="lib/log4j.jar"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
@@ -549,8 +567,8 @@
|
||||
<include name="bindings/java/.classpath"/>
|
||||
<include name="bindings/java/.project"/>
|
||||
<include name="bindings/java/.sigar_shellrc"/>
|
||||
<include name="bindings/java/lib/*.jar"/>
|
||||
<include name="bindings/java/lib/*.dll"/>
|
||||
<include name="bindings/java/lib/log4j.jar"/>
|
||||
<include name="bindings/java/lib/junit.jar"/>
|
||||
<exclude name="**/.svn/**"/>
|
||||
<exclude name="bindings/java/build/**"/>
|
||||
</fileset>
|
||||
|
||||
@@ -0,0 +1,524 @@
|
||||
<!--
|
||||
Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
||||
This file is part of SIGAR.
|
||||
|
||||
SIGAR is free software; you can redistribute it and/or modify
|
||||
it under the terms version 2 of the GNU General Public License as
|
||||
published by the Free Software Foundation. This program is distributed
|
||||
in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA.
|
||||
-->
|
||||
|
||||
<property environment="env"/>
|
||||
|
||||
<property name="build" location="build"/>
|
||||
<property name="jni.bin" location="${build}"/>
|
||||
<property name="jni.define.name" value="JNI"/>
|
||||
<property name="jni.source.dir" value="src"/>
|
||||
<property name="jni.src.java" value="src"/>
|
||||
<property name="jni.libprefix" value="java"/>
|
||||
<property name="jni.libversion" value=""/>
|
||||
<property name="uni.sdk.version" value="4u"/>
|
||||
<property name="osx.min" value="-mmacosx-version-min=10.3"/>
|
||||
|
||||
<property name="cpptasks.jar" location="lib/cpptasks.jar"/>
|
||||
|
||||
<taskdef name="cc" classname="net.sf.antcontrib.cpptasks.CCTask">
|
||||
<classpath location="${cpptasks.jar}"/>
|
||||
</taskdef>
|
||||
|
||||
<target name="jni-init">
|
||||
<mkdir dir="${build}/classes"/>
|
||||
|
||||
<available property="libproc.h" file="/usr/include/libproc.h"/>
|
||||
|
||||
<condition property="jni.debug" value="true">
|
||||
<isset property="jni.dmalloc"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.optim" value="true">
|
||||
<not>
|
||||
<istrue value="${jni.debug}"/>
|
||||
</not>
|
||||
</condition>
|
||||
|
||||
<condition property="static.gcc">
|
||||
<os arch="i386"/><!-- only for x86 solaris -->
|
||||
</condition>
|
||||
|
||||
<condition property="jni.javahome" value="${env.JAVA_HOME}">
|
||||
<isset property="env.JAVA_HOME"/>
|
||||
</condition>
|
||||
<condition property="jni.javahome" value="${java.home}">
|
||||
<not>
|
||||
<isset property="jni.javahome"/>
|
||||
</not>
|
||||
</condition>
|
||||
|
||||
<echo>java.home=${jni.javahome}</echo>
|
||||
|
||||
<checksum file="${jni.javahome}/include/jni.h" property="jni.md5"/>
|
||||
|
||||
<condition property="linux">
|
||||
<equals arg1="${os.name}" arg2="Linux"/>
|
||||
</condition>
|
||||
<condition property="solaris">
|
||||
<equals arg1="${os.name}" arg2="SunOS"/>
|
||||
</condition>
|
||||
<condition property="win32">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="hpux">
|
||||
<equals arg1="${os.name}" arg2="HP-UX"/>
|
||||
</condition>
|
||||
<condition property="aix">
|
||||
<equals arg1="${os.name}" arg2="AIX"/>
|
||||
</condition>
|
||||
<condition property="darwin">
|
||||
<equals arg1="${os.name}" arg2="Mac OS X"/>
|
||||
</condition>
|
||||
<condition property="freebsd">
|
||||
<equals arg1="${os.name}" arg2="FreeBSD"/>
|
||||
</condition>
|
||||
<condition property="openbsd">
|
||||
<equals arg1="${os.name}" arg2="OpenBSD"/>
|
||||
</condition>
|
||||
<condition property="netbsd">
|
||||
<equals arg1="${os.name}" arg2="NetBSD"/>
|
||||
</condition>
|
||||
<condition property="osf1">
|
||||
<equals arg1="${os.name}" arg2="OSF1"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.os" value="linux">
|
||||
<isset property="linux"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.os" value="win32">
|
||||
<isset property="win32"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.os" value="solaris">
|
||||
<isset property="solaris"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.os" value="aix">
|
||||
<isset property="aix"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.os" value="hpux">
|
||||
<isset property="hpux"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.os" value="darwin">
|
||||
<isset property="darwin"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.os" value="freebsd">
|
||||
<isset property="freebsd"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.os" value="openbsd">
|
||||
<isset property="openbsd"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.os" value="netbsd">
|
||||
<isset property="netbsd"/>
|
||||
</condition>
|
||||
|
||||
<!-- darwin and freebsd use the same source files -->
|
||||
<condition property="jni.src" value="darwin">
|
||||
<isset property="freebsd"/>
|
||||
</condition>
|
||||
<condition property="jni.src" value="darwin">
|
||||
<isset property="openbsd"/>
|
||||
</condition>
|
||||
<condition property="jni.src" value="darwin">
|
||||
<isset property="netbsd"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.os" value="osf1">
|
||||
<isset property="osf1"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.jdk.os" value="${jni.os}">
|
||||
<and>
|
||||
<isfalse value="${hpux}"/>
|
||||
<isfalse value="${osf1}"/>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.jdk.os" value="hp-ux">
|
||||
<istrue value="${hpux}"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.jdk.os" value="alpha">
|
||||
<istrue value="${osf1}"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.src" value="${jni.os}">
|
||||
<isfalse value="${jni.src}"/>
|
||||
</condition>
|
||||
|
||||
<echo message="jni.src=${jni.src}, jni.jdk.os=${jni.jdk.os}, ${sun.arch.data.model}-bit"/>
|
||||
|
||||
<javac srcdir="${jni.src.java}" destdir="${build}/classes" debug="true"
|
||||
source="1.4" target="1.4"
|
||||
includes="org/hyperic/jni/*.java"/>
|
||||
|
||||
<taskdef name="libarch" classname="org.hyperic.jni.ArchNameTask">
|
||||
<classpath location="${build}/classes"/>
|
||||
</taskdef>
|
||||
<taskdef name="copydep" classname="org.hyperic.jni.CopyDependsTask">
|
||||
<classpath location="${build}/classes"/>
|
||||
</taskdef>
|
||||
|
||||
<libarch/>
|
||||
|
||||
<property name="jni.project.archname"
|
||||
value="${project.name}-${jni.libarch}"/>
|
||||
|
||||
<condition property="jni.libname"
|
||||
value="${jni.libprefix}${jni.project.archname}${jni.libversion}">
|
||||
<isfalse value="${jni.libname}"/>
|
||||
</condition>
|
||||
|
||||
<property name="jni.libname.full"
|
||||
value="${jni.libpre}${jni.libname}${jni.libext}"/>
|
||||
|
||||
<property name="jni.objdir" value="${build}/obj/${jni.libarch}"/>
|
||||
|
||||
<condition property="uni.sdk"
|
||||
value="/Developer/SDKs/MacOSX10.${uni.sdk.version}.sdk">
|
||||
<istrue value="${darwin}"/>
|
||||
</condition>
|
||||
|
||||
<condition property="jni.cc" value="uni-cc">
|
||||
<isset property="darwin"/>
|
||||
</condition>
|
||||
|
||||
<property name="jni.cc" value="jni-cc"/>
|
||||
|
||||
<condition property="cc.runtime" value="static">
|
||||
<isset property="win32"/>
|
||||
</condition>
|
||||
<condition property="cc.runtime" value="dynamic">
|
||||
<not>
|
||||
<isset property="win32"/>
|
||||
</not>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="jni-lib-copy" if="jni.libarch">
|
||||
<mkdir dir="${jni.bin}/lib"/>
|
||||
|
||||
<copy toDir="${jni.bin}/lib" overwrite="true">
|
||||
<fileset dir="${jni.objdir}/lib"/>
|
||||
</copy>
|
||||
|
||||
<chmod perm="a+x">
|
||||
<fileset dir="${jni.bin}/lib">
|
||||
<include name="*.sl"/>
|
||||
</fileset>
|
||||
</chmod>
|
||||
</target>
|
||||
|
||||
<target name="jni-compile" if="jni.libarch">
|
||||
<antcall target="${jni.cc}" inheritRefs="true"/>
|
||||
</target>
|
||||
|
||||
<!-- run jni-cc twice {ppc,i386}, then feed both to lipo to build a universal binary -->
|
||||
<target name="uni-cc" if="jni.libarch">
|
||||
<property name="shlib" value="${jni.objdir}/lib/lib${jni.libname}.dylib"/>
|
||||
|
||||
<!-- ppc -->
|
||||
<echo message="build 'ppc' arch"/>
|
||||
<antcall target="jni-cc" inheritRefs="true">
|
||||
<param name="uni.arch" value="ppc"/>
|
||||
</antcall>
|
||||
|
||||
<copy file="${shlib}" tofile="${shlib}.ppc"/>
|
||||
|
||||
<!-- i386 -->
|
||||
<echo message="build 'i386' arch"/>
|
||||
<delete>
|
||||
<fileset dir="${jni.objdir}" includes="*.o"/>
|
||||
</delete>
|
||||
|
||||
<antcall target="jni-cc" inheritRefs="true">
|
||||
<param name="uni.arch" value="i386"/>
|
||||
</antcall>
|
||||
|
||||
<copy file="${shlib}" tofile="${shlib}.i386"/>
|
||||
|
||||
<echo message="lipo 'ppc'+'i386'"/>
|
||||
<exec executable="lipo">
|
||||
<arg line="-create ${shlib}.ppc ${shlib}.i386 -output ${jni.objdir}/lib/lib${jni.libname}.dylib"/>
|
||||
</exec>
|
||||
|
||||
<delete>
|
||||
<fileset dir="${jni.objdir}/lib" includes="*.ppc,*.i386"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="jni-cc" if="jni.libarch">
|
||||
<mkdir dir="${jni.objdir}/lib"/>
|
||||
|
||||
<echo message="jni libname=${jni.libname}"/>
|
||||
|
||||
<cc outtype="shared"
|
||||
outfile="${jni.objdir}/lib/${jni.libname}"
|
||||
objdir="${jni.objdir}"
|
||||
runtime="${cc.runtime}"
|
||||
relentless="false">
|
||||
|
||||
<!-- HPUX -->
|
||||
<compiler name="hp" if="hpux">
|
||||
<compilerarg value="+Z"/>
|
||||
|
||||
<defineset>
|
||||
<define name="${jni.define.name}_HPUX"/>
|
||||
<define name="_HPUX_SOURCE"/>
|
||||
<define name="_REENTRANT"/>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<linker name="hp" if="hpux">
|
||||
<libset if="jni.libset.libs"
|
||||
dir="${jni.libset.dir}"
|
||||
libs="${jni.libset.libs}"/>
|
||||
|
||||
<syslibset libs="nsl"/>
|
||||
<syslibset libs="nm"/>
|
||||
</linker>
|
||||
|
||||
<!-- Solaris -->
|
||||
<compiler name="gcc" if="solaris">
|
||||
<compilerarg value="-O2" if="jni.optim"/>
|
||||
<compilerarg value="-g" if="jni.debug"/>
|
||||
<compilerarg value="-Wall"/>
|
||||
<compilerarg value="-Werror" if="jni.werror"/>
|
||||
<compilerarg value="-m64" if="jni.arch64"/>
|
||||
<defineset>
|
||||
<define name="${jni.define.name}_SOLARIS"/>
|
||||
<define name="_REENTRANT"/>
|
||||
<define name="_POSIX_PTHREAD_SEMANTICS"/>
|
||||
<define name="DMALLOC" if="jni.dmalloc"/>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<linker name="gcc" if="solaris">
|
||||
<!-- required for modern gcc to avoid libgcc_s.so dependency -->
|
||||
<!-- this arg is ignored by older gcc -->
|
||||
<linkerarg value="-static-libgcc"/>
|
||||
<linkerarg value="-m64" if="jni.arch64"/>
|
||||
|
||||
<libset if="jni.libset.libs"
|
||||
dir="${jni.libset.dir}"
|
||||
libs="${jni.libset.libs}"/>
|
||||
<libset if="jni.dmalloc"
|
||||
dir="${jni.dmalloc}/lib"
|
||||
libs="dmallocth"/>
|
||||
</linker>
|
||||
|
||||
<!-- Linux -->
|
||||
<compiler name="gcc" debug="${jni.debug}" if="linux">
|
||||
<compilerarg value="-O2" if="jni.optim"/>
|
||||
<compilerarg value="-g" if="jni.debug"/>
|
||||
<compilerarg value="-Wall"/>
|
||||
<compilerarg value="-Werror" if="jni.werror"/>
|
||||
<compilerarg value="${jni.gccm}" if="jni.gccm"/>
|
||||
<defineset>
|
||||
<define name="${jni.define.name}_LINUX"/>
|
||||
<define name="_REENTRANT"/>
|
||||
<define name="DMALLOC" if="jni.dmalloc"/>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<linker name="gcc" if="linux">
|
||||
<libset if="jni.libset.libs"
|
||||
dir="${jni.libset.dir}"
|
||||
libs="${jni.libset.libs}"/>
|
||||
<libset if="jni.dmalloc"
|
||||
dir="${jni.dmalloc}/lib"
|
||||
libs="dmallocth"/>
|
||||
<linkerarg value="${jni.gccm}" if="jni.gccm"/>
|
||||
</linker>
|
||||
|
||||
<!-- Darwin -->
|
||||
<compiler name="gcc" if="darwin">
|
||||
<compilerarg value="-Wall"/>
|
||||
<compilerarg value="-Werror" if="jni.werror"/>
|
||||
<compilerarg value="-m64" if="jni.arch64"/>
|
||||
<compilerarg value="-O2" if="jni.optim"/>
|
||||
<compilerarg value="-g" if="jni.debug"/>
|
||||
<compilerarg value="-isysroot"/>
|
||||
<compilerarg value="${uni.sdk}"/>
|
||||
<compilerarg value="-arch"/>
|
||||
<compilerarg value="${uni.arch}"/>
|
||||
<compilerarg value="${osx.min}"/>
|
||||
|
||||
<sysincludepath location="/Developer/Headers/FlatCarbon"/>
|
||||
|
||||
<defineset>
|
||||
<define name="DARWIN"/>
|
||||
<define name="DARWIN_HAS_LIBPROC_H" if="libproc.h"/>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<linker name="gcc" if="darwin">
|
||||
<linkerarg value="-m64" if="jni.arch64"/>
|
||||
<linkerarg value="-Wl,-syslibroot,${uni.sdk}"/>
|
||||
<linkerarg value="-arch"/>
|
||||
<linkerarg value="${uni.arch}"/>
|
||||
<linkerarg value="${osx.min}"/>
|
||||
|
||||
<!-- for Gestalt() -->
|
||||
<linkerarg value="-framework"/>
|
||||
<linkerarg value="CoreServices"/>
|
||||
|
||||
<linkerarg value="-sectcreate,__TEXT,__info_plist,${jni.info.plist}" if="jni.info.plist"/>
|
||||
|
||||
<libset if="jni.libset.libs"
|
||||
dir="${jni.libset.dir}"
|
||||
libs="${jni.libset.libs}"/>
|
||||
|
||||
<syslibset libs="IOKit"/>
|
||||
</linker>
|
||||
|
||||
<!-- Freebsd -->
|
||||
<compiler name="gcc" if="freebsd">
|
||||
<compilerarg value="-O2" if="jni.optim"/>
|
||||
<compilerarg value="-g" if="jni.debug"/>
|
||||
<compilerarg value="-Wall"/>
|
||||
<compilerarg value="-Werror" if="jni.werror"/>
|
||||
<defineset>
|
||||
<define name="${jni.define.name}_FREEBSD"/>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<linker name="gcc" if="freebsd">
|
||||
<libset if="jni.libset.libs"
|
||||
dir="${jni.libset.dir}"
|
||||
libs="${jni.libset.libs}"/>
|
||||
<syslibset libs="kvm"/>
|
||||
</linker>
|
||||
|
||||
<!-- OpenBSD -->
|
||||
<compiler name="gcc" if="openbsd">
|
||||
<compilerarg value="-O2" if="jni.optim"/>
|
||||
<compilerarg value="-g" if="jni.debug"/>
|
||||
<compilerarg value="-Wall"/>
|
||||
<!-- <compilerarg value="-Werror" if="jni.werror"/> -->
|
||||
<defineset>
|
||||
<define name="${jni.define.name}_OPENBSD"/>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<linker name="gcc" if="openbsd">
|
||||
<libset if="jni.libset.libs"
|
||||
dir="${jni.libset.dir}"
|
||||
libs="${jni.libset.libs}"/>
|
||||
<syslibset libs="kvm"/>
|
||||
</linker>
|
||||
|
||||
<!-- NetBSD -->
|
||||
<compiler name="gcc" if="netbsd">
|
||||
<compilerarg value="-O2" if="jni.optim"/>
|
||||
<compilerarg value="-g" if="jni.debug"/>
|
||||
<compilerarg value="-Wall"/>
|
||||
<!-- <compilerarg value="-Werror" if="jni.werror"/> -->
|
||||
<defineset>
|
||||
<define name="${jni.define.name}_NETBSD"/>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<linker name="gcc" if="netbsd">
|
||||
<libset if="jni.libset.libs"
|
||||
dir="${jni.libset.dir}"
|
||||
libs="${jni.libset.libs}"/>
|
||||
<syslibset libs="kvm"/>
|
||||
</linker>
|
||||
|
||||
<!-- AIX -->
|
||||
<compiler name="xlc_r" if="aix">
|
||||
<compilerarg value="-q64" if="jni.arch64"/>
|
||||
<defineset>
|
||||
<define name="${jni.define.name}_AIX"/>
|
||||
<define name="_ALL_SOURCE"/>
|
||||
<define name="_ANSI_C_SOURCE"/>
|
||||
<define name="_POSIX_SOURCE"/>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<linker name="xlc_r" if="aix">
|
||||
<linkerarg value="-b64" if="jni.arch64"/>
|
||||
<libset if="jni.libset.libs"
|
||||
dir="${jni.libset.dir}"
|
||||
libs="${jni.libset.libs}"/>
|
||||
</linker>
|
||||
|
||||
<!-- WIN32 -->
|
||||
<linker name="msvc" debug="${jni.debug}" if="win32">
|
||||
<libset if="jni.libset.libs"
|
||||
dir="${jni.libset.dir}"
|
||||
libs="${jni.libset.libs}"/>
|
||||
|
||||
<linkerarg value="/MACHINE:X64" if="jni.arch64"/>
|
||||
<linkerarg value="${jni.info.res}" if="jni.info.res"/>
|
||||
<syslibset libs="kernel32,user32,advapi32,ws2_32,netapi32,shell32,pdh,version"/>
|
||||
</linker>
|
||||
|
||||
<compiler name="msvc" debug="${jni.debug}" if="win32">
|
||||
<defineset>
|
||||
<define name="WIN32"/>
|
||||
<define name="_CRT_SECURE_NO_DEPRECATE"/>
|
||||
<!-- XXX 2008 MSC express/SDK does not include atl headers -->
|
||||
<define name="SIGAR_NO_ATL" if="jni.noatl"/>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<!-- OSF1 -->
|
||||
<compiler name="gcc" if="osf1">
|
||||
<compilerarg value="-Wall"/>
|
||||
<compilerarg value="-pthread"/>
|
||||
<defineset>
|
||||
<define name="${jni.define.name}_OSF1"/>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<linker name="gcc" if="osf1">
|
||||
<libset if="jni.libset.libs"
|
||||
dir="${jni.libset.dir}"
|
||||
libs="${jni.libset.libs}"/>
|
||||
|
||||
<syslibset libs="mach"/>
|
||||
</linker>
|
||||
|
||||
<!-- C sources -->
|
||||
<fileset dir="${jni.source.dir}">
|
||||
<patternset refid="jni.source.files"/>
|
||||
</fileset>
|
||||
|
||||
<includepath>
|
||||
<path refid="jni.include.dirs"/>
|
||||
</includepath>
|
||||
|
||||
<sysincludepath location="${jni.javahome}/include"/>
|
||||
<sysincludepath location="${jni.javahome}/include/${jni.jdk.os}"/>
|
||||
<sysincludepath location="${jni.dmalloc}/include"
|
||||
if="jni.dmalloc"/>
|
||||
</cc>
|
||||
</target>
|
||||
|
||||
<target name="jni-clean">
|
||||
<delete dir="${jni.objdir}"/>
|
||||
</target>
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
|
||||
cpptasks.pat - provides support for HP cc and AIX xlc_r
|
||||
the classes listed below are copy-n-pastes from existing cpptasks
|
||||
classes, simply changed program names, flags, etc. the HP classes
|
||||
were submitted as a patch to ant-contrib-developers on 10/09/2002,
|
||||
to which there was no response, so have not bothered to submit the aix
|
||||
patch.
|
||||
SubsystemEnum patch is for the osf1 javac (aka tru64).
|
||||
was throwing IllegalAccessError. why clone a final String[] anyhow??
|
||||
CUtil patch is for jdk 1.3 (StringBuffer.indexOf is 1.4+)
|
||||
GccLinker patch adds -arch to known flags for building universal binaries
|
||||
|
||||
added | derived from
|
||||
--------------------------
|
||||
HPCompiler | aCCCompiler
|
||||
HPLinker | aCCLinker
|
||||
XlcCompiler | VisualAgeCCompiler
|
||||
XlcLinker | VisualAgeLinker
|
||||
|
||||
cpptasks.pat applies to:
|
||||
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/ant-contrib \
|
||||
co -D"2006/04/28 15:00:00" cpptasks
|
||||
@@ -0,0 +1,696 @@
|
||||
Index: src/net/sf/antcontrib/cpptasks/CUtil.java
|
||||
===================================================================
|
||||
RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/CUtil.java,v
|
||||
retrieving revision 1.28
|
||||
diff -u -r1.28 CUtil.java
|
||||
--- src/net/sf/antcontrib/cpptasks/CUtil.java 17 Mar 2006 16:38:12 -0000 1.28
|
||||
+++ src/net/sf/antcontrib/cpptasks/CUtil.java 29 Apr 2006 02:35:28 -0000
|
||||
@@ -438,19 +438,19 @@
|
||||
StringBuffer buf = new StringBuffer (attrValue);
|
||||
int quotePos;
|
||||
|
||||
- for (quotePos = -1; (quotePos = buf.indexOf("\"", quotePos + 1)) >= 0;) {
|
||||
+ for (quotePos = -1; (quotePos = buf.toString().indexOf("\"", quotePos + 1)) >= 0;) {
|
||||
buf.deleteCharAt(quotePos);
|
||||
buf.insert (quotePos, """);
|
||||
quotePos += 5;
|
||||
}
|
||||
|
||||
- for (quotePos = -1; (quotePos = buf.indexOf("<", quotePos + 1)) >= 0;) {
|
||||
+ for (quotePos = -1; (quotePos = buf.toString().indexOf("<", quotePos + 1)) >= 0;) {
|
||||
buf.deleteCharAt(quotePos);
|
||||
buf.insert (quotePos, "<");
|
||||
quotePos += 3;
|
||||
}
|
||||
|
||||
- for (quotePos = -1; (quotePos = buf.indexOf(">", quotePos + 1)) >= 0;) {
|
||||
+ for (quotePos = -1; (quotePos = buf.toString().indexOf(">", quotePos + 1)) >= 0;) {
|
||||
buf.deleteCharAt(quotePos);
|
||||
buf.insert (quotePos, ">");
|
||||
quotePos += 3;
|
||||
Index: src/net/sf/antcontrib/cpptasks/CompilerEnum.java
|
||||
===================================================================
|
||||
RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/CompilerEnum.java,v
|
||||
retrieving revision 1.18
|
||||
diff -u -r1.18 CompilerEnum.java
|
||||
--- src/net/sf/antcontrib/cpptasks/CompilerEnum.java 8 Jul 2004 22:30:53 -0000 1.18
|
||||
+++ src/net/sf/antcontrib/cpptasks/CompilerEnum.java 29 Apr 2006 02:35:28 -0000
|
||||
@@ -25,7 +25,9 @@
|
||||
import net.sf.antcontrib.cpptasks.devstudio.DevStudioResourceCompiler;
|
||||
import net.sf.antcontrib.cpptasks.gcc.GccCCompiler;
|
||||
import net.sf.antcontrib.cpptasks.hp.aCCCompiler;
|
||||
+import net.sf.antcontrib.cpptasks.hp.HPCompiler;
|
||||
import net.sf.antcontrib.cpptasks.ibm.VisualAgeCCompiler;
|
||||
+import net.sf.antcontrib.cpptasks.ibm.XlcCompiler;
|
||||
import net.sf.antcontrib.cpptasks.intel.IntelLinux32CCompiler;
|
||||
import net.sf.antcontrib.cpptasks.intel.IntelLinux64CCompiler;
|
||||
import net.sf.antcontrib.cpptasks.intel.IntelWin32CCompiler;
|
||||
@@ -205,6 +207,8 @@
|
||||
new ProcessorEnumValue("armcpp", ADSCCompiler.getArmCpp()),
|
||||
new ProcessorEnumValue("tcc", ADSCCompiler.getThumbCC()),
|
||||
new ProcessorEnumValue("tcpp", ADSCCompiler.getThumbCpp()),
|
||||
+ new ProcessorEnumValue("hp", HPCompiler.getInstance()),
|
||||
+ new ProcessorEnumValue("xlc_r", XlcCompiler.getInstance()),
|
||||
// GCC Cross Compilers
|
||||
new ProcessorEnumValue(
|
||||
"sparc-sun-solaris2-gcc",
|
||||
Index: src/net/sf/antcontrib/cpptasks/LinkerEnum.java
|
||||
===================================================================
|
||||
RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/LinkerEnum.java,v
|
||||
retrieving revision 1.16
|
||||
diff -u -r1.16 LinkerEnum.java
|
||||
--- src/net/sf/antcontrib/cpptasks/LinkerEnum.java 8 Jul 2004 22:30:53 -0000 1.16
|
||||
+++ src/net/sf/antcontrib/cpptasks/LinkerEnum.java 29 Apr 2006 02:35:28 -0000
|
||||
@@ -25,7 +25,9 @@
|
||||
import net.sf.antcontrib.cpptasks.gcc.GppLinker;
|
||||
import net.sf.antcontrib.cpptasks.gcc.LdLinker;
|
||||
import net.sf.antcontrib.cpptasks.hp.aCCLinker;
|
||||
+import net.sf.antcontrib.cpptasks.hp.HPLinker;
|
||||
import net.sf.antcontrib.cpptasks.ibm.VisualAgeLinker;
|
||||
+import net.sf.antcontrib.cpptasks.ibm.XlcLinker;
|
||||
import net.sf.antcontrib.cpptasks.intel.IntelLinux32Linker;
|
||||
import net.sf.antcontrib.cpptasks.intel.IntelLinux64Linker;
|
||||
import net.sf.antcontrib.cpptasks.intel.IntelWin32Linker;
|
||||
@@ -72,6 +74,8 @@
|
||||
new ProcessorEnumValue("armcpp", ADSLinker.getInstance()),
|
||||
new ProcessorEnumValue("tcc", ADSLinker.getInstance()),
|
||||
new ProcessorEnumValue("tcpp", ADSLinker.getInstance()),
|
||||
+ new ProcessorEnumValue("hp", HPLinker.getInstance()),
|
||||
+ new ProcessorEnumValue("xlc_r", XlcLinker.getInstance()),
|
||||
// gcc cross compilers
|
||||
new ProcessorEnumValue(
|
||||
"sparc-sun-solaris2-gcc",
|
||||
Index: src/net/sf/antcontrib/cpptasks/SubsystemEnum.java
|
||||
===================================================================
|
||||
RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/SubsystemEnum.java,v
|
||||
retrieving revision 1.7
|
||||
diff -u -r1.7 SubsystemEnum.java
|
||||
--- src/net/sf/antcontrib/cpptasks/SubsystemEnum.java 28 Feb 2004 20:04:02 -0000 1.7
|
||||
+++ src/net/sf/antcontrib/cpptasks/SubsystemEnum.java 29 Apr 2006 02:35:28 -0000
|
||||
@@ -29,6 +29,6 @@
|
||||
setValue("gui");
|
||||
}
|
||||
public String[] getValues() {
|
||||
- return (String[]) values.clone();
|
||||
+ return values;
|
||||
}
|
||||
}
|
||||
Index: src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java
|
||||
===================================================================
|
||||
RCS file:
|
||||
/cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java,v
|
||||
retrieving revision 1.32
|
||||
diff -u -r1.32 GccLinker.java
|
||||
--- src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java 28 Feb 2004
|
||||
20:01:15 -0000 1.32
|
||||
+++ src/net/sf/antcontrib/cpptasks/gcc/GccLinker.java 29 Apr 2006
|
||||
17:27:50 -0000
|
||||
@@ -35,7 +35,7 @@
|
||||
private static String[] linkerOptions = new String[]{"-bundle",
|
||||
"-dynamiclib", "-nostartfiles", "-nostdlib", "-prebind",
|
||||
"-s",
|
||||
"-static", "-shared", "-symbolic", "-Xlinker",
|
||||
- "--export-all-symbols", "-static-libgcc",};
|
||||
+ "--export-all-symbols", "-static-libgcc", "-arch"};
|
||||
private static final GccLinker dllLinker = new GccLinker("gcc",
|
||||
objFiles,
|
||||
discardFiles, "lib", ".so", false, new GccLinker("gcc",
|
||||
objFiles,
|
||||
discardFiles, "lib", ".so", true, null));
|
||||
|
||||
--- /dev/null 2006-04-28 19:36:02.000000000 -0700
|
||||
+++ src/net/sf/antcontrib/cpptasks/hp/HPCompiler.java 2006-04-28 17:08:22.000000000 -0700
|
||||
@@ -0,0 +1,161 @@
|
||||
+/*
|
||||
+ * The Apache Software License, Version 1.1
|
||||
+ *
|
||||
+ * Copyright (c) 2001 The Ant-Contrib project. 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 acknowlegement:
|
||||
+ * "This product includes software developed by the
|
||||
+ * Apache Software Foundation (http://www.apache.org/)."
|
||||
+ * Alternately, this acknowlegement may appear in the software itself,
|
||||
+ * if and wherever such third-party acknowlegements normally appear.
|
||||
+ *
|
||||
+ * 4. The names "The Jakarta Project", "Ant", 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 names without prior written
|
||||
+ * permission of the Apache Group.
|
||||
+ *
|
||||
+ * 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/>.
|
||||
+ */
|
||||
+package net.sf.antcontrib.cpptasks.hp;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.util.Vector;
|
||||
+
|
||||
+import net.sf.antcontrib.cpptasks.CUtil;
|
||||
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
|
||||
+import net.sf.antcontrib.cpptasks.compiler.Linker;
|
||||
+import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler;
|
||||
+import org.apache.tools.ant.types.Environment;
|
||||
+
|
||||
+/**
|
||||
+ * Adapter for the HP compiler
|
||||
+ *
|
||||
+ * @author Curt Arnold
|
||||
+ */
|
||||
+public final class HPCompiler extends GccCompatibleCCompiler {
|
||||
+
|
||||
+ private String identifier;
|
||||
+ private File[] includePath;
|
||||
+ private static final HPCompiler instance =
|
||||
+ new HPCompiler("cc", false, null);
|
||||
+
|
||||
+ /**
|
||||
+ * Private constructor. Use GccCCompiler.getInstance() to get
|
||||
+ * singleton instance of this class.
|
||||
+ */
|
||||
+ private HPCompiler(
|
||||
+ String command,
|
||||
+ boolean newEnvironment,
|
||||
+ Environment env) {
|
||||
+ super(command, "-help", false, null, newEnvironment, env);
|
||||
+ }
|
||||
+
|
||||
+ public int getMaximumCommandLength() {
|
||||
+ return Integer.MAX_VALUE;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets singleton instance of this class
|
||||
+ */
|
||||
+ public static HPCompiler getInstance() {
|
||||
+ return instance;
|
||||
+ }
|
||||
+
|
||||
+ public File[] getEnvironmentIncludePath() {
|
||||
+ if (includePath == null) {
|
||||
+ File ccLoc = CUtil.getExecutableLocation("cc");
|
||||
+ if (ccLoc != null) {
|
||||
+ File compilerIncludeDir =
|
||||
+ new File(new File(ccLoc, "../include").getAbsolutePath());
|
||||
+ if (compilerIncludeDir.exists()) {
|
||||
+ includePath = new File[2];
|
||||
+ includePath[0] = compilerIncludeDir;
|
||||
+ }
|
||||
+ }
|
||||
+ if (includePath == null) {
|
||||
+ includePath = new File[1];
|
||||
+ }
|
||||
+ includePath[includePath.length - 1] = new File("/usr/include");
|
||||
+ }
|
||||
+ return includePath;
|
||||
+ }
|
||||
+
|
||||
+ public void addImpliedArgs(
|
||||
+ Vector args,
|
||||
+ boolean debug,
|
||||
+ boolean multithreaded,
|
||||
+ boolean exceptions,
|
||||
+ LinkType linkType) {
|
||||
+ args.addElement("-c");
|
||||
+ if (debug) {
|
||||
+ args.addElement("-g");
|
||||
+ }
|
||||
+ /*
|
||||
+ if (multithreaded) {
|
||||
+ args.addElement("-mt");
|
||||
+ }
|
||||
+ */
|
||||
+ if (linkType.isSharedLibrary()) {
|
||||
+ args.addElement("+z");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void addWarningSwitch(Vector args, int level) {
|
||||
+ switch (level) {
|
||||
+ case 0 :
|
||||
+ args.addElement("-w");
|
||||
+ break;
|
||||
+
|
||||
+ case 1 :
|
||||
+ case 2 :
|
||||
+ args.addElement("+w");
|
||||
+ break;
|
||||
+ /*
|
||||
+ case 3:
|
||||
+ case 4:
|
||||
+ case 5:
|
||||
+ args.addElement("+w2");
|
||||
+ break;
|
||||
+ */
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public Linker getLinker(LinkType linkType) {
|
||||
+ return HPLinker.getInstance().getLinker(linkType);
|
||||
+ }
|
||||
+}
|
||||
--- /dev/null 2006-04-28 19:36:02.000000000 -0700
|
||||
+++ src/net/sf/antcontrib/cpptasks/hp/HPLinker.java 2006-04-28 17:08:22.000000000 -0700
|
||||
@@ -0,0 +1,153 @@
|
||||
+/*
|
||||
+ * The Apache Software License, Version 1.1
|
||||
+ *
|
||||
+ * Copyright (c) 2001 The Ant-Contrib project. 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 acknowlegement:
|
||||
+ * "This product includes software developed by the
|
||||
+ * Apache Software Foundation (http://www.apache.org/)."
|
||||
+ * Alternately, this acknowlegement may appear in the software itself,
|
||||
+ * if and wherever such third-party acknowlegements normally appear.
|
||||
+ *
|
||||
+ * 4. The names "The Jakarta Project", "Ant", 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 names without prior written
|
||||
+ * permission of the Apache Group.
|
||||
+ *
|
||||
+ * 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/>.
|
||||
+ */
|
||||
+package net.sf.antcontrib.cpptasks.hp;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.util.Vector;
|
||||
+
|
||||
+import net.sf.antcontrib.cpptasks.CUtil;
|
||||
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
|
||||
+import net.sf.antcontrib.cpptasks.compiler.Linker;
|
||||
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
|
||||
+
|
||||
+/**
|
||||
+ * Adapter for HP linker
|
||||
+ *
|
||||
+ * @author Curt Arnold
|
||||
+ */
|
||||
+public final class HPLinker extends AbstractLdLinker
|
||||
+{
|
||||
+ private static final String[] objFiles = new String[]
|
||||
+ { ".o", ".a", ".lib", ".dll", ".so", ".sl" };
|
||||
+ private static final String[] discardFiles = new String[0];
|
||||
+
|
||||
+ private static final HPLinker instance =
|
||||
+ new HPLinker("ld", objFiles, discardFiles, "", "");
|
||||
+ private static final HPLinker dllLinker =
|
||||
+ new HPLinker("ld", objFiles, discardFiles, "lib", ".sl");
|
||||
+ private static final HPLinker arLinker =
|
||||
+ new HPLinker("ld", objFiles, discardFiles, "", ".a");
|
||||
+
|
||||
+ private File[] libDirs;
|
||||
+
|
||||
+ private HPLinker(String command, String[] extensions,
|
||||
+ String[] ignoredExtensions, String outputPrefix,
|
||||
+ String outputSuffix) {
|
||||
+ super(command, "-help", extensions, ignoredExtensions,
|
||||
+ outputPrefix, outputSuffix,false,null);
|
||||
+ }
|
||||
+
|
||||
+ public static HPLinker getInstance() {
|
||||
+ return instance;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns library path.
|
||||
+ *
|
||||
+ */
|
||||
+ public File[] getLibraryPath() {
|
||||
+ if(libDirs == null) {
|
||||
+ File CCloc = CUtil.getExecutableLocation("ld");
|
||||
+ if(CCloc != null) {
|
||||
+ File compilerLib = new File(
|
||||
+ new File(CCloc, "../lib").getAbsolutePath());
|
||||
+ if (compilerLib.exists()) {
|
||||
+ libDirs = new File[2];
|
||||
+ libDirs[0] = compilerLib;
|
||||
+ }
|
||||
+ }
|
||||
+ if (libDirs == null) {
|
||||
+ libDirs = new File[1];
|
||||
+ }
|
||||
+ }
|
||||
+ libDirs[libDirs.length-1] = new File("/usr/lib");
|
||||
+ return libDirs;
|
||||
+ }
|
||||
+
|
||||
+ public void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
|
||||
+/* if(linkType.isStaticRuntime()) {
|
||||
+ args.addElement("-static");
|
||||
+ }
|
||||
+*/
|
||||
+ if(linkType.isSharedLibrary()) {
|
||||
+ args.addElement("-b");
|
||||
+ }
|
||||
+/*
|
||||
+ if (linkType.isStaticLibrary()) {
|
||||
+ args.addElement("-Wl,-noshared");
|
||||
+ }
|
||||
+*/
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public Linker getLinker(LinkType type) {
|
||||
+ if(type.isStaticLibrary()) {
|
||||
+ return arLinker;
|
||||
+ }
|
||||
+ if(type.isSharedLibrary()) {
|
||||
+ return dllLinker;
|
||||
+ }
|
||||
+ return instance;
|
||||
+ }
|
||||
+
|
||||
+ public void addIncremental(boolean incremental, Vector args) {
|
||||
+ /*
|
||||
+ if (incremental) {
|
||||
+ args.addElement("-xidlon");
|
||||
+ } else {
|
||||
+ args.addElement("-xidloff");
|
||||
+ }
|
||||
+ */
|
||||
+ }
|
||||
+}
|
||||
--- /dev/null 2006-04-28 19:36:02.000000000 -0700
|
||||
+++ src/net/sf/antcontrib/cpptasks/ibm/XlcCompiler.java 2006-04-28 17:08:22.000000000 -0700
|
||||
@@ -0,0 +1,138 @@
|
||||
+/*
|
||||
+ * The Apache Software License, Version 1.1
|
||||
+ *
|
||||
+ * Copyright (c) 2001 The Ant-Contrib project. 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 acknowlegement:
|
||||
+ * "This product includes software developed by the
|
||||
+ * Ant-Contrib project (http://sourceforge.net/projects/ant-contrib)."
|
||||
+ * Alternately, this acknowlegement may appear in the software itself,
|
||||
+ * if and wherever such third-party acknowlegements normally appear.
|
||||
+ *
|
||||
+ * 4. The names "Ant-Contrib"
|
||||
+ * 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 "Ant-Contrib"
|
||||
+ * nor may "Ant-Contrib" appear in their names without prior written
|
||||
+ * permission of the Ant-Contrib project.
|
||||
+ *
|
||||
+ * 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 ANT-CONTRIB PROJECT 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.
|
||||
+ * ====================================================================
|
||||
+ */
|
||||
+package net.sf.antcontrib.cpptasks.ibm;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.util.Vector;
|
||||
+
|
||||
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
|
||||
+import net.sf.antcontrib.cpptasks.compiler.Linker;
|
||||
+import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler;
|
||||
+import org.apache.tools.ant.types.Environment;
|
||||
+
|
||||
+
|
||||
+/**
|
||||
+ * Adapter for the IBM(r) Visual Age(tm) C++ compiler for AIX(tm)
|
||||
+ *
|
||||
+ * @author Curt Arnold
|
||||
+ */
|
||||
+public final class XlcCompiler extends GccCompatibleCCompiler {
|
||||
+ private String identifier;
|
||||
+ private File[] includePath;
|
||||
+ private static final XlcCompiler instance =
|
||||
+ new XlcCompiler("xlc_r", false, null);
|
||||
+
|
||||
+ /**
|
||||
+ * Private constructor. Use getInstance() to get
|
||||
+ * singleton instance of this class.
|
||||
+ */
|
||||
+ private XlcCompiler(String command, boolean newEnvironment, Environment env) {
|
||||
+ super(command, "-help", false, null, newEnvironment, env);
|
||||
+ }
|
||||
+
|
||||
+ public int getMaximumCommandLength() {
|
||||
+ return Integer.MAX_VALUE;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets singleton instance of this class
|
||||
+ */
|
||||
+ public static XlcCompiler getInstance() {
|
||||
+ return instance;
|
||||
+ }
|
||||
+
|
||||
+ public void addImpliedArgs(
|
||||
+ Vector args,
|
||||
+ boolean debug,
|
||||
+ boolean multithreaded,
|
||||
+ boolean exceptions,
|
||||
+ LinkType linkType) {
|
||||
+ args.addElement("-c");
|
||||
+ if (debug) {
|
||||
+ args.addElement("-g");
|
||||
+ }
|
||||
+ if (linkType.isSharedLibrary()) {
|
||||
+ args.addElement("-fpic");
|
||||
+ args.addElement("-qmkshrobj");
|
||||
+
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void addWarningSwitch(Vector args, int level) {
|
||||
+ switch (level) {
|
||||
+ case 0 :
|
||||
+ args.addElement("-w");
|
||||
+ break;
|
||||
+
|
||||
+ case 1 :
|
||||
+ args.addElement("-qflag=s:s");
|
||||
+ break;
|
||||
+
|
||||
+ case 2 :
|
||||
+ args.addElement("-qflag=e:e");
|
||||
+ break;
|
||||
+
|
||||
+ case 3 :
|
||||
+ args.addElement("-qflag=w:w");
|
||||
+ break;
|
||||
+
|
||||
+ case 4 :
|
||||
+ args.addElement("-qflag=i:i");
|
||||
+ break;
|
||||
+
|
||||
+ case 5 :
|
||||
+ args.addElement("-qhalt=w:w");
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public Linker getLinker(LinkType linkType) {
|
||||
+ return VisualAgeLinker.getInstance().getLinker(linkType);
|
||||
+ }
|
||||
+}
|
||||
--- /dev/null 2006-04-28 19:36:02.000000000 -0700
|
||||
+++ src/net/sf/antcontrib/cpptasks/ibm/XlcLinker.java 2006-04-28 17:08:22.000000000 -0700
|
||||
@@ -0,0 +1,112 @@
|
||||
+/*
|
||||
+ * The Apache Software License, Version 1.1
|
||||
+ *
|
||||
+ * Copyright (c) 2001 The Ant-Contrib project. 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 acknowlegement:
|
||||
+ * "This product includes software developed by the
|
||||
+ * Ant-Contrib project (http://sourceforge.net/projects/ant-contrib)."
|
||||
+ * Alternately, this acknowlegement may appear in the software itself,
|
||||
+ * if and wherever such third-party acknowlegements normally appear.
|
||||
+ *
|
||||
+ * 4. The names "Ant-Contrib"
|
||||
+ * 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 "Ant-Contrib"
|
||||
+ * nor may "Ant-Contrib" appear in their names without prior written
|
||||
+ * permission of the Ant-Contrib project.
|
||||
+ *
|
||||
+ * 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 ANT-CONTRIB PROJECT 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.
|
||||
+ * ====================================================================
|
||||
+ */
|
||||
+package net.sf.antcontrib.cpptasks.ibm;
|
||||
+
|
||||
+import java.util.Vector;
|
||||
+
|
||||
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
|
||||
+import net.sf.antcontrib.cpptasks.compiler.Linker;
|
||||
+import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
|
||||
+import net.sf.antcontrib.cpptasks.gcc.GccLibrarian;
|
||||
+
|
||||
+/**
|
||||
+ * Adapter for IBM(r) Visual Age(tm) Linker for AIX(tm)
|
||||
+ *
|
||||
+ * @author Curt Arnold
|
||||
+ */
|
||||
+public final class XlcLinker extends AbstractLdLinker
|
||||
+{
|
||||
+ private static final String[] objFiles = new String[]
|
||||
+ { ".o", ".a", ".lib",".dll", ".so", ".sl"};
|
||||
+ private static final String[] discardFiles = new String[]
|
||||
+ { };
|
||||
+
|
||||
+ private static final XlcLinker instance =
|
||||
+ new XlcLinker("ld", objFiles, discardFiles, "", "");
|
||||
+ private static final XlcLinker dllLinker =
|
||||
+ new XlcLinker("ld", objFiles, discardFiles, "lib", ".so");
|
||||
+
|
||||
+ private XlcLinker(String command, String[] extensions,
|
||||
+ String[] ignoredExtensions, String outputPrefix,
|
||||
+ String outputSuffix) {
|
||||
+ //
|
||||
+ // just guessing that -? might display something useful
|
||||
+ //
|
||||
+ super(command, "-?", extensions, ignoredExtensions,
|
||||
+ outputPrefix, outputSuffix,false,null);
|
||||
+ }
|
||||
+
|
||||
+ public static XlcLinker getInstance() {
|
||||
+ return instance;
|
||||
+ }
|
||||
+
|
||||
+ public void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
|
||||
+ if(debug) {
|
||||
+ //args.addElement("-g");
|
||||
+ }
|
||||
+ if(linkType.isSharedLibrary()) {
|
||||
+ args.addElement("-bdynamic");
|
||||
+ args.addElement("-G");
|
||||
+ args.addElement("-bnoentry");
|
||||
+ args.addElement("-bexpall");
|
||||
+ args.addElement("-lc_r");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public Linker getLinker(LinkType type) {
|
||||
+ if(type.isStaticLibrary()) {
|
||||
+ return GccLibrarian.getInstance();
|
||||
+ }
|
||||
+ if(type.isSharedLibrary()) {
|
||||
+ return dllLinker;
|
||||
+ }
|
||||
+ return instance;
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,452 @@
|
||||
/*
|
||||
* Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
||||
* This file is part of SIGAR.
|
||||
*
|
||||
* SIGAR is free software; you can redistribute it and/or modify
|
||||
* it under the terms version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation. This program is distributed
|
||||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
package org.hyperic.jni;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.StringTokenizer;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
public class ArchLoader {
|
||||
private Object loadLock = new Object();
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
private final static String osName = System.getProperty("os.name");
|
||||
|
||||
public final static boolean IS_WIN32 = osName.startsWith("Windows");
|
||||
public final static boolean IS_AIX = osName.equals("AIX");
|
||||
public final static boolean IS_HPUX = osName.equals("HP-UX");
|
||||
public final static boolean IS_SOLARIS = osName.equals("SunOS");
|
||||
public final static boolean IS_LINUX = osName.equals("Linux");
|
||||
public final static boolean IS_DARWIN = osName.equals("Mac OS X") || osName.equals("Darwin");
|
||||
public final static boolean IS_OSF1 = osName.equals("OSF1");
|
||||
public final static boolean IS_FREEBSD = osName.equals("FreeBSD");
|
||||
public final static boolean IS_NETWARE = osName.equals("NetWare");
|
||||
|
||||
private String packageName;
|
||||
private String name;
|
||||
private String resourcePath;
|
||||
private Class loaderClass;
|
||||
private String jarName;
|
||||
private String libName = null;
|
||||
private File nativeLibrary;
|
||||
private String version;
|
||||
|
||||
public ArchLoader() { }
|
||||
|
||||
public ArchLoader(Class loaderClass) {
|
||||
setLoaderClass(loaderClass); //e.g. Sigar.class
|
||||
|
||||
//argh. possible for loaderClass.getPackage()
|
||||
//to return null depending on ClassLoader
|
||||
String pname = loaderClass.getName();
|
||||
int ix = pname.lastIndexOf(".");
|
||||
pname = pname.substring(0, ix);
|
||||
setPackageName(pname); //e.g. org.hyperic.sigar
|
||||
|
||||
ix = pname.lastIndexOf(".");
|
||||
setName(pname.substring(ix+1)); //e.g. sigar
|
||||
|
||||
setJarName(getName() + ".jar");
|
||||
|
||||
setResourcePath(toResName(pname)); //e.g. org.hyperic/sigar
|
||||
}
|
||||
|
||||
public Class getLoaderClass() {
|
||||
return this.loaderClass;
|
||||
}
|
||||
|
||||
public void setLoaderClass(Class value) {
|
||||
this.loaderClass = value;
|
||||
}
|
||||
|
||||
public ClassLoader getClassLoader() {
|
||||
return getLoaderClass().getClassLoader();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String value) {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return this.packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String value) {
|
||||
this.packageName = value;
|
||||
}
|
||||
|
||||
public String getResourcePath() {
|
||||
return this.resourcePath;
|
||||
}
|
||||
|
||||
public void setResourcePath(String value) {
|
||||
this.resourcePath = value;
|
||||
}
|
||||
|
||||
public String getJarName() {
|
||||
return this.jarName;
|
||||
}
|
||||
|
||||
public void setJarName(String value) {
|
||||
this.jarName = value;
|
||||
}
|
||||
|
||||
public String getLibName() {
|
||||
return this.libName;
|
||||
}
|
||||
|
||||
public void setLibName(String value) {
|
||||
this.libName = value;
|
||||
}
|
||||
|
||||
public String getArchLibName()
|
||||
throws ArchNotSupportedException {
|
||||
|
||||
return getName() + "-" + ArchName.getName();
|
||||
}
|
||||
|
||||
public String getDefaultLibName()
|
||||
throws ArchNotSupportedException {
|
||||
|
||||
return
|
||||
System.getProperty(getPackageName() + ".libname",
|
||||
//e.g. javasigar-x86-linux
|
||||
"java" + getArchLibName());
|
||||
}
|
||||
|
||||
public File getNativeLibrary() {
|
||||
return this.nativeLibrary;
|
||||
}
|
||||
|
||||
private String toResName(String name) {
|
||||
StringBuffer sb = new StringBuffer(name);
|
||||
for (int i=0; i < sb.length(); i++) {
|
||||
if (sb.charAt(i) == '.') {
|
||||
sb.setCharAt(i, '/');
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String getLibraryPrefix() {
|
||||
if (IS_WIN32 || IS_NETWARE) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "lib";
|
||||
}
|
||||
|
||||
public static String getLibraryExtension() {
|
||||
if (IS_WIN32) {
|
||||
return ".dll";
|
||||
}
|
||||
|
||||
if (IS_NETWARE) {
|
||||
return ".nlm";
|
||||
}
|
||||
|
||||
if (IS_DARWIN) {
|
||||
return ".dylib";
|
||||
}
|
||||
|
||||
if (IS_HPUX) {
|
||||
return ".sl";
|
||||
}
|
||||
|
||||
return ".so";
|
||||
}
|
||||
|
||||
public String getLibraryName()
|
||||
throws ArchNotSupportedException {
|
||||
String libName;
|
||||
|
||||
if ((libName = getLibName()) == null) {
|
||||
libName = getDefaultLibName();
|
||||
setLibName(libName);
|
||||
}
|
||||
|
||||
String prefix = getLibraryPrefix();
|
||||
String ext = getLibraryExtension();
|
||||
|
||||
return prefix + libName + ext;
|
||||
}
|
||||
|
||||
public String getVersionedLibraryName() {
|
||||
|
||||
if (this.version == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
getLibraryName();
|
||||
} catch (ArchNotSupportedException e) {
|
||||
return null;
|
||||
}
|
||||
String prefix = getLibraryPrefix();
|
||||
String ext = getLibraryExtension();
|
||||
|
||||
return prefix + this.libName + '-' + this.version + ext;
|
||||
}
|
||||
|
||||
private boolean isJarURL(URL url) {
|
||||
if (url == null) {
|
||||
return false;
|
||||
}
|
||||
String name = url.getFile();
|
||||
|
||||
String jarName = getJarName();
|
||||
if (name.indexOf(jarName) != -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int ix = jarName.indexOf(".jar");
|
||||
if (ix != -1) {
|
||||
//check for a versioned name-x.x.jar
|
||||
jarName = jarName.substring(0, ix) + "-";
|
||||
|
||||
//lastIndex else could match "sigar-bin/"
|
||||
ix = name.lastIndexOf(jarName);
|
||||
if (ix != -1) {
|
||||
jarName = name.substring(ix);
|
||||
ix = jarName.indexOf(".jar");
|
||||
if (ix == -1) {
|
||||
return false;
|
||||
}
|
||||
this.version =
|
||||
jarName.substring(jarName.indexOf('-')+1, ix);
|
||||
jarName = jarName.substring(0, ix+4);
|
||||
setJarName(jarName); //for future reference
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String findJarPath(String libName)
|
||||
throws ArchLoaderException {
|
||||
return findJarPath(libName, true);
|
||||
}
|
||||
|
||||
private String findJarPath(String libName, boolean isRequired)
|
||||
throws ArchLoaderException {
|
||||
/*
|
||||
* native libraries should be installed along side
|
||||
* ${this.name}.jar, try to find where ${this.name}.jar
|
||||
* is on disk and use that path.
|
||||
*/
|
||||
if (getJarName() == null) {
|
||||
throw new ArchLoaderException("jarName is null");
|
||||
}
|
||||
|
||||
String path = getResourcePath();
|
||||
ClassLoader loader = getClassLoader();
|
||||
URL url = loader.getResource(path);
|
||||
|
||||
if (!isJarURL(url)) {
|
||||
url = null;
|
||||
}
|
||||
|
||||
if ((url == null) && (loader instanceof URLClassLoader)) {
|
||||
URL[] urls = ((URLClassLoader)loader).getURLs();
|
||||
|
||||
for (int i=0; i<urls.length; i++) {
|
||||
if (isJarURL(urls[i])) {
|
||||
url = urls[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (url == null) {
|
||||
if (isRequired) {
|
||||
throw new ArchLoaderException("Unable to find " +
|
||||
getJarName());
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
path = url.getFile();
|
||||
|
||||
if (path.startsWith("file:")) {
|
||||
path = path.substring(5);
|
||||
}
|
||||
File file = new File(path);
|
||||
String jarName = getJarName();
|
||||
|
||||
while ((file != null) &&
|
||||
!file.getName().startsWith(jarName))
|
||||
{
|
||||
file = file.getParentFile();
|
||||
}
|
||||
|
||||
if (libName == null) {
|
||||
//return path containing ${this.name}.jar
|
||||
//which may or may not be -x.x.x.x versioned
|
||||
libName = jarName;
|
||||
}
|
||||
|
||||
if ((file != null) &&
|
||||
((file = file.getParentFile()) != null))
|
||||
{
|
||||
String dir = URLDecoder.decode(file.toString());
|
||||
if (findNativeLibrary(dir, libName)) {
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//java.lang.ClassLoader does not delegate native linking
|
||||
//to the parent ClassLoader.
|
||||
//overriding these methods provides a workaround.
|
||||
protected void systemLoadLibrary(String name) {
|
||||
System.loadLibrary(name);
|
||||
}
|
||||
|
||||
protected void systemLoad(String name) {
|
||||
System.load(name);
|
||||
}
|
||||
|
||||
protected boolean containsNativeLibrary(File dir, String name) {
|
||||
if (name == null) {
|
||||
return false;
|
||||
}
|
||||
File file = new File(dir, name);
|
||||
if (file.exists()) {
|
||||
this.nativeLibrary = file;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean findNativeLibrary(String dir, String name) {
|
||||
//must be an absolute path; this allows relative to $PWD
|
||||
File path = new File(dir).getAbsoluteFile();
|
||||
if (containsNativeLibrary(path, name)) {
|
||||
return true;
|
||||
}
|
||||
else if (containsNativeLibrary(path, getVersionedLibraryName())) {
|
||||
return true;
|
||||
}
|
||||
//try w/o arch name (e.g. "libsigar.so")
|
||||
return containsNativeLibrary(path,
|
||||
getLibraryPrefix() +
|
||||
getName() +
|
||||
getLibraryExtension());
|
||||
}
|
||||
|
||||
protected boolean findInJavaLibraryPath(String libName) {
|
||||
String path = System.getProperty("java.library.path", "");
|
||||
StringTokenizer tok =
|
||||
new StringTokenizer(path, File.pathSeparator);
|
||||
while (tok.hasMoreTokens()) {
|
||||
path = tok.nextToken();
|
||||
if (findNativeLibrary(path, libName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void loadLibrary(String path)
|
||||
throws ArchNotSupportedException,
|
||||
ArchLoaderException {
|
||||
|
||||
try {
|
||||
String libName = getLibraryName();
|
||||
|
||||
if (path == null) {
|
||||
//e.g. org.hyperic.sigar.path
|
||||
path = System.getProperty(getPackageName() + ".path");
|
||||
}
|
||||
|
||||
if (path != null) {
|
||||
if (path.equals("-")) {
|
||||
return; //assume library is already loaded
|
||||
}
|
||||
findJarPath(null, false); //check for versioned .jar
|
||||
findNativeLibrary(path, libName);
|
||||
}
|
||||
else {
|
||||
if (findJarPath(libName, false) == null) {
|
||||
findInJavaLibraryPath(libName);
|
||||
}
|
||||
}
|
||||
|
||||
//nativeLibrary set when findJarPath() calls findNativeLibrary()
|
||||
if (this.nativeLibrary != null) {
|
||||
systemLoad(this.nativeLibrary.toString());
|
||||
}
|
||||
else {
|
||||
//LD_LIBRARY_PATH must be set for linux and solaris
|
||||
//SHLIB_PATH must be set for hpux
|
||||
//PATH must be set for windows
|
||||
systemLoadLibrary(libName);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
String reason = e.getMessage();
|
||||
if (reason == null) {
|
||||
reason = e.getClass().getName();
|
||||
}
|
||||
|
||||
String msg =
|
||||
"Failed to load " + libName +
|
||||
": " + reason;
|
||||
|
||||
throw new ArchLoaderException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void load()
|
||||
throws ArchNotSupportedException,
|
||||
ArchLoaderException {
|
||||
load(null);
|
||||
}
|
||||
|
||||
public void load(String path)
|
||||
throws ArchNotSupportedException,
|
||||
ArchLoaderException {
|
||||
/*
|
||||
* System.loadLibrary() is only supposed to load the library
|
||||
* once per-classloader. but we make extra sure that is the case.
|
||||
*/
|
||||
synchronized (this.loadLock) {
|
||||
if (this.loaded) {
|
||||
return;
|
||||
}
|
||||
loadLibrary(path);
|
||||
this.loaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
||||
* This file is part of SIGAR.
|
||||
*
|
||||
* SIGAR is free software; you can redistribute it and/or modify
|
||||
* it under the terms version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation. This program is distributed
|
||||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
package org.hyperic.jni;
|
||||
|
||||
public class ArchLoaderException extends Exception {
|
||||
|
||||
public ArchLoaderException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ArchLoaderException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
||||
* This file is part of SIGAR.
|
||||
*
|
||||
* SIGAR is free software; you can redistribute it and/or modify
|
||||
* it under the terms version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation. This program is distributed
|
||||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
package org.hyperic.jni;
|
||||
|
||||
/**
|
||||
* Helper class for naming the jni library with
|
||||
* platform/arch name for which it is binary compatible.
|
||||
*/
|
||||
public class ArchName {
|
||||
|
||||
static boolean useDmalloc =
|
||||
System.getProperty("jni.dmalloc") != null;
|
||||
|
||||
public static String getName() throws ArchNotSupportedException {
|
||||
String name = getArchName();
|
||||
if (useDmalloc) {
|
||||
name += "-dmalloc";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public static boolean is64() {
|
||||
return "64".equals(System.getProperty("sun.arch.data.model"));
|
||||
}
|
||||
|
||||
private static String getArchName() throws ArchNotSupportedException {
|
||||
String name = System.getProperty("os.name");
|
||||
String arch = System.getProperty("os.arch");
|
||||
String version = System.getProperty("os.version");
|
||||
String majorVersion = version.substring(0, 1); //4.x, 5.x, etc.
|
||||
|
||||
if (arch.endsWith("86")) {
|
||||
arch = "x86";
|
||||
}
|
||||
|
||||
if (name.equals("Linux")) {
|
||||
return arch + "-linux";
|
||||
}
|
||||
else if (name.indexOf("Windows") > -1) {
|
||||
return arch + "-winnt";
|
||||
}
|
||||
else if (name.equals("SunOS")) {
|
||||
if (arch.startsWith("sparcv") && is64()) {
|
||||
arch = "sparc64";
|
||||
}
|
||||
return arch + "-solaris";
|
||||
}
|
||||
else if (name.equals("HP-UX")) {
|
||||
if (arch.startsWith("IA64")) {
|
||||
arch = "ia64";
|
||||
}
|
||||
else {
|
||||
arch = "pa";
|
||||
}
|
||||
if (version.indexOf("11") > -1) {
|
||||
return arch + "-hpux-11";
|
||||
}
|
||||
}
|
||||
else if (name.equals("AIX")) {
|
||||
if (majorVersion.equals("6")) {
|
||||
//v5 binary is compatible with v6
|
||||
majorVersion = "5";
|
||||
}
|
||||
//arch == "ppc" on 32-bit, "ppc64" on 64-bit
|
||||
return arch + "-aix-" + majorVersion;
|
||||
}
|
||||
else if (name.equals("Mac OS X") || name.equals("Darwin")) {
|
||||
if (is64()) {
|
||||
return "universal64-macosx";
|
||||
}
|
||||
else {
|
||||
return "universal-macosx";
|
||||
}
|
||||
}
|
||||
else if (name.equals("FreeBSD")) {
|
||||
//none of the 4,5,6 major versions are binary compatible
|
||||
return arch + "-freebsd-" + majorVersion;
|
||||
}
|
||||
else if (name.equals("OpenBSD")) {
|
||||
return arch + "-openbsd-" + majorVersion;
|
||||
}
|
||||
else if (name.equals("NetBSD")) {
|
||||
return arch + "-netbsd-" + majorVersion;
|
||||
}
|
||||
else if (name.equals("OSF1")) {
|
||||
return "alpha-osf1-" + majorVersion;
|
||||
}
|
||||
else if (name.equals("NetWare")) {
|
||||
return "x86-netware-" + majorVersion;
|
||||
}
|
||||
|
||||
String desc = arch + "-" + name + "-" + version;
|
||||
|
||||
throw new ArchNotSupportedException("platform (" + desc + ") not supported");
|
||||
}
|
||||
|
||||
private ArchName () { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
||||
* This file is part of SIGAR.
|
||||
*
|
||||
* SIGAR is free software; you can redistribute it and/or modify
|
||||
* it under the terms version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation. This program is distributed
|
||||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
package org.hyperic.jni;
|
||||
|
||||
import org.apache.tools.ant.Task;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
|
||||
public class ArchNameTask extends Task {
|
||||
|
||||
public void execute() throws BuildException {
|
||||
String osArch = System.getProperty("os.arch");
|
||||
|
||||
if (getProject().getProperty("jni.dmalloc") != null) {
|
||||
ArchName.useDmalloc = true;
|
||||
}
|
||||
|
||||
String archName;
|
||||
|
||||
try {
|
||||
archName = ArchName.getName();
|
||||
} catch (ArchNotSupportedException e) {
|
||||
//ok: can still compile *.java
|
||||
System.out.println(e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println(archName);
|
||||
getProject().setProperty("jni.libarch", archName);
|
||||
getProject().setProperty("jni.libpre",
|
||||
ArchLoader.getLibraryPrefix());
|
||||
getProject().setProperty("jni.libext",
|
||||
ArchLoader.getLibraryExtension());
|
||||
|
||||
String compiler;
|
||||
if (ArchLoader.IS_WIN32) {
|
||||
compiler = "msvc";
|
||||
}
|
||||
else if (ArchLoader.IS_HPUX) {
|
||||
compiler = "hp";
|
||||
}
|
||||
else if (ArchLoader.IS_AIX) {
|
||||
compiler = "xlc_r";
|
||||
}
|
||||
else {
|
||||
compiler = "gcc";
|
||||
getProject().setProperty("jni.compiler.isgcc", "true");
|
||||
}
|
||||
|
||||
getProject().setProperty("jni.compiler", compiler);
|
||||
|
||||
if (ArchName.is64()) {
|
||||
getProject().setProperty("jni.arch64", "true");
|
||||
if (ArchLoader.IS_LINUX) {
|
||||
if (!osArch.equals("ia64")) {
|
||||
getProject().setProperty("jni.gccm", "-m64");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ArchLoader.IS_LINUX && osArch.equals("s390")) {
|
||||
//gcc defaults to m64 on s390x platforms
|
||||
getProject().setProperty("jni.gccm", "-m31");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
||||
* This file is part of SIGAR.
|
||||
*
|
||||
* SIGAR is free software; you can redistribute it and/or modify
|
||||
* it under the terms version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation. This program is distributed
|
||||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
package org.hyperic.jni;
|
||||
|
||||
public class ArchNotSupportedException extends Exception {
|
||||
|
||||
public ArchNotSupportedException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ArchNotSupportedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
||||
* This file is part of SIGAR.
|
||||
*
|
||||
* SIGAR is free software; you can redistribute it and/or modify
|
||||
* it under the terms version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation. This program is distributed
|
||||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
package org.hyperic.jni;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.taskdefs.Copy;
|
||||
|
||||
public class CopyDependsTask extends Copy {
|
||||
|
||||
private File depends;
|
||||
|
||||
protected void validateAttributes()
|
||||
throws BuildException {
|
||||
|
||||
super.validateAttributes();
|
||||
if (this.depends == null) {
|
||||
throw new BuildException("missing depends attribute");
|
||||
}
|
||||
}
|
||||
|
||||
public void execute()
|
||||
throws BuildException {
|
||||
|
||||
if (this.destFile.exists()) {
|
||||
String state;
|
||||
if (this.depends.lastModified() >
|
||||
this.destFile.lastModified())
|
||||
{
|
||||
this.setOverwrite(true);
|
||||
state = "out of date";
|
||||
}
|
||||
else {
|
||||
state = "up to date";
|
||||
}
|
||||
|
||||
log(this.destFile +
|
||||
" " + state + " with " +
|
||||
this.depends);
|
||||
}
|
||||
|
||||
super.execute();
|
||||
}
|
||||
|
||||
public File getDepends() {
|
||||
return this.depends;
|
||||
}
|
||||
|
||||
public void setDepends(String depends) {
|
||||
this.depends = new File(depends);
|
||||
}
|
||||
}
|
||||
@@ -17,13 +17,25 @@
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#define UNICODE
|
||||
#define _UNICODE
|
||||
|
||||
#include "javasigar.h"
|
||||
#include "win32bindings.h"
|
||||
|
||||
#define MAX_MSG_LENGTH 8192
|
||||
#define MAX_ERROR_LENGTH 1024
|
||||
|
||||
#define REG_MSGFILE_ROOT "SYSTEM\\CurrentControlSet\\Services\\EventLog\\"
|
||||
#define REG_MSGFILE_ROOT L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\"
|
||||
#define FILESEP L";"
|
||||
#define STRING_SIG "Ljava/lang/String;"
|
||||
|
||||
#define UNICODE_SetStringField(field, str) \
|
||||
id = JENV->GetFieldID(env, cls, field, STRING_SIG); \
|
||||
value = JENV->NewString(env, (const jchar *)str, wcslen(str)); \
|
||||
JENV->SetObjectField(env, obj, id, value)
|
||||
|
||||
#define ARRLEN(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
|
||||
static void win32_set_pointer(JNIEnv *env, jobject obj, const void *ptr)
|
||||
{
|
||||
@@ -57,27 +69,32 @@ static HANDLE win32_get_pointer(JNIEnv *env, jobject obj)
|
||||
return h;
|
||||
}
|
||||
|
||||
static int get_messagefile_dll(const char *app, char *source, char *dllfile)
|
||||
static int get_messagefile_dll(LPWSTR app, LPWSTR source, LPWSTR dllfile)
|
||||
{
|
||||
HKEY hk;
|
||||
char buf[MAX_MSG_LENGTH];
|
||||
WCHAR buf[MAX_MSG_LENGTH];
|
||||
DWORD type, data = sizeof(buf);
|
||||
LONG rc;
|
||||
|
||||
sprintf(buf, "%s%s\\%s", REG_MSGFILE_ROOT, app, source);
|
||||
rc = RegOpenKey(HKEY_LOCAL_MACHINE, buf, &hk);
|
||||
wcscpy(buf, REG_MSGFILE_ROOT);
|
||||
wcscat(buf, app);
|
||||
wcscat(buf, L"\\");
|
||||
wcscat(buf, source);
|
||||
|
||||
rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf,
|
||||
0, KEY_READ, &hk);
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = RegQueryValueEx(hk, "EventMessageFile", NULL, &type,
|
||||
(UCHAR *)buf, &data);
|
||||
rc = RegQueryValueEx(hk, L"EventMessageFile", NULL, &type,
|
||||
(LPBYTE)buf, &data);
|
||||
if (rc) {
|
||||
RegCloseKey(hk);
|
||||
return rc;
|
||||
}
|
||||
|
||||
strncpy(dllfile, buf, MAX_MSG_LENGTH);
|
||||
wcsncpy(dllfile, buf, MAX_MSG_LENGTH);
|
||||
dllfile[MAX_MSG_LENGTH-1] = '\0';
|
||||
|
||||
RegCloseKey(hk);
|
||||
@@ -85,13 +102,13 @@ static int get_messagefile_dll(const char *app, char *source, char *dllfile)
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static int get_formatted_message(EVENTLOGRECORD *pevlr, char *dllfile,
|
||||
char *msg)
|
||||
static int get_formatted_message(EVENTLOGRECORD *pevlr, LPWSTR dllfile,
|
||||
LPWSTR msg)
|
||||
{
|
||||
LPVOID msgbuf = NULL;
|
||||
char msgdll[MAX_MSG_LENGTH];
|
||||
char *insert_strs[56], *ptr;
|
||||
int i, max = sizeof(insert_strs) / sizeof(char *);
|
||||
WCHAR msgdll[MAX_MSG_LENGTH];
|
||||
LPWSTR insert_strs[56], ptr;
|
||||
int i, max = ARRLEN(insert_strs);
|
||||
const DWORD flags =
|
||||
FORMAT_MESSAGE_FROM_HMODULE |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
@@ -99,25 +116,20 @@ static int get_formatted_message(EVENTLOGRECORD *pevlr, char *dllfile,
|
||||
FORMAT_MESSAGE_ARGUMENT_ARRAY |
|
||||
FORMAT_MESSAGE_MAX_WIDTH_MASK;
|
||||
|
||||
if (!ExpandEnvironmentStrings(dllfile, msgdll, sizeof(msgdll))) {
|
||||
if (!ExpandEnvironmentStrings(dllfile, msgdll, ARRLEN(msgdll))) {
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
memset(insert_strs, '\0', sizeof(insert_strs));
|
||||
ptr = (char *)((LPBYTE)pevlr + pevlr->StringOffset);
|
||||
ptr = (LPWSTR)((LPBYTE)pevlr + pevlr->StringOffset);
|
||||
for (i = 0; i < pevlr->NumStrings && i < max; i++) {
|
||||
insert_strs[i] = ptr;
|
||||
ptr += strlen(ptr) + 1;
|
||||
ptr += wcslen(ptr) + 1;
|
||||
}
|
||||
|
||||
ptr = msgdll;
|
||||
ptr = wcstok(msgdll, FILESEP);
|
||||
while (ptr) {
|
||||
HINSTANCE hlib;
|
||||
char *delim = strchr(ptr, ';');
|
||||
|
||||
if (delim) {
|
||||
*delim++ = '\0';
|
||||
}
|
||||
|
||||
hlib = LoadLibraryEx(ptr, NULL,
|
||||
LOAD_LIBRARY_AS_DATAFILE);
|
||||
@@ -126,20 +138,20 @@ static int get_formatted_message(EVENTLOGRECORD *pevlr, char *dllfile,
|
||||
hlib,
|
||||
pevlr->EventID,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_ENGLISH_US),
|
||||
(LPTSTR) &msgbuf,
|
||||
sizeof(msgbuf),
|
||||
insert_strs);
|
||||
(LPWSTR) &msgbuf,
|
||||
sizeof(msgbuf), //min bytes w/ FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
(va_list *)insert_strs);
|
||||
FreeLibrary(hlib);
|
||||
|
||||
if (msgbuf) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
ptr = delim;
|
||||
ptr = wcstok(NULL, FILESEP);
|
||||
}
|
||||
|
||||
if (msgbuf) {
|
||||
strncpy(msg, msgbuf, MAX_MSG_LENGTH);
|
||||
wcsncpy(msg, msgbuf, MAX_MSG_LENGTH);
|
||||
msg[MAX_MSG_LENGTH-1] = '\0';
|
||||
LocalFree(msgbuf);
|
||||
return ERROR_SUCCESS;
|
||||
@@ -153,9 +165,9 @@ JNIEXPORT void SIGAR_JNI(win32_EventLog_openlog)
|
||||
(JNIEnv *env, jobject obj, jstring lpSourceName)
|
||||
{
|
||||
HANDLE h;
|
||||
const char *name;
|
||||
LPWSTR name;
|
||||
|
||||
name = JENV->GetStringUTFChars(env, lpSourceName, 0);
|
||||
name = (LPWSTR)JENV->GetStringChars(env, lpSourceName, NULL);
|
||||
|
||||
h = OpenEventLog(NULL, name);
|
||||
if (h == NULL) {
|
||||
@@ -163,12 +175,12 @@ JNIEXPORT void SIGAR_JNI(win32_EventLog_openlog)
|
||||
DWORD lastError = GetLastError();
|
||||
|
||||
sprintf(buf, "Unable to open event log: %d", lastError);
|
||||
JENV->ReleaseStringUTFChars(env, lpSourceName, name);
|
||||
JENV->ReleaseStringChars(env, lpSourceName, name);
|
||||
win32_throw_exception(env, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
JENV->ReleaseStringUTFChars(env, lpSourceName, name);
|
||||
JENV->ReleaseStringChars(env, lpSourceName, name);
|
||||
|
||||
/* Save the handle for later use */
|
||||
win32_set_pointer(env, obj, h);
|
||||
@@ -217,16 +229,16 @@ JNIEXPORT jobject SIGAR_JNI(win32_EventLog_readlog)
|
||||
{
|
||||
EVENTLOGRECORD *pevlr;
|
||||
BYTE buffer[8192];
|
||||
char dllfile[MAX_MSG_LENGTH];
|
||||
char msg[MAX_MSG_LENGTH];
|
||||
WCHAR dllfile[MAX_MSG_LENGTH];
|
||||
WCHAR msg[MAX_MSG_LENGTH];
|
||||
DWORD dwRead, dwNeeded;
|
||||
LPSTR source, machineName;
|
||||
LPWSTR source, machineName;
|
||||
HANDLE h;
|
||||
BOOL rv;
|
||||
jclass cls = WIN32_FIND_CLASS("EventLogRecord");
|
||||
jobject eventObj; /* Actual instance of the EventLogRecord */
|
||||
jfieldID id;
|
||||
const char *name;
|
||||
jstring value;
|
||||
LPWSTR name;
|
||||
|
||||
h = win32_get_pointer(env, obj);
|
||||
|
||||
@@ -254,59 +266,54 @@ JNIEXPORT jobject SIGAR_JNI(win32_EventLog_readlog)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
eventObj = JENV->AllocObject(env, cls);
|
||||
obj = JENV->AllocObject(env, cls);
|
||||
|
||||
id = JENV->GetFieldID(env, cls, "recordNumber", "J");
|
||||
JENV->SetLongField(env, eventObj, id, pevlr->RecordNumber);
|
||||
JENV->SetLongField(env, obj, id, pevlr->RecordNumber);
|
||||
|
||||
id = JENV->GetFieldID(env, cls, "timeGenerated", "J");
|
||||
JENV->SetLongField(env, eventObj, id, pevlr->TimeGenerated);
|
||||
JENV->SetLongField(env, obj, id, pevlr->TimeGenerated);
|
||||
|
||||
id = JENV->GetFieldID(env, cls, "timeWritten", "J");
|
||||
JENV->SetLongField(env, eventObj, id, pevlr->TimeWritten);
|
||||
JENV->SetLongField(env, obj, id, pevlr->TimeWritten);
|
||||
|
||||
id = JENV->GetFieldID(env, cls, "eventId", "J");
|
||||
JENV->SetLongField(env, eventObj, id, pevlr->EventID);
|
||||
JENV->SetLongField(env, obj, id, pevlr->EventID);
|
||||
|
||||
id = JENV->GetFieldID(env, cls, "eventType", "S");
|
||||
JENV->SetShortField(env, eventObj, id, pevlr->EventType);
|
||||
JENV->SetShortField(env, obj, id, pevlr->EventType);
|
||||
|
||||
/* Extract string data from the end of the structure. Lame. */
|
||||
|
||||
id = JENV->GetFieldID(env, cls, "source", "Ljava/lang/String;");
|
||||
source = (LPSTR)((LPBYTE)pevlr + sizeof(EVENTLOGRECORD));
|
||||
SetStringField(env, eventObj, id, source);
|
||||
source = (LPWSTR)((LPBYTE)pevlr + sizeof(EVENTLOGRECORD));
|
||||
UNICODE_SetStringField("source", source);
|
||||
|
||||
name = JENV->GetStringUTFChars(env, jname, 0);
|
||||
name = (LPWSTR)JENV->GetStringChars(env, jname, NULL);
|
||||
|
||||
/* Get the formatted message */
|
||||
if ((pevlr->NumStrings > 0) &&
|
||||
(get_messagefile_dll(name, source, dllfile) == ERROR_SUCCESS) &&
|
||||
(get_formatted_message(pevlr, dllfile, msg) == ERROR_SUCCESS))
|
||||
{
|
||||
id = JENV->GetFieldID(env, cls, "message",
|
||||
"Ljava/lang/String;");
|
||||
SetStringField(env, eventObj, id, msg);
|
||||
UNICODE_SetStringField("message", msg);
|
||||
}
|
||||
else if (pevlr->NumStrings > 0) {
|
||||
char *tmp = (LPSTR)((LPBYTE)pevlr + pevlr->StringOffset);
|
||||
id = JENV->GetFieldID(env, cls, "message", "Ljava/lang/String;");
|
||||
SetStringField(env, eventObj, id, tmp);
|
||||
LPWSTR tmp = (LPWSTR)((LPBYTE)pevlr + pevlr->StringOffset);
|
||||
UNICODE_SetStringField("message", tmp);
|
||||
}
|
||||
JENV->ReleaseStringUTFChars(env, jname, name);
|
||||
JENV->ReleaseStringChars(env, jname, name);
|
||||
|
||||
/* Increment up to the machine name. */
|
||||
id = JENV->GetFieldID(env, cls, "computerName", "Ljava/lang/String;");
|
||||
machineName = (LPSTR)((LPBYTE)pevlr + sizeof(EVENTLOGRECORD) +
|
||||
strlen(source) + 1);
|
||||
SetStringField(env, eventObj, id, machineName);
|
||||
machineName = (LPWSTR)((LPBYTE)pevlr + sizeof(EVENTLOGRECORD) +
|
||||
wcslen(source) + 1);
|
||||
UNICODE_SetStringField("computerName", machineName);
|
||||
|
||||
/* Get user id info */
|
||||
if (pevlr->UserSidLength > 0) {
|
||||
char name[256];
|
||||
char domain[256];
|
||||
DWORD namelen = sizeof(name);
|
||||
DWORD domainlen = sizeof(domain);
|
||||
WCHAR name[256];
|
||||
WCHAR domain[256];
|
||||
DWORD namelen = ARRLEN(name);
|
||||
DWORD domainlen = ARRLEN(domain);
|
||||
DWORD len;
|
||||
SID_NAME_USE snu;
|
||||
PSID sid;
|
||||
@@ -314,12 +321,11 @@ JNIEXPORT jobject SIGAR_JNI(win32_EventLog_readlog)
|
||||
sid = (PSID)((LPBYTE)pevlr + pevlr->UserSidOffset);
|
||||
if (LookupAccountSid(NULL, sid, name, &namelen, domain,
|
||||
&domainlen, &snu)) {
|
||||
id = JENV->GetFieldID(env, cls, "user", "Ljava/lang/String;");
|
||||
SetStringField(env, eventObj, id, name);
|
||||
UNICODE_SetStringField("user", name);
|
||||
}
|
||||
}
|
||||
|
||||
return eventObj;
|
||||
return obj;
|
||||
}
|
||||
|
||||
JNIEXPORT void SIGAR_JNI(win32_EventLog_waitForChange)
|
||||
|
||||
@@ -106,6 +106,19 @@ JNIEXPORT jint SIGAR_JNI(win32_RegistryKey_RegLoadKey)
|
||||
return lResult;
|
||||
}
|
||||
|
||||
/* http://msdn.microsoft.com/en-us/library/aa384129(VS.85).aspx */
|
||||
#ifndef KEY_WOW64_64KEY
|
||||
#define KEY_WOW64_64KEY 0x0100
|
||||
#endif
|
||||
#ifndef KEY_WOW64_32KEY
|
||||
#define KEY_WOW64_32KEY 0x0200
|
||||
#endif
|
||||
|
||||
static DWORD RegOpenOpts[] = {
|
||||
KEY_WOW64_32KEY,
|
||||
KEY_WOW64_64KEY
|
||||
};
|
||||
|
||||
JNIEXPORT jlong SIGAR_JNI(win32_RegistryKey_RegOpenKey)
|
||||
(JNIEnv *env, jclass, jlong hkey, jstring subkey)
|
||||
{
|
||||
@@ -113,6 +126,7 @@ JNIEXPORT jlong SIGAR_JNI(win32_RegistryKey_RegOpenKey)
|
||||
jsize len = env->GetStringLength(subkey);
|
||||
LPTSTR lpSubkey = (LPTSTR)env->GetStringChars(subkey, NULL);
|
||||
LPTSTR copy;
|
||||
int i;
|
||||
|
||||
/* required under IBM/WebSphere 4.0 for certain keys */
|
||||
if (lpSubkey[len] != '\0') {
|
||||
@@ -122,7 +136,18 @@ JNIEXPORT jlong SIGAR_JNI(win32_RegistryKey_RegOpenKey)
|
||||
else {
|
||||
copy = lpSubkey;
|
||||
}
|
||||
RegOpenKey((HKEY)hkey, copy, &hkeyResult);
|
||||
|
||||
/* try both flags so 32-bit apps can access registry entries
|
||||
of 64-bit apps and vice-versa */
|
||||
for (i=0; i<sizeof(RegOpenOpts)/sizeof(RegOpenOpts[0]); i++) {
|
||||
DWORD status =
|
||||
RegOpenKeyEx((HKEY)hkey, copy,
|
||||
0, KEY_READ|RegOpenOpts[i],
|
||||
&hkeyResult);
|
||||
if (status == ERROR_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
env->ReleaseStringChars(subkey, (const jchar *)lpSubkey);
|
||||
if (copy != lpSubkey) {
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
package org.hyperic.sigar;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
|
||||
@@ -54,24 +56,24 @@ public abstract class FileTail extends FileWatcher {
|
||||
}
|
||||
|
||||
public void onChange(FileInfo info) {
|
||||
InputStream in = null;
|
||||
Reader reader = null;
|
||||
String name = info.getName();
|
||||
|
||||
try {
|
||||
if (this.useSudo) {
|
||||
reader =
|
||||
new InputStreamReader(new SudoFileInputStream(name));
|
||||
in = new SudoFileInputStream(name);
|
||||
}
|
||||
else {
|
||||
reader = new FileReader(name);
|
||||
in = new FileInputStream(name);
|
||||
}
|
||||
|
||||
long offset = getOffset(info);
|
||||
|
||||
if (offset > 0) {
|
||||
reader.skip(offset);
|
||||
in.skip(offset); //use InputStream to skip bytes
|
||||
}
|
||||
|
||||
reader = new InputStreamReader(in);
|
||||
tail(info, reader);
|
||||
} catch (IOException e) {
|
||||
error(name, e);
|
||||
@@ -79,6 +81,9 @@ public abstract class FileTail extends FileWatcher {
|
||||
if (reader != null) {
|
||||
try { reader.close(); } catch (IOException e) { }
|
||||
}
|
||||
if (in != null) {
|
||||
try { in.close(); } catch (IOException e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) [2004-2009], Hyperic, Inc.
|
||||
* This file is part of SIGAR.
|
||||
*
|
||||
* SIGAR is free software; you can redistribute it and/or modify
|
||||
* it under the terms version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation. This program is distributed
|
||||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
package org.hyperic.sigar;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
/**
|
||||
* The Humidor provides access to a single Sigar instance. Sigar has a
|
||||
* high-cost setup/teardown and has a high amount of caching, used to determine
|
||||
* things like the % of CPU used in-between calls.
|
||||
*
|
||||
* The Humidor also synchronizes access to all Sigar methods, so all
|
||||
* calls will be serialized.
|
||||
*/
|
||||
public class Humidor {
|
||||
private static final Humidor INSTANCE = new Humidor();
|
||||
private Object LOCK = new Object();
|
||||
private InvocationHandler _handler;
|
||||
private SigarProxy _sigar;
|
||||
private Sigar _impl;
|
||||
|
||||
private Humidor() {}
|
||||
|
||||
public Humidor(Sigar sigar) {
|
||||
_impl = sigar;
|
||||
}
|
||||
|
||||
private static class MyHandler implements InvocationHandler {
|
||||
private SigarProxy _sigar;
|
||||
private Object _lock = new Object();
|
||||
|
||||
public MyHandler(SigarProxy sigar) {
|
||||
_sigar = sigar;
|
||||
}
|
||||
|
||||
public Object invoke(Object proxy, Method meth, Object[] args)
|
||||
throws Throwable
|
||||
{
|
||||
try {
|
||||
synchronized (_lock) {
|
||||
return meth.invoke(_sigar, args);
|
||||
}
|
||||
} catch(InvocationTargetException e) {
|
||||
throw e.getTargetException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SigarProxy getSigar() {
|
||||
synchronized(LOCK) {
|
||||
if (_sigar == null) {
|
||||
if (_impl == null) {
|
||||
_impl = new Sigar();
|
||||
}
|
||||
_handler = new MyHandler(_impl);
|
||||
_sigar = (SigarProxy)
|
||||
Proxy.newProxyInstance(Humidor.class.getClassLoader(),
|
||||
new Class[] { SigarProxy.class },
|
||||
_handler);
|
||||
}
|
||||
return _sigar;
|
||||
}
|
||||
}
|
||||
|
||||
public static Humidor getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -158,6 +158,8 @@ public interface SigarProxy {
|
||||
|
||||
public NetStat getNetStat() throws SigarException;
|
||||
|
||||
public String getNetServicesName(int protocol, long port);
|
||||
|
||||
public Who[] getWhoList() throws SigarException;
|
||||
|
||||
public Tcp getTcp() throws SigarException;
|
||||
|
||||
@@ -123,7 +123,7 @@ public class SigarProxyCache
|
||||
* The java.lang.reflect.InvocationHandler used by the Proxy.
|
||||
* This method handles caching of all Sigar type objects.
|
||||
*/
|
||||
public Object invoke(Object proxy, Method method, Object[] args)
|
||||
public synchronized Object invoke(Object proxy, Method method, Object[] args)
|
||||
throws SigarException, SigarNotImplementedException {
|
||||
|
||||
SigarCacheObject cacheVal = null;
|
||||
|
||||
@@ -83,7 +83,12 @@ public class Top {
|
||||
|
||||
String cpuPerc = "?";
|
||||
|
||||
List info = Ps.getInfo(sigar, pid);
|
||||
List info;
|
||||
try {
|
||||
info = Ps.getInfo(sigar, pid);
|
||||
} catch (SigarException e) {
|
||||
continue; //process may have gone away
|
||||
}
|
||||
try {
|
||||
ProcCpu cpu = sigar.getProcCpu(pid);
|
||||
cpuPerc = CpuPerc.format(cpu.getPercent());
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Version extends SigarCommandBase {
|
||||
|
||||
os.println("Sigar version......." + version);
|
||||
os.println("Build date.........." + build);
|
||||
os.println("SVN rev............." + scm);
|
||||
os.println("SCM rev............." + scm);
|
||||
String host = getHostName();
|
||||
String fqdn;
|
||||
Sigar sigar = new Sigar();
|
||||
|
||||
@@ -79,6 +79,7 @@ public class SigarTestRunner extends SigarCommandBase {
|
||||
TestUptime.class,
|
||||
TestVMware.class,
|
||||
TestWho.class,
|
||||
TestHumidor.class
|
||||
};
|
||||
|
||||
private static final Class[] WIN32_TESTS = {
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) [2004-2009], Hyperic, Inc.
|
||||
* This file is part of SIGAR.
|
||||
*
|
||||
* SIGAR is free software; you can redistribute it and/or modify
|
||||
* it under the terms version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation. This program is distributed
|
||||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
package org.hyperic.sigar.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.hyperic.sigar.CpuPerc;
|
||||
import org.hyperic.sigar.Humidor;
|
||||
import org.hyperic.sigar.Sigar;
|
||||
import org.hyperic.sigar.SigarException;
|
||||
import org.hyperic.sigar.SigarProxy;
|
||||
|
||||
public class TestHumidor extends SigarTestCase {
|
||||
|
||||
public TestHumidor(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
private static class HumidorThread extends Thread {
|
||||
private SigarProxy sigar;
|
||||
private HumidorThread(SigarProxy sigar) {
|
||||
this.sigar = sigar;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
getProcCpu(this.sigar);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void getProcCpu(SigarProxy sigar) throws Exception {
|
||||
long[] pids = sigar.getProcList();
|
||||
for (int j=0; j<10; j++) {
|
||||
for (int i=0; i<pids.length; i++) {
|
||||
try {
|
||||
double cpu = sigar.getProcCpu(pids[i]).getPercent();
|
||||
if (SigarTestCase.getVerbose()) {
|
||||
System.out.println(Thread.currentThread().getName() +
|
||||
" " + pids[i] + "=" + CpuPerc.format(cpu));
|
||||
}
|
||||
} catch (SigarException e) {
|
||||
//ok - process may have gone away or permission denied.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void runTests(SigarProxy sigar) throws Exception {
|
||||
ArrayList threads = new ArrayList();
|
||||
for (int i=0; i<3; i++) {
|
||||
Thread t = new HumidorThread(sigar);
|
||||
threads.add(t);
|
||||
t.start();
|
||||
}
|
||||
for (int i=0; i<threads.size(); i++) {
|
||||
Thread t = (Thread)threads.get(i);
|
||||
t.join();
|
||||
}
|
||||
}
|
||||
|
||||
public void testGlobalInstance() throws Exception {
|
||||
runTests(Humidor.getInstance().getSigar());
|
||||
}
|
||||
|
||||
public void testInstance() throws Exception {
|
||||
Sigar sigar = new Sigar();
|
||||
runTests(new Humidor(sigar).getSigar());
|
||||
sigar.close();
|
||||
}
|
||||
|
||||
//uncomment to see if this test will indeed cause a segfault
|
||||
//without the protection of the Humidor
|
||||
//public void testUnwrapped() throws Exception {
|
||||
// runTests(new Sigar());
|
||||
//}
|
||||
}
|
||||
@@ -61,6 +61,7 @@ public class TestPTQL extends SigarTestCase {
|
||||
"Args.*.eq=org.apache.tools.ant.Main", //'*' == any arg
|
||||
"Args.*.ct=java", //'*' == any arg
|
||||
"Args.*.ew=sigar.jar", //'*' == any arg
|
||||
"Modules.*.re=libc|kernel",
|
||||
"Port.tcp.eq=80,Cred.Uid.eq=0", //root owned http port
|
||||
"Port.udp.eq=161,Cred.Uid.eq=0", //root owned snmp port
|
||||
"Port.tcp.eq=8080,Cred.Uid.eq=1003", //dougm owned jboss port
|
||||
@@ -157,9 +158,16 @@ public class TestPTQL extends SigarTestCase {
|
||||
assertTrue(THIS_PROCESS,
|
||||
runQuery(sigar, THIS_PROCESS) == 1);
|
||||
|
||||
assertTrue(JAVA_PROCESS + " vs. " + OTHER_JAVA_PROCESS,
|
||||
runQuery(sigar, JAVA_PROCESS) !=
|
||||
runQuery(sigar, OTHER_JAVA_PROCESS));
|
||||
int numProcs = runQuery(sigar, JAVA_PROCESS);
|
||||
int numOtherProcs = runQuery(sigar, OTHER_JAVA_PROCESS);
|
||||
String msg =
|
||||
JAVA_PROCESS +
|
||||
" [" + numProcs + "] vs. [" + numOtherProcs + "] "+
|
||||
OTHER_JAVA_PROCESS;
|
||||
|
||||
//process may have gone away in between runQuery's above.
|
||||
//assertTrue(msg, numProcs != numOtherProcs);
|
||||
traceln(msg);
|
||||
|
||||
for (int i=0; i<OK_QUERIES.length; i++) {
|
||||
String qs = OK_QUERIES[i];
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package org.hyperic.sigar.test;
|
||||
|
||||
import java.util.Date;
|
||||
import org.hyperic.sigar.Sigar;
|
||||
import org.hyperic.sigar.Uptime;
|
||||
|
||||
@@ -32,6 +33,9 @@ public class TestUptime extends SigarTestCase {
|
||||
|
||||
Uptime uptime = sigar.getUptime();
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
traceln("\nboottime=" +
|
||||
new Date(now - (long)uptime.getUptime()*1000));
|
||||
assertTrue(uptime.getUptime() > 0);
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,10 @@ public class TestEventLog extends SigarTestCase {
|
||||
EventLog log = new EventLog();
|
||||
|
||||
log.open(logname);
|
||||
if (log.getNumberOfRecords() == 0) {
|
||||
log.close();
|
||||
return 0; //else log.getOldestRecord() throws Exception
|
||||
}
|
||||
int oldestRecord = log.getOldestRecord();
|
||||
int numRecords = log.getNumberOfRecords();
|
||||
traceln("oldest=" + oldestRecord +
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
|
||||
package org.hyperic.sigar.win32.test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.hyperic.sigar.test.SigarTestCase;
|
||||
import org.hyperic.sigar.win32.RegistryKey;
|
||||
|
||||
public class TestRegistryKey extends TestCase {
|
||||
public class TestRegistryKey extends SigarTestCase {
|
||||
|
||||
private static final boolean TEST_WRITE = false;
|
||||
|
||||
@@ -37,6 +39,71 @@ public class TestRegistryKey extends TestCase {
|
||||
software.close();
|
||||
}
|
||||
|
||||
public void testHardwareValues() throws Exception {
|
||||
RegistryKey hw =
|
||||
RegistryKey.LocalMachine.openSubKey("HARDWARE\\DESCRIPTION\\System");
|
||||
try {
|
||||
ArrayList values = new ArrayList();
|
||||
hw.getMultiStringValue("SystemBiosVersion", values);
|
||||
assertGtZeroTrace("SystemBiosVersion.size()", values.size());
|
||||
traceln("SystemBiosVersion=" + values);
|
||||
} catch (Exception e) {}
|
||||
RegistryKey cpu0 = hw.openSubKey("CentralProcessor\\0");
|
||||
String cpu = cpu0.getStringValue("ProcessorNameString");
|
||||
assertLengthTrace("cpu0", cpu);
|
||||
cpu0.close();
|
||||
hw.close();
|
||||
}
|
||||
|
||||
public void testSoftwareValues() throws Exception {
|
||||
RegistryKey ms =
|
||||
RegistryKey.LocalMachine.openSubKey("SOFTWARE\\Microsoft");
|
||||
|
||||
RegistryKey msmq = null;
|
||||
try {
|
||||
msmq = ms.openSubKey("MSMQ\\Parameters");
|
||||
} catch (Exception e) { /*not installed - ok*/ }
|
||||
if (msmq != null) {
|
||||
traceln("MSMQ...");
|
||||
if (msmq.getSubKeyNames().length > 0) {
|
||||
try {
|
||||
String build = msmq.getStringValue("CurrentBuild");
|
||||
assertLengthTrace("CurrentBuild", build);
|
||||
int id = msmq.getIntValue("SeqID");
|
||||
assertGtZeroTrace("SeqID", id);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
msmq.close();
|
||||
}
|
||||
|
||||
RegistryKey sql = null;
|
||||
try {
|
||||
sql = ms.openSubKey("Microsoft SQL Server\\MSSQL.1\\Setup");
|
||||
} catch (Exception e) { /*not installed - ok*/ }
|
||||
if (sql != null) {
|
||||
traceln("MsSQL...");
|
||||
try {
|
||||
String edition = sql.getStringValue("Edition");
|
||||
assertLengthTrace("Edition", edition);
|
||||
} catch (Exception e) {}
|
||||
sql.close();
|
||||
}
|
||||
ms.close();
|
||||
|
||||
final String TC =
|
||||
"SOFTWARE\\Apache Software Foundation\\Procrun 2.0\\Tomcat6\\Parameters\\Java";
|
||||
try {
|
||||
RegistryKey tc =
|
||||
RegistryKey.LocalMachine.openSubKey(TC);
|
||||
traceln("Tomcat6...");
|
||||
ArrayList values = new ArrayList();
|
||||
tc.getMultiStringValue("Options", values);
|
||||
assertGtZeroTrace("Options.size()", values.size());
|
||||
traceln("Options=" + values);
|
||||
tc.close();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
//dont want to be writing to the registry
|
||||
public void testRegistryWrite() throws Exception {
|
||||
if (!TEST_WRITE) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
copyright.year=2004-2008
|
||||
copyright.year=2004-2009
|
||||
version.major=1
|
||||
version.minor=6
|
||||
version.maint=0
|
||||
version.maint=3
|
||||
version.build=0
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef sigar_proc_cred_name_t * Sigar__ProcCredName;
|
||||
typedef sigar_file_attrs_t * Sigar__FileAttrs;
|
||||
typedef sigar_cpu_t * Sigar__Cpu;
|
||||
typedef sigar_cpu_info_t * Sigar__CpuInfo;
|
||||
typedef sigar_cpu_perc_t * Sigar__CpuPerc;
|
||||
typedef sigar_net_interface_config_t * Sigar__NetInterfaceConfig;
|
||||
typedef sigar_swap_t * Sigar__Swap;
|
||||
typedef sigar_proc_state_t * Sigar__ProcState;
|
||||
|
||||
@@ -14,6 +14,7 @@ Sigar::ProcCredName T_PTROBJ
|
||||
Sigar::FileAttrs T_PTROBJ
|
||||
Sigar::Cpu T_PTROBJ
|
||||
Sigar::CpuInfo T_PTROBJ
|
||||
Sigar::CpuPerc T_PTROBJ
|
||||
Sigar::NetInterfaceConfig T_PTROBJ
|
||||
Sigar::Swap T_PTROBJ
|
||||
Sigar::ProcState T_PTROBJ
|
||||
|
||||
@@ -270,6 +270,8 @@ static VALUE rb_sigar_cpu_info_list(VALUE obj)
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
static VALUE rb_cSigarCpuPerc;
|
||||
|
||||
static VALUE rb_cSigarFileSystem;
|
||||
|
||||
static VALUE rb_sigar_file_system_list(VALUE obj)
|
||||
|
||||
@@ -120,6 +120,10 @@ int sigar_procfs_args_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
|
||||
int sigar_mem_calc_ram(sigar_t *sigar, sigar_mem_t *mem);
|
||||
|
||||
int sigar_statvfs(sigar_t *sigar,
|
||||
const char *dirname,
|
||||
sigar_file_system_usage_t *fsusage);
|
||||
|
||||
double sigar_file_system_usage_calc_used(sigar_t *sigar,
|
||||
sigar_file_system_usage_t *fs);
|
||||
|
||||
|
||||
+58
-716
File diff suppressed because it is too large.
Load diff
@@ -1,542 +0,0 @@
|
||||
/* IBM_PROLOG_BEGIN_TAG */
|
||||
/* This is an automatically generated prolog. */
|
||||
/* */
|
||||
/* bos52B src/bos/usr/ccs/lib/libperfstat/libperfstat.h 1.4.1.6 */
|
||||
/* */
|
||||
/* Licensed Materials - Property of IBM */
|
||||
/* */
|
||||
/* Restricted Materials of IBM */
|
||||
/* */
|
||||
/* (C) COPYRIGHT International Business Machines Corp. 2000,2003 */
|
||||
/* All Rights Reserved */
|
||||
/* */
|
||||
/* US Government Users Restricted Rights - Use, duplication or */
|
||||
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */
|
||||
/* */
|
||||
/* IBM_PROLOG_END_TAG */
|
||||
/*
|
||||
* @(#)91 1.4.1.6 src/bos/usr/ccs/lib/libperfstat/libperfstat.h, libperfstat, bos52B, b2003_06F6 2/6/03 06:43:34
|
||||
* LEVEL 1, 5 Years Bull Confidential Information
|
||||
*
|
||||
*/
|
||||
#ifndef LIBPERFSTAT_H
|
||||
#define LIBPERFSTAT_H
|
||||
|
||||
/* This file describes the structures and constants used by the libperfstat API */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IDENTIFIER_LENGTH 64 /* length of strings included in the structures */
|
||||
|
||||
#define FIRST_CPU "" /* pseudo-name for the first logical cpu */
|
||||
#define FIRST_DISK "" /* pseudo-name for the first disk */
|
||||
#define FIRST_DISKPATH "" /* pseudo-name for the first disk path */
|
||||
#define FIRST_DISKADAPTER "" /* pseudo-name for the first disk adapter */
|
||||
#define FIRST_NETINTERFACE "" /* pseudo-name for the first network interface */
|
||||
#define FIRST_PAGINGSPACE "" /* pseudo-name for the first paging space */
|
||||
#define FIRST_PROTOCOL "" /* pseudo-name for the first protocol */
|
||||
#define FIRST_NETBUFFER "" /* pseudo-name for the first network buffer size */
|
||||
|
||||
#define DEFAULT_DEF "not available"
|
||||
|
||||
typedef struct { /* structure element identifier */
|
||||
char name[IDENTIFIER_LENGTH]; /* name of the identifier */
|
||||
} perfstat_id_t;
|
||||
|
||||
typedef struct { /* cpu information */
|
||||
char name[IDENTIFIER_LENGTH]; /* logical processor name (cpu0, cpu1, ..) */
|
||||
u_longlong_t user; /* raw number of clock ticks spent in user mode */
|
||||
u_longlong_t sys; /* raw number of clock ticks spent in system mode */
|
||||
u_longlong_t idle; /* raw number of clock ticks spent idle */
|
||||
u_longlong_t wait; /* raw number of clock ticks spent waiting for I/O */
|
||||
u_longlong_t pswitch; /* number of context switches (changes of currently running process) */
|
||||
u_longlong_t syscall; /* number of system calls executed */
|
||||
u_longlong_t sysread; /* number of read system calls executed */
|
||||
u_longlong_t syswrite; /* number of write system calls executed */
|
||||
u_longlong_t sysfork; /* number of fork system call executed */
|
||||
u_longlong_t sysexec; /* number of exec system call executed */
|
||||
u_longlong_t readch; /* number of characters tranferred with read system call */
|
||||
u_longlong_t writech; /* number of characters tranferred with write system call */
|
||||
u_longlong_t bread; /* number of block reads */
|
||||
u_longlong_t bwrite; /* number of block writes */
|
||||
u_longlong_t lread; /* number of logical read requests */
|
||||
u_longlong_t lwrite; /* number of logical write requests */
|
||||
u_longlong_t phread; /* number of physical reads (reads on raw device) */
|
||||
u_longlong_t phwrite; /* number of physical writes (writes on raw device) */
|
||||
u_longlong_t iget; /* number of inode lookups */
|
||||
u_longlong_t namei; /* number of vnode lookup from a path name */
|
||||
u_longlong_t dirblk; /* number of 512-byte block reads by the directory search routine to locate an entry for a file */
|
||||
u_longlong_t msg; /* number of IPC message operations */
|
||||
u_longlong_t sema; /* number of IPC semaphore operations */
|
||||
} perfstat_cpu_t;
|
||||
|
||||
typedef struct { /* global cpu information */
|
||||
int ncpus; /* number of active logical processors */
|
||||
int ncpus_cfg; /* number of configured processors */
|
||||
char description[IDENTIFIER_LENGTH]; /* processor description (type/official name) */
|
||||
u_longlong_t processorHZ; /* processor speed in Hz */
|
||||
u_longlong_t user; /* raw total number of clock ticks spent in user mode */
|
||||
u_longlong_t sys; /* raw total number of clock ticks spent in system mode */
|
||||
u_longlong_t idle; /* raw total number of clock ticks spent idle */
|
||||
u_longlong_t wait; /* raw total number of clock ticks spent waiting for I/O */
|
||||
u_longlong_t pswitch; /* number of process switches (change in currently running process) */
|
||||
u_longlong_t syscall; /* number of system calls executed */
|
||||
u_longlong_t sysread; /* number of read system calls executed */
|
||||
u_longlong_t syswrite; /* number of write system calls executed */
|
||||
u_longlong_t sysfork; /* number of forks system calls executed */
|
||||
u_longlong_t sysexec; /* number of execs system calls executed */
|
||||
u_longlong_t readch; /* number of characters tranferred with read system call */
|
||||
u_longlong_t writech; /* number of characters tranferred with write system call */
|
||||
u_longlong_t devintrs; /* number of device interrupts */
|
||||
u_longlong_t softintrs; /* number of software interrupts */
|
||||
time_t lbolt; /* number of ticks since last reboot */
|
||||
u_longlong_t loadavg[3]; /* (1<<SBITS) times the average number of runnables processes during the last 1, 5 and 15 minutes. */
|
||||
/* To calculate the load average, divide the numbers by (1<<SBITS). SBITS is defined in <sys/proc.h>. */
|
||||
u_longlong_t runque; /* length of the run queue (processes ready) */
|
||||
u_longlong_t swpque; /* ength of the swap queue (processes waiting to be paged in) */
|
||||
u_longlong_t bread; /* number of blocks read */
|
||||
u_longlong_t bwrite; /* number of blocks written */
|
||||
u_longlong_t lread; /* number of logical read requests */
|
||||
u_longlong_t lwrite; /* number of logical write requests */
|
||||
u_longlong_t phread; /* number of physical reads (reads on raw devices) */
|
||||
u_longlong_t phwrite; /* number of physical writes (writes on raw devices) */
|
||||
u_longlong_t runocc; /* updated whenever runque is updated, i.e. the runqueue is occupied.
|
||||
* This can be used to compute the simple average of ready processes */
|
||||
u_longlong_t swpocc; /* updated whenever swpque is updated. i.e. the swpqueue is occupied.
|
||||
* This can be used to compute the simple average processes waiting to be paged in */
|
||||
u_longlong_t iget; /* number of inode lookups */
|
||||
u_longlong_t namei; /* number of vnode lookup from a path name */
|
||||
u_longlong_t dirblk; /* number of 512-byte block reads by the directory search routine to locate an entry for a file */
|
||||
u_longlong_t msg; /* number of IPC message operations */
|
||||
u_longlong_t sema; /* number of IPC semaphore operations */
|
||||
u_longlong_t rcvint; /* number of tty receive interrupts */
|
||||
u_longlong_t xmtint; /* number of tyy transmit interrupts */
|
||||
u_longlong_t mdmint; /* number of modem interrupts */
|
||||
u_longlong_t tty_rawinch; /* number of raw input characters */
|
||||
u_longlong_t tty_caninch; /* number of canonical input characters (always zero) */
|
||||
u_longlong_t tty_rawoutch;/* number of raw output characters */
|
||||
u_longlong_t ksched; /* number of kernel processes created */
|
||||
u_longlong_t koverf; /* kernel process creation attempts where:
|
||||
* -the user has forked to their maximum limit
|
||||
* -the configuration limit of processes has been reached */
|
||||
u_longlong_t kexit; /* number of kernel processes that became zombies */
|
||||
u_longlong_t rbread; /* number of remote read requests */
|
||||
u_longlong_t rcread; /* number of cached remote reads */
|
||||
u_longlong_t rbwrt; /* number of remote writes */
|
||||
u_longlong_t rcwrt; /* number of cached remote writes */
|
||||
u_longlong_t traps; /* number of traps */
|
||||
int ncpus_high; /* index of highest processor online */
|
||||
} perfstat_cpu_total_t;
|
||||
|
||||
typedef struct { /* disk information */
|
||||
char name[IDENTIFIER_LENGTH]; /* name of the disk */
|
||||
char description[IDENTIFIER_LENGTH]; /* disk description (from ODM) */
|
||||
char vgname[IDENTIFIER_LENGTH]; /* volume group name (from ODM) */
|
||||
u_longlong_t size; /* size of the disk (in MB) */
|
||||
u_longlong_t free; /* free portion of the disk (in MB) */
|
||||
u_longlong_t bsize; /* disk block size (in bytes) */
|
||||
u_longlong_t xrate; /* kbytes/sec xfer rate capability */
|
||||
u_longlong_t xfers; /* number of transfers to/from disk */
|
||||
u_longlong_t wblks; /* number of blocks written to disk */
|
||||
u_longlong_t rblks; /* number of blocks read from disk */
|
||||
u_longlong_t qdepth; /* queue depth */
|
||||
u_longlong_t time; /* amount of time disk is active */
|
||||
char adapter[IDENTIFIER_LENGTH]; /* disk adapter name (from ODM) */
|
||||
uint paths_count; /* number of paths defined to the disk */
|
||||
} perfstat_disk_t;
|
||||
|
||||
typedef struct { /* global disk information */
|
||||
int number; /* total number of disks */
|
||||
u_longlong_t size; /* total size of all disks (in MB) */
|
||||
u_longlong_t free; /* free portion of all disks (in MB) */
|
||||
u_longlong_t xrate; /* total kbytes/sec xfer rate capability */
|
||||
u_longlong_t xfers; /* total number of transfers to/from disk */
|
||||
u_longlong_t wblks; /* 512 bytes blocks written to all disks */
|
||||
u_longlong_t rblks; /* 512 bytes blocks read from all disks */
|
||||
u_longlong_t time; /* amount of time disks are active */
|
||||
} perfstat_disk_total_t;
|
||||
|
||||
typedef struct { /* Disk adapter information */
|
||||
char name[IDENTIFIER_LENGTH]; /* name of the adapter (from ODM) */
|
||||
char description[IDENTIFIER_LENGTH]; /* adapter description (from ODM) */
|
||||
int number; /* number of disks connected to adapter */
|
||||
u_longlong_t size; /* total size of all disks (in MB) */
|
||||
u_longlong_t free; /* free portion of all disks (in MB) */
|
||||
u_longlong_t xrate; /* total kbytes/sec xfer rate capability */
|
||||
u_longlong_t xfers; /* total number of transfers to/from disk */
|
||||
u_longlong_t rblks; /* 512 bytes blocks written via adapter */
|
||||
u_longlong_t wblks; /* 512 bytes blocks read via adapter */
|
||||
u_longlong_t time; /* amount of time disks are active */
|
||||
} perfstat_diskadapter_t;
|
||||
|
||||
typedef struct { /* mpio information */
|
||||
char name[IDENTIFIER_LENGTH]; /* name of the path */
|
||||
u_longlong_t xrate; /* total kbytes/sec xfer rate capability */
|
||||
u_longlong_t xfers; /* total number of transfers via the path */
|
||||
u_longlong_t rblks; /* 512 bytes blocks written via the path */
|
||||
u_longlong_t wblks; /* 512 bytes blocks read via the path */
|
||||
u_longlong_t time; /* amount of time disks are active */
|
||||
char adapter[IDENTIFIER_LENGTH]; /* disk adapter name (from ODM) */
|
||||
} perfstat_diskpath_t;
|
||||
|
||||
typedef struct { /* Virtual memory utilization */
|
||||
u_longlong_t virt_total; /* total virtual memory (in 4KB pages) */
|
||||
u_longlong_t real_total; /* total real memory (in 4KB pages) */
|
||||
u_longlong_t real_free; /* free real memory (in 4KB pages) */
|
||||
u_longlong_t real_pinned; /* real memory which is pinned (in 4KB pages) */
|
||||
u_longlong_t real_inuse; /* real memory which is in use (in 4KB pages) */
|
||||
u_longlong_t pgbad; /* number of bad pages */
|
||||
u_longlong_t pgexct; /* number of page faults */
|
||||
u_longlong_t pgins; /* number of pages paged in */
|
||||
u_longlong_t pgouts; /* number of pages paged out */
|
||||
u_longlong_t pgspins; /* number of page ins from paging space */
|
||||
u_longlong_t pgspouts; /* number of page outs from paging space */
|
||||
u_longlong_t scans; /* number of page scans by clock */
|
||||
u_longlong_t cycles; /* number of page replacement cycles */
|
||||
u_longlong_t pgsteals; /* number of page steals */
|
||||
u_longlong_t numperm; /* number of frames used for files (in 4KB pages) */
|
||||
u_longlong_t pgsp_total; /* total paging space (in 4KB pages) */
|
||||
u_longlong_t pgsp_free; /* free paging space (in 4KB pages) */
|
||||
u_longlong_t pgsp_rsvd; /* reserved paging space (in 4KB pages) */
|
||||
u_longlong_t real_system; /* real memory used by system segments (in 4KB pages). This is the sum of all the used pages in segment marked for system usage.
|
||||
* Since segment classifications are not always guaranteed to be accurate, this number is only an approximation. */
|
||||
u_longlong_t real_user; /* real memory used by non-system segments (in 4KB pages). This is the sum of all pages used in segments not marked for system usage.
|
||||
* Since segment classifications are not always guaranteed to be accurate, this number is only an approximation. */
|
||||
u_longlong_t real_process; /* real memory used by process segments (in 4KB pages). This is real_total-real_free-numperm-real_system. Since real_system is an
|
||||
* approximation, this number is too. */
|
||||
|
||||
} perfstat_memory_total_t;
|
||||
|
||||
typedef struct { /* Description of the network interface */
|
||||
char name[IDENTIFIER_LENGTH]; /* name of the interface */
|
||||
char description[IDENTIFIER_LENGTH]; /* interface description (from ODM, similar to lscfg output) */
|
||||
uchar type; /* ethernet, tokenring, etc. interpretation can be done using /usr/include/net/if_types.h */
|
||||
u_longlong_t mtu; /* network frame size */
|
||||
u_longlong_t ipackets; /* number of packets received on interface */
|
||||
u_longlong_t ibytes; /* number of bytes received on interface */
|
||||
u_longlong_t ierrors; /* number of input errors on interface */
|
||||
u_longlong_t opackets; /* number of packets sent on interface */
|
||||
u_longlong_t obytes; /* number of bytes sent on interface */
|
||||
u_longlong_t oerrors; /* number of output errors on interface */
|
||||
u_longlong_t collisions; /* number of collisions on csma interface */
|
||||
u_longlong_t bitrate; /* adapter rating in bit per second */
|
||||
} perfstat_netinterface_t;
|
||||
|
||||
typedef struct { /* Description of the network interfaces */
|
||||
int number; /* number of network interfaces */
|
||||
u_longlong_t ipackets; /* number of packets received on interface */
|
||||
u_longlong_t ibytes; /* number of bytes received on interface */
|
||||
u_longlong_t ierrors; /* number of input errors on interface */
|
||||
u_longlong_t opackets; /* number of packets sent on interface */
|
||||
u_longlong_t obytes; /* number of bytes sent on interface */
|
||||
u_longlong_t oerrors; /* number of output errors on interface */
|
||||
u_longlong_t collisions; /* number of collisions on csma interface */
|
||||
} perfstat_netinterface_total_t;
|
||||
|
||||
enum {
|
||||
LV_PAGING=1,
|
||||
NFS_PAGING
|
||||
};
|
||||
|
||||
typedef struct { /* Paging space data for a specific logical volume */
|
||||
char name[IDENTIFIER_LENGTH]; /* Paging space name */
|
||||
char type; /* type of paging device (LV_PAGING or NFS_PAGING) *
|
||||
* Possible values are: *
|
||||
* LV_PAGING logical volume *
|
||||
* NFS_PAGING NFS file */
|
||||
union{
|
||||
struct{
|
||||
char hostname[IDENTIFIER_LENGTH]; /* host name of paging server */
|
||||
char filename[IDENTIFIER_LENGTH]; /* swap file name on server */
|
||||
} nfs_paging;
|
||||
struct{
|
||||
char vgname[IDENTIFIER_LENGTH];/* volume group name */
|
||||
} lv_paging;
|
||||
} id;
|
||||
longlong_t lp_size; /* size in number of logical partitions */
|
||||
longlong_t mb_size; /* size in megabytes */
|
||||
longlong_t mb_used; /* portion used in megabytes */
|
||||
longlong_t io_pending; /* number of pending I/O */
|
||||
char active; /* indicates if active (1 if so, 0 if not) */
|
||||
char automatic; /* indicates if automatic (1 if so, 0 if not) */
|
||||
} perfstat_pagingspace_t;
|
||||
|
||||
typedef struct { /* network buffers */
|
||||
char name[IDENTIFIER_LENGTH]; /* size in ascii, always power of 2 (ex: "32", "64", "128") */
|
||||
u_longlong_t inuse; /* number of buffer currently allocated */
|
||||
u_longlong_t calls; /* number of buffer allocations since last reset */
|
||||
u_longlong_t delayed; /* number of delayed allocations */
|
||||
u_longlong_t free; /* number of free calls */
|
||||
u_longlong_t failed; /* number of failed allocations */
|
||||
u_longlong_t highwatermark; /* high threshold for number of buffer allocated */
|
||||
u_longlong_t freed; /* number of buffers freed */
|
||||
} perfstat_netbuffer_t;
|
||||
|
||||
typedef struct { /* utilization of protocols */
|
||||
char name[IDENTIFIER_LENGTH]; /* ip, ipv6, icmp, icmpv6, udp, tcp, rpc, nfs, nfsv2, nfsv3*/
|
||||
union{
|
||||
struct{
|
||||
u_longlong_t ipackets; /* number of input packets */
|
||||
u_longlong_t ierrors; /* number of input errors */
|
||||
u_longlong_t iqueueoverflow; /* number of input queue overflows */
|
||||
u_longlong_t opackets; /* number of output packets */
|
||||
u_longlong_t oerrors; /* number of output errors */
|
||||
} ip;
|
||||
struct{
|
||||
u_longlong_t ipackets; /* number of input packets */
|
||||
u_longlong_t ierrors; /* number of input errors */
|
||||
u_longlong_t iqueueoverflow; /* number of input queue overflows */
|
||||
u_longlong_t opackets; /* number of output packets */
|
||||
u_longlong_t oerrors; /* number of output errors */
|
||||
} ipv6;
|
||||
struct{
|
||||
u_longlong_t received; /* number of packets received */
|
||||
u_longlong_t sent; /* number of packets sent */
|
||||
u_longlong_t errors; /* number of errors */
|
||||
} icmp;
|
||||
struct{
|
||||
u_longlong_t received; /* number of packets received */
|
||||
u_longlong_t sent; /* number of packets sent */
|
||||
u_longlong_t errors; /* number of errors */
|
||||
} icmpv6;
|
||||
struct{
|
||||
u_longlong_t ipackets; /* number of input packets */
|
||||
u_longlong_t ierrors; /* number of input errors */
|
||||
u_longlong_t opackets; /* number of output packets */
|
||||
u_longlong_t no_socket; /* number of packets dropped due to no socket */
|
||||
} udp;
|
||||
struct{
|
||||
u_longlong_t ipackets; /* number of input packets */
|
||||
u_longlong_t ierrors; /* number of input errors */
|
||||
u_longlong_t opackets; /* number of output packets */
|
||||
u_longlong_t initiated; /* number of connections initiated */
|
||||
u_longlong_t accepted; /* number of connections accepted */
|
||||
u_longlong_t established; /* number of connections established */
|
||||
u_longlong_t dropped; /* number of connections dropped */
|
||||
} tcp;
|
||||
struct{
|
||||
struct{
|
||||
struct{
|
||||
u_longlong_t calls; /* total NFS client RPC connection-oriented calls */
|
||||
u_longlong_t badcalls; /* rejected NFS client RPC calls */
|
||||
u_longlong_t badxids; /* bad NFS client RPC call responses */
|
||||
u_longlong_t timeouts; /* timed out NFS client RPC calls with no reply */
|
||||
u_longlong_t newcreds; /* total NFS client RPC authentication refreshes */
|
||||
u_longlong_t badverfs; /* total NFS client RPC bad verifier in response */
|
||||
u_longlong_t timers; /* NFS client RPC timout greater than timeout value */
|
||||
u_longlong_t nomem; /* NFS client RPC calls memory allocation failure */
|
||||
u_longlong_t cantconn; /* failed NFS client RPC calls */
|
||||
u_longlong_t interrupts;/* NFS client RPC calls fail due to interrupt */
|
||||
} stream; /* connection oriented rpc client */
|
||||
struct{
|
||||
u_longlong_t calls; /* total NFS client RPC connectionless calls */
|
||||
u_longlong_t badcalls; /* rejected NFS client RPC calls */
|
||||
u_longlong_t retrans; /* retransmitted NFS client RPC calls */
|
||||
u_longlong_t badxids; /* bad NFS client RPC call responses */
|
||||
u_longlong_t timeouts; /* timed out NFS client RPC calls with no reply */
|
||||
u_longlong_t newcreds; /* total NFS client RPC authentication refreshes */
|
||||
u_longlong_t badverfs; /* total NFS client RPC bad verifier in response */
|
||||
u_longlong_t timers; /* NFS client RPC timout greater than timeout value */
|
||||
u_longlong_t nomem; /* NFS client RPC calls memory allocation failure */
|
||||
u_longlong_t cantsend; /* NFS client RPC calls not sent */
|
||||
} dgram; /* connection less rpc client */
|
||||
} client; /* rpc client */
|
||||
struct{
|
||||
struct{
|
||||
u_longlong_t calls; /* total NFS server RPC connection-oriented requests */
|
||||
u_longlong_t badcalls; /* rejected NFS server RPC requests */
|
||||
u_longlong_t nullrecv; /* NFS server RPC calls failed due to unavailable packet */
|
||||
u_longlong_t badlen; /* NFS server RPC requests failed due to bad length */
|
||||
u_longlong_t xdrcall; /* NFS server RPC requests failed due to bad header */
|
||||
u_longlong_t dupchecks;/* NFS server RPC calls found in request cache */
|
||||
u_longlong_t dupreqs; /* total NFS server RPC call duplicates */
|
||||
} stream; /* connection oriented rpc server */
|
||||
struct{
|
||||
u_longlong_t calls; /* total NFS server RPC connectionless requests */
|
||||
u_longlong_t badcalls; /* rejected NFS server RPC requests */
|
||||
u_longlong_t nullrecv; /* NFS server RPC calls failed due to unavailable packet */
|
||||
u_longlong_t badlen; /* NFS server RPC requests failed due to bad length */
|
||||
u_longlong_t xdrcall; /* NFS server RPC requests failed due to bad header */
|
||||
u_longlong_t dupchecks;/* NFS server RPC calls found in request cache */
|
||||
u_longlong_t dupreqs; /* total NFS server RPC call duplicates */
|
||||
} dgram; /* connection less rpc server */
|
||||
} server; /* rpc server*/
|
||||
} rpc;
|
||||
struct{
|
||||
struct{
|
||||
u_longlong_t calls; /* total NFS client requests */
|
||||
u_longlong_t badcalls; /* total NFS client failed calls */
|
||||
u_longlong_t clgets; /* total number of client nfs clgets */
|
||||
u_longlong_t cltoomany;/* total number of client nfs cltoomany */
|
||||
|
||||
} client; /* nfs client */
|
||||
struct{
|
||||
u_longlong_t calls; /* total NFS server requests */
|
||||
u_longlong_t badcalls; /* total NFS server failed calls */
|
||||
u_longlong_t public_v2; /* total number of nfs version 2 server calls */
|
||||
u_longlong_t public_v3; /* total number of nfs version 3 server calls */
|
||||
} server; /* nfs server */
|
||||
} nfs;
|
||||
struct{
|
||||
struct{
|
||||
u_longlong_t calls; /* NFS V2 client requests */
|
||||
u_longlong_t null; /* NFS V2 client null requests */
|
||||
u_longlong_t getattr; /* NFS V2 client getattr requests */
|
||||
u_longlong_t setattr; /* NFS V2 client setattr requests */
|
||||
u_longlong_t root; /* NFS V2 client root requests */
|
||||
u_longlong_t lookup; /* NFS V2 client file name lookup requests */
|
||||
u_longlong_t readlink; /* NFS V2 client readlink requests */
|
||||
u_longlong_t read; /* NFS V2 client read requests */
|
||||
u_longlong_t writecache;/* NFS V2 client write cache requests */
|
||||
u_longlong_t write; /* NFS V2 client write requests */
|
||||
u_longlong_t create; /* NFS V2 client file creation requests */
|
||||
u_longlong_t remove; /* NFS V2 client file removal requests */
|
||||
u_longlong_t rename; /* NFS V2 client file rename requests */
|
||||
u_longlong_t link; /* NFS V2 client link creation requests */
|
||||
u_longlong_t symlink; /* NFS V2 client symbolic link creation requests */
|
||||
u_longlong_t mkdir; /* NFS V2 client directory creation requests */
|
||||
u_longlong_t rmdir; /* NFS V2 client directory removal requests */
|
||||
u_longlong_t readdir; /* NFS V2 client read-directory requests */
|
||||
u_longlong_t statfs; /* NFS V2 client file stat requests */
|
||||
} client; /* nfs2 client */
|
||||
struct{
|
||||
u_longlong_t calls; /* NFS V2 server requests */
|
||||
u_longlong_t null; /* NFS V2 server null requests */
|
||||
u_longlong_t getattr; /* NFS V2 server getattr requests */
|
||||
u_longlong_t setattr; /* NFS V2 server setattr requests */
|
||||
u_longlong_t root; /* NFS V2 server root requests */
|
||||
u_longlong_t lookup; /* NFS V2 server file name lookup requests */
|
||||
u_longlong_t readlink; /* NFS V2 server readlink requests */
|
||||
u_longlong_t read; /* NFS V2 server read requests */
|
||||
u_longlong_t writecache;/* NFS V2 server cache requests */
|
||||
u_longlong_t write; /* NFS V2 server write requests */
|
||||
u_longlong_t create; /* NFS V2 server file creation requests */
|
||||
u_longlong_t remove; /* NFS V2 server file removal requests */
|
||||
u_longlong_t rename; /* NFS V2 server file rename requests */
|
||||
u_longlong_t link; /* NFS V2 server link creation requests */
|
||||
u_longlong_t symlink; /* NFS V2 server symbolic link creation requests */
|
||||
u_longlong_t mkdir; /* NFS V2 server directory creation requests */
|
||||
u_longlong_t rmdir; /* NFS V2 server directory removal requests */
|
||||
u_longlong_t readdir; /* NFS V2 server read-directory requests */
|
||||
u_longlong_t statfs; /* NFS V2 server file stat requests */
|
||||
} server; /* nfsv2 server */
|
||||
} nfsv2;
|
||||
struct{
|
||||
struct{
|
||||
u_longlong_t calls; /* NFS V3 client calls */
|
||||
u_longlong_t null; /* NFS V3 client null requests */
|
||||
u_longlong_t getattr; /* NFS V3 client getattr requests */
|
||||
u_longlong_t setattr; /* NFS V3 client setattr requests */
|
||||
u_longlong_t lookup; /* NFS V3 client file name lookup requests */
|
||||
u_longlong_t access; /* NFS V3 client access requests */
|
||||
u_longlong_t readlink; /* NFS V3 client readlink requests */
|
||||
u_longlong_t read; /* NFS V3 client read requests */
|
||||
u_longlong_t write; /* NFS V3 client write requests */
|
||||
u_longlong_t create; /* NFS V3 client file creation requests */
|
||||
u_longlong_t mkdir; /* NFS V3 client directory creation requests */
|
||||
u_longlong_t symlink; /* NFS V3 client symbolic link creation requests */
|
||||
u_longlong_t mknod; /* NFS V3 client mknod creation requests */
|
||||
u_longlong_t remove; /* NFS V3 client file removal requests */
|
||||
u_longlong_t rmdir; /* NFS V3 client directory removal requests */
|
||||
u_longlong_t rename; /* NFS V3 client file rename requests */
|
||||
u_longlong_t link; /* NFS V3 client link creation requests */
|
||||
u_longlong_t readdir; /* NFS V3 client read-directory requests */
|
||||
u_longlong_t readdirplus; /* NFS V3 client read-directory plus requests */
|
||||
u_longlong_t fsstat; /* NFS V3 client file stat requests */
|
||||
u_longlong_t fsinfo; /* NFS V3 client file info requests */
|
||||
u_longlong_t pathconf; /* NFS V3 client path configure requests */
|
||||
u_longlong_t commit; /* NFS V3 client commit requests */
|
||||
} client; /* nfsv3 client */
|
||||
struct{
|
||||
u_longlong_t calls; /* NFS V3 server requests */
|
||||
u_longlong_t null; /* NFS V3 server null requests */
|
||||
u_longlong_t getattr; /* NFS V3 server getattr requests */
|
||||
u_longlong_t setattr; /* NFS V3 server setattr requests */
|
||||
u_longlong_t lookup; /* NFS V3 server file name lookup requests */
|
||||
u_longlong_t access; /* NFS V3 server file access requests */
|
||||
u_longlong_t readlink; /* NFS V3 server readlink requests */
|
||||
u_longlong_t read; /* NFS V3 server read requests */
|
||||
u_longlong_t write; /* NFS V3 server write requests */
|
||||
u_longlong_t create; /* NFS V3 server file creation requests */
|
||||
u_longlong_t mkdir; /* NFS V3 server director6 creation requests */
|
||||
u_longlong_t symlink; /* NFS V3 server symbolic link creation requests */
|
||||
u_longlong_t mknod; /* NFS V3 server mknode creation requests */
|
||||
u_longlong_t remove; /* NFS V3 server file removal requests */
|
||||
u_longlong_t rmdir; /* NFS V3 server directory removal requests */
|
||||
u_longlong_t rename; /* NFS V3 server file rename requests */
|
||||
u_longlong_t link; /* NFS V3 server link creation requests */
|
||||
u_longlong_t readdir; /* NFS V3 server read-directory requests */
|
||||
u_longlong_t readdirplus; /* NFS V3 server read-directory plus requests */
|
||||
u_longlong_t fsstat; /* NFS V3 server file stat requests */
|
||||
u_longlong_t fsinfo; /* NFS V3 server file info requests */
|
||||
u_longlong_t pathconf; /* NFS V3 server path configure requests */
|
||||
u_longlong_t commit; /* NFS V3 server commit requests */
|
||||
} server; /* nfsv3 server */
|
||||
} nfsv3;
|
||||
} u;
|
||||
} perfstat_protocol_t;
|
||||
|
||||
extern int perfstat_cpu_total(perfstat_id_t *name,
|
||||
perfstat_cpu_total_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
extern int perfstat_cpu(perfstat_id_t *name,
|
||||
perfstat_cpu_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
extern int perfstat_disk_total(perfstat_id_t *name,
|
||||
perfstat_disk_total_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
extern int perfstat_disk(perfstat_id_t *name,
|
||||
perfstat_disk_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
extern int perfstat_diskadapter(perfstat_id_t *name,
|
||||
perfstat_diskadapter_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
extern int perfstat_diskpath(perfstat_id_t *name,
|
||||
perfstat_diskpath_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
extern int perfstat_memory_total(perfstat_id_t *name,
|
||||
perfstat_memory_total_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
extern int perfstat_netinterface_total(perfstat_id_t *name,
|
||||
perfstat_netinterface_total_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
extern int perfstat_netinterface(perfstat_id_t *name,
|
||||
perfstat_netinterface_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
|
||||
extern int perfstat_pagingspace(perfstat_id_t *name,
|
||||
perfstat_pagingspace_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
|
||||
extern int perfstat_netbuffer(perfstat_id_t *name,
|
||||
perfstat_netbuffer_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
|
||||
extern int perfstat_protocol(perfstat_id_t *name,
|
||||
perfstat_protocol_t* userbuff,
|
||||
int sizeof_userbuff,
|
||||
int desired_number);
|
||||
|
||||
extern void perfstat_reset(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*undef LIBPERFSTAT_H*/
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<project name="sigar-perflib" default="build" basedir=".">
|
||||
<property name="build" location="build"/>
|
||||
|
||||
<property name="cpptasks.jar"
|
||||
location="../../../../bindings/java/hyperic_jni/lib/cpptasks.jar"/>
|
||||
|
||||
<taskdef name="cc" classname="net.sf.antcontrib.cpptasks.CCTask">
|
||||
<classpath location="${cpptasks.jar}"/>
|
||||
</taskdef>
|
||||
|
||||
<target name="build">
|
||||
<mkdir dir="${build}"/>
|
||||
|
||||
<cc outtype="shared"
|
||||
outfile="${build}/sigar_aixperfstat"
|
||||
objdir="${build}"
|
||||
link="shared"
|
||||
relentless="false">
|
||||
|
||||
<compiler name="xlc_r">
|
||||
<defineset>
|
||||
</defineset>
|
||||
</compiler>
|
||||
|
||||
<linker name="xlc_r">
|
||||
<libset dir="." libs="perfstat,pthreads"/>
|
||||
</linker>
|
||||
|
||||
<includepath location="../"/>
|
||||
|
||||
<fileset dir=".">
|
||||
<include name="sigar_perfstat.c"/>
|
||||
</fileset>
|
||||
</cc>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
</project>
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
|
||||
* This file is part of SIGAR.
|
||||
*
|
||||
* SIGAR is free software; you can redistribute it and/or modify
|
||||
* it under the terms version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation. This program is distributed
|
||||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#include <libperfstat.h>
|
||||
#include <pthread.h>
|
||||
|
||||
/*
|
||||
* ibm docs say:
|
||||
* "name Must be set to NULL.
|
||||
* desired_number Must be set to 1."
|
||||
* so we just hardcode that in our wrapper.
|
||||
*/
|
||||
int sigar_perfstat_cpu_total(perfstat_cpu_total_t *cpu_total)
|
||||
{
|
||||
return perfstat_cpu_total(NULL, cpu_total, sizeof(*cpu_total), 1);
|
||||
}
|
||||
|
||||
int sigar_perfstat_cpu(perfstat_id_t *id,
|
||||
perfstat_cpu_t *cpu,
|
||||
int num)
|
||||
{
|
||||
return perfstat_cpu(id, cpu, sizeof(*cpu), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_pagingspace(perfstat_id_t *id,
|
||||
perfstat_pagingspace_t *pagingspace,
|
||||
int num)
|
||||
{
|
||||
return perfstat_pagingspace(id, pagingspace, sizeof(*pagingspace), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_memory(perfstat_memory_total_t *memory)
|
||||
{
|
||||
return perfstat_memory_total(NULL, memory, sizeof(*memory), 1);
|
||||
}
|
||||
|
||||
int sigar_perfstat_disk(perfstat_id_t *id,
|
||||
perfstat_disk_t *disk,
|
||||
int num)
|
||||
{
|
||||
return perfstat_disk(id, disk, sizeof(*disk), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_diskadapter(perfstat_id_t *id,
|
||||
perfstat_diskadapter_t *adapter,
|
||||
int num)
|
||||
{
|
||||
return perfstat_diskadapter(id, adapter, sizeof(*adapter), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_diskpath(perfstat_id_t *id,
|
||||
perfstat_diskpath_t *diskpath,
|
||||
int num)
|
||||
{
|
||||
return perfstat_diskpath(id, diskpath, sizeof(*diskpath), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_netinterface(perfstat_id_t *id,
|
||||
perfstat_netinterface_t *netinterface)
|
||||
|
||||
{
|
||||
return perfstat_netinterface(id, netinterface,
|
||||
sizeof(*netinterface), 1);
|
||||
}
|
||||
|
||||
int sigar_perfstat_netbuffer(perfstat_id_t *id,
|
||||
perfstat_netbuffer_t *netbuffer,
|
||||
int num)
|
||||
{
|
||||
return perfstat_netbuffer(id, netbuffer, sizeof(*netbuffer), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_protocol(perfstat_id_t *id,
|
||||
perfstat_protocol_t *proto,
|
||||
int num)
|
||||
{
|
||||
return perfstat_protocol(id, proto, sizeof(*proto), num);
|
||||
}
|
||||
|
||||
/*
|
||||
* not a perfstat function, but from libpthreads.a
|
||||
* requires the same tricks to link on 4.3 and run on 5.2
|
||||
*/
|
||||
int sigar_thread_rusage(struct rusage *usage, int mode)
|
||||
{
|
||||
return pthread_getrusage_np(pthread_self(), usage, mode);
|
||||
}
|
||||
+1
-41
@@ -25,8 +25,6 @@
|
||||
#include <procinfo.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include "libperfstat.h"
|
||||
|
||||
enum {
|
||||
KOFFSET_LOADAVG,
|
||||
KOFFSET_VAR,
|
||||
@@ -46,50 +44,12 @@ typedef struct {
|
||||
|
||||
typedef int (*proc_fd_func_t) (sigar_t *, sigar_pid_t, sigar_proc_fd_t *);
|
||||
|
||||
typedef int (*perfstat_cpu_total_func_t)(perfstat_cpu_total_t *);
|
||||
|
||||
typedef int (*perfstat_cpu_func_t)(perfstat_id_t *,
|
||||
perfstat_cpu_t *,
|
||||
int);
|
||||
|
||||
typedef int (*perfstat_swap_func_t)(perfstat_id_t *,
|
||||
perfstat_pagingspace_t *,
|
||||
int);
|
||||
|
||||
typedef int (*perfstat_mem_func_t)(perfstat_memory_total_t *);
|
||||
|
||||
typedef int (*perfstat_disk_func_t)(perfstat_id_t *,
|
||||
perfstat_disk_t *,
|
||||
int);
|
||||
|
||||
typedef int (*perfstat_ifstat_func_t)(perfstat_id_t *,
|
||||
perfstat_netinterface_t *);
|
||||
|
||||
typedef int (*perfstat_protocol_func_t)(perfstat_id_t *,
|
||||
perfstat_protocol_t *,
|
||||
int);
|
||||
|
||||
typedef int (*thread_rusage_func_t)(struct rusage *, int);
|
||||
|
||||
struct sigar_t {
|
||||
SIGAR_T_BASE;
|
||||
int kmem;
|
||||
int dmem;
|
||||
/* offsets for seeking on kmem */
|
||||
long koffsets[KOFFSET_MAX];
|
||||
proc_fd_func_t getprocfd;
|
||||
struct {
|
||||
int avail;
|
||||
perfstat_cpu_func_t cpu;
|
||||
perfstat_cpu_total_func_t cpu_total;
|
||||
perfstat_swap_func_t swap;
|
||||
perfstat_mem_func_t mem;
|
||||
perfstat_disk_func_t disk;
|
||||
perfstat_ifstat_func_t ifstat;
|
||||
perfstat_protocol_func_t protocol;
|
||||
thread_rusage_func_t thread_rusage;
|
||||
void *handle;
|
||||
} perfstat;
|
||||
int pagesize;
|
||||
swaps_t swaps;
|
||||
time_t last_getprocs;
|
||||
@@ -106,6 +66,6 @@ struct sigar_t {
|
||||
|
||||
#define HAVE_STRERROR_R
|
||||
|
||||
#define SIGAR_EPERM_KMEM (SIGAR_OS_START_ERROR+1)
|
||||
#define SIGAR_EPERM_KMEM (SIGAR_OS_START_ERROR+EACCES)
|
||||
|
||||
#endif /* SIGAR_OS_H */
|
||||
+297
-61
@@ -39,6 +39,7 @@
|
||||
#include <mach/thread_info.h>
|
||||
#include <mach/vm_map.h>
|
||||
#include <mach/shared_memory_server.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#define __OPENTRANSPORTPROVIDERS__
|
||||
#include <Gestalt.h>
|
||||
#include <CFString.h>
|
||||
@@ -252,7 +253,7 @@ int sigar_os_open(sigar_t **sigar)
|
||||
|
||||
(*sigar)->ncpu = ncpu;
|
||||
(*sigar)->lcpu = -1;
|
||||
|
||||
(*sigar)->argmax = 0;
|
||||
(*sigar)->boot_time = boottime.tv_sec; /* XXX seems off a bit */
|
||||
|
||||
(*sigar)->pagesize = getpagesize();
|
||||
@@ -294,6 +295,27 @@ char *sigar_os_error_string(sigar_t *sigar, int err)
|
||||
}
|
||||
}
|
||||
|
||||
/* ARG_MAX in FreeBSD 6.0 == 262144, which blows up the stack */
|
||||
#define SIGAR_ARG_MAX 65536
|
||||
|
||||
#ifdef DARWIN
|
||||
static size_t sigar_argmax_get(sigar_t *sigar)
|
||||
{
|
||||
#ifdef KERN_ARGMAX
|
||||
int mib[] = { CTL_KERN, KERN_ARGMAX };
|
||||
size_t size = sizeof(sigar->argmax);
|
||||
|
||||
if (sigar->argmax != 0) {
|
||||
return sigar->argmax;
|
||||
}
|
||||
if (sysctl(mib, NMIB(mib), &sigar->argmax, &size, NULL, 0) == 0) {
|
||||
return sigar->argmax;
|
||||
}
|
||||
#endif
|
||||
return SIGAR_ARG_MAX;
|
||||
}
|
||||
#endif /* DARWIN */
|
||||
|
||||
#if defined(DARWIN)
|
||||
static int sigar_vmstat(sigar_t *sigar, vm_statistics_data_t *vmstat)
|
||||
{
|
||||
@@ -441,7 +463,8 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||
return status;
|
||||
}
|
||||
|
||||
mem->free = vmstat.free_count * sigar->pagesize;
|
||||
mem->free = vmstat.free_count;
|
||||
mem->free *= sigar->pagesize;
|
||||
#elif defined(__FreeBSD__)
|
||||
if ((status = sigar_vmstat(sigar, &vmstat)) == SIGAR_OK) {
|
||||
mem->free = vmstat.v_free_count;
|
||||
@@ -536,16 +559,81 @@ static int getswapinfo_sysctl(struct kvm_swap *swap_ary,
|
||||
#define getswapinfo_sysctl(swap_ary, swap_max) SIGAR_ENOTIMPL
|
||||
#endif
|
||||
|
||||
int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
|
||||
#define SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) ((val * bsize) >> 1)
|
||||
|
||||
#ifdef DARWIN
|
||||
#define VM_DIR "/private/var/vm"
|
||||
#define SWAPFILE "swapfile"
|
||||
|
||||
static int sigar_swap_fs_get(sigar_t *sigar, sigar_swap_t *swap) /* <= 10.3 */
|
||||
{
|
||||
int status;
|
||||
#if defined(DARWIN)
|
||||
DIR *dirp;
|
||||
struct dirent *ent;
|
||||
char swapfile[SSTRLEN(VM_DIR) + SSTRLEN("/") + SSTRLEN(SWAPFILE) + 12];
|
||||
struct stat swapstat;
|
||||
struct statfs vmfs;
|
||||
sigar_uint64_t val, bsize;
|
||||
|
||||
swap->used = swap->total = swap->free = 0;
|
||||
|
||||
if (!(dirp = opendir(VM_DIR))) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
/* looking for "swapfile0", "swapfile1", etc. */
|
||||
while ((ent = readdir(dirp))) {
|
||||
char *ptr = swapfile;
|
||||
|
||||
if ((ent->d_namlen < SSTRLEN(SWAPFILE)+1) || /* n/a, see comment above */
|
||||
(ent->d_namlen > SSTRLEN(SWAPFILE)+11)) /* ensure no overflow */
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strnEQ(ent->d_name, SWAPFILE, SSTRLEN(SWAPFILE))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* sprintf(swapfile, "%s/%s", VM_DIR, ent->d_name) */
|
||||
|
||||
memcpy(ptr, VM_DIR, SSTRLEN(VM_DIR));
|
||||
ptr += SSTRLEN(VM_DIR);
|
||||
|
||||
*ptr++ = '/';
|
||||
|
||||
memcpy(ptr, ent->d_name, ent->d_namlen+1);
|
||||
|
||||
if (stat(swapfile, &swapstat) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
swap->used += swapstat.st_size;
|
||||
}
|
||||
|
||||
closedir(dirp);
|
||||
|
||||
if (statfs(VM_DIR, &vmfs) < 0) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
bsize = vmfs.f_bsize / 512;
|
||||
val = vmfs.f_bfree;
|
||||
swap->total = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) + swap->used;
|
||||
|
||||
swap->free = swap->total - swap->used;
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
static int sigar_swap_sysctl_get(sigar_t *sigar, sigar_swap_t *swap)
|
||||
|
||||
{
|
||||
#ifdef VM_SWAPUSAGE /* => 10.4 */
|
||||
struct xsw_usage sw_usage;
|
||||
size_t size = sizeof(sw_usage);
|
||||
int mib[] = { CTL_VM, VM_SWAPUSAGE };
|
||||
vm_statistics_data_t vmstat;
|
||||
|
||||
if (sysctl(mib, NMIB(mib), &sw_usage, &size, NULL, 0) < 0) {
|
||||
if (sysctl(mib, NMIB(mib), &sw_usage, &size, NULL, 0) != 0) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
@@ -553,6 +641,26 @@ int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
|
||||
swap->used = sw_usage.xsu_used;
|
||||
swap->free = sw_usage.xsu_avail;
|
||||
|
||||
return SIGAR_OK;
|
||||
#else
|
||||
return SIGAR_ENOTIMPL; /* <= 10.3 */
|
||||
#endif
|
||||
}
|
||||
#endif /* DARWIN */
|
||||
|
||||
int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
|
||||
{
|
||||
int status;
|
||||
#if defined(DARWIN)
|
||||
vm_statistics_data_t vmstat;
|
||||
|
||||
if (sigar_swap_sysctl_get(sigar, swap) != SIGAR_OK) {
|
||||
status = sigar_swap_fs_get(sigar, swap); /* <= 10.3 */
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if ((status = sigar_vmstat(sigar, &vmstat)) != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
@@ -679,6 +787,52 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__) && (__FreeBSD_version >= 700000)
|
||||
#define HAVE_KERN_CP_TIMES /* kern.cp_times came later than 7.0, not sure exactly when */
|
||||
static int sigar_cp_times_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
|
||||
{
|
||||
int maxcpu, status;
|
||||
size_t len = sizeof(maxcpu), size;
|
||||
long *times;
|
||||
|
||||
if (sysctlbyname("kern.smp.maxcpus", &maxcpu, &len, NULL, 0) == -1) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
size = sizeof(long) * maxcpu * CPUSTATES;
|
||||
times = malloc(size);
|
||||
if (sysctlbyname("kern.cp_times", times, &size, NULL, 0) == -1) {
|
||||
status = errno;
|
||||
}
|
||||
else {
|
||||
int i, maxid = (size / CPUSTATES / sizeof(long));
|
||||
long *cp_time = times;
|
||||
status = SIGAR_OK;
|
||||
|
||||
for (i=0; i<maxid; i++) {
|
||||
sigar_cpu_t *cpu;
|
||||
|
||||
SIGAR_CPU_LIST_GROW(cpulist);
|
||||
|
||||
cpu = &cpulist->data[cpulist->number++];
|
||||
cpu->user = SIGAR_TICK2MSEC(cp_time[CP_USER]);
|
||||
cpu->nice = SIGAR_TICK2MSEC(cp_time[CP_NICE]);
|
||||
cpu->sys = SIGAR_TICK2MSEC(cp_time[CP_SYS]);
|
||||
cpu->idle = SIGAR_TICK2MSEC(cp_time[CP_IDLE]);
|
||||
cpu->wait = 0; /*N/A*/
|
||||
cpu->irq = SIGAR_TICK2MSEC(cp_time[CP_INTR]);
|
||||
cpu->soft_irq = 0; /*N/A*/
|
||||
cpu->stolen = 0; /*N/A*/
|
||||
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle + cpu->irq;
|
||||
cp_time += CPUSTATES;
|
||||
}
|
||||
}
|
||||
|
||||
free(times);
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
|
||||
{
|
||||
#ifdef DARWIN
|
||||
@@ -726,7 +880,12 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
|
||||
|
||||
sigar_cpu_list_create(cpulist);
|
||||
|
||||
/* XXX howto multi cpu in freebsd?
|
||||
#ifdef HAVE_KERN_CP_TIMES
|
||||
if ((status = sigar_cp_times_get(sigar, cpulist)) == SIGAR_OK) {
|
||||
return SIGAR_OK;
|
||||
}
|
||||
#endif
|
||||
/* XXX no multi cpu in freebsd < 7.0, howbout others?
|
||||
* for now just report all metrics on the 1st cpu
|
||||
* 0's for the rest
|
||||
*/
|
||||
@@ -895,6 +1054,10 @@ static int sigar_get_pinfo(sigar_t *sigar, sigar_pid_t pid)
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
#ifdef DARWIN
|
||||
#define GLOBAL_SHARED_SIZE (SHARED_TEXT_REGION_SIZE + SHARED_DATA_REGION_SIZE)
|
||||
#endif
|
||||
|
||||
int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_mem_t *procmem)
|
||||
{
|
||||
@@ -906,6 +1069,8 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
mach_msg_type_number_t count;
|
||||
# ifdef DARWIN_HAS_LIBPROC_H
|
||||
struct proc_taskinfo pti;
|
||||
struct proc_regioninfo pri;
|
||||
|
||||
if (sigar->libproc) {
|
||||
int sz =
|
||||
sigar->proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &pti, sizeof(pti));
|
||||
@@ -917,6 +1082,15 @@ int sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
procmem->minor_faults = SIGAR_FIELD_NOTIMPL;
|
||||
procmem->major_faults = SIGAR_FIELD_NOTIMPL;
|
||||
procmem->share = SIGAR_FIELD_NOTIMPL;
|
||||
|
||||
sz = sigar->proc_pidinfo(pid, PROC_PIDREGIONINFO, 0, &pri, sizeof(pri));
|
||||
if (sz == sizeof(pri)) {
|
||||
if ((pri.pri_share_mode == SM_EMPTY) &&
|
||||
(procmem->size > GLOBAL_SHARED_SIZE))
|
||||
{
|
||||
procmem->size -= GLOBAL_SHARED_SIZE; /* SIGAR-123 */
|
||||
}
|
||||
}
|
||||
return SIGAR_OK;
|
||||
}
|
||||
}
|
||||
@@ -1284,12 +1458,21 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
|
||||
#if defined(DARWIN)
|
||||
typedef struct {
|
||||
char buffer[8096], *ptr, *end;
|
||||
char *buf, *ptr, *end;
|
||||
int count;
|
||||
} sigar_kern_proc_args_t;
|
||||
|
||||
static void sigar_kern_proc_args_destroy(sigar_kern_proc_args_t *kargs)
|
||||
{
|
||||
if (kargs->buf) {
|
||||
free(kargs->buf);
|
||||
kargs->buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* re-usable hack for use by proc_args and proc_env */
|
||||
static int sigar_kern_proc_args_get(sigar_pid_t pid,
|
||||
static int sigar_kern_proc_args_get(sigar_t *sigar,
|
||||
sigar_pid_t pid,
|
||||
char *exe,
|
||||
sigar_kern_proc_args_t *kargs)
|
||||
{
|
||||
@@ -1298,21 +1481,23 @@ static int sigar_kern_proc_args_get(sigar_pid_t pid,
|
||||
* http://darwinsource.opendarwin.org/10.4.1/adv_cmds-79.1/ps.tproj/print.c
|
||||
*/
|
||||
int mib[3], len;
|
||||
size_t size = sizeof(kargs->buffer);
|
||||
char *args = kargs->buffer;
|
||||
size_t size = sigar_argmax_get(sigar);
|
||||
|
||||
kargs->buf = malloc(size);
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_PROCARGS2;
|
||||
mib[2] = pid;
|
||||
|
||||
if (sysctl(mib, NMIB(mib), args, &size, NULL, 0) < 0) {
|
||||
if (sysctl(mib, NMIB(mib), kargs->buf, &size, NULL, 0) < 0) {
|
||||
sigar_kern_proc_args_destroy(kargs);
|
||||
return errno;
|
||||
}
|
||||
|
||||
kargs->end = &args[size];
|
||||
kargs->end = &kargs->buf[size];
|
||||
|
||||
memcpy(&kargs->count, args, sizeof(kargs->count));
|
||||
kargs->ptr = args + sizeof(kargs->count);
|
||||
memcpy(&kargs->count, kargs->buf, sizeof(kargs->count));
|
||||
kargs->ptr = kargs->buf + sizeof(kargs->count);
|
||||
|
||||
len = strlen(kargs->ptr);
|
||||
if (exe) {
|
||||
@@ -1321,6 +1506,7 @@ static int sigar_kern_proc_args_get(sigar_pid_t pid,
|
||||
kargs->ptr += len+1;
|
||||
|
||||
if (kargs->ptr == kargs->end) {
|
||||
sigar_kern_proc_args_destroy(kargs);
|
||||
return exe ? SIGAR_OK : ENOENT;
|
||||
}
|
||||
|
||||
@@ -1331,6 +1517,7 @@ static int sigar_kern_proc_args_get(sigar_pid_t pid,
|
||||
}
|
||||
|
||||
if (kargs->ptr == kargs->end) {
|
||||
sigar_kern_proc_args_destroy(kargs);
|
||||
return exe ? SIGAR_OK : ENOENT;
|
||||
}
|
||||
|
||||
@@ -1362,9 +1549,6 @@ static int kern_proc_args_skip_argv(sigar_kern_proc_args_t *kargs)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ARG_MAX in FreeBSD 6.0 == 262144, which blows up the stack */
|
||||
#define SIGAR_ARG_MAX 65536
|
||||
|
||||
int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_args_t *procargs)
|
||||
{
|
||||
@@ -1373,7 +1557,7 @@ int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_kern_proc_args_t kargs;
|
||||
char *ptr, *end;
|
||||
|
||||
status = sigar_kern_proc_args_get(pid, NULL, &kargs);
|
||||
status = sigar_kern_proc_args_get(sigar, pid, NULL, &kargs);
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
@@ -1409,6 +1593,7 @@ int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
ptr += alen;
|
||||
}
|
||||
|
||||
sigar_kern_proc_args_destroy(&kargs);
|
||||
return SIGAR_OK;
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
char buffer[SIGAR_ARG_MAX+1], *ptr=buffer;
|
||||
@@ -1487,13 +1672,14 @@ int sigar_proc_env_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_kern_proc_args_t kargs;
|
||||
char *ptr, *end;
|
||||
|
||||
status = sigar_kern_proc_args_get(pid, NULL, &kargs);
|
||||
status = sigar_kern_proc_args_get(sigar, pid, NULL, &kargs);
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = kern_proc_args_skip_argv(&kargs);
|
||||
if (status != SIGAR_OK) {
|
||||
sigar_kern_proc_args_destroy(&kargs);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1533,6 +1719,7 @@ int sigar_proc_env_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
}
|
||||
}
|
||||
|
||||
sigar_kern_proc_args_destroy(&kargs);
|
||||
return SIGAR_OK;
|
||||
#else
|
||||
char **env;
|
||||
@@ -1647,7 +1834,7 @@ int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
int status;
|
||||
sigar_kern_proc_args_t kargs;
|
||||
|
||||
status = sigar_kern_proc_args_get(pid, procexe->name, &kargs);
|
||||
status = sigar_kern_proc_args_get(sigar, pid, procexe->name, &kargs);
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
@@ -1701,10 +1888,36 @@ int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DARWIN
|
||||
static int sigar_dlinfo_modules(sigar_t *sigar, sigar_proc_modules_t *procmods)
|
||||
{
|
||||
uint32_t i, count = _dyld_image_count();
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
int status;
|
||||
const char *name =
|
||||
_dyld_get_image_name(i);
|
||||
|
||||
if (name == NULL) {
|
||||
continue;
|
||||
}
|
||||
status =
|
||||
procmods->module_getter(procmods->data,
|
||||
(char *)name, strlen(name));
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
/* not an error; just stop iterating */
|
||||
break;
|
||||
}
|
||||
}
|
||||
return SIGAR_OK;
|
||||
}
|
||||
#endif /* DARWIN */
|
||||
|
||||
int sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_modules_t *procmods)
|
||||
{
|
||||
#ifdef SIGAR_HAS_DLINFO_MODULES
|
||||
#if defined(SIGAR_HAS_DLINFO_MODULES) || defined(DARWIN)
|
||||
if (pid == sigar_pid_get(sigar)) {
|
||||
return sigar_dlinfo_modules(sigar, procmods);
|
||||
}
|
||||
@@ -1722,7 +1935,7 @@ int sigar_thread_cpu_get(sigar_t *sigar,
|
||||
sigar_uint64_t id,
|
||||
sigar_thread_cpu_t *cpu)
|
||||
{
|
||||
#ifdef DARWIN
|
||||
#if defined(DARWIN)
|
||||
mach_port_t self = mach_thread_self();
|
||||
thread_basic_info_data_t info;
|
||||
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
|
||||
@@ -1739,6 +1952,8 @@ int sigar_thread_cpu_get(sigar_t *sigar,
|
||||
cpu->user = tval2nsec(info.user_time);
|
||||
cpu->sys = tval2nsec(info.system_time);
|
||||
cpu->total = cpu->user + cpu->sys;
|
||||
#elif defined(__NetBSD__)
|
||||
return SIGAR_ENOTIMPL; /* http://tinyurl.com/chbvln */
|
||||
#else
|
||||
/* XXX this is not per-thread, it is for the whole-process.
|
||||
* just want to use for the shell time command at the moment.
|
||||
@@ -1851,6 +2066,7 @@ int sigar_file_system_list_get(sigar_t *sigar,
|
||||
fs = malloc(len);
|
||||
|
||||
if ((num = sigar_getfsstat(fs, len, MNT_NOWAIT)) < 0) {
|
||||
free(fs);
|
||||
return errno;
|
||||
}
|
||||
|
||||
@@ -1894,6 +2110,7 @@ int sigar_file_system_list_get(sigar_t *sigar,
|
||||
sigar_fs_type_init(fsp);
|
||||
}
|
||||
|
||||
free(fs);
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
@@ -1977,48 +2194,39 @@ int sigar_disk_usage_get(sigar_t *sigar, const char *name,
|
||||
IOObjectRelease(service);
|
||||
IOObjectRelease(parent);
|
||||
|
||||
return SIGAR_OK;
|
||||
#elif defined(__FreeBSD__)
|
||||
/* XXX incomplete */
|
||||
struct sigar_statfs buf;
|
||||
|
||||
if (sigar_statfs(name, &buf) < 0) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
SIGAR_DISK_STATS_INIT(disk);
|
||||
|
||||
disk->reads = buf.f_syncreads + buf.f_asyncreads;
|
||||
disk->writes = buf.f_syncwrites + buf.f_asyncwrites;
|
||||
return SIGAR_OK;
|
||||
#else
|
||||
SIGAR_DISK_STATS_INIT(disk);
|
||||
return SIGAR_ENOTIMPL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) ((val * bsize) >> 1)
|
||||
|
||||
int sigar_file_system_usage_get(sigar_t *sigar,
|
||||
const char *dirname,
|
||||
sigar_file_system_usage_t *fsusage)
|
||||
{
|
||||
struct sigar_statfs buf;
|
||||
sigar_uint64_t val, bsize;
|
||||
int status = sigar_statvfs(sigar, dirname, fsusage);
|
||||
|
||||
if (sigar_statfs(dirname, &buf) < 0) {
|
||||
return errno;
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
bsize = buf.f_bsize / 512;
|
||||
val = buf.f_blocks;
|
||||
fsusage->total = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
val = buf.f_bfree;
|
||||
fsusage->free = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
val = buf.f_bavail;
|
||||
fsusage->avail = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
fsusage->used = fsusage->total - fsusage->free;
|
||||
fsusage->files = buf.f_files;
|
||||
fsusage->free_files = buf.f_ffree;
|
||||
fsusage->use_percent = sigar_file_system_usage_calc_used(sigar, fsusage);
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
fsusage->disk_reads = buf.f_syncreads + buf.f_asyncreads;
|
||||
fsusage->disk_writes = buf.f_syncwrites + buf.f_asyncwrites;
|
||||
fsusage->disk_read_bytes = SIGAR_FIELD_NOTIMPL;
|
||||
fsusage->disk_write_bytes = SIGAR_FIELD_NOTIMPL;
|
||||
fsusage->disk_queue = SIGAR_FIELD_NOTIMPL;
|
||||
#elif defined(DARWIN)
|
||||
sigar_disk_usage_get(sigar, dirname, &fsusage->disk);
|
||||
#else
|
||||
SIGAR_DISK_STATS_INIT(&fsusage->disk);
|
||||
#endif
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
@@ -2271,6 +2479,26 @@ static int sigar_ifmsg_init(sigar_t *sigar)
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
static int has_ifaddr(char *name)
|
||||
{
|
||||
int sock, status;
|
||||
struct ifreq ifr;
|
||||
|
||||
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
return errno;
|
||||
}
|
||||
SIGAR_SSTRCPY(ifr.ifr_name, name);
|
||||
if (ioctl(sock, SIOCGIFADDR, &ifr) == 0) {
|
||||
status = SIGAR_OK;
|
||||
}
|
||||
else {
|
||||
status = errno;
|
||||
}
|
||||
|
||||
close(sock);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int sigar_ifmsg_iter(sigar_t *sigar, ifmsg_iter_t *iter)
|
||||
{
|
||||
char *end = sigar->ifconf_buf + sigar->ifconf_len;
|
||||
@@ -2305,18 +2533,26 @@ static int sigar_ifmsg_iter(sigar_t *sigar, ifmsg_iter_t *iter)
|
||||
if (sdl->sdl_family != AF_LINK) {
|
||||
continue;
|
||||
}
|
||||
if (!((sdl->sdl_type == IFT_ETHER) ||
|
||||
(sdl->sdl_type == IFT_LOOP)))
|
||||
{
|
||||
continue; /* XXX deal w/ other weirdo interfaces */
|
||||
}
|
||||
|
||||
switch (iter->type) {
|
||||
case IFMSG_ITER_LIST:
|
||||
if (sdl->sdl_type == IFT_OTHER) {
|
||||
if (has_ifaddr(sdl->sdl_data) != SIGAR_OK) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!((sdl->sdl_type == IFT_ETHER) ||
|
||||
(sdl->sdl_type == IFT_LOOP)))
|
||||
{
|
||||
break; /* XXX deal w/ other weirdo interfaces */
|
||||
}
|
||||
|
||||
SIGAR_NET_IFLIST_GROW(iter->data.iflist);
|
||||
|
||||
/* sdl_data doesn't include a trailing \0, it is only sdl_nlen long */
|
||||
name = malloc(sdl->sdl_nlen+1);
|
||||
memcpy(name, sdl->sdl_data, sdl->sdl_nlen+1);
|
||||
memcpy(name, sdl->sdl_data, sdl->sdl_nlen);
|
||||
name[sdl->sdl_nlen] = '\0'; /* add the missing \0 */
|
||||
|
||||
iter->data.iflist->data[iter->data.iflist->number++] = name;
|
||||
break;
|
||||
@@ -3113,7 +3349,7 @@ int sigar_os_sys_info_get(sigar_t *sigar,
|
||||
{
|
||||
#ifdef DARWIN
|
||||
char *codename = NULL;
|
||||
long version, version_major, version_minor, version_fix;
|
||||
SInt32 version, version_major, version_minor, version_fix;
|
||||
|
||||
SIGAR_SSTRCPY(sysinfo->name, "MacOSX");
|
||||
SIGAR_SSTRCPY(sysinfo->vendor_name, "Mac OS X");
|
||||
@@ -3139,13 +3375,13 @@ int sigar_os_sys_info_get(sigar_t *sigar,
|
||||
|
||||
snprintf(sysinfo->vendor_version,
|
||||
sizeof(sysinfo->vendor_version),
|
||||
"%ld.%ld",
|
||||
version_major, version_minor);
|
||||
"%d.%d",
|
||||
(int)version_major, (int)version_minor);
|
||||
|
||||
snprintf(sysinfo->version,
|
||||
sizeof(sysinfo->version),
|
||||
"%s.%ld",
|
||||
sysinfo->vendor_version, version_fix);
|
||||
"%s.%d",
|
||||
sysinfo->vendor_version, (int)version_fix);
|
||||
|
||||
if (version_major == 10) {
|
||||
switch (version_minor) {
|
||||
|
||||
@@ -60,6 +60,7 @@ struct sigar_t {
|
||||
sigar_pid_t last_pid;
|
||||
bsd_pinfo_t *pinfo;
|
||||
int lcpu;
|
||||
size_t argmax;
|
||||
#ifdef DARWIN
|
||||
mach_port_t mach_port;
|
||||
# ifdef DARWIN_HAS_LIBPROC_H
|
||||
|
||||
+28
-32
@@ -380,15 +380,28 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX: pst_cmd is only 64 chars of the command args.
|
||||
* according to HP forums there isn't a way to get them
|
||||
* all if > 64
|
||||
*/
|
||||
int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_args_t *procargs)
|
||||
{
|
||||
char *args, *arg;
|
||||
#ifdef PSTAT_GETCOMMANDLINE
|
||||
char buf[1024]; /* kernel limit */
|
||||
|
||||
# ifdef pstat_getcommandline /* 11i v2 + */
|
||||
if (pstat_getcommandline(buf, sizeof(buf), sizeof(buf[0]), pid) == -1) {
|
||||
return errno;
|
||||
}
|
||||
# else
|
||||
union pstun pu;
|
||||
|
||||
pu.pst_command = buf;
|
||||
if (pstat(PSTAT_GETCOMMANDLINE, pu, sizeof(buf), sizeof(buf[0]), pid) == -1) {
|
||||
return errno;
|
||||
}
|
||||
# endif /* pstat_getcommandline */
|
||||
|
||||
args = buf;
|
||||
#else
|
||||
struct pst_status status;
|
||||
|
||||
if (pstat_getproc(&status, sizeof(status), 0, pid) == -1) {
|
||||
@@ -396,6 +409,7 @@ int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
}
|
||||
|
||||
args = status.pst_cmd;
|
||||
#endif
|
||||
|
||||
while (*args && (arg = sigar_getword(&args, ' '))) {
|
||||
SIGAR_PROC_ARGS_GROW(procargs);
|
||||
@@ -415,8 +429,8 @@ int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_fd_t *procfd)
|
||||
{
|
||||
struct pst_status status;
|
||||
int idx, i, n;
|
||||
struct pst_fileinfo psf[16];
|
||||
int idx=0, n;
|
||||
struct pst_fileinfo2 psf[16];
|
||||
|
||||
procfd->total = 0;
|
||||
|
||||
@@ -424,15 +438,13 @@ int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
return errno;
|
||||
}
|
||||
|
||||
/* man pstat_getfile for index splaination */
|
||||
idx = (status.pst_idx << 16) | (0 & 0xffff);
|
||||
|
||||
while ((n = pstat_getfile(psf, sizeof(psf[0]),
|
||||
/* HPUX 11.31 removed the deprecated pstat_getfile call */
|
||||
while ((n = pstat_getfile2(psf, sizeof(psf[0]),
|
||||
sizeof(psf)/sizeof(psf[0]),
|
||||
idx)) > 0)
|
||||
idx, pid)) > 0)
|
||||
{
|
||||
procfd->total += n;
|
||||
idx = psf[n-1].psf_idx + 1;
|
||||
idx = psf[n-1].psf_fd + 1;
|
||||
}
|
||||
|
||||
if (n == -1) {
|
||||
@@ -618,33 +630,17 @@ int sigar_disk_usage_get(sigar_t *sigar, const char *name,
|
||||
return SIGAR_ENOTIMPL;
|
||||
}
|
||||
|
||||
/* XXX this is exactly the same as linux and solaris is darn close */
|
||||
#include <sys/vfs.h>
|
||||
|
||||
#define SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) ((val * bsize) >> 1)
|
||||
|
||||
int sigar_file_system_usage_get(sigar_t *sigar,
|
||||
const char *dirname,
|
||||
sigar_file_system_usage_t *fsusage)
|
||||
{
|
||||
struct statfs buf;
|
||||
struct stat sb;
|
||||
sigar_uint64_t val, bsize;
|
||||
int status = sigar_statvfs(sigar, dirname, fsusage);
|
||||
|
||||
if (statfs(dirname, &buf) != 0) {
|
||||
return errno;
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
bsize = buf.f_bsize / 512;
|
||||
val = buf.f_blocks;
|
||||
fsusage->total = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
val = buf.f_bfree;
|
||||
fsusage->free = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
val = buf.f_bavail;
|
||||
fsusage->avail = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
fsusage->used = fsusage->total - fsusage->free;
|
||||
fsusage->files = buf.f_files;
|
||||
fsusage->free_files = buf.f_ffree;
|
||||
fsusage->use_percent = sigar_file_system_usage_calc_used(sigar, fsusage);
|
||||
|
||||
SIGAR_DISK_STATS_INIT(&fsusage->disk);
|
||||
|
||||
@@ -882,6 +882,11 @@ int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
return sigar_procfs_args_get(sigar, pid, procargs);
|
||||
}
|
||||
|
||||
/* glibc 2.8 XXX use sysconf(_SC_ARG_MAX) */
|
||||
#ifndef ARG_MAX
|
||||
#define ARG_MAX 131072
|
||||
#endif
|
||||
|
||||
int sigar_proc_env_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_proc_env_t *procenv)
|
||||
{
|
||||
@@ -1053,7 +1058,6 @@ int sigar_thread_cpu_get(sigar_t *sigar,
|
||||
}
|
||||
|
||||
#include <mntent.h>
|
||||
#include <sys/statfs.h>
|
||||
|
||||
int sigar_os_fs_type_get(sigar_file_system_t *fsp)
|
||||
{
|
||||
@@ -1081,7 +1085,7 @@ int sigar_os_fs_type_get(sigar_file_system_t *fsp)
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
if (strEQ(type, "ocfs2")) {
|
||||
if (strnEQ(type, "ocfs", 4)) {
|
||||
fsp->type = SIGAR_FSTYPE_LOCAL_DISK;
|
||||
}
|
||||
break;
|
||||
@@ -1453,31 +1457,16 @@ int sigar_disk_usage_get(sigar_t *sigar, const char *name,
|
||||
return status;
|
||||
}
|
||||
|
||||
#include <sys/vfs.h>
|
||||
|
||||
#define SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) ((val * bsize) >> 1)
|
||||
|
||||
int sigar_file_system_usage_get(sigar_t *sigar,
|
||||
const char *dirname,
|
||||
sigar_file_system_usage_t *fsusage)
|
||||
{
|
||||
struct statfs buf;
|
||||
sigar_uint64_t val, bsize;
|
||||
int status = sigar_statvfs(sigar, dirname, fsusage);
|
||||
|
||||
if (statfs(dirname, &buf) != 0) {
|
||||
return errno;
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
bsize = buf.f_bsize / 512;
|
||||
val = buf.f_blocks;
|
||||
fsusage->total = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
val = buf.f_bfree;
|
||||
fsusage->free = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
val = buf.f_bavail;
|
||||
fsusage->avail = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
fsusage->used = fsusage->total - fsusage->free;
|
||||
fsusage->files = buf.f_files;
|
||||
fsusage->free_files = buf.f_ffree;
|
||||
fsusage->use_percent = sigar_file_system_usage_calc_used(sigar, fsusage);
|
||||
|
||||
(void)sigar_disk_usage_get(sigar, dirname, &fsusage->disk);
|
||||
|
||||
@@ -21,84 +21,6 @@
|
||||
#include "sigar_util.h"
|
||||
#include "sigar_os.h"
|
||||
|
||||
int sigar_get_multi_kstats(sigar_t *sigar,
|
||||
kstat_list_t *kl,
|
||||
const char *name,
|
||||
kstat_t **retval)
|
||||
{
|
||||
kstat_ctl_t *kc = sigar->kc;
|
||||
kstat_t *ksp;
|
||||
int i = 0;
|
||||
int dev;
|
||||
kid_t id = sigar_kstat_update(sigar);
|
||||
|
||||
if (id == -1) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
name += kl->nlen; /* e.g. "hme0" + 3 */
|
||||
dev = atoi(name);
|
||||
|
||||
if ((kl->num == 0) || (id > 0)) {
|
||||
while ((ksp = kstat_lookup(kc, kl->name, i, NULL))) {
|
||||
if (i+1 > kl->num) {
|
||||
kl->num = i+1;
|
||||
kl->ks = realloc(kl->ks, kl->num * sizeof(*kl->ks));
|
||||
}
|
||||
kl->ks[i] = ksp;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (dev >= kl->num) {
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
*retval = kl->ks[dev];
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
#define KSTAT_LIST_INIT(sigar, dev) \
|
||||
sigar->koffsets.dev[0] = -1; \
|
||||
sigar->ks.dev.num = 0; \
|
||||
sigar->ks.dev.ks = NULL; \
|
||||
sigar->ks.dev.name = #dev; \
|
||||
sigar->ks.dev.nlen = sizeof(#dev)-1
|
||||
|
||||
void sigar_init_multi_kstats(sigar_t *sigar)
|
||||
{
|
||||
KSTAT_LIST_INIT(sigar, lo);
|
||||
KSTAT_LIST_INIT(sigar, hme);
|
||||
KSTAT_LIST_INIT(sigar, dmfe);
|
||||
KSTAT_LIST_INIT(sigar, ge);
|
||||
KSTAT_LIST_INIT(sigar, eri);
|
||||
}
|
||||
|
||||
void sigar_free_multi_kstats(sigar_t *sigar)
|
||||
{
|
||||
if (sigar->ks.lo.num) {
|
||||
free(sigar->ks.lo.ks);
|
||||
KSTAT_LIST_INIT(sigar, lo);
|
||||
}
|
||||
if (sigar->ks.hme.num) {
|
||||
free(sigar->ks.hme.ks);
|
||||
KSTAT_LIST_INIT(sigar, hme);
|
||||
}
|
||||
if (sigar->ks.dmfe.num) {
|
||||
free(sigar->ks.dmfe.ks);
|
||||
KSTAT_LIST_INIT(sigar, dmfe);
|
||||
}
|
||||
if (sigar->ks.ge.num) {
|
||||
free(sigar->ks.ge.ks);
|
||||
KSTAT_LIST_INIT(sigar, ge);
|
||||
}
|
||||
if (sigar->ks.eri.num) {
|
||||
free(sigar->ks.eri.ks);
|
||||
KSTAT_LIST_INIT(sigar, eri);
|
||||
}
|
||||
}
|
||||
|
||||
int sigar_get_kstats(sigar_t *sigar)
|
||||
{
|
||||
kstat_ctl_t *kc = sigar->kc;
|
||||
@@ -169,9 +91,6 @@ int sigar_get_kstats(sigar_t *sigar)
|
||||
sigar->ks.syspages = kstat_lookup(kc, "unix", -1, "system_pages");
|
||||
sigar->ks.mempages = kstat_lookup(kc, "bunyip", -1, "mempages");
|
||||
|
||||
/* reset offsets on kstat_chain_update */
|
||||
sigar_free_multi_kstats(sigar);
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
@@ -225,84 +144,6 @@ static SIGAR_INLINE int kstat_named_offset(kstat_t *ksp, const char *name)
|
||||
return -2; /* not found */
|
||||
}
|
||||
|
||||
static char *kstat_keys_lo[] = {
|
||||
"ipackets", /* RX_PACKETS */
|
||||
"opackets", /* TX_PACKETS */
|
||||
NULL
|
||||
};
|
||||
|
||||
static char *kstat_keys_hme[] = {
|
||||
"ipackets", /* RX_PACKETS */
|
||||
"rbytes", /* RX_BYTES */
|
||||
"ierrors", /* RX_ERRORS */
|
||||
"missed", /* RX_DROPPED */
|
||||
"oflo", /* RX_OVERRUNS */
|
||||
"framing", /* RX_FRAME */
|
||||
"opackets", /* TX_PACKETS */
|
||||
"obytes", /* TX_BYTES */
|
||||
"oerrors", /* TX_ERRORS */
|
||||
"missed", /* TX_DROPPED */
|
||||
"oflo", /* TX_OVERRUNS */
|
||||
"collisions", /* TX_COLLISIONS */
|
||||
"nocarrier", /* TX_CARRIER */
|
||||
"ifspeed", /* SPEED */
|
||||
NULL
|
||||
};
|
||||
|
||||
static char *kstat_keys_dmfe[] = {
|
||||
"ipackets", /* RX_PACKETS */
|
||||
"rbytes", /* RX_BYTES */
|
||||
"ierrors", /* RX_ERRORS */
|
||||
"missed", /* RX_DROPPED */
|
||||
"oflo", /* RX_OVERRUNS */
|
||||
"framing", /* RX_FRAME */
|
||||
"opackets", /* TX_PACKETS */
|
||||
"obytes", /* TX_BYTES */
|
||||
"oerrors", /* TX_ERRORS */
|
||||
"missed", /* TX_DROPPED */
|
||||
"oflo", /* TX_OVERRUNS */
|
||||
"collisions", /* TX_COLLISIONS */
|
||||
"nocarrier", /* TX_CARRIER */
|
||||
"ifspeed", /* SPEED */
|
||||
NULL
|
||||
};
|
||||
|
||||
static char *kstat_keys_ge[] = {
|
||||
"ipackets", /* RX_PACKETS */
|
||||
"rbytes", /* RX_BYTES */
|
||||
"ierrors", /* RX_ERRORS */
|
||||
"drop", /* RX_DROPPED */
|
||||
"toolong_errors", /* RX_OVERRUNS */
|
||||
"framing", /* RX_FRAME */
|
||||
"opackets", /* TX_PACKETS */
|
||||
"obytes", /* TX_BYTES */
|
||||
"oerrors", /* TX_ERRORS */
|
||||
"drop", /* TX_DROPPED */
|
||||
"toolong_errors", /* TX_OVERRUNS */
|
||||
"collisions", /* TX_COLLISIONS */
|
||||
"nocarrier", /* TX_CARRIER */
|
||||
"ifspeed", /* SPEED */
|
||||
NULL
|
||||
};
|
||||
|
||||
static char *kstat_keys_eri[] = {
|
||||
"ipackets", /* RX_PACKETS */
|
||||
"rbytes", /* RX_BYTES */
|
||||
"ierrors", /* RX_ERRORS */
|
||||
"drop", /* RX_DROPPED */
|
||||
"rx_overflow", /* RX_OVERRUNS */
|
||||
"parity_error", /* RX_FRAME */
|
||||
"opackets", /* TX_PACKETS */
|
||||
"obytes", /* TX_BYTES */
|
||||
"oerrors", /* TX_ERRORS */
|
||||
"drop", /* TX_DROPPED */
|
||||
"rx_overflow", /* TX_OVERRUNS */
|
||||
"collisions", /* TX_COLLISIONS */
|
||||
"nocarrier", /* TX_CARRIER */
|
||||
"ifspeed", /* SPEED */
|
||||
NULL
|
||||
};
|
||||
|
||||
static char *kstat_keys_system[] = {
|
||||
"boot_time",
|
||||
"avenrun_1min",
|
||||
@@ -324,11 +165,6 @@ static char *kstat_keys_syspages[] = {
|
||||
};
|
||||
|
||||
static char **kstat_keys[] = {
|
||||
kstat_keys_lo,
|
||||
kstat_keys_hme,
|
||||
kstat_keys_dmfe,
|
||||
kstat_keys_ge,
|
||||
kstat_keys_eri,
|
||||
kstat_keys_system,
|
||||
kstat_keys_mempages,
|
||||
kstat_keys_syspages,
|
||||
|
||||
@@ -79,90 +79,6 @@ int sigar_proc_status_get(sigar_t *sigar, pstatus_t *pstatus, sigar_pid_t pid);
|
||||
#define CPU_ONLINE(n) \
|
||||
(p_online(n, P_STATUS) == P_ONLINE)
|
||||
|
||||
/* loopback interface only has these two metrics */
|
||||
typedef enum {
|
||||
KSTAT_LO_RX_PACKETS,
|
||||
KSTAT_LO_TX_PACKETS,
|
||||
KSTAT_LO_MAX
|
||||
} kstat_lo_off_e;
|
||||
|
||||
/* hme, ge and dmfe network devices provide
|
||||
* the same metrics, but in some cases with
|
||||
* different names and in all cases, the
|
||||
* offsets are different.
|
||||
*/
|
||||
typedef enum {
|
||||
KSTAT_HME_RX_PACKETS,
|
||||
KSTAT_HME_RX_BYTES,
|
||||
KSTAT_HME_RX_ERRORS,
|
||||
KSTAT_HME_RX_DROPPED,
|
||||
KSTAT_HME_RX_OVERRUNS,
|
||||
KSTAT_HME_RX_FRAME,
|
||||
KSTAT_HME_TX_PACKETS,
|
||||
KSTAT_HME_TX_BYTES,
|
||||
KSTAT_HME_TX_ERRORS,
|
||||
KSTAT_HME_TX_DROPPED,
|
||||
KSTAT_HME_TX_OVERRUNS,
|
||||
KSTAT_HME_TX_COLLISIONS,
|
||||
KSTAT_HME_TX_CARRIER,
|
||||
KSTAT_HME_SPEED,
|
||||
KSTAT_HME_MAX
|
||||
} kstat_hme_off_e;
|
||||
|
||||
typedef enum {
|
||||
KSTAT_DMFE_RX_PACKETS,
|
||||
KSTAT_DMFE_RX_BYTES,
|
||||
KSTAT_DMFE_RX_ERRORS,
|
||||
KSTAT_DMFE_RX_DROPPED,
|
||||
KSTAT_DMFE_RX_OVERRUNS,
|
||||
KSTAT_DMFE_RX_FRAME,
|
||||
KSTAT_DMFE_TX_PACKETS,
|
||||
KSTAT_DMFE_TX_BYTES,
|
||||
KSTAT_DMFE_TX_ERRORS,
|
||||
KSTAT_DMFE_TX_DROPPED,
|
||||
KSTAT_DMFE_TX_OVERRUNS,
|
||||
KSTAT_DMFE_TX_COLLISIONS,
|
||||
KSTAT_DMFE_TX_CARRIER,
|
||||
KSTAT_DMFE_SPEED,
|
||||
KSTAT_DMFE_MAX
|
||||
} kstat_dmfe_off_e;
|
||||
|
||||
typedef enum {
|
||||
KSTAT_GE_RX_PACKETS,
|
||||
KSTAT_GE_RX_BYTES,
|
||||
KSTAT_GE_RX_ERRORS,
|
||||
KSTAT_GE_RX_DROPPED,
|
||||
KSTAT_GE_RX_OVERRUNS,
|
||||
KSTAT_GE_RX_FRAME,
|
||||
KSTAT_GE_TX_PACKETS,
|
||||
KSTAT_GE_TX_BYTES,
|
||||
KSTAT_GE_TX_ERRORS,
|
||||
KSTAT_GE_TX_DROPPED,
|
||||
KSTAT_GE_TX_OVERRUNS,
|
||||
KSTAT_GE_TX_COLLISIONS,
|
||||
KSTAT_GE_TX_CARRIER,
|
||||
KSTAT_GE_SPEED,
|
||||
KSTAT_GE_MAX
|
||||
} kstat_ge_off_e;
|
||||
|
||||
typedef enum {
|
||||
KSTAT_ERI_RX_PACKETS,
|
||||
KSTAT_ERI_RX_BYTES,
|
||||
KSTAT_ERI_RX_ERRORS,
|
||||
KSTAT_ERI_RX_DROPPED,
|
||||
KSTAT_ERI_RX_OVERRUNS,
|
||||
KSTAT_ERI_RX_FRAME,
|
||||
KSTAT_ERI_TX_PACKETS,
|
||||
KSTAT_ERI_TX_BYTES,
|
||||
KSTAT_ERI_TX_ERRORS,
|
||||
KSTAT_ERI_TX_DROPPED,
|
||||
KSTAT_ERI_TX_OVERRUNS,
|
||||
KSTAT_ERI_TX_COLLISIONS,
|
||||
KSTAT_ERI_TX_CARRIER,
|
||||
KSTAT_ERI_SPEED,
|
||||
KSTAT_ERI_MAX
|
||||
} kstat_eri_off_e;
|
||||
|
||||
typedef enum {
|
||||
KSTAT_SYSTEM_BOOT_TIME,
|
||||
KSTAT_SYSTEM_LOADAVG_1,
|
||||
@@ -184,11 +100,6 @@ typedef enum {
|
||||
} kstat_syspages_off_e;
|
||||
|
||||
enum {
|
||||
KSTAT_KEYS_lo,
|
||||
KSTAT_KEYS_hme,
|
||||
KSTAT_KEYS_dmfe,
|
||||
KSTAT_KEYS_ge,
|
||||
KSTAT_KEYS_eri,
|
||||
KSTAT_KEYS_system,
|
||||
KSTAT_KEYS_mempages,
|
||||
KSTAT_KEYS_syspages,
|
||||
@@ -234,19 +145,9 @@ struct sigar_t {
|
||||
kstat_t *system;
|
||||
kstat_t *syspages;
|
||||
kstat_t *mempages;
|
||||
kstat_list_t hme;
|
||||
kstat_list_t dmfe;
|
||||
kstat_list_t ge;
|
||||
kstat_list_t eri;
|
||||
kstat_list_t lo;
|
||||
} ks;
|
||||
|
||||
struct {
|
||||
int lo[KSTAT_LO_MAX];
|
||||
int hme[KSTAT_HME_MAX];
|
||||
int dmfe[KSTAT_DMFE_MAX];
|
||||
int ge[KSTAT_GE_MAX];
|
||||
int eri[KSTAT_ERI_MAX];
|
||||
int system[KSTAT_SYSTEM_MAX];
|
||||
int mempages[KSTAT_MEMPAGES_MAX];
|
||||
int syspages[KSTAT_SYSPAGES_MAX];
|
||||
@@ -305,21 +206,6 @@ struct sigar_t {
|
||||
if (sigar->koffsets.type[0] == -1) \
|
||||
sigar_koffsets_lookup(ksp, sigar->koffsets.type, KSTAT_KEYS_##type)
|
||||
|
||||
#define sigar_koffsets_init_lo(sigar, ksp) \
|
||||
sigar_koffsets_init(sigar, ksp, lo)
|
||||
|
||||
#define sigar_koffsets_init_hme(sigar, ksp) \
|
||||
sigar_koffsets_init(sigar, ksp, hme)
|
||||
|
||||
#define sigar_koffsets_init_dmfe(sigar, ksp) \
|
||||
sigar_koffsets_init(sigar, ksp, dmfe)
|
||||
|
||||
#define sigar_koffsets_init_ge(sigar, ksp) \
|
||||
sigar_koffsets_init(sigar, ksp, ge)
|
||||
|
||||
#define sigar_koffsets_init_eri(sigar, ksp) \
|
||||
sigar_koffsets_init(sigar, ksp, eri)
|
||||
|
||||
#define sigar_koffsets_init_system(sigar, ksp) \
|
||||
sigar_koffsets_init(sigar, ksp, system)
|
||||
|
||||
|
||||
+52
-254
@@ -118,8 +118,6 @@ int sigar_os_open(sigar_t **sig)
|
||||
sigar->koffsets.mempages[0] = -1;
|
||||
sigar->koffsets.syspages[0] = -1;
|
||||
|
||||
sigar_init_multi_kstats(sigar);
|
||||
|
||||
if ((status = sigar_get_kstats(sigar)) != SIGAR_OK) {
|
||||
fprintf(stderr, "status=%d\n", status);
|
||||
}
|
||||
@@ -154,8 +152,6 @@ int sigar_os_close(sigar_t *sigar)
|
||||
{
|
||||
kstat_close(sigar->kc);
|
||||
|
||||
sigar_free_multi_kstats(sigar);
|
||||
|
||||
if (sigar->ks.lcpu) {
|
||||
free(sigar->ks.cpu);
|
||||
free(sigar->ks.cpu_info);
|
||||
@@ -468,12 +464,12 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
|
||||
/* merge times of logical processors */
|
||||
ent = sigar_cache_get(chips, chip_id);
|
||||
if (ent->value) {
|
||||
cpu = &cpulist->data[(int)ent->value-1];
|
||||
cpu = &cpulist->data[(long)ent->value-1];
|
||||
}
|
||||
else {
|
||||
SIGAR_CPU_LIST_GROW(cpulist);
|
||||
cpu = &cpulist->data[cpulist->number++];
|
||||
ent->value = (void *)(int)cpulist->number;
|
||||
ent->value = (void *)(long)cpulist->number;
|
||||
SIGAR_ZERO(cpu);
|
||||
|
||||
if (is_debug) {
|
||||
@@ -1352,8 +1348,6 @@ int sigar_file_system_list_get(sigar_t *sigar,
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
typedef struct {
|
||||
char device[PATH_MAX];
|
||||
char name[8];
|
||||
@@ -1716,29 +1710,16 @@ int sigar_disk_usage_get(sigar_t *sigar, const char *name,
|
||||
return status;
|
||||
}
|
||||
|
||||
#define SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) ((val * bsize) >> 1)
|
||||
|
||||
int sigar_file_system_usage_get(sigar_t *sigar,
|
||||
const char *dirname,
|
||||
sigar_file_system_usage_t *fsusage)
|
||||
{
|
||||
struct statvfs buf;
|
||||
sigar_uint64_t val, bsize;
|
||||
int status = sigar_statvfs(sigar, dirname, fsusage);
|
||||
|
||||
if (statvfs(dirname, &buf) != 0) {
|
||||
return errno;
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
bsize = buf.f_frsize / 512;
|
||||
val = buf.f_blocks;
|
||||
fsusage->total = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
val = buf.f_bfree;
|
||||
fsusage->free = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
val = buf.f_bavail;
|
||||
fsusage->avail = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
fsusage->used = fsusage->total - fsusage->free;
|
||||
fsusage->files = buf.f_files;
|
||||
fsusage->free_files = buf.f_ffree;
|
||||
fsusage->use_percent = sigar_file_system_usage_calc_used(sigar, fsusage);
|
||||
|
||||
sigar_disk_usage_get(sigar, dirname, &fsusage->disk);
|
||||
@@ -1938,207 +1919,6 @@ int sigar_net_route_list_get(sigar_t *sigar,
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
#define kHME(v) kSTAT_uint(v, hme)
|
||||
|
||||
static int sigar_net_ifstat_get_hme(sigar_t *sigar, const char *name,
|
||||
sigar_net_interface_stat_t *ifstat)
|
||||
{
|
||||
kstat_ctl_t *kc = sigar->kc;
|
||||
kstat_t *ksp;
|
||||
int status;
|
||||
|
||||
status = sigar_get_multi_kstats(sigar, &sigar->ks.hme,
|
||||
name, &ksp);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
kstat_read(kc, ksp, NULL);
|
||||
|
||||
sigar_koffsets_init_hme(sigar, ksp);
|
||||
|
||||
ifstat->rx_packets = kHME(KSTAT_HME_RX_PACKETS);
|
||||
ifstat->rx_bytes = kHME(KSTAT_HME_RX_BYTES);
|
||||
ifstat->rx_errors = kHME(KSTAT_HME_RX_ERRORS);
|
||||
ifstat->rx_dropped = kHME(KSTAT_HME_RX_DROPPED); /*XXX*/
|
||||
ifstat->rx_overruns = kHME(KSTAT_HME_RX_OVERRUNS); /*XXX*/
|
||||
ifstat->rx_frame = kHME(KSTAT_HME_RX_FRAME);
|
||||
|
||||
ifstat->tx_packets = kHME(KSTAT_HME_TX_PACKETS);
|
||||
ifstat->tx_bytes = kHME(KSTAT_HME_TX_BYTES);
|
||||
ifstat->tx_errors = kHME(KSTAT_HME_TX_ERRORS);
|
||||
ifstat->tx_dropped = kHME(KSTAT_HME_TX_DROPPED); /*XXX*/
|
||||
ifstat->tx_overruns = kHME(KSTAT_HME_TX_OVERRUNS); /*XXX*/
|
||||
ifstat->tx_collisions = kHME(KSTAT_HME_TX_COLLISIONS);
|
||||
ifstat->tx_carrier = kHME(KSTAT_HME_TX_CARRIER);
|
||||
ifstat->speed = kHME(KSTAT_HME_SPEED);
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
#define kDMFE(v) kSTAT_uint(v, dmfe)
|
||||
|
||||
static int sigar_net_ifstat_get_dmfe(sigar_t *sigar, const char *name,
|
||||
sigar_net_interface_stat_t *ifstat)
|
||||
{
|
||||
kstat_ctl_t *kc = sigar->kc;
|
||||
kstat_t *ksp;
|
||||
int status;
|
||||
|
||||
status = sigar_get_multi_kstats(sigar, &sigar->ks.dmfe,
|
||||
name, &ksp);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
kstat_read(kc, ksp, NULL);
|
||||
|
||||
sigar_koffsets_init_dmfe(sigar, ksp);
|
||||
|
||||
ifstat->rx_packets = kDMFE(KSTAT_DMFE_RX_PACKETS);
|
||||
ifstat->rx_bytes = kDMFE(KSTAT_DMFE_RX_BYTES);
|
||||
ifstat->rx_errors = kDMFE(KSTAT_DMFE_RX_ERRORS);
|
||||
ifstat->rx_dropped = kDMFE(KSTAT_DMFE_RX_DROPPED); /*XXX*/
|
||||
ifstat->rx_overruns = kDMFE(KSTAT_DMFE_RX_OVERRUNS); /*XXX*/
|
||||
ifstat->rx_frame = kDMFE(KSTAT_DMFE_RX_FRAME);
|
||||
|
||||
ifstat->tx_packets = kDMFE(KSTAT_DMFE_TX_PACKETS);
|
||||
ifstat->tx_bytes = kDMFE(KSTAT_DMFE_TX_BYTES);
|
||||
ifstat->tx_errors = kDMFE(KSTAT_DMFE_TX_ERRORS);
|
||||
ifstat->tx_dropped = kDMFE(KSTAT_DMFE_TX_DROPPED); /*XXX*/
|
||||
ifstat->tx_overruns = kDMFE(KSTAT_DMFE_TX_OVERRUNS); /*XXX*/
|
||||
ifstat->tx_collisions = kDMFE(KSTAT_DMFE_TX_COLLISIONS);
|
||||
ifstat->tx_carrier = kDMFE(KSTAT_DMFE_TX_CARRIER);
|
||||
|
||||
ifstat->speed = kDMFE(KSTAT_DMFE_SPEED);
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
#define kGE(v) kSTAT_uint(v, ge)
|
||||
|
||||
static int sigar_net_ifstat_get_ge(sigar_t *sigar, const char *name,
|
||||
sigar_net_interface_stat_t *ifstat)
|
||||
{
|
||||
kstat_ctl_t *kc = sigar->kc;
|
||||
kstat_t *ksp;
|
||||
int status;
|
||||
|
||||
status = sigar_get_multi_kstats(sigar, &sigar->ks.ge,
|
||||
name, &ksp);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
kstat_read(kc, ksp, NULL);
|
||||
|
||||
sigar_koffsets_init_ge(sigar, ksp);
|
||||
|
||||
ifstat->rx_packets = kGE(KSTAT_GE_RX_PACKETS);
|
||||
ifstat->rx_bytes = kGE(KSTAT_GE_RX_BYTES);
|
||||
ifstat->rx_errors = kGE(KSTAT_GE_RX_ERRORS);
|
||||
ifstat->rx_dropped = kGE(KSTAT_GE_RX_DROPPED); /*XXX*/
|
||||
ifstat->rx_overruns = kGE(KSTAT_GE_RX_OVERRUNS); /*XXX*/
|
||||
ifstat->rx_frame = kGE(KSTAT_GE_RX_FRAME);
|
||||
|
||||
ifstat->tx_packets = kGE(KSTAT_GE_TX_PACKETS);
|
||||
ifstat->tx_bytes = kGE(KSTAT_GE_TX_BYTES);
|
||||
ifstat->tx_errors = kGE(KSTAT_GE_TX_ERRORS);
|
||||
ifstat->tx_dropped = kGE(KSTAT_GE_TX_DROPPED); /*XXX*/
|
||||
ifstat->tx_overruns = kGE(KSTAT_GE_TX_OVERRUNS); /*XXX*/
|
||||
ifstat->tx_collisions = kGE(KSTAT_GE_TX_COLLISIONS);
|
||||
ifstat->tx_carrier = kGE(KSTAT_GE_TX_CARRIER);
|
||||
|
||||
ifstat->speed = kGE(KSTAT_GE_SPEED);
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
#define kERI(v) kSTAT_uint(v, eri)
|
||||
|
||||
static int sigar_net_ifstat_get_eri(sigar_t *sigar, const char *name,
|
||||
sigar_net_interface_stat_t *ifstat)
|
||||
{
|
||||
kstat_ctl_t *kc = sigar->kc;
|
||||
kstat_t *ksp;
|
||||
int status;
|
||||
|
||||
status = sigar_get_multi_kstats(sigar, &sigar->ks.eri,
|
||||
name, &ksp);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
kstat_read(kc, ksp, NULL);
|
||||
|
||||
sigar_koffsets_init_eri(sigar, ksp);
|
||||
|
||||
ifstat->rx_packets = kERI(KSTAT_ERI_RX_PACKETS);
|
||||
ifstat->rx_bytes = kERI(KSTAT_ERI_RX_BYTES);
|
||||
ifstat->rx_errors = kERI(KSTAT_ERI_RX_ERRORS);
|
||||
ifstat->rx_dropped = kERI(KSTAT_ERI_RX_DROPPED); /*XXX*/
|
||||
ifstat->rx_overruns = kERI(KSTAT_ERI_RX_OVERRUNS); /*XXX*/
|
||||
ifstat->rx_frame = kERI(KSTAT_ERI_RX_FRAME);
|
||||
|
||||
ifstat->tx_packets = kERI(KSTAT_ERI_TX_PACKETS);
|
||||
ifstat->tx_bytes = kERI(KSTAT_ERI_TX_BYTES);
|
||||
ifstat->tx_errors = kERI(KSTAT_ERI_TX_ERRORS);
|
||||
ifstat->tx_dropped = kERI(KSTAT_ERI_TX_DROPPED); /*XXX*/
|
||||
ifstat->tx_overruns = kERI(KSTAT_ERI_TX_OVERRUNS); /*XXX*/
|
||||
ifstat->tx_collisions = kERI(KSTAT_ERI_TX_COLLISIONS);
|
||||
ifstat->tx_carrier = kERI(KSTAT_ERI_TX_CARRIER);
|
||||
|
||||
ifstat->speed = kERI(KSTAT_ERI_SPEED);
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
#define kLO(v) kSTAT_uint(v, lo)
|
||||
|
||||
#define jLO aHO
|
||||
|
||||
static int sigar_net_ifstat_get_lo(sigar_t *sigar, const char *name,
|
||||
sigar_net_interface_stat_t *ifstat)
|
||||
{
|
||||
kstat_ctl_t *kc = sigar->kc;
|
||||
kstat_t *ksp;
|
||||
int status;
|
||||
|
||||
status = sigar_get_multi_kstats(sigar, &sigar->ks.lo,
|
||||
name, &ksp);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
kstat_read(kc, ksp, NULL);
|
||||
|
||||
sigar_koffsets_init_lo(sigar, ksp);
|
||||
|
||||
ifstat->rx_packets = kLO(KSTAT_LO_RX_PACKETS);
|
||||
ifstat->rx_bytes = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->rx_errors = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->rx_dropped = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->rx_overruns = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->rx_frame = SIGAR_FIELD_NOTIMPL;
|
||||
|
||||
ifstat->tx_packets = kLO(KSTAT_LO_TX_PACKETS);
|
||||
ifstat->tx_bytes = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->tx_errors = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->tx_dropped = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->tx_overruns = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->tx_collisions = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->tx_carrier = SIGAR_FIELD_NOTIMPL;
|
||||
|
||||
ifstat->speed = SIGAR_FIELD_NOTIMPL;
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
static void ifstat_kstat_common(sigar_net_interface_stat_t *ifstat,
|
||||
kstat_named_t *data, int ndata)
|
||||
{
|
||||
@@ -2163,8 +1943,13 @@ static void ifstat_kstat_common(sigar_net_interface_stat_t *ifstat,
|
||||
break;
|
||||
case 'i':
|
||||
if (strEQ(ptr, "ipackets")) {
|
||||
if (ifstat->rx_packets == 0) {
|
||||
ifstat->rx_packets = value;
|
||||
}
|
||||
}
|
||||
else if (strEQ(ptr, "ipackets64")) {
|
||||
ifstat->rx_packets = data[i].value.ui64;
|
||||
}
|
||||
else if (strEQ(ptr, "ierrors")) {
|
||||
ifstat->rx_errors = value;
|
||||
}
|
||||
@@ -2190,8 +1975,13 @@ static void ifstat_kstat_common(sigar_net_interface_stat_t *ifstat,
|
||||
break;
|
||||
case 'o':
|
||||
if (strEQ(ptr, "obytes")) {
|
||||
if (ifstat->tx_bytes == 0) {
|
||||
ifstat->tx_bytes = value;
|
||||
}
|
||||
}
|
||||
else if (strEQ(ptr, "obytes64")) {
|
||||
ifstat->tx_bytes = data[i].value.ui64;
|
||||
}
|
||||
else if (strEQ(ptr, "oerrors")) {
|
||||
ifstat->tx_errors = value;
|
||||
}
|
||||
@@ -2199,16 +1989,26 @@ static void ifstat_kstat_common(sigar_net_interface_stat_t *ifstat,
|
||||
ifstat->tx_overruns = value;
|
||||
}
|
||||
else if (strEQ(ptr, "opackets")) {
|
||||
if (ifstat->tx_packets == 0) {
|
||||
ifstat->tx_packets = value;
|
||||
}
|
||||
}
|
||||
else if (strEQ(ptr, "opackets64")) {
|
||||
ifstat->tx_packets = data[i].value.ui64;
|
||||
}
|
||||
else if (strEQ(ptr, "toolong_errors")) {
|
||||
ifstat->tx_overruns = value;
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
if (strEQ(ptr, "rbytes")) {
|
||||
if (ifstat->rx_bytes == 0) {
|
||||
ifstat->rx_bytes = value;
|
||||
}
|
||||
}
|
||||
else if (strEQ(ptr, "rbytes64")) {
|
||||
ifstat->rx_bytes = data[i].value.ui64;
|
||||
}
|
||||
else if (strEQ(ptr, "rx_overflow")) {
|
||||
ifstat->rx_overruns = value;
|
||||
}
|
||||
@@ -2238,8 +2038,6 @@ static int sigar_net_ifstat_get_any(sigar_t *sigar, const char *name,
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
SIGAR_ZERO(ifstat);
|
||||
|
||||
data = (kstat_named_t *)ksp->ks_data;
|
||||
|
||||
ifstat_kstat_common(ifstat, data, ksp->ks_ndata);
|
||||
@@ -2247,42 +2045,42 @@ static int sigar_net_ifstat_get_any(sigar_t *sigar, const char *name,
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
/* loopback interface only has rx/tx packets */
|
||||
static int sigar_net_ifstat_get_lo(sigar_t *sigar, const char *name,
|
||||
sigar_net_interface_stat_t *ifstat)
|
||||
{
|
||||
ifstat->rx_packets = 0;
|
||||
ifstat->rx_bytes = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->rx_errors = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->rx_dropped = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->rx_overruns = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->rx_frame = SIGAR_FIELD_NOTIMPL;
|
||||
|
||||
ifstat->tx_packets = 0;
|
||||
ifstat->tx_bytes = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->tx_errors = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->tx_dropped = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->tx_overruns = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->tx_collisions = SIGAR_FIELD_NOTIMPL;
|
||||
ifstat->tx_carrier = SIGAR_FIELD_NOTIMPL;
|
||||
|
||||
ifstat->speed = SIGAR_FIELD_NOTIMPL;
|
||||
|
||||
return sigar_net_ifstat_get_any(sigar, name, ifstat);
|
||||
}
|
||||
|
||||
int sigar_net_interface_stat_get(sigar_t *sigar, const char *name,
|
||||
sigar_net_interface_stat_t *ifstat)
|
||||
{
|
||||
ifstat->speed = SIGAR_FIELD_NOTIMPL;
|
||||
|
||||
switch (*name) {
|
||||
case 'd':
|
||||
if (strnEQ(name, "dmfe", 4)) {
|
||||
return sigar_net_ifstat_get_dmfe(sigar, name, ifstat);
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
if (strnEQ(name, "eri", 3)) {
|
||||
return sigar_net_ifstat_get_eri(sigar, name, ifstat);
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
if (strnEQ(name, "ge", 2)) {
|
||||
return sigar_net_ifstat_get_ge(sigar, name, ifstat);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
if (strnEQ(name, "hme", 3)) {
|
||||
return sigar_net_ifstat_get_hme(sigar, name, ifstat);
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
if (strnEQ(name, "lo", 2)) {
|
||||
return sigar_net_ifstat_get_lo(sigar, name, ifstat);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
else {
|
||||
SIGAR_ZERO(ifstat);
|
||||
return sigar_net_ifstat_get_any(sigar, name, ifstat);
|
||||
}
|
||||
}
|
||||
|
||||
#define TCPQ_SIZE(s) ((s) >= 0 ? (s) : 0)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#define PERFBUF_SIZE 8192
|
||||
|
||||
#define PERF_TITLE_PROC 230
|
||||
#define PERF_TITLE_SYS_KEY "2"
|
||||
#define PERF_TITLE_MEM_KEY "4"
|
||||
#define PERF_TITLE_PROC_KEY "230"
|
||||
#define PERF_TITLE_CPU_KEY "238"
|
||||
@@ -975,11 +976,41 @@ SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar,
|
||||
}
|
||||
}
|
||||
|
||||
#define PERF_TITLE_UPTIME_KEY 674 /* System Up Time */
|
||||
|
||||
SIGAR_DECLARE(int) sigar_uptime_get(sigar_t *sigar,
|
||||
sigar_uptime_t *uptime)
|
||||
{
|
||||
uptime->uptime = GetTickCount() / 1000;
|
||||
int status;
|
||||
PERF_OBJECT_TYPE *object =
|
||||
get_perf_object_inst(sigar, PERF_TITLE_SYS_KEY, 0, &status);
|
||||
PERF_INSTANCE_DEFINITION *inst;
|
||||
PERF_COUNTER_DEFINITION *counter;
|
||||
BYTE *data;
|
||||
DWORD i;
|
||||
|
||||
if (!object) {
|
||||
return status;
|
||||
}
|
||||
|
||||
data = (BYTE *)((BYTE *)object + object->DefinitionLength);
|
||||
|
||||
for (i=0, counter = PdhFirstCounter(object);
|
||||
i<object->NumCounters;
|
||||
i++, counter = PdhNextCounter(counter))
|
||||
{
|
||||
if (counter->CounterNameTitleIndex == PERF_TITLE_UPTIME_KEY) {
|
||||
DWORD offset = counter->CounterOffset;
|
||||
LONGLONG time = object->PerfTime.QuadPart;
|
||||
LONGLONG freq = object->PerfFreq.QuadPart;
|
||||
LONGLONG counter = *((LONGLONG *)(data + offset));
|
||||
uptime->uptime = (time - counter) / freq;
|
||||
return SIGAR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/* http://msdn.microsoft.com/en-us/library/ms724408.aspx */
|
||||
return GetTickCount() / 1000;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1223,11 +1254,13 @@ SIGAR_DECLARE(int) sigar_proc_cred_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
|
||||
sigar_int64_t sigar_time_now_millis(void)
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
FILETIME time;
|
||||
|
||||
GetSystemTimeAsFileTime(&time);
|
||||
GetSystemTime(&st);
|
||||
SystemTimeToFileTime(&st, &time);
|
||||
|
||||
return FILETIME2MSEC(time);
|
||||
return sigar_FileTimeToTime(&time) / 1000;
|
||||
}
|
||||
|
||||
SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
|
||||
+22
-5
@@ -20,13 +20,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifndef WIN32
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include "sigar.h"
|
||||
#include "sigar_private.h"
|
||||
@@ -111,7 +114,7 @@ SIGAR_DECLARE(int) sigar_proc_cpu_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
sigar_cache_entry_t *entry;
|
||||
sigar_proc_cpu_t *prev;
|
||||
sigar_uint64_t otime, time_now = sigar_time_now_millis();
|
||||
sigar_int64_t time_diff, total_diff;
|
||||
sigar_uint64_t time_diff, total_diff;
|
||||
int status;
|
||||
|
||||
if (!sigar->proc_cpu) {
|
||||
@@ -148,6 +151,11 @@ SIGAR_DECLARE(int) sigar_proc_cpu_get(sigar_t *sigar, sigar_pid_t pid,
|
||||
|
||||
memcpy(prev, proccpu, sizeof(*prev));
|
||||
|
||||
if (proccpu->total < otime) {
|
||||
/* XXX this should not happen */
|
||||
otime = 0;
|
||||
}
|
||||
|
||||
if (otime == 0) {
|
||||
proccpu->percent = 0.0;
|
||||
/* first time called */
|
||||
@@ -439,6 +447,11 @@ static int sigar_common_fs_type_get(sigar_file_system_t *fsp)
|
||||
fsp->type = SIGAR_FSTYPE_LOCAL_DISK;
|
||||
}
|
||||
break;
|
||||
case 'z':
|
||||
if (strEQ(type, "zfs")) {
|
||||
fsp->type = SIGAR_FSTYPE_LOCAL_DISK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return fsp->type;
|
||||
@@ -1797,19 +1810,23 @@ sigar_net_interface_config_primary_get(sigar_t *sigar,
|
||||
|
||||
if ((status != SIGAR_OK) ||
|
||||
(ifconfig->flags & SIGAR_IFF_LOOPBACK) ||
|
||||
!ifconfig->hwaddr.addr.in || /* no mac address */
|
||||
strchr(iflist.data[i], ':')) /* alias */
|
||||
!ifconfig->hwaddr.addr.in) /* no mac address */
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!possible_config.flags) {
|
||||
/* save for later for use if we're not connected to the net */
|
||||
/* save for later for use if we're not connected to the net
|
||||
* or all interfaces are aliases (e.g. solaris zone)
|
||||
*/
|
||||
memcpy(&possible_config, ifconfig, sizeof(*ifconfig));
|
||||
}
|
||||
if (!ifconfig->address.addr.in) {
|
||||
continue; /* no ip address */
|
||||
}
|
||||
if (strchr(iflist.data[i], ':')) {
|
||||
continue; /* alias */
|
||||
}
|
||||
|
||||
found = 1;
|
||||
break;
|
||||
|
||||
@@ -61,6 +61,62 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "sigar.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
# include <sys/param.h>
|
||||
# include <sys/mount.h>
|
||||
#else
|
||||
# include <sys/statvfs.h>
|
||||
# define HAVE_STATVFS
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#define SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) ((val * bsize) >> 1)
|
||||
|
||||
int sigar_statvfs(sigar_t *sigar,
|
||||
const char *dirname,
|
||||
sigar_file_system_usage_t *fsusage)
|
||||
{
|
||||
sigar_uint64_t val, bsize;
|
||||
#ifdef HAVE_STATVFS
|
||||
struct statvfs buf;
|
||||
int status =
|
||||
# if defined(__sun) && !defined(_LP64)
|
||||
/* http://bugs.opensolaris.org/view_bug.do?bug_id=4462986 */
|
||||
statvfs(dirname, (void *)&buf);
|
||||
# else
|
||||
statvfs(dirname, &buf);
|
||||
# endif
|
||||
#else
|
||||
struct statfs buf;
|
||||
int status = statfs(dirname, &buf);
|
||||
#endif
|
||||
|
||||
if (status != 0) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
#ifdef HAVE_STATVFS
|
||||
bsize = buf.f_frsize / 512;
|
||||
#else
|
||||
bsize = buf.f_bsize / 512;
|
||||
#endif
|
||||
val = buf.f_blocks;
|
||||
fsusage->total = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
val = buf.f_bfree;
|
||||
fsusage->free = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
val = buf.f_bavail;
|
||||
fsusage->avail = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||
fsusage->used = fsusage->total - fsusage->free;
|
||||
fsusage->files = buf.f_files;
|
||||
fsusage->free_files = buf.f_ffree;
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* whittled down version of apr/file_info/{unix,win32}/filestat.c
|
||||
* to fillin sigar_fileattrs_t
|
||||
|
||||
+9
-13
@@ -28,6 +28,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(_AIX)
|
||||
#include <sys/socket.h>
|
||||
@@ -292,11 +293,6 @@ SIGAR_DECLARE(int) sigar_uptime_string(sigar_t *sigar,
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
/* threadsafe alternative to inet_ntoa (inet_ntop4 from apr) */
|
||||
int sigar_inet_ntoa(sigar_t *sigar,
|
||||
sigar_uint32_t address,
|
||||
@@ -614,14 +610,14 @@ SIGAR_DECLARE(int) sigar_cpu_perc_calculate(sigar_cpu_t *prev,
|
||||
double diff_wait, diff_irq, diff_soft_irq, diff_stolen;
|
||||
double diff_total;
|
||||
|
||||
diff_user = (sigar_int64_t)(curr->user - prev->user);
|
||||
diff_sys = (sigar_int64_t)(curr->sys - prev->sys);
|
||||
diff_nice = (sigar_int64_t)(curr->nice - prev->nice);
|
||||
diff_idle = (sigar_int64_t)(curr->idle - prev->idle);
|
||||
diff_wait = (sigar_int64_t)(curr->wait - prev->wait);
|
||||
diff_irq = (sigar_int64_t)(curr->irq - prev->irq);
|
||||
diff_soft_irq = (sigar_int64_t)(curr->soft_irq - prev->soft_irq);
|
||||
diff_stolen = (sigar_int64_t)(curr->stolen - prev->stolen);
|
||||
diff_user = curr->user - prev->user;
|
||||
diff_sys = curr->sys - prev->sys;
|
||||
diff_nice = curr->nice - prev->nice;
|
||||
diff_idle = curr->idle - prev->idle;
|
||||
diff_wait = curr->wait - prev->wait;
|
||||
diff_irq = curr->irq - prev->irq;
|
||||
diff_soft_irq = curr->soft_irq - prev->soft_irq;
|
||||
diff_stolen = curr->stolen - prev->stolen;
|
||||
|
||||
diff_user = diff_user < 0 ? 0 : diff_user;
|
||||
diff_sys = diff_sys < 0 ? 0 : diff_sys;
|
||||
|
||||
@@ -1144,6 +1144,65 @@ static int SIGAPI ptql_args_match(sigar_t *sigar,
|
||||
return matched ? SIGAR_OK : !SIGAR_OK;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
sigar_t *sigar;
|
||||
ptql_branch_t *branch;
|
||||
sigar_uint32_t ix;
|
||||
int matched;
|
||||
} proc_modules_match_t;
|
||||
|
||||
static int proc_modules_match(void *data, char *name, int len)
|
||||
{
|
||||
proc_modules_match_t *matcher =
|
||||
(proc_modules_match_t *)data;
|
||||
ptql_branch_t *branch = matcher->branch;
|
||||
|
||||
if (branch->op_flags & PTQL_OP_FLAG_GLOB) { /* Modules.*.ct=libc */
|
||||
matcher->matched =
|
||||
ptql_str_match(matcher->sigar, branch, name);
|
||||
|
||||
if (matcher->matched) {
|
||||
return !SIGAR_OK; /* stop iterating */
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (matcher->ix++ == branch->data.ui32) { /* Modules.3.ct=libc */
|
||||
matcher->matched =
|
||||
ptql_str_match(matcher->sigar, branch, name);
|
||||
return !SIGAR_OK; /* stop iterating */
|
||||
}
|
||||
}
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
static int SIGAPI ptql_modules_match(sigar_t *sigar,
|
||||
sigar_pid_t pid,
|
||||
void *data)
|
||||
{
|
||||
ptql_branch_t *branch =
|
||||
(ptql_branch_t *)data;
|
||||
int status;
|
||||
sigar_proc_modules_t procmods;
|
||||
proc_modules_match_t matcher;
|
||||
|
||||
matcher.sigar = sigar;
|
||||
matcher.branch = branch;
|
||||
matcher.ix = 0;
|
||||
matcher.matched = 0;
|
||||
|
||||
procmods.module_getter = proc_modules_match;
|
||||
procmods.data = &matcher;
|
||||
|
||||
status = sigar_proc_modules_get(sigar, pid, &procmods);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return matcher.matched ? SIGAR_OK : !SIGAR_OK;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *key;
|
||||
int klen;
|
||||
@@ -1316,6 +1375,10 @@ static ptql_lookup_t PTQL_Args[] = {
|
||||
{ NULL, ptql_args_match, 0, 0, PTQL_VALUE_TYPE_ANY, ptql_args_branch_init }
|
||||
};
|
||||
|
||||
static ptql_lookup_t PTQL_Modules[] = {
|
||||
{ NULL, ptql_modules_match, 0, 0, PTQL_VALUE_TYPE_ANY, ptql_args_branch_init }
|
||||
};
|
||||
|
||||
static ptql_lookup_t PTQL_Env[] = {
|
||||
{ NULL, ptql_env_match, 0, 0, PTQL_VALUE_TYPE_ANY, ptql_branch_init_any }
|
||||
};
|
||||
@@ -1342,6 +1405,7 @@ static ptql_entry_t ptql_map[] = {
|
||||
{ "State", PTQL_State },
|
||||
{ "Fd", PTQL_Fd },
|
||||
{ "Args", PTQL_Args },
|
||||
{ "Modules", PTQL_Modules },
|
||||
{ "Env", PTQL_Env },
|
||||
{ "Port", PTQL_Port },
|
||||
{ "Pid", PTQL_Pid },
|
||||
|
||||
+1
-5
@@ -824,13 +824,9 @@ SIGAR_DECLARE(int) sigar_rpc_ping(char *host,
|
||||
rpc_stat = clnt_call(client, NULLPROC, (xdrproc_t)xdr_void, NULL,
|
||||
(xdrproc_t)xdr_void, NULL, timeout);
|
||||
|
||||
if (rpc_stat != RPC_SUCCESS) {
|
||||
return rpc_stat;
|
||||
}
|
||||
|
||||
clnt_destroy(client);
|
||||
|
||||
return RPC_SUCCESS;
|
||||
return rpc_stat;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ static sigar_version_t sigar_version = {
|
||||
"@@ARCHLIB@@",
|
||||
"@@BINNAME@@",
|
||||
"SIGAR-@@VERSION_STRING@@, "
|
||||
"SVN revision @@SCM_REVISION@@, "
|
||||
"SCM revision @@SCM_REVISION@@, "
|
||||
"built @@BUILD_DATE@@ as @@ARCHLIB@@",
|
||||
@@VERSION_MAJOR@@,
|
||||
@@VERSION_MINOR@@,
|
||||
|
||||
Reference in new issue
Block a user