Example #1
0
void CSVSortList::enumMonitor(string &szDeviceIndex)
{
    OBJECT objDevice = GetEntity(szDeviceIndex,  m_szIDCUser, m_szIDCPwd);
    if(objDevice != INVALID_VALUE)
    {
        list<string> lsMonitorID;
        list<string>::iterator lstItem;
        if (GetSubMonitorsIDByEntity(objDevice, lsMonitorID))
        {
            string szDeviceName ("");
            MAPNODE mainnode = GetEntityMainAttribNode(objDevice);
            if(mainnode != INVALID_VALUE)
                FindNodeValue(mainnode, "sv_name", szDeviceName);
            
            int nIndex = 0;
            base_param monitor;
            for(lstItem = lsMonitorID.begin(); lstItem != lsMonitorID.end(); lstItem ++)
            {
                string szMonitorId = (*lstItem).c_str();
                OBJECT objMonitor = GetMonitor(szMonitorId, m_szIDCUser, m_szIDCPwd);
                if(objMonitor != INVALID_VALUE)
                {
                    MAPNODE node = GetMonitorMainAttribNode(objMonitor);
                    if(node != INVALID_VALUE)
                    {
                        string szName (""), szIndex ("");
                        FindNodeValue(node, "sv_name", szName);
                        FindNodeValue(node, "sv_index", szIndex);
                        if(szIndex.empty())
                            nIndex = FindIndexByID(szMonitorId);
                        else
                            nIndex = atoi(szIndex.c_str());

                        monitor.szIndex = szMonitorId;
                        monitor.szName = szDeviceName + ":" + szName;
                        m_sortList[nIndex] = monitor;
                    }
                    CloseMonitor(objMonitor);
                }
            }
        }
        CloseEntity(objDevice);
    }
}
Example #2
0
void CHZDLReport::GetData(string deviceName, string & sIP, bool & useCPU, bool & useMemory, float & CPUUtl, float & MemoryUtl)
{
	list<string> getMonList;
	list<string>::iterator getMonItem;
	string MonitorID;

	OBJECT tmpObjMonitor = NULL;
	OBJECT tmpObjTempMonitor = NULL;
	MAPNODE tmpMonitorNode = NULL;
	MAPNODE tmpMonitorTempNode = NULL;
	MAPNODE tempParamNode = NULL;
	LISTITEM ParamItem;
	bool bFind;
	string tmpMonitorTempName;

	useCPU = false;
	useMemory = false;
	CPUUtl = 0;
	MemoryUtl = 0;

	bFind = GetSubMonitorsIDByEntity(GetEntity(deviceName), getMonList);
	if (!bFind) return;

	MAPNODE tmpEntityNode = NULL;
	tmpEntityNode = GetEntityMainAttribNode(GetEntity(deviceName));
	string v;
	bFind = FindNodeValue(tmpEntityNode, "_MachineName", v);
	if (bFind)
	{
		sIP = v;
	}

	getMonItem = getMonList.begin();
	
	while ( (getMonItem != getMonList.end()) && ( (!useCPU) || (!useMemory) ) )
	{
		MonitorID = *getMonItem;
		tmpObjMonitor = GetMonitor(MonitorID);
		if (tmpObjMonitor != INVALID_VALUE)
		{
			tmpMonitorNode = GetMonitorMainAttribNode(tmpObjMonitor);
			string TypeID;
			bFind = FindNodeValue(tmpMonitorNode, "sv_monitortype", TypeID);
			int iType = atoi(TypeID.c_str());
			tmpObjTempMonitor = GetMonitorTemplet(iType);
			if(tmpObjTempMonitor!=INVALID_VALUE)
			{
				tmpMonitorTempNode = GetMTMainAttribNode(tmpObjTempMonitor);	
				bFind = FindNodeValue(tmpMonitorTempNode, "sv_name", tmpMonitorTempName);

				if (!useCPU)
				{
					string stmp1 = "CPU";
					string stmp2 = "Cpu";
					string stmp3 = "cpu";
					if ( findString(tmpMonitorTempName, stmp1) || findString(tmpMonitorTempName, stmp2) || findString(tmpMonitorTempName, stmp3) )
					{
						bFind = FindMTReturnFirst(tmpObjTempMonitor, ParamItem);
						bool findPrimary = false;
						while( ((tempParamNode=::FindNext(ParamItem)) != INVALID_VALUE) && !findPrimary )
						{ 
							string szPrimary;
							FindNodeValue(tempParamNode, "sv_primary",szPrimary);
							if(strcmp(szPrimary.c_str(), "1") == 0)
							{
								findPrimary = true;
								string tmpFieldName;
								FindNodeValue(tempParamNode, "sv_name", tmpFieldName);
								CPUUtl = CalcAverage(MonitorID, tmpFieldName);
							}
						}
						useCPU = true;
					}
				} 
				if (!useMemory)
				{
					string stmp = "Memory";
					if ( findString(tmpMonitorTempName, stmp) )
					{
						bFind = FindMTReturnFirst(tmpObjTempMonitor, ParamItem);
						bool findPrimary = false;
						while( ((tempParamNode=::FindNext(ParamItem)) != INVALID_VALUE) && !findPrimary )
						{ 
							string szPrimary;
							FindNodeValue(tempParamNode, "sv_primary",szPrimary);
							if(strcmp(szPrimary.c_str(), "1") == 0)
							{
								findPrimary = true;
								string tmpFieldName;
								FindNodeValue(tempParamNode, "sv_name", tmpFieldName);
								MemoryUtl = CalcAverage(MonitorID, tmpFieldName);
							}
						}
						useMemory = true;
					}
				}
			}	
		}
		getMonItem++;
	}
}
Example #3
0
bool CSVWholeview::enumMonitors(const string &szDeviceID, const string &szDeviceName, WTableCell *pTableCell)
{
    map<int, base_param, less<int> > sortList;
    map<int, base_param, less<int> >::iterator lsItem;

    OBJECT objDevice = GetEntity(szDeviceID,  m_szIDCUser, m_szIDCPwd);
    if(objDevice != INVALID_VALUE)
    {
        list<string> lsMonitorID;
        list<string>::iterator lstItem;
        if (GetSubMonitorsIDByEntity(objDevice, lsMonitorID))
        {
            base_param monitor;
            string szMonitorId("");
            OBJECT objMonitor = INVALID_VALUE;
            MAPNODE node = INVALID_VALUE;

            string szName(""), szIndex("");

            int nIndex = 0;
            for(lstItem = lsMonitorID.begin(); lstItem != lsMonitorID.end(); lstItem ++)
            {
                szMonitorId = (*lstItem).c_str();
                objMonitor = GetMonitor(szMonitorId, m_szIDCUser, m_szIDCPwd);
                if(objMonitor != INVALID_VALUE)
                {
                    node = GetMonitorMainAttribNode(objMonitor);
                    if(node != INVALID_VALUE)
                    {
                        FindNodeValue(node, "sv_name", szName);
                        FindNodeValue(node, "sv_index", szIndex);
                        if(szIndex.empty())
                            nIndex = FindIndexByID(szMonitorId);
                        else
                            nIndex = atoi(szIndex.c_str());
                        monitor.szIndex = szMonitorId;
                        monitor.szName = szName;

                        lsItem = sortList.find(nIndex);
                        while(lsItem != sortList.end())
                        {
                            nIndex ++;//= nMax;
                            lsItem = sortList.find(nIndex);
                        }
                        sortList[nIndex] = monitor;
                    }
                    CloseMonitor(objMonitor);
                }
            }
        }
        CloseEntity(objDevice);
    }
    string szShowText(""), szContent("");
    int nState = dyn_normal;
    bool bShowDevice = false;

    for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++)
    {
        // get monitor's current state
        nState = getMonitorState(lsItem->second.szIndex, szShowText);
        WImage *pMonitor = NULL;
        if(m_nShowType == -1 || m_nShowType == nState || 
            (m_nShowType == dyn_normal && nState == dyn_no_data) ||
            (m_nShowType == dyn_error && nState == dyn_bad))
        {
            bShowDevice = true;
            pMonitor = new WImage("/Images/state_green.gif", pTableCell);
        }
        if(pMonitor)
        {   
            // change show image by state
            switch(nState)
            {
            case dyn_no_data:
                pMonitor->setImageRef("/Images/state_grey.gif");
                break;
            case dyn_normal:
                pMonitor->setImageRef("/Images/state_green.gif");
                break;
            case dyn_warnning:
                pMonitor->setImageRef("/Images/state_yellow.gif");
                break;
            case dyn_error:
            case dyn_bad:
                pMonitor->setImageRef("/Images/state_red.gif");
                break;
            case dyn_disable:
                pMonitor->setImageRef("/Images/state_stop.gif");
                break;
            }

            // monitor's style && onclick event
            szContent = "style='cursor:pointer;' onclick = 'window.open(\"SimpleReport.exe?id=" + lsItem->second.szIndex + "\");'";
            sprintf(pMonitor->contextmenu_, szContent.c_str());
            pMonitor->setToolTip(szDeviceName + ":" + lsItem->second.szName + "\r\n" + szShowText);
        }
    }
    return bShowDevice;
}
Example #4
0
void CCheckBoxTreeView::AddMontiorInDevice(WTreeNode* pDeviceNode,bool bExpand)
{	
	OutputDebugString("AddMonitorInDevice()\n");
    if(pDeviceNode!=NULL)
    {
        //OutputDebugString("AddMontiorInDevice\n");
        map<int, base_param, less<int> > sortList;
        map<int, base_param, less<int> >::iterator lsItem;
        pDeviceNode->bMExpand=true;
        OBJECT objDevice = GetEntity(pDeviceNode->strId);
        if(objDevice != INVALID_VALUE)
        {
            list<string> lsMonitorID;
            list<string>::iterator lstItem;
            if (GetSubMonitorsIDByEntity(objDevice, lsMonitorID))
            {
                base_param monitor;
                //nMax = lsMonitorID.size();
                for(lstItem = lsMonitorID.begin(); lstItem != lsMonitorID.end(); lstItem ++)
                {
                    string szMonitorId = (*lstItem).c_str();
                    OBJECT objMonitor = GetMonitor(szMonitorId);
                    if(objMonitor != INVALID_VALUE)
                    {
                        MAPNODE node = GetMonitorMainAttribNode(objMonitor);
                        if(node != INVALID_VALUE)
                        {
                            string szName = "", szIndex = "";
                            FindNodeValue(node, "sv_name", szName);
                            FindNodeValue(node, "sv_index", szIndex);
                            if(szIndex.empty())
                                szIndex = findIndexByRealID(szMonitorId);
                            monitor.szIndex = szMonitorId;
                            monitor.szName = szName;

                            int nIndex = atoi(szIndex.c_str());
                            lsItem = sortList.find(nIndex);
                            while(lsItem != sortList.end())
                            {
                                //PrintDebugString("be found");
                                //nMax ++;
                                nIndex ++;//= nMax;
                                lsItem = sortList.find(nIndex);
                            }
                            sortList[nIndex] = monitor;
                        }
                        CloseMonitor(objMonitor);
                    }
                }
            }
            CloseEntity(objDevice);			
        }
        for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++)
        {
            WTreeNode *pNode=makeTreeFile(lsItem->second.szName,lsItem->second.szIndex, Tree_MONITOR, pDeviceNode, false,	
                    true,"/Images/cbb-6application.gif","/Images/cbb-6application.gif");
            if(bExpand)
            {
                if(pDeviceNode->treeCheckBox_->isChecked())
                pNode->treeCheckBox_->setChecked(true);
            }
        }
    }
}