当前位置: 首页>>代码示例>>C++>>正文


C++ NodeData::GetBody方法代码示例

本文整理汇总了C++中NodeData::GetBody方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeData::GetBody方法的具体用法?C++ NodeData::GetBody怎么用?C++ NodeData::GetBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeData的用法示例。


在下文中一共展示了NodeData::GetBody方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

bool NodeToVnfmEvent::
unknown(NodeData & a_rNodeData, DashBoard & a_board)
{
    gLog->WARNING("unknown");
    gLog->WARNING("%-24s| unknown - [%d] [%s]",
        "NodeToVnfmEvent",
        a_rNodeData.GetCommand(),
        a_rNodeData.GetBody().c_str());
    return true;
}
开发者ID:Ntels-sup,项目名称:SRC_ATOM_BE,代码行数:10,代码来源:NodeToVnfmEvent.cpp

示例2: atoi

bool NodeToVnfmEvent::
perfTps(NodeData & a_rNodeData, DashBoard & a_board)
{
    m_sHttpData.Clear();

    gLog->DEBUG("%-24s| perf tps",
        "NodeToVnfmEvent");

    // vector 로 전달 된다고 합시다.
    // timestamp, Tps_Title, Tps_Cnt
    // Tps_Name 으로 된 값에 Sum 을 해서 보내야 하나요??
    // 받아서 Board 에 Sum 만 하면 되요..
    std::string     timestamp;
    std::string     tpsTitle;
    int             cnt;

    std::string &   apiMsg = a_rNodeData.GetBody();

    size_t  first   = 0;
    size_t  end     = apiMsg.find('\0', first);

    try
    {
        timestamp       = apiMsg.substr(first).c_str();

        first   = end + 1;
        end     = apiMsg.find('\0', first);
        tpsTitle= apiMsg.substr(first).c_str();

        first   = end + 1;
        end     = apiMsg.find('\0', first);
        cnt     = atoi(apiMsg.substr(first).c_str());

    } catch(std::exception & e) {

        gLog->WARNING("%-24s| perfTps - pasing fail",
            "NodeToVnfmEvent");
        return false;
    }

    a_board.SetTPS(timestamp, tpsTitle,     cnt);

    gLog->DEBUG("---- TPS : [%s] [%d]", tpsTitle.c_str(), cnt);

    return true;
}
开发者ID:Ntels-sup,项目名称:SRC_ATOM_BE,代码行数:46,代码来源:NodeToVnfmEvent.cpp

示例3: atoll

bool NodeToVnfmEvent::
perf(NodeData & a_rNodeData, DashBoard & a_board)
{
    m_sHttpData.Clear();

    gLog->DEBUG("%-24s| perf",
        "NodeToVnfmEvent");

    std::string  &  body = a_rNodeData.GetBody();

    if(body.size() <= 0)
    {
        gLog->WARNING("%-24s| perf - no body",
            "NodeToVnfmEvent");

        return false;
    }

    gLog->DEBUG("%-24s| perf - [%s]",
        "NodeToVnfmEvent",
        body.c_str());

    try
    {
        rabbit::document    doc;
        doc.parse(body);


        // 1) CPU
        rabbit::array       cpu_list = doc["BODY"]["RSC_GRP_04"]["LIST"];

        std::string         key =
            (cpu_list.at(0)).as_string();
        std::string         cpu_usage =
            doc["BODY"]["RSC_GRP_04"][key.c_str()]["usage"].as_string();

        a_board.SetCPU(cpu_usage);


        // 2) MEM
        rabbit::array       mem_list = doc["BODY"]["RSC_GRP_02"]["LIST"];
        key =
            (mem_list.at(0)).as_string();
        std::string         mem_usage =
            doc["BODY"]["RSC_GRP_02"][key.c_str()]["usage"].as_string();

        a_board.SetMEM(mem_usage);


        // 4) NET
        std::string     net_rx;
        std::string     net_tx;
        rabbit::array   net_list = doc["BODY"]["RSC_GRP_11"]["LIST"];
        for(auto nLoop = 0u; nLoop < net_list.size(); ++nLoop)
        {
            key        = net_list.at(nLoop).as_string();
            net_rx     = doc["BODY"]["RSC_GRP_11"][key.c_str()]["RX"].as_string();
            net_tx     = doc["BODY"]["RSC_GRP_11"][key.c_str()]["TX"].as_string();

            a_board.SetNET(key, net_rx, net_tx);
        }

        // 5) TIME
        std::string timestamp   = doc["BODY"]["time"].as_string();
        std::string dst_yn      = doc["BODY"]["dst_yn"].as_string();

        a_board.SetTIME(timestamp, dst_yn);


        // 3) DISK
        unsigned long long  disk_total = 0;
        unsigned long long  disk_used  = 0;

        rabbit::array       disk_list = doc["BODY"]["RSC_GRP_05"]["LIST"];
        for(auto nLoop = 0u; nLoop < disk_list.size(); ++nLoop)
        {
            key        = disk_list.at(nLoop).as_string();
            disk_total += atoll(doc["BODY"]["RSC_GRP_05"][key.c_str()]["total"].as_string().c_str());
            disk_used  += atoll(doc["BODY"]["RSC_GRP_05"][key.c_str()]["used"].as_string().c_str());
        }

        unsigned long long disk_used_percent = 0;

        if(disk_total == 0)
            disk_used_percent = 0;
        else
            disk_used_percent = (disk_used / disk_total) * 100;

        key = "total";
        std::string disk_usage = std::to_string(disk_used_percent);
        a_board.SetDISK(key, disk_usage);


    } catch(rabbit::type_mismatch & e) {

        gLog->WARNING("%-24s| perf - type mismatch [%s]",
            "NodeToVnfmEvent",
            body.c_str());
        return false;
    } catch(rabbit::parse_error & e) {
//.........这里部分代码省略.........
开发者ID:Ntels-sup,项目名称:SRC_ATOM_BE,代码行数:101,代码来源:NodeToVnfmEvent.cpp

示例4: catch

bool NodeToVnfmEvent::
event(NodeData & a_rNodeData, DashBoard & a_board)
{
    gLog->DEBUG("%-24s| event",
        "NodeToVnfmEvent");

    m_sHttpData.Clear();

    std::string     event_type;
    std::string     timestamp;
    std::string     code;
    std::string     severity;
    std::string     probable_cause;
    std::string     additional_text;
    int             coresponse_action_cnt = 0;
    std::string     coresponse_action;

    try {
        rabbit::document    doc;
        doc.parse(a_rNodeData.GetBody());

        rabbit::object      root = doc["BODY"];

        event_type      = root["event_type"].as_string();
        timestamp       = root["prc_date"].as_string();
        code            = root["code"].as_string();
        severity        = root["perceived_severity"].as_string();
        probable_cause  = root["probable_cause"].as_string();
        additional_text = root["additional_text"].as_string();

        if(root["coresponse_action"].is_null() == false)
        {
            coresponse_action_cnt = root["coresponse_action_cnt"].as_int();
            coresponse_action     = root["coresponse_action"].as_string();
        }

    } catch(rabbit::type_mismatch & e) {

        gLog->WARNING("%-24s| event - type mismatch [%s]",
            "NodeToVnfmEvent",
            a_rNodeData.GetBody().c_str());
        return false;
    } catch(rabbit::parse_error & e) {

        gLog->WARNING("%-24s| event - parse error [%s]",
            "NodeToVnfmEvent",
            a_rNodeData.GetBody().c_str());
        return false;
    } catch(...) {
        gLog->WARNING("%-24s| event - [%s]",
            "NodeToVnfmEvent",
            a_rNodeData.GetBody().c_str());
        return false;
    }

    rabbit::object      oRoot;
    rabbit::object      oBody   = oRoot["event"];

    oBody["server-uuid"]        = a_board.GetUUID();
    oBody["event_type"]         = event_type;
    oBody["timestamp"]          = timestamp;
    oBody["perceived_severity"] = severity;
    oBody["additional_text"]    = additional_text;
    oBody["alarm_code"]         = code;

    if(coresponse_action.size() > 0)
    {
        if(coresponse_action_cnt == 0)
            oBody["coresponse_action_cnt"] = 1;
        else
            oBody["coresponse_action_cnt"] = coresponse_action_cnt;

        oBody["coresponse_action"] = coresponse_action;
    }

    std::string body    = oRoot.str();

    char uriBuf[URI_MAX_SIZE];
    sprintf(uriBuf, "%s/vnf/event", a_board.GetVnfmServiceURL());

    m_sHttpData.AddLine("POST", uriBuf, "HTTP/1.1");
    m_sHttpData.AddHeader("Content-Type", "application/json");
    m_sHttpData.AddBody(body.c_str(), body.size());

    return true;
}
开发者ID:Ntels-sup,项目名称:SRC_ATOM_BE,代码行数:86,代码来源:NodeToVnfmEvent.cpp


注:本文中的NodeData::GetBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。