Author: mladen.turk(a)jboss.com
Date: 2007-09-10 05:43:56 -0400 (Mon, 10 Sep 2007)
New Revision: 1010
Modified:
trunk/sight/native/os/linux/common.c
trunk/sight/native/os/linux/tcpstat.c
trunk/sight/native/os/linux/udpstat.c
Log:
Figure out the pid of the sockets
Modified: trunk/sight/native/os/linux/common.c
===================================================================
--- trunk/sight/native/os/linux/common.c 2007-09-10 08:13:56 UTC (rev 1009)
+++ trunk/sight/native/os/linux/common.c 2007-09-10 09:43:56 UTC (rev 1010)
@@ -70,6 +70,8 @@
continue;
while (!readdir_r(fd, &fbuf, &fent)) {
char fname[64];
+ if (!fent)
+ break;
if (!apr_isdigit(*fent->d_name)) {
/* Skip non numeric files */
continue;
Modified: trunk/sight/native/os/linux/tcpstat.c
===================================================================
--- trunk/sight/native/os/linux/tcpstat.c 2007-09-10 08:13:56 UTC (rev 1009)
+++ trunk/sight/native/os/linux/tcpstat.c 2007-09-10 09:43:56 UTC (rev 1010)
@@ -32,6 +32,8 @@
#define SIGHT_WANT_LATE_DLL
#include "sight_private.h"
+extern int sight_stat_by_inode(ino_t, uid_t, struct stat *, pid_t *);
+
/*
* TCP statistics implementation
*/
@@ -330,8 +332,8 @@
unsigned long rxq, txq, timelen, retr, inode;
int num, d, uid, timer_run, timeout;
char more[512];
+ struct stat sb;
-
tcpconn_enum_t *e = J2P(handle, tcpconn_enum_t *);
if (!e || !e->tnet)
@@ -388,9 +390,11 @@
/* TODO: See what's the actual value of timelen */
tmo = timelen;
sight_tcpconn_set_tmo(_E, conn, tmo);
- /* TODO: Search for create timestamp and pid by browsing
- * the /proc/pid/fd for matching inode
- */
+ if (!sight_stat_by_inode(inode, uid, &sb, &pid)) {
+ apr_time_t ctime;
+ apr_time_ansi_put(&ctime, sb.st_ctime);
+ sight_tcpconn_set_cts(_E, conn, apr_time_as_msec(ctime));
+ }
sight_tcpconn_set_pid(_E, conn, pid);
sight_tcpconn_set_state(_E, conn, tcp2sstate[state & 0xFF]);
Modified: trunk/sight/native/os/linux/udpstat.c
===================================================================
--- trunk/sight/native/os/linux/udpstat.c 2007-09-10 08:13:56 UTC (rev 1009)
+++ trunk/sight/native/os/linux/udpstat.c 2007-09-10 09:43:56 UTC (rev 1010)
@@ -32,6 +32,8 @@
#define SIGHT_WANT_LATE_DLL
#include "sight_private.h"
+extern int sight_stat_by_inode(ino_t, uid_t, struct stat *, pid_t *);
+
/*
* UDP statistics implementation
*/
@@ -237,6 +239,7 @@
int num, d, uid, timer_run, timeout;
char more[512];
int laddr = 0;
+ struct stat sb;
udpconn_enum_t *e = J2P(handle, udpconn_enum_t *);
@@ -300,9 +303,11 @@
/* TODO: See what's the actual value of timelen */
tmo = timelen;
sight_udpconn_set_tmo(_E, conn, tmo);
- /* TODO: Search for create timestamp and pid by browsing
- * the /proc/pid/fd for matching inode
- */
+ if (!sight_stat_by_inode(inode, uid, &sb, &pid)) {
+ apr_time_t ctime;
+ apr_time_ansi_put(&ctime, sb.st_ctime);
+ sight_udpconn_set_cts(_E, conn, apr_time_as_msec(ctime));
+ }
sight_udpconn_set_pid(_E, conn, pid);
switch (state) {