Added extra info in sig circuit status. Fixed status separators. Handle changes in monitoring module.
git-svn-id: http://yate.null.ro/svn/yate/trunk@4615 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
86cb8a3ca1
commit
0cfacb132b
|
@ -1882,6 +1882,7 @@ bool InterfaceInfo::load()
|
|||
nl->setParam(lookup(ALARMS_COUNT,s_ifacesInfo,""),"0");
|
||||
}
|
||||
TelEngine::destruct(list);
|
||||
TelEngine::destruct(parts);
|
||||
}
|
||||
updateExpire();
|
||||
return true;
|
||||
|
@ -1939,6 +1940,7 @@ bool LinkInfo::load()
|
|||
nl->setParam(lookup(UPTIME,s_linkInfo,""),"0");
|
||||
}
|
||||
TelEngine::destruct(list);
|
||||
TelEngine::destruct(parts);
|
||||
}
|
||||
updateExpire();
|
||||
return true;
|
||||
|
@ -1992,26 +1994,41 @@ NamedList* LinksetInfo::parseLinksetInfo(String& info,const String& link, NamedL
|
|||
cutNewLine(info);
|
||||
DDebug(&__plugin,DebugAll,"LinksetInfo::parseLinkInfo(info='%s',link='%s', infoFill='%p') [%p]",info.c_str(),link.c_str(),infoFill,this);
|
||||
NamedList* nl = (infoFill ? infoFill : new NamedList(link));
|
||||
ObjList* params = info.split(',',false);
|
||||
for (ObjList* o = params->skipNull(); o; o = o->skipNext()) {
|
||||
String* param = static_cast<String*>(o->get());
|
||||
int pos = param->find("=");
|
||||
if (pos < 0)
|
||||
|
||||
ObjList* parts = info.split(';',false);
|
||||
for (ObjList* obj = parts->skipNull(); obj; obj = obj->skipNext()) {
|
||||
String* infoPart = static_cast<String*>(obj->get());
|
||||
if (TelEngine::null(infoPart))
|
||||
continue;
|
||||
String nameParam = param->substr(0,pos);
|
||||
String valParam = param->substr(pos + 1);
|
||||
int type = lookup(nameParam,s_linksetStatus,0);
|
||||
if (type > 0)
|
||||
nl->setParam(lookup(type,s_linksetInfo,""),valParam);
|
||||
}
|
||||
String idQuery = lookup(ID,s_linksetInfo);
|
||||
String linksetId = nl->getValue(idQuery,"");
|
||||
if (linksetId.null()) {
|
||||
ObjList* params = infoPart->split(',',false);
|
||||
for (ObjList* o = params->skipNull(); o; o = o->skipNext()) {
|
||||
String* param = static_cast<String*>(o->get());
|
||||
int pos = param->find("=");
|
||||
if (pos < 0)
|
||||
continue;
|
||||
String nameParam = param->substr(0,pos);
|
||||
String valParam = param->substr(pos + 1);
|
||||
int type = lookup(nameParam,s_linksetStatus,0);
|
||||
if (type > 0) {
|
||||
if (type == TYPE && (valParam.null() || valParam != "ss7-mtp3")) {
|
||||
TelEngine::destruct(params);
|
||||
TelEngine::destruct(nl);
|
||||
TelEngine::destruct(parts);
|
||||
return 0;
|
||||
}
|
||||
nl->setParam(lookup(type,s_linksetInfo,""),valParam);
|
||||
}
|
||||
}
|
||||
TelEngine::destruct(params);
|
||||
}
|
||||
NamedString* linksetId = nl->getParam(lookup(ID,s_linksetInfo));
|
||||
NamedString* typeStr = nl->getParam(lookup(TYPE,s_linksetInfo));
|
||||
if (TelEngine::null(linksetId) || TelEngine::null(typeStr)) {
|
||||
TelEngine::destruct(parts);
|
||||
TelEngine::destruct(nl);
|
||||
return 0;
|
||||
}
|
||||
TelEngine::destruct(params);
|
||||
TelEngine::destruct(parts);
|
||||
if (!nl->getParam(lookup(ALARMS_COUNT,s_linksetInfo,"")))
|
||||
nl->setParam(lookup(ALARMS_COUNT,s_linksetInfo,""),"0");
|
||||
return nl;
|
||||
|
@ -2079,28 +2096,37 @@ NamedList* TrunkInfo::parseTrunkInfo(String& info, const String& trunk, NamedLis
|
|||
cutNewLine(info);
|
||||
DDebug(&__plugin,DebugAll,"TrunkInfo::parseTrunkInfo(info='%s',trunk='%s', infoFill='%p') [%p]",info.c_str(),trunk.c_str(),infoFill,this);
|
||||
NamedList* nl = (infoFill ? infoFill : new NamedList(trunk));
|
||||
ObjList* params = info.split(',',false);
|
||||
for (ObjList* o = params->skipNull(); o; o = o->skipNext()) {
|
||||
String* param = static_cast<String*>(o->get());
|
||||
int pos = param->find("=");
|
||||
if (pos < 0)
|
||||
continue;
|
||||
String nameParam = param->substr(0,pos);
|
||||
String valParam = param->substr(pos + 1);
|
||||
|
||||
int type = lookup(nameParam,s_trunkStatus,0);
|
||||
if (type > 0)
|
||||
nl->setParam(lookup(type,s_trunkInfo,""),valParam);
|
||||
ObjList* parts = info.split(';',false);
|
||||
for (ObjList* obj = parts->skipNull(); obj; obj = obj->skipNext()) {
|
||||
String* infoPart = static_cast<String*>(obj->get());
|
||||
if (TelEngine::null(infoPart))
|
||||
continue;
|
||||
ObjList* params = infoPart->split(',',false);
|
||||
for (ObjList* o = params->skipNull(); o; o = o->skipNext()) {
|
||||
String* param = static_cast<String*>(o->get());
|
||||
int pos = param->find("=");
|
||||
if (pos < 0) {
|
||||
TelEngine::destruct(params);
|
||||
continue;
|
||||
}
|
||||
String nameParam = param->substr(0,pos);
|
||||
String valParam = param->substr(pos + 1);
|
||||
|
||||
int type = lookup(nameParam,s_trunkStatus,0);
|
||||
if (type > 0)
|
||||
nl->setParam(lookup(type,s_trunkInfo,""),valParam);
|
||||
}
|
||||
TelEngine::destruct(params);
|
||||
}
|
||||
// check that it's indeed a trunk
|
||||
String idQuery = lookup(ID,s_trunkInfo);
|
||||
String trunkId = nl->getValue(idQuery,"");
|
||||
if (trunkId.null()) {
|
||||
TelEngine::destruct(params);
|
||||
NamedString* trunkId = nl->getParam(lookup(ID,s_trunkInfo));
|
||||
if (TelEngine::null(trunkId)) {
|
||||
TelEngine::destruct(parts);
|
||||
TelEngine::destruct(nl);
|
||||
return 0;
|
||||
}
|
||||
TelEngine::destruct(params);
|
||||
TelEngine::destruct(parts);
|
||||
if (!nl->getParam(lookup(ALARMS_COUNT,s_trunkInfo,"")))
|
||||
nl->setParam(lookup(ALARMS_COUNT,s_trunkInfo,""),"0");
|
||||
return nl;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <yatesig.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace TelEngine;
|
||||
namespace { // anonymous
|
||||
|
@ -233,7 +234,7 @@ private:
|
|||
// Create or initialize a trunk
|
||||
bool initTrunk(NamedList& sect, int type);
|
||||
// Get the status of a trunk
|
||||
void status(SigTrunk* trunk, String& retVal, const String& target);
|
||||
void status(SigTrunk* trunk, String& retVal, const String& target, bool details);
|
||||
// Append a topmost non-trunk component
|
||||
bool appendTopmost(SigTopmost* topmost);
|
||||
// Remove a topmost component without deleting it
|
||||
|
@ -2235,7 +2236,7 @@ bool SigDriver::received(Message& msg, int id)
|
|||
RefPointer<SigTrunk> trunk = findTrunk(trunkName,false);
|
||||
m_trunksMutex.unlock();
|
||||
if (trunk) {
|
||||
status(trunk,msg.retValue(),target);
|
||||
status(trunk,msg.retValue(),target,msg.getBoolValue(YSTRING("details"),true));
|
||||
return true;
|
||||
}
|
||||
m_topmostMutex.lock();
|
||||
|
@ -2258,40 +2259,93 @@ bool SigDriver::received(Message& msg, int id)
|
|||
return false;
|
||||
}
|
||||
|
||||
void SigDriver::status(SigTrunk* trunk, String& retVal, const String& target)
|
||||
// Utility used in status
|
||||
static void countCic(SignallingCircuit* cic, unsigned int& avail, unsigned int& resetting,
|
||||
unsigned int& locked)
|
||||
{
|
||||
if (!cic->locked(SignallingCircuit::LockLockedBusy))
|
||||
avail++;
|
||||
else {
|
||||
if (cic->locked(SignallingCircuit::Resetting))
|
||||
resetting++;
|
||||
if (cic->locked(SignallingCircuit::LockLocked))
|
||||
locked++;
|
||||
}
|
||||
}
|
||||
|
||||
void SigDriver::status(SigTrunk* trunk, String& retVal, const String& target, bool details)
|
||||
{
|
||||
bool all = target.null();
|
||||
String detail;
|
||||
String ctrlStatus = "Unknown";
|
||||
unsigned int circuits = 0;
|
||||
unsigned int calls = 0;
|
||||
unsigned int count = 0;
|
||||
int singleCic = false;
|
||||
unsigned int availableCics = 0;
|
||||
unsigned int resettingCics = 0;
|
||||
unsigned int lockedCics = 0;
|
||||
while (true) {
|
||||
SignallingCallControl* ctrl = trunk ? trunk->controller() : 0;
|
||||
if (!ctrl)
|
||||
break;
|
||||
Lock lckCtrl(ctrl);
|
||||
|
||||
if (ctrl->circuits())
|
||||
circuits = ctrl->circuits()->count();
|
||||
else
|
||||
ctrlStatus = ctrl->statusName();
|
||||
if (!ctrl->circuits()) {
|
||||
// Count now the number of calls. It should be 0 !!!
|
||||
calls = ctrl->calls().count();
|
||||
break;
|
||||
|
||||
}
|
||||
SignallingCircuitRange range(target,0);
|
||||
SignallingCircuitRange* rptr = ⦥
|
||||
if (target == "*" || target == "all")
|
||||
if (target == "*" || target == "all") {
|
||||
range.add(ctrl->circuits()->base(),ctrl->circuits()->last());
|
||||
all = true;
|
||||
}
|
||||
else if (range.count() == 0)
|
||||
rptr = ctrl->circuits()->findRange(target);
|
||||
else
|
||||
singleCic = (range.count() == 1) && (-1 != target.toInteger(-1));
|
||||
// Count calls, circuits and circuit status if complete status was requested
|
||||
if (all) {
|
||||
calls = ctrl->calls().count();
|
||||
ObjList* o = ctrl->circuits()->circuits().skipNull();
|
||||
for (; o; o = o->skipNext()) {
|
||||
circuits++;
|
||||
SignallingCircuit* cic = static_cast<SignallingCircuit*>(o->get());
|
||||
countCic(cic,availableCics,resettingCics,lockedCics);
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0; rptr && i < rptr->count(); i++) {
|
||||
SignallingCircuit* cic = ctrl->circuits()->find((*rptr)[i]);
|
||||
if (!cic)
|
||||
continue;
|
||||
count++;
|
||||
detail.append(String(cic->code()) + "=",",");
|
||||
if (cic->span())
|
||||
detail << cic->span()->id();
|
||||
detail << "|" << SignallingCircuit::lookupStatus(cic->status());
|
||||
detail << "|" << String::boolText(0 != cic->locked(SignallingCircuit::LockLocal));
|
||||
detail << "|" << String::boolText(0 != cic->locked(SignallingCircuit::LockRemote));
|
||||
detail << "|" << String::boolText(0 != cic->locked(SignallingCircuit::LockChanged|SignallingCircuit::Resetting));
|
||||
if (!singleCic) {
|
||||
if (!all)
|
||||
countCic(cic,availableCics,resettingCics,lockedCics);
|
||||
if (!details)
|
||||
continue;
|
||||
detail.append(String(cic->code()) + "=",",");
|
||||
if (cic->span())
|
||||
detail << cic->span()->id();
|
||||
detail << "|" << SignallingCircuit::lookupStatus(cic->status());
|
||||
detail << "|" << String::boolText(0 != cic->locked(SignallingCircuit::LockLocal));
|
||||
detail << "|" << String::boolText(0 != cic->locked(SignallingCircuit::LockRemote));
|
||||
detail << "|" << String::boolText(0 != cic->locked(SignallingCircuit::LockChanged|SignallingCircuit::Resetting));
|
||||
}
|
||||
else {
|
||||
detail.append("circuit=",",");
|
||||
detail << cic->code();
|
||||
detail << ",span=" << (cic->span() ? cic->span()->id() : String::empty());
|
||||
detail << ",status=" << SignallingCircuit::lookupStatus(cic->status());
|
||||
detail << ",lockedlocal=" << String::boolText(0 != cic->locked(SignallingCircuit::LockLocal));
|
||||
detail << ",lockedremote=" << String::boolText(0 != cic->locked(SignallingCircuit::LockRemote));
|
||||
detail << ",changing=" << String::boolText(0 != cic->locked(SignallingCircuit::LockChanged|SignallingCircuit::Resetting));
|
||||
char tmp[9];
|
||||
::sprintf(tmp,"%x",cic->locked(-1));
|
||||
detail << ",flags=0x" << tmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2300,14 +2354,23 @@ void SigDriver::status(SigTrunk* trunk, String& retVal, const String& target)
|
|||
retVal << "module=" << name();
|
||||
retVal << ",trunk=" << trunk->name();
|
||||
retVal << ",type=" << lookup(trunk->type(),SigTrunk::s_type);
|
||||
retVal << ",circuits=" << circuits;
|
||||
retVal << ",status=" << (trunk->controller() ? trunk->controller()->statusName() : "Unknown");
|
||||
retVal << ",calls=" << (trunk->controller() ? trunk->controller()->calls().count() : 0);
|
||||
if (!target.null()) {
|
||||
retVal << ";count=" << count;
|
||||
retVal << ",format=Span|Status|LockedLocal|LockedRemote|Changing";
|
||||
retVal << ";" << detail;
|
||||
if (!singleCic) {
|
||||
if (target)
|
||||
retVal << ",format=Span|Status|LockedLocal|LockedRemote|Changing";
|
||||
if (all) {
|
||||
retVal << ";circuits=" << circuits;
|
||||
retVal << ",status=" << ctrlStatus;
|
||||
retVal << ",calls=" << calls;
|
||||
}
|
||||
else
|
||||
retVal << ";status=" << ctrlStatus;
|
||||
retVal << ",available=" << availableCics;
|
||||
retVal << ",resetting=" << resettingCics;
|
||||
retVal << ",locked=" << lockedCics;
|
||||
if (target)
|
||||
retVal << ",count=" << count;
|
||||
}
|
||||
retVal.append(detail,";");
|
||||
retVal << "\r\n";
|
||||
}
|
||||
|
||||
|
@ -3100,7 +3163,7 @@ bool SigLinkSet::initialize(NamedList& params)
|
|||
void SigLinkSet::status(String& retVal)
|
||||
{
|
||||
retVal << "type=" << (m_linkset ? m_linkset->componentType() : "");
|
||||
retVal << ",status=" << (m_linkset && m_linkset->operational() ? "" : "non-") << "operational";
|
||||
retVal << ";status=" << (m_linkset && m_linkset->operational() ? "" : "non-") << "operational";
|
||||
}
|
||||
|
||||
void SigLinkSet::ifStatus(String& status)
|
||||
|
@ -3166,7 +3229,7 @@ void SigSS7Sccp::status(String& retVal)
|
|||
if (!m_sccp)
|
||||
return;
|
||||
retVal << "type=" << m_sccp->componentType();
|
||||
retVal << ",sent=" << m_sccp->messagesSend();
|
||||
retVal << ";sent=" << m_sccp->messagesSend();
|
||||
retVal << ",received=" << m_sccp->messagesReceived();
|
||||
retVal << ",translations=" << m_sccp->translations();
|
||||
retVal << ",errors=" << m_sccp->errors();
|
||||
|
@ -3987,7 +4050,7 @@ void SigSS7Tcap::status(String& retVal)
|
|||
retVal << "type=" << (m_tcap ? m_tcap->componentType() : "");
|
||||
NamedList p("");
|
||||
m_tcap->status(p);
|
||||
retVal << ",totalIncoming=" << p.getValue("totalIncoming","0");
|
||||
retVal << ";totalIncoming=" << p.getValue("totalIncoming","0");
|
||||
retVal << ",totalOutgoing=" << p.getValue("totalOutgoing","0");
|
||||
retVal << ",totalDiscarded=" << p.getValue("totalDiscarded","0");
|
||||
retVal << ",totalNormal=" << p.getValue("totalNormal","0");
|
||||
|
|
Loading…
Reference in New Issue