Added session idle time and user name the client is connecting with to the dprintSession and dprintAllSessions functions. Also changed last_read from time_t to unsigned long to match the hkheartbeat.

This commit is contained in:
Markus Makela 2015-03-13 08:49:34 +02:00
parent a7ae856de2
commit 5fb9353b47
2 changed files with 17 additions and 3 deletions

View File

@ -608,14 +608,21 @@ SESSION *ptr;
ptr = allSessions;
while (ptr)
{
double idle = (hkheartbeat - ptr->client->last_read);
idle = idle > 0 ? idle/10.0:0;
dcb_printf(dcb, "Session %d (%p)\n",ptr->ses_id, ptr);
dcb_printf(dcb, "\tState: %s\n", session_state(ptr->state));
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client);
if (ptr->client && ptr->client->remote)
dcb_printf(dcb, "\tClient Address: %s\n", ptr->client->remote);
dcb_printf(dcb, "\tClient Address: %s%s%s\n",
ptr->client->user?ptr->client->user:"",
ptr->client->user?"@":"",
ptr->client->remote);
dcb_printf(dcb, "\tConnected: %s",
asctime_r(localtime_r(&ptr->stats.connect, &result), timebuf));
if(ptr->client->state == DCB_STATE_POLLING)
dcb_printf(dcb, "\tIdle: %.0f seconds\n",idle);
ptr = ptr->next;
}
spinlock_release(&session_spin);
@ -637,14 +644,21 @@ struct tm result;
char buf[30];
int i;
double idle = (hkheartbeat - ptr->client->last_read);
idle = idle > 0 ? idle/10.f:0;
dcb_printf(dcb, "Session %d (%p)\n",ptr->ses_id, ptr);
dcb_printf(dcb, "\tState: %s\n", session_state(ptr->state));
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client);
if (ptr->client && ptr->client->remote)
dcb_printf(dcb, "\tClient Address: %s\n", ptr->client->remote);
dcb_printf(dcb, "\tClient Address: %s%s%s\n",
ptr->client->user?ptr->client->user:"",
ptr->client->user?"@":"",
ptr->client->remote);
dcb_printf(dcb, "\tConnected: %s",
asctime_r(localtime_r(&ptr->stats.connect, &result), buf));
if(ptr->client->state == DCB_STATE_POLLING)
dcb_printf(dcb, "\tIdle: %.0f seconds",idle);
if (ptr->n_filters)
{
for (i = 0; i < ptr->n_filters; i++)

View File

@ -261,7 +261,7 @@ typedef struct dcb {
SPINLOCK polloutlock;
int polloutbusy;
int writecheck;
time_t last_read; /*< Last time the DCB received data */
unsigned long last_read; /*< Last time the DCB received data */
unsigned int high_water; /**< High water mark */
unsigned int low_water; /**< Low water mark */
struct server *server; /**< The associated backend server */