From f8c583fbc80a2f0c96ec86a358d8eb717f420416 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 8 Aug 2007 05:34:21 +0000 Subject: [PATCH] remove _stat from sigar_tcp names --- bindings/java/src/jni/generate.pl | 4 ++-- .../java/src/org/hyperic/sigar/Sigar.java | 4 ++-- .../src/org/hyperic/sigar/SigarProxy.java | 2 +- .../src/org/hyperic/sigar/cmd/Netstat.java | 4 ++-- .../org/hyperic/sigar/test/TestTcpStat.java | 8 +++---- include/sigar.h | 6 ++--- include/sigar_private.h | 2 +- src/os/aix/aix_sigar.c | 24 +++++++++---------- src/os/darwin/darwin_sigar.c | 24 +++++++++---------- src/os/hpux/hpux_sigar.c | 6 ++--- src/os/linux/linux_sigar.c | 22 ++++++++--------- src/os/osf1/osf1_sigar.c | 4 ++-- src/os/solaris/solaris_sigar.c | 22 ++++++++--------- src/os/stub/stub_sigar.c | 4 ++-- src/os/win32/win32_sigar.c | 22 ++++++++--------- src/sigar.c | 8 +++---- 16 files changed, 82 insertions(+), 84 deletions(-) diff --git a/bindings/java/src/jni/generate.pl b/bindings/java/src/jni/generate.pl index 263a14f6..2d6943cf 100644 --- a/bindings/java/src/jni/generate.pl +++ b/bindings/java/src/jni/generate.pl @@ -1022,7 +1022,7 @@ my %classes = ( name => 'all_outbound_total', type => 'Int', }, ], - TcpStat => [ + Tcp => [ { name => 'active_opens', type => 'Long', desc => '', @@ -1366,7 +1366,7 @@ my %cmds = ( Solaris => '', Win32 => '', }, - TcpStat => { + Tcp => { Linux => 'cat /proc/net/snmp', Solaris => 'netstat -s -P tcp', }, diff --git a/bindings/java/src/org/hyperic/sigar/Sigar.java b/bindings/java/src/org/hyperic/sigar/Sigar.java index 72e9a401..45e9f2cf 100644 --- a/bindings/java/src/org/hyperic/sigar/Sigar.java +++ b/bindings/java/src/org/hyperic/sigar/Sigar.java @@ -781,9 +781,9 @@ public class Sigar implements SigarProxy { * TCP-MIB stats * @exception SigarException on failure. */ - public TcpStat getTcpStat() + public Tcp getTcp() throws SigarException { - return TcpStat.fetch(this); + return Tcp.fetch(this); } public NfsClientV2 getNfsClientV2() diff --git a/bindings/java/src/org/hyperic/sigar/SigarProxy.java b/bindings/java/src/org/hyperic/sigar/SigarProxy.java index 26773293..e2ec93ea 100644 --- a/bindings/java/src/org/hyperic/sigar/SigarProxy.java +++ b/bindings/java/src/org/hyperic/sigar/SigarProxy.java @@ -157,7 +157,7 @@ public interface SigarProxy { public Who[] getWhoList() throws SigarException; - public TcpStat getTcpStat() throws SigarException; + public Tcp getTcp() throws SigarException; public NfsClientV2 getNfsClientV2() throws SigarException; diff --git a/bindings/java/src/org/hyperic/sigar/cmd/Netstat.java b/bindings/java/src/org/hyperic/sigar/cmd/Netstat.java index 910f7422..c8f84e2b 100644 --- a/bindings/java/src/org/hyperic/sigar/cmd/Netstat.java +++ b/bindings/java/src/org/hyperic/sigar/cmd/Netstat.java @@ -26,7 +26,7 @@ import org.hyperic.sigar.NetServices; import org.hyperic.sigar.SigarException; import org.hyperic.sigar.NetConnection; import org.hyperic.sigar.NetFlags; -import org.hyperic.sigar.TcpStat; +import org.hyperic.sigar.Tcp; /** * Display network connections. @@ -161,7 +161,7 @@ public class Netstat extends SigarCommandBase { } private void outputTcpStats() throws SigarException { - TcpStat stat = this.sigar.getTcpStat(); + Tcp stat = this.sigar.getTcp(); final String dnt = " "; println(dnt + stat.getActiveOpens() + " active connections openings"); println(dnt + stat.getPassiveOpens() + " passive connection openings"); diff --git a/bindings/java/src/org/hyperic/sigar/test/TestTcpStat.java b/bindings/java/src/org/hyperic/sigar/test/TestTcpStat.java index 3a20d6e7..57e9ceac 100644 --- a/bindings/java/src/org/hyperic/sigar/test/TestTcpStat.java +++ b/bindings/java/src/org/hyperic/sigar/test/TestTcpStat.java @@ -20,7 +20,7 @@ package org.hyperic.sigar.test; import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarNotImplementedException; -import org.hyperic.sigar.TcpStat; +import org.hyperic.sigar.Tcp; public class TestTcpStat extends SigarTestCase { @@ -30,17 +30,15 @@ public class TestTcpStat extends SigarTestCase { public void testCreate() throws Exception { Sigar sigar = getSigar(); - TcpStat tcp; + Tcp tcp; try { - tcp = sigar.getTcpStat(); + tcp = sigar.getTcp(); } catch (SigarNotImplementedException e) { return; } traceln(""); - //assertGtZeroTrace("MaxConn", tcp.getMaxConn()); //XXX -1 on linux - traceln("MaxConn=" + tcp.getMaxConn()); assertGtEqZeroTrace("ActiveOpens", tcp.getActiveOpens()); assertGtEqZeroTrace("PassiveOpens", tcp.getPassiveOpens()); assertGtEqZeroTrace("AttemptFails", tcp.getAttemptFails()); diff --git a/include/sigar.h b/include/sigar.h index f46c8a8c..7104518b 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -697,11 +697,11 @@ typedef struct { sigar_uint64_t out_segs; sigar_uint64_t retrans_segs; sigar_uint64_t out_rsts; -} sigar_tcp_stat_t; +} sigar_tcp_t; SIGAR_DECLARE(int) -sigar_tcp_stat_get(sigar_t *sigar, - sigar_tcp_stat_t *tcpstat); +sigar_tcp_get(sigar_t *sigar, + sigar_tcp_t *tcp); typedef struct { sigar_uint64_t null; diff --git a/include/sigar_private.h b/include/sigar_private.h index 21fc6ecd..67227cea 100644 --- a/include/sigar_private.h +++ b/include/sigar_private.h @@ -276,7 +276,7 @@ int sigar_net_connection_list_grow(sigar_net_connection_list_t *connlist); SIGAR_ZERO(&ifconfig->hwaddr.addr.mac); \ ifconfig->hwaddr.family = SIGAR_AF_LINK -int sigar_tcp_stat_curr_estab(sigar_t *sigar, sigar_tcp_stat_t *tcpstat); +int sigar_tcp_curr_estab(sigar_t *sigar, sigar_tcp_t *tcp); int sigar_who_list_create(sigar_who_list_t *wholist); diff --git a/src/os/aix/aix_sigar.c b/src/os/aix/aix_sigar.c index aaa41ea9..c863670d 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -2264,8 +2264,8 @@ int sigar_net_connection_walk(sigar_net_connection_walker_t *walker) } SIGAR_DECLARE(int) -sigar_tcp_stat_get(sigar_t *sigar, - sigar_tcp_stat_t *tcpstat) +sigar_tcp_get(sigar_t *sigar, + sigar_tcp_t *tcp) { perfstat_id_t id; perfstat_protocol_t proto; @@ -2280,16 +2280,16 @@ sigar_tcp_stat_get(sigar_t *sigar, return ENOENT; } - tcpstat->active_opens = proto.u.tcp.initiated; - tcpstat->passive_opens = proto.u.tcp.accepted; - tcpstat->attempt_fails = proto.u.tcp.dropped; - tcpstat->estab_resets = proto.u.tcp.dropped; - tcpstat->curr_estab = proto.u.tcp.established; - tcpstat->in_segs = proto.u.tcp.ipackets; - tcpstat->out_segs = proto.u.tcp.opackets; - tcpstat->retrans_segs = 0; - /* tcpstat->inerrs = proto.u.tcp.ierrors; */ - tcpstat->out_rsts = 0; + tcp->active_opens = proto.u.tcp.initiated; + tcp->passive_opens = proto.u.tcp.accepted; + tcp->attempt_fails = proto.u.tcp.dropped; + tcp->estab_resets = proto.u.tcp.dropped; + tcp->curr_estab = proto.u.tcp.established; + tcp->in_segs = proto.u.tcp.ipackets; + tcp->out_segs = proto.u.tcp.opackets; + tcp->retrans_segs = 0; + /* tcp->inerrs = proto.u.tcp.ierrors; */ + tcp->out_rsts = 0; } #define NFS_V2_STAT_SET(type) \ diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index c3564915..4bcbd302 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -2212,8 +2212,8 @@ int sigar_net_connection_walk(sigar_net_connection_walker_t *walker) #endif SIGAR_DECLARE(int) -sigar_tcp_stat_get(sigar_t *sigar, - sigar_tcp_stat_t *tcpstat) +sigar_tcp_get(sigar_t *sigar, + sigar_tcp_t *tcp) { struct tcpstat mib; int var[4] = { CTL_NET, PF_INET, IPPROTO_TCP, TCPCTL_STATS }; @@ -2223,17 +2223,17 @@ sigar_tcp_stat_get(sigar_t *sigar, return errno; } - tcpstat->active_opens = mib.tcps_connattempt; - tcpstat->passive_opens = mib.tcps_accepts; - tcpstat->attempt_fails = mib.tcps_conndrops; - tcpstat->estab_resets = mib.tcps_drops; - if (sigar_tcp_stat_curr_estab(sigar, tcpstat) != SIGAR_OK) { - tcpstat->curr_estab = -1; + tcp->active_opens = mib.tcps_connattempt; + tcp->passive_opens = mib.tcps_accepts; + tcp->attempt_fails = mib.tcps_conndrops; + tcp->estab_resets = mib.tcps_drops; + if (sigar_tcp_curr_estab(sigar, tcp) != SIGAR_OK) { + tcp->curr_estab = -1; } - tcpstat->in_segs = mib.tcps_rcvtotal; - tcpstat->out_segs = mib.tcps_sndtotal - mib.tcps_sndrexmitpack; - tcpstat->retrans_segs = mib.tcps_sndrexmitpack; - tcpstat->out_rsts = mib.tcps_sndctrl - mib.tcps_closed; + tcp->in_segs = mib.tcps_rcvtotal; + tcp->out_segs = mib.tcps_sndtotal - mib.tcps_sndrexmitpack; + tcp->retrans_segs = mib.tcps_sndrexmitpack; + tcp->out_rsts = mib.tcps_sndctrl - mib.tcps_closed; return SIGAR_OK; } diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index 120940bf..750a0f07 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -1070,8 +1070,8 @@ static struct { }; SIGAR_DECLARE(int) -sigar_tcp_stat_get(sigar_t *sigar, - sigar_tcp_stat_t *tcpstat) +sigar_tcp_get(sigar_t *sigar, + sigar_tcp_t *tcp) { int i; @@ -1087,7 +1087,7 @@ sigar_tcp_stat_get(sigar_t *sigar, val = -1; } - *(sigar_uint64_t *)((char *)tcpstat + tcps_lu[i].offset) = val; + *(sigar_uint64_t *)((char *)tcp + tcps_lu[i].offset) = val; } return SIGAR_OK; diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 21874e62..e93a1293 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -2126,8 +2126,8 @@ static int sigar_net_connection_get(sigar_t *sigar, #define SNMP_TCP_PREFIX "Tcp: " SIGAR_DECLARE(int) -sigar_tcp_stat_get(sigar_t *sigar, - sigar_tcp_stat_t *tcpstat) +sigar_tcp_get(sigar_t *sigar, + sigar_tcp_t *tcp) { FILE *fp; char buffer[1024], *ptr=buffer; @@ -2152,16 +2152,16 @@ sigar_tcp_stat_get(sigar_t *sigar, /* assuming field order, same in 2.2, 2.4 and 2.6 kernels */ /* Tcp: RtoAlgorithm RtoMin RtoMax MaxConn */ ptr = sigar_skip_multiple_token(ptr, 5); - tcpstat->active_opens = sigar_strtoull(ptr); - tcpstat->passive_opens = sigar_strtoull(ptr); - tcpstat->attempt_fails = sigar_strtoull(ptr); - tcpstat->estab_resets = sigar_strtoull(ptr); - tcpstat->curr_estab = sigar_strtoull(ptr); - tcpstat->in_segs = sigar_strtoull(ptr); - tcpstat->out_segs = sigar_strtoull(ptr); - tcpstat->retrans_segs = sigar_strtoull(ptr); + tcp->active_opens = sigar_strtoull(ptr); + tcp->passive_opens = sigar_strtoull(ptr); + tcp->attempt_fails = sigar_strtoull(ptr); + tcp->estab_resets = sigar_strtoull(ptr); + tcp->curr_estab = sigar_strtoull(ptr); + tcp->in_segs = sigar_strtoull(ptr); + tcp->out_segs = sigar_strtoull(ptr); + tcp->retrans_segs = sigar_strtoull(ptr); (void)sigar_strtoull(ptr); /* InErrs */ - tcpstat->out_rsts = sigar_strtoull(ptr); + tcp->out_rsts = sigar_strtoull(ptr); } return status; diff --git a/src/os/osf1/osf1_sigar.c b/src/os/osf1/osf1_sigar.c index 6537c43c..4089a2bb 100644 --- a/src/os/osf1/osf1_sigar.c +++ b/src/os/osf1/osf1_sigar.c @@ -540,8 +540,8 @@ int sigar_net_connection_walk(sigar_net_connection_walker_t *walker) } SIGAR_DECLARE(int) -sigar_tcp_stat_get(sigar_t *sigar, - sigar_tcp_stat_t *tcpstat) +sigar_tcp_get(sigar_t *sigar, + sigar_tcp_t *tcp) { return SIGAR_ENOTIMPL; } diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 8eabeb86..e93652bc 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -2386,8 +2386,8 @@ int sigar_net_connection_walk(sigar_net_connection_walker_t *walker) } SIGAR_DECLARE(int) -sigar_tcp_stat_get(sigar_t *sigar, - sigar_tcp_stat_t *tcpstat) +sigar_tcp_get(sigar_t *sigar, + sigar_tcp_t *tcp) { char *data; int len; @@ -2403,15 +2403,15 @@ sigar_tcp_stat_get(sigar_t *sigar, } if (mib) { - tcpstat->active_opens = mib->tcpActiveOpens; - tcpstat->passive_opens = mib->tcpPassiveOpens; - tcpstat->attempt_fails = mib->tcpAttemptFails; - tcpstat->estab_resets = mib->tcpEstabResets; - tcpstat->curr_estab = mib->tcpCurrEstab; - tcpstat->in_segs = mib->tcpInSegs; - tcpstat->out_segs = mib->tcpOutSegs; - tcpstat->retrans_segs = mib->tcpRetransSegs; - tcpstat->out_rsts = mib->tcpOutRsts; + tcp->active_opens = mib->tcpActiveOpens; + tcp->passive_opens = mib->tcpPassiveOpens; + tcp->attempt_fails = mib->tcpAttemptFails; + tcp->estab_resets = mib->tcpEstabResets; + tcp->curr_estab = mib->tcpCurrEstab; + tcp->in_segs = mib->tcpInSegs; + tcp->out_segs = mib->tcpOutSegs; + tcp->retrans_segs = mib->tcpRetransSegs; + tcp->out_rsts = mib->tcpOutRsts; return SIGAR_OK; } else { diff --git a/src/os/stub/stub_sigar.c b/src/os/stub/stub_sigar.c index f953c51d..4b677a5b 100644 --- a/src/os/stub/stub_sigar.c +++ b/src/os/stub/stub_sigar.c @@ -254,8 +254,8 @@ int sigar_net_connection_walk(sigar_net_connection_walker_t *walker) } SIGAR_DECLARE(int) -sigar_tcp_stat_get(sigar_t *sigar, - sigar_tcp_stat_t *tcpstat) +sigar_tcp_get(sigar_t *sigar, + sigar_tcp_t *tcp) { return SIGAR_ENOTIMPL; } diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index f363ea35..c03c5c88 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -2786,8 +2786,8 @@ sigar_net_connection_walk(sigar_net_connection_walker_t *walker) sigar->iphlpapi.get_tcp_stats.func SIGAR_DECLARE(int) -sigar_tcp_stat_get(sigar_t *sigar, - sigar_tcp_stat_t *tcpstat) +sigar_tcp_get(sigar_t *sigar, + sigar_tcp_t *tcp) { MIB_TCPSTATS mib; int status; @@ -2804,15 +2804,15 @@ sigar_tcp_stat_get(sigar_t *sigar, return status; } - tcpstat->active_opens = mib.dwActiveOpens; - tcpstat->passive_opens = mib.dwPassiveOpens; - tcpstat->attempt_fails = mib.dwAttemptFails; - tcpstat->estab_resets = mib.dwEstabResets; - tcpstat->curr_estab = mib.dwCurrEstab; - tcpstat->in_segs = mib.dwInSegs; - tcpstat->out_segs = mib.dwOutSegs; - tcpstat->retrans_segs = mib.dwRetransSegs; - tcpstat->out_rsts = mib.dwOutRsts; + tcp->active_opens = mib.dwActiveOpens; + tcp->passive_opens = mib.dwPassiveOpens; + tcp->attempt_fails = mib.dwAttemptFails; + tcp->estab_resets = mib.dwEstabResets; + tcp->curr_estab = mib.dwCurrEstab; + tcp->in_segs = mib.dwInSegs; + tcp->out_segs = mib.dwOutSegs; + tcp->retrans_segs = mib.dwRetransSegs; + tcp->out_rsts = mib.dwOutRsts; return SIGAR_OK; } diff --git a/src/sigar.c b/src/sigar.c index b82d2e32..c1a2b708 100644 --- a/src/sigar.c +++ b/src/sigar.c @@ -876,23 +876,23 @@ static int tcp_curr_estab_count(sigar_net_connection_walker_t *walker, if ((conn->state == SIGAR_TCP_ESTABLISHED) || (conn->state == SIGAR_TCP_CLOSE_WAIT)) { - ((sigar_tcp_stat_t *)walker->data)->curr_estab++; + ((sigar_tcp_t *)walker->data)->curr_estab++; } return SIGAR_OK; } /* TCP-MIB::tcpCurrEstab */ -int sigar_tcp_stat_curr_estab(sigar_t *sigar, sigar_tcp_stat_t *tcpstat) +int sigar_tcp_curr_estab(sigar_t *sigar, sigar_tcp_t *tcp) { sigar_net_connection_walker_t walker; walker.sigar = sigar; - walker.data = tcpstat; + walker.data = tcp; walker.add_connection = tcp_curr_estab_count; walker.flags = SIGAR_NETCONN_CLIENT|SIGAR_NETCONN_TCP; - tcpstat->curr_estab = 0; + tcp->curr_estab = 0; return sigar_net_connection_walk(&walker); }