void AMySQLServer::emit(AXmlElement& target) const { if (target.useName().isEmpty()) target.useName().assign("AMySQLServer", 12); ADatabase::emitXml(target); target.addElement(ASW("client",6)).addData(mysql_get_client_info()); if (mp_mydata) { target.addElement(ASW("stat",4)).addData(mysql_stat(mp_mydata)); target.addElement(ASW("server",6)).addData(mysql_get_server_info(mp_mydata)); target.addElement(ASW("host",4)).addData(mysql_get_host_info(mp_mydata)); } }
void AOSContextManager::adminEmitXml(AXmlElement& eBase, const AHTTPRequestHeader& request) { AOSAdminInterface::adminEmitXml(eBase, request); //a_Check if specific context is required AString contextId; if (request.getUrl().getParameterPairs().get(ASW("contextId",9), contextId)) { //a_Find the specific context { ALock lock(m_InUseSync); for (CONTEXT_INUSE::const_iterator cit = m_InUse.begin(); cit != m_InUse.end(); ++cit) { if (contextId == AString::fromPointer(*cit)) { adminAddProperty(eBase, ASW("contextDetail",7), *(*cit), AXmlElement::ENC_CDATADIRECT); return; } } } { ALock lock(m_ErrorHistory.useSync()); for (ABase *p = m_ErrorHistory.useTail(); p; p = p->usePrev()) { AOSContext *pContext = dynamic_cast<AOSContext *>(p); if (contextId == AString::fromPointer(pContext)) { adminAddProperty(eBase, ASW("contextDetail",7), *pContext, AXmlElement::ENC_CDATADIRECT); return; } } } { ALock lock(m_History.useSync()); for (ABase *p = m_History.useTail(); p; p = p->usePrev()) { AOSContext *pContext = dynamic_cast<AOSContext *>(p); if (contextId == AString::fromPointer(pContext)) { adminAddProperty(eBase, ASW("contextDetail",7), *pContext, AXmlElement::ENC_CDATADIRECT); return; } } } //a_Context no longer available adminAddError(eBase, ASWNL("AOSContext no longer available")); } else { //a_Display context summary for (size_t i=0; i < m_Queues.size(); ++i) { AOSContextQueueInterface *pQueue = m_Queues.at(i); if (pQueue) adminAddProperty(eBase, AString::fromSize_t(i), pQueue->getClass()); else adminAddProperty(eBase, AString::fromSize_t(i), AConstant::ASTRING_NULL); } adminAddPropertyWithAction( eBase, ASW("log_level",9), AString::fromInt(m_DefaultEventLogLevel), ASW("Update",6), ASWNL("Maximum event to log 0:Disabled 1:Error, 2:Event, 3:Warning, 4:Info, 5:Debug"), ASW("Set",3) ); { AString str; str.assign('['); str.append(AString::fromSize_t(m_History.size())); str.append('/'); str.append(AString::fromSize_t(m_HistoryMaxSize)); str.append(']'); AXmlElement& eHistory = eBase.addElement("object").addAttribute("name", "history"); adminAddPropertyWithAction(eHistory, ASWNL("max_size"), str, ASW("Set",3), ASWNL("Set maximum AOSContext history size (objects not immediately deleted)"), ASW("Set",3)); } adminAddPropertyWithAction( eBase, ASW("clear_history",13), AConstant::ASTRING_EMPTY, ASW("Clear",5), ASWNL("Clear context history: 0:all 1:history 2:error history"), ASW("Clear",5) ); { AString str; str.assign('['); str.append(AString::fromSize_t(m_ErrorHistory.size())); str.append('/'); str.append(AString::fromSize_t(m_ErrorHistoryMaxSize)); str.append(']'); AXmlElement& eErrorHistory = eBase.addElement("object").addAttribute("name", "error_history"); adminAddPropertyWithAction(eErrorHistory, ASWNL("max_size"), str, ASW("Set",3), ASWNL("Set maximum AOSContext error history size (objects not immediately deleted)"), ASW("Set",3)); } { AString str; str.assign('['); str.append(AString::fromSize_t(m_FreeStore.size())); str.append('/'); str.append(AString::fromSize_t(m_FreeStoreMaxSize)); str.append(']'); AXmlElement& eFreestore = eBase.addElement("object").addAttribute("name", "freestore"); adminAddPropertyWithAction(eFreestore, ASWNL("max_size"), str, ASW("Set",3), ASWNL("Set maximum AOSContext freestore size (objects not immediately deleted)"), ASW("Set",3)); } AXmlElement& eInUse = eBase.addElement("object"); eInUse.addAttribute("name", "InUse"); eInUse.addAttribute("size", AString::fromSize_t(m_InUse.size())); CONTEXT_INUSE::const_iterator citU = m_InUse.begin(); if (citU != m_InUse.end()) { ALock lock(m_InUseSync); while(citU != m_InUse.end()) { AXmlElement& eProp = adminAddProperty(eInUse, ASW("context",7), (*citU)->useEventVisitor(), AXmlElement::ENC_CDATADIRECT); eProp.addAttribute(ASW("errors",6), AString::fromSize_t((*citU)->useEventVisitor().getErrorCount())); eProp.addElement(ASW("url",3)).addData((*citU)->useEventVisitor().useName(), AXmlElement::ENC_CDATADIRECT); eProp.addElement(ASW("contextId",9)).addData(AString::fromPointer(*citU), AXmlElement::ENC_CDATADIRECT); ++citU; } } { AXmlElement& eHistory = eBase.addElement("object").addAttribute("name", "history"); ALock lock(m_History.useSync()); for (ABase *p = m_History.useTail(); p; p = p->usePrev()) { AOSContext *pContext = dynamic_cast<AOSContext *>(p); if (pContext) { AXmlElement& eProp = adminAddProperty(eHistory, ASW("context",7), pContext->useEventVisitor(), AXmlElement::ENC_CDATADIRECT); eProp.addAttribute(ASW("errors",6), AString::fromSize_t(pContext->useEventVisitor().getErrorCount())); eProp.addElement(ASW("url",3), pContext->useEventVisitor().useName(), AXmlElement::ENC_CDATADIRECT); eProp.addElement(ASW("contextId",3)).addData(AString::fromPointer(pContext), AXmlElement::ENC_CDATADIRECT); } else ATHROW(this, AException::InvalidObject); } } { AXmlElement& eErrorHistory = eBase.addElement("object").addAttribute("name", "error_history"); ALock lock(m_ErrorHistory.useSync()); for (ABase *p = m_ErrorHistory.useTail(); p; p = p->usePrev()) { AOSContext *pContext = dynamic_cast<AOSContext *>(p); if (pContext) { AXmlElement& eProp = adminAddProperty(eErrorHistory, ASW("context",7), pContext->useEventVisitor(), AXmlElement::ENC_CDATADIRECT); eProp.addAttribute(ASW("errors",6), AString::fromSize_t(pContext->useEventVisitor().getErrorCount())); eProp.addElement(ASW("url",3), pContext->useEventVisitor().useName(), AXmlElement::ENC_CDATADIRECT); eProp.addElement(ASW("contextId",3)).addData(AString::fromPointer(pContext), AXmlElement::ENC_CDATADIRECT); } else ATHROW(this, AException::InvalidObject); } } } }