stream->write_function(stream, "PingState\t%d/%d/%d\n", gp->ping_min, gp->ping_count, gp->ping_max);
stream->write_function(stream, "State \t%s\n", sofia_state_names[gp->state]);
stream->write_function(stream, "Status \t%s%s\n", status_names[gp->status], gp->pinging ? " (ping)" : "");
+ stream->write_function(stream, "Uptime \t%ld\n", gp->status == SOFIA_GATEWAY_UP ? switch_time_now()-gp->uptime : 0);
stream->write_function(stream, "CallsIN \t%u\n", gp->ib_calls);
stream->write_function(stream, "CallsOUT\t%u\n", gp->ob_calls);
stream->write_function(stream, "FailedCallsIN\t%u\n", gp->ib_failed_calls);
stream->write_function(stream, " <pinging>%d</pinging>\n", gp->pinging);
stream->write_function(stream, " <state>%s</state>\n", sofia_state_names[gp->state]);
stream->write_function(stream, " <status>%s</status>\n", status_names[gp->status]);
+ stream->write_function(stream, " <uptime>%ld</uptime>\n", gp->status == SOFIA_GATEWAY_UP ? switch_time_now()-gp->uptime : 0);
stream->write_function(stream, " <calls-in>%u</calls-in>\n", gp->ib_calls);
stream->write_function(stream, " <calls-out>%u</calls-out>\n", gp->ob_calls);
stream->write_function(stream, " <failed-calls-in>%u</failed-calls-in>\n", gp->ib_failed_calls);
if (!switch_true(register_str)) {
gateway->state = REG_STATE_NOREG;
gateway->status = SOFIA_GATEWAY_UP;
+ gateway->uptime = switch_time_now();
}
if (zstr(auth_username)) {
if (gateway->ping_count >= gateway->ping_min && gateway->status != SOFIA_GATEWAY_UP) {
gateway->status = SOFIA_GATEWAY_UP;
+ gateway->uptime = switch_time_now();
sofia_reg_fire_custom_gateway_state_event(gateway, status, phrase);
}
switch (ostate) {
case REG_STATE_NOREG:
- if (!gateway_ptr->ping && !gateway_ptr->pinging) {
+ if (!gateway_ptr->ping && !gateway_ptr->pinging && gateway_ptr->status != SOFIA_GATEWAY_UP) {
gateway_ptr->status = SOFIA_GATEWAY_UP;
+ gateway_ptr->uptime = switch_time_now();
}
break;
case REG_STATE_REGISTER:
gateway_ptr->expires = now + delta;
gateway_ptr->state = REG_STATE_REGED;
- gateway_ptr->status = SOFIA_GATEWAY_UP;
+ if (gateway_ptr->status != SOFIA_GATEWAY_UP) {
+ gateway_ptr->status = SOFIA_GATEWAY_UP;
+ gateway_ptr->uptime = switch_time_now();
+ }
break;
case REG_STATE_UNREGISTER: