remove _stat from sigar_tcp names

This commit is contained in:
Doug MacEachern 2007-08-08 05:34:21 +00:00
parent 7e0b4af3ca
commit f8c583fbc8
16 changed files with 82 additions and 84 deletions

View File

@ -1022,7 +1022,7 @@ my %classes = (
name => 'all_outbound_total', type => 'Int', name => 'all_outbound_total', type => 'Int',
}, },
], ],
TcpStat => [ Tcp => [
{ {
name => 'active_opens', type => 'Long', name => 'active_opens', type => 'Long',
desc => '', desc => '',
@ -1366,7 +1366,7 @@ my %cmds = (
Solaris => '', Solaris => '',
Win32 => '', Win32 => '',
}, },
TcpStat => { Tcp => {
Linux => 'cat /proc/net/snmp', Linux => 'cat /proc/net/snmp',
Solaris => 'netstat -s -P tcp', Solaris => 'netstat -s -P tcp',
}, },

View File

@ -781,9 +781,9 @@ public class Sigar implements SigarProxy {
* TCP-MIB stats * TCP-MIB stats
* @exception SigarException on failure. * @exception SigarException on failure.
*/ */
public TcpStat getTcpStat() public Tcp getTcp()
throws SigarException { throws SigarException {
return TcpStat.fetch(this); return Tcp.fetch(this);
} }
public NfsClientV2 getNfsClientV2() public NfsClientV2 getNfsClientV2()

View File

@ -157,7 +157,7 @@ public interface SigarProxy {
public Who[] getWhoList() throws SigarException; public Who[] getWhoList() throws SigarException;
public TcpStat getTcpStat() throws SigarException; public Tcp getTcp() throws SigarException;
public NfsClientV2 getNfsClientV2() throws SigarException; public NfsClientV2 getNfsClientV2() throws SigarException;

View File

@ -26,7 +26,7 @@ import org.hyperic.sigar.NetServices;
import org.hyperic.sigar.SigarException; import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.NetConnection; import org.hyperic.sigar.NetConnection;
import org.hyperic.sigar.NetFlags; import org.hyperic.sigar.NetFlags;
import org.hyperic.sigar.TcpStat; import org.hyperic.sigar.Tcp;
/** /**
* Display network connections. * Display network connections.
@ -161,7 +161,7 @@ public class Netstat extends SigarCommandBase {
} }
private void outputTcpStats() throws SigarException { private void outputTcpStats() throws SigarException {
TcpStat stat = this.sigar.getTcpStat(); Tcp stat = this.sigar.getTcp();
final String dnt = " "; final String dnt = " ";
println(dnt + stat.getActiveOpens() + " active connections openings"); println(dnt + stat.getActiveOpens() + " active connections openings");
println(dnt + stat.getPassiveOpens() + " passive connection openings"); println(dnt + stat.getPassiveOpens() + " passive connection openings");

View File

@ -20,7 +20,7 @@ package org.hyperic.sigar.test;
import org.hyperic.sigar.Sigar; import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarNotImplementedException; import org.hyperic.sigar.SigarNotImplementedException;
import org.hyperic.sigar.TcpStat; import org.hyperic.sigar.Tcp;
public class TestTcpStat extends SigarTestCase { public class TestTcpStat extends SigarTestCase {
@ -30,17 +30,15 @@ public class TestTcpStat extends SigarTestCase {
public void testCreate() throws Exception { public void testCreate() throws Exception {
Sigar sigar = getSigar(); Sigar sigar = getSigar();
TcpStat tcp; Tcp tcp;
try { try {
tcp = sigar.getTcpStat(); tcp = sigar.getTcp();
} catch (SigarNotImplementedException e) { } catch (SigarNotImplementedException e) {
return; return;
} }
traceln(""); traceln("");
//assertGtZeroTrace("MaxConn", tcp.getMaxConn()); //XXX -1 on linux
traceln("MaxConn=" + tcp.getMaxConn());
assertGtEqZeroTrace("ActiveOpens", tcp.getActiveOpens()); assertGtEqZeroTrace("ActiveOpens", tcp.getActiveOpens());
assertGtEqZeroTrace("PassiveOpens", tcp.getPassiveOpens()); assertGtEqZeroTrace("PassiveOpens", tcp.getPassiveOpens());
assertGtEqZeroTrace("AttemptFails", tcp.getAttemptFails()); assertGtEqZeroTrace("AttemptFails", tcp.getAttemptFails());

View File

@ -697,11 +697,11 @@ typedef struct {
sigar_uint64_t out_segs; sigar_uint64_t out_segs;
sigar_uint64_t retrans_segs; sigar_uint64_t retrans_segs;
sigar_uint64_t out_rsts; sigar_uint64_t out_rsts;
} sigar_tcp_stat_t; } sigar_tcp_t;
SIGAR_DECLARE(int) SIGAR_DECLARE(int)
sigar_tcp_stat_get(sigar_t *sigar, sigar_tcp_get(sigar_t *sigar,
sigar_tcp_stat_t *tcpstat); sigar_tcp_t *tcp);
typedef struct { typedef struct {
sigar_uint64_t null; sigar_uint64_t null;

View File

@ -276,7 +276,7 @@ int sigar_net_connection_list_grow(sigar_net_connection_list_t *connlist);
SIGAR_ZERO(&ifconfig->hwaddr.addr.mac); \ SIGAR_ZERO(&ifconfig->hwaddr.addr.mac); \
ifconfig->hwaddr.family = SIGAR_AF_LINK 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); int sigar_who_list_create(sigar_who_list_t *wholist);

View File

@ -2264,8 +2264,8 @@ int sigar_net_connection_walk(sigar_net_connection_walker_t *walker)
} }
SIGAR_DECLARE(int) SIGAR_DECLARE(int)
sigar_tcp_stat_get(sigar_t *sigar, sigar_tcp_get(sigar_t *sigar,
sigar_tcp_stat_t *tcpstat) sigar_tcp_t *tcp)
{ {
perfstat_id_t id; perfstat_id_t id;
perfstat_protocol_t proto; perfstat_protocol_t proto;
@ -2280,16 +2280,16 @@ sigar_tcp_stat_get(sigar_t *sigar,
return ENOENT; return ENOENT;
} }
tcpstat->active_opens = proto.u.tcp.initiated; tcp->active_opens = proto.u.tcp.initiated;
tcpstat->passive_opens = proto.u.tcp.accepted; tcp->passive_opens = proto.u.tcp.accepted;
tcpstat->attempt_fails = proto.u.tcp.dropped; tcp->attempt_fails = proto.u.tcp.dropped;
tcpstat->estab_resets = proto.u.tcp.dropped; tcp->estab_resets = proto.u.tcp.dropped;
tcpstat->curr_estab = proto.u.tcp.established; tcp->curr_estab = proto.u.tcp.established;
tcpstat->in_segs = proto.u.tcp.ipackets; tcp->in_segs = proto.u.tcp.ipackets;
tcpstat->out_segs = proto.u.tcp.opackets; tcp->out_segs = proto.u.tcp.opackets;
tcpstat->retrans_segs = 0; tcp->retrans_segs = 0;
/* tcpstat->inerrs = proto.u.tcp.ierrors; */ /* tcp->inerrs = proto.u.tcp.ierrors; */
tcpstat->out_rsts = 0; tcp->out_rsts = 0;
} }
#define NFS_V2_STAT_SET(type) \ #define NFS_V2_STAT_SET(type) \

View File

@ -2212,8 +2212,8 @@ int sigar_net_connection_walk(sigar_net_connection_walker_t *walker)
#endif #endif
SIGAR_DECLARE(int) SIGAR_DECLARE(int)
sigar_tcp_stat_get(sigar_t *sigar, sigar_tcp_get(sigar_t *sigar,
sigar_tcp_stat_t *tcpstat) sigar_tcp_t *tcp)
{ {
struct tcpstat mib; struct tcpstat mib;
int var[4] = { CTL_NET, PF_INET, IPPROTO_TCP, TCPCTL_STATS }; int var[4] = { CTL_NET, PF_INET, IPPROTO_TCP, TCPCTL_STATS };
@ -2223,17 +2223,17 @@ sigar_tcp_stat_get(sigar_t *sigar,
return errno; return errno;
} }
tcpstat->active_opens = mib.tcps_connattempt; tcp->active_opens = mib.tcps_connattempt;
tcpstat->passive_opens = mib.tcps_accepts; tcp->passive_opens = mib.tcps_accepts;
tcpstat->attempt_fails = mib.tcps_conndrops; tcp->attempt_fails = mib.tcps_conndrops;
tcpstat->estab_resets = mib.tcps_drops; tcp->estab_resets = mib.tcps_drops;
if (sigar_tcp_stat_curr_estab(sigar, tcpstat) != SIGAR_OK) { if (sigar_tcp_curr_estab(sigar, tcp) != SIGAR_OK) {
tcpstat->curr_estab = -1; tcp->curr_estab = -1;
} }
tcpstat->in_segs = mib.tcps_rcvtotal; tcp->in_segs = mib.tcps_rcvtotal;
tcpstat->out_segs = mib.tcps_sndtotal - mib.tcps_sndrexmitpack; tcp->out_segs = mib.tcps_sndtotal - mib.tcps_sndrexmitpack;
tcpstat->retrans_segs = mib.tcps_sndrexmitpack; tcp->retrans_segs = mib.tcps_sndrexmitpack;
tcpstat->out_rsts = mib.tcps_sndctrl - mib.tcps_closed; tcp->out_rsts = mib.tcps_sndctrl - mib.tcps_closed;
return SIGAR_OK; return SIGAR_OK;
} }

View File

@ -1070,8 +1070,8 @@ static struct {
}; };
SIGAR_DECLARE(int) SIGAR_DECLARE(int)
sigar_tcp_stat_get(sigar_t *sigar, sigar_tcp_get(sigar_t *sigar,
sigar_tcp_stat_t *tcpstat) sigar_tcp_t *tcp)
{ {
int i; int i;
@ -1087,7 +1087,7 @@ sigar_tcp_stat_get(sigar_t *sigar,
val = -1; 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; return SIGAR_OK;

View File

@ -2126,8 +2126,8 @@ static int sigar_net_connection_get(sigar_t *sigar,
#define SNMP_TCP_PREFIX "Tcp: " #define SNMP_TCP_PREFIX "Tcp: "
SIGAR_DECLARE(int) SIGAR_DECLARE(int)
sigar_tcp_stat_get(sigar_t *sigar, sigar_tcp_get(sigar_t *sigar,
sigar_tcp_stat_t *tcpstat) sigar_tcp_t *tcp)
{ {
FILE *fp; FILE *fp;
char buffer[1024], *ptr=buffer; 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 */ /* assuming field order, same in 2.2, 2.4 and 2.6 kernels */
/* Tcp: RtoAlgorithm RtoMin RtoMax MaxConn */ /* Tcp: RtoAlgorithm RtoMin RtoMax MaxConn */
ptr = sigar_skip_multiple_token(ptr, 5); ptr = sigar_skip_multiple_token(ptr, 5);
tcpstat->active_opens = sigar_strtoull(ptr); tcp->active_opens = sigar_strtoull(ptr);
tcpstat->passive_opens = sigar_strtoull(ptr); tcp->passive_opens = sigar_strtoull(ptr);
tcpstat->attempt_fails = sigar_strtoull(ptr); tcp->attempt_fails = sigar_strtoull(ptr);
tcpstat->estab_resets = sigar_strtoull(ptr); tcp->estab_resets = sigar_strtoull(ptr);
tcpstat->curr_estab = sigar_strtoull(ptr); tcp->curr_estab = sigar_strtoull(ptr);
tcpstat->in_segs = sigar_strtoull(ptr); tcp->in_segs = sigar_strtoull(ptr);
tcpstat->out_segs = sigar_strtoull(ptr); tcp->out_segs = sigar_strtoull(ptr);
tcpstat->retrans_segs = sigar_strtoull(ptr); tcp->retrans_segs = sigar_strtoull(ptr);
(void)sigar_strtoull(ptr); /* InErrs */ (void)sigar_strtoull(ptr); /* InErrs */
tcpstat->out_rsts = sigar_strtoull(ptr); tcp->out_rsts = sigar_strtoull(ptr);
} }
return status; return status;

View File

@ -540,8 +540,8 @@ int sigar_net_connection_walk(sigar_net_connection_walker_t *walker)
} }
SIGAR_DECLARE(int) SIGAR_DECLARE(int)
sigar_tcp_stat_get(sigar_t *sigar, sigar_tcp_get(sigar_t *sigar,
sigar_tcp_stat_t *tcpstat) sigar_tcp_t *tcp)
{ {
return SIGAR_ENOTIMPL; return SIGAR_ENOTIMPL;
} }

View File

@ -2386,8 +2386,8 @@ int sigar_net_connection_walk(sigar_net_connection_walker_t *walker)
} }
SIGAR_DECLARE(int) SIGAR_DECLARE(int)
sigar_tcp_stat_get(sigar_t *sigar, sigar_tcp_get(sigar_t *sigar,
sigar_tcp_stat_t *tcpstat) sigar_tcp_t *tcp)
{ {
char *data; char *data;
int len; int len;
@ -2403,15 +2403,15 @@ sigar_tcp_stat_get(sigar_t *sigar,
} }
if (mib) { if (mib) {
tcpstat->active_opens = mib->tcpActiveOpens; tcp->active_opens = mib->tcpActiveOpens;
tcpstat->passive_opens = mib->tcpPassiveOpens; tcp->passive_opens = mib->tcpPassiveOpens;
tcpstat->attempt_fails = mib->tcpAttemptFails; tcp->attempt_fails = mib->tcpAttemptFails;
tcpstat->estab_resets = mib->tcpEstabResets; tcp->estab_resets = mib->tcpEstabResets;
tcpstat->curr_estab = mib->tcpCurrEstab; tcp->curr_estab = mib->tcpCurrEstab;
tcpstat->in_segs = mib->tcpInSegs; tcp->in_segs = mib->tcpInSegs;
tcpstat->out_segs = mib->tcpOutSegs; tcp->out_segs = mib->tcpOutSegs;
tcpstat->retrans_segs = mib->tcpRetransSegs; tcp->retrans_segs = mib->tcpRetransSegs;
tcpstat->out_rsts = mib->tcpOutRsts; tcp->out_rsts = mib->tcpOutRsts;
return SIGAR_OK; return SIGAR_OK;
} }
else { else {

View File

@ -254,8 +254,8 @@ int sigar_net_connection_walk(sigar_net_connection_walker_t *walker)
} }
SIGAR_DECLARE(int) SIGAR_DECLARE(int)
sigar_tcp_stat_get(sigar_t *sigar, sigar_tcp_get(sigar_t *sigar,
sigar_tcp_stat_t *tcpstat) sigar_tcp_t *tcp)
{ {
return SIGAR_ENOTIMPL; return SIGAR_ENOTIMPL;
} }

View File

@ -2786,8 +2786,8 @@ sigar_net_connection_walk(sigar_net_connection_walker_t *walker)
sigar->iphlpapi.get_tcp_stats.func sigar->iphlpapi.get_tcp_stats.func
SIGAR_DECLARE(int) SIGAR_DECLARE(int)
sigar_tcp_stat_get(sigar_t *sigar, sigar_tcp_get(sigar_t *sigar,
sigar_tcp_stat_t *tcpstat) sigar_tcp_t *tcp)
{ {
MIB_TCPSTATS mib; MIB_TCPSTATS mib;
int status; int status;
@ -2804,15 +2804,15 @@ sigar_tcp_stat_get(sigar_t *sigar,
return status; return status;
} }
tcpstat->active_opens = mib.dwActiveOpens; tcp->active_opens = mib.dwActiveOpens;
tcpstat->passive_opens = mib.dwPassiveOpens; tcp->passive_opens = mib.dwPassiveOpens;
tcpstat->attempt_fails = mib.dwAttemptFails; tcp->attempt_fails = mib.dwAttemptFails;
tcpstat->estab_resets = mib.dwEstabResets; tcp->estab_resets = mib.dwEstabResets;
tcpstat->curr_estab = mib.dwCurrEstab; tcp->curr_estab = mib.dwCurrEstab;
tcpstat->in_segs = mib.dwInSegs; tcp->in_segs = mib.dwInSegs;
tcpstat->out_segs = mib.dwOutSegs; tcp->out_segs = mib.dwOutSegs;
tcpstat->retrans_segs = mib.dwRetransSegs; tcp->retrans_segs = mib.dwRetransSegs;
tcpstat->out_rsts = mib.dwOutRsts; tcp->out_rsts = mib.dwOutRsts;
return SIGAR_OK; return SIGAR_OK;
} }

View File

@ -876,23 +876,23 @@ static int tcp_curr_estab_count(sigar_net_connection_walker_t *walker,
if ((conn->state == SIGAR_TCP_ESTABLISHED) || if ((conn->state == SIGAR_TCP_ESTABLISHED) ||
(conn->state == SIGAR_TCP_CLOSE_WAIT)) (conn->state == SIGAR_TCP_CLOSE_WAIT))
{ {
((sigar_tcp_stat_t *)walker->data)->curr_estab++; ((sigar_tcp_t *)walker->data)->curr_estab++;
} }
return SIGAR_OK; return SIGAR_OK;
} }
/* TCP-MIB::tcpCurrEstab */ /* 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; sigar_net_connection_walker_t walker;
walker.sigar = sigar; walker.sigar = sigar;
walker.data = tcpstat; walker.data = tcp;
walker.add_connection = tcp_curr_estab_count; walker.add_connection = tcp_curr_estab_count;
walker.flags = SIGAR_NETCONN_CLIENT|SIGAR_NETCONN_TCP; walker.flags = SIGAR_NETCONN_CLIENT|SIGAR_NETCONN_TCP;
tcpstat->curr_estab = 0; tcp->curr_estab = 0;
return sigar_net_connection_walk(&walker); return sigar_net_connection_walk(&walker);
} }