WsELKService.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "WsELKService.hpp"
  2. Cws_elkEx::Cws_elkEx()
  3. {
  4. }
  5. Cws_elkEx::~Cws_elkEx()
  6. {
  7. }
  8. void Cws_elkEx::init(IPropertyTree *cfg, const char *process, const char *service)
  9. {
  10. if(cfg == nullptr)
  11. throw MakeStringException(-1, "Cannot initialize Cws_elkEx, cfg is NULL");
  12. StringBuffer xpath;
  13. xpath.appendf("Software/EspProcess[@name=\"%s\"]/EspService[@name=\"%s\"]", process, service);
  14. m_serviceCfg.setown(cfg->getPropTree(xpath.str()));
  15. #ifdef _DEBUG
  16. StringBuffer thexml;
  17. toXML(m_serviceCfg, thexml,0,0);
  18. DBGLOG("^^^^^^%s", thexml.str());
  19. #endif
  20. }
  21. bool Cws_elkEx::onGetConfigDetails(IEspContext &context, IEspGetConfigDetailsRequest &req, IEspGetConfigDetailsResponse &resp)
  22. {
  23. if (m_serviceCfg)
  24. {
  25. StringBuffer kibanacfgentry;
  26. m_serviceCfg->getProp("ELKIntegration/Kibana/@integrateKibana", kibanacfgentry);
  27. resp.setIntegrateKibana(kibanacfgentry.str());
  28. m_serviceCfg->getProp("ELKIntegration/Kibana/@kibanaAddress", kibanacfgentry.clear());
  29. resp.setKibanaAddress(kibanacfgentry.str());
  30. m_serviceCfg->getProp("ELKIntegration/Kibana/@kibanaPort", kibanacfgentry.clear());
  31. resp.setKibanaPort(kibanacfgentry.str());
  32. m_serviceCfg->getProp("ELKIntegration/Kibana/@kibanaEntryPointURI", kibanacfgentry.clear());
  33. resp.setKibanaEntryPointURI(kibanacfgentry.str());
  34. m_serviceCfg->getProp("ELKIntegration/ElasticSearch/@reportElasticHealth", kibanacfgentry.clear());
  35. resp.setReportElasticSearchHealth(kibanacfgentry.str());
  36. m_serviceCfg->getProp("ELKIntegration/ElasticSearch/@elasticSearchAddresses", kibanacfgentry.clear());
  37. resp.setElasticSearchAddresses(kibanacfgentry.str());
  38. m_serviceCfg->getProp("ELKIntegration/ElasticSearch/@elasticSearchPort", kibanacfgentry.clear());
  39. resp.setElasticSearchPort(kibanacfgentry.str());
  40. m_serviceCfg->getProp("ELKIntegration/LogStash/@reportLogStashHealth", kibanacfgentry.clear());
  41. resp.setReportLogStashHealth(kibanacfgentry.str());
  42. m_serviceCfg->getProp("ELKIntegration/LogStash/@logStashAddresses", kibanacfgentry.clear());
  43. resp.setLogStashAddress(kibanacfgentry.str());
  44. m_serviceCfg->getProp("ELKIntegration/LogStash/@logStashPort", kibanacfgentry.clear());
  45. resp.setLogStashPort(kibanacfgentry.str());
  46. return true;
  47. }
  48. return false;
  49. }