Ejemplo n.º 1
0
inline bool operator==(const std::tr1::unordered_set<size_t> &a, const std::tr1::unordered_set<size_t> &b) {
  if (a.size() != b.size()) return false;

  std::tr1::unordered_set<size_t>::const_iterator cit = a.begin();
  while (a.end() != cit) {
    if (b.end() == b.find(*cit))
      return false;
    cit++;
  }
 
  return true;
}
Ejemplo n.º 2
0
void serverProcessReplacement(unsigned int timeDelta) 
{
	unsigned int servertickaddr=0x602350;
	unsigned int serverthisptr=0x9E5EC0;

	for (auto it = sServerProcessResponders.begin(); it != sServerProcessResponders.end(); it++)
		(*it)(timeDelta);

	__asm 
	{
		mov ecx,serverthisptr
		push timeDelta
		call servertickaddr
	}
	
	return;

}
Ejemplo n.º 3
0
void outputDiskCombinedGauges(int gtype, const merged_gauge_map_t& prev, const merged_gauge_map_t& gauges,
			      bool& first, const std::tr1::unordered_set<int>& diskIds)
{
	for (std::tr1::unordered_set<int>::const_iterator idIter = diskIds.begin(); idIter != diskIds.end(); ++idIter) {
		local_key_set_t keys;

		for (const_gauge_iterator iter = gauges.begin(); iter != gauges.end(); ++iter) {
			if (IID_IS4DISK(iter->first.sid.iid) && IID2DISKNO(iter->first.sid.iid)== *idIter) {
				local_key_t key = iter->first;
				key.sid.iid = 0;

				keys.insert(key);
			}
		}

		
		for (local_key_set_t::iterator iter = keys.begin(); iter != keys.end(); ++iter) {
			if (first) first = false; else printf(",");
			if (gtype == GT_PRODUCT) {
				// {pid,mid=0,usr|sys|idl|wt,host=0}
				printf("{\"gtype\":\"P\",\"pid\":%d,\"type\":\"disk\"", iter->sid.pid);
			}
			else if (gtype == GT_MODULE) {
				// {pid,mid,usr|sys|idl|wt,host=0}
				printf("{\"gtype\":\"M\",\"pid\":%d,\"mid\":%d,\"type\":\"disk\"", iter->sid.pid, iter->sid.mid);
			}
			else if (gtype == GT_HOST) {
				// {pid=0,mid=0,usr|sys|idl|wt,host}
				// TODO: host-name, ip6
				char buf[128];
				if (iter->hip.ver == 4) inet_ntop(AF_INET, &iter->hip.ip.ip4, buf, sizeof buf);
				else if (iter->hip.ver == 6) inet_ntop(AF_INET6, &iter->hip.ip.ip6[0], buf, sizeof buf);
				printf("{\"gtype\":\"H\",\"ip\":\"%s\",\"host\":\"%s\",\"type\":\"disk\"", buf, buf);
			}

			printf(",\"name\":\"disk-%d\"", *idIter);
		
			int64_t rCalls = 0, rBytes = 0, wCalls = 0, wBytes = 0;
			local_key_t key = *iter; 

			key.sid.iid = IID_DISK(*idIter, DISK_T_R_CALLS);
			const_gauge_iterator iter1 = prev.find(key), iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				rCalls = iter2->second.gval - iter1->second.gval;

			key.sid.iid = IID_DISK(*idIter, DISK_T_R_BYTES);
			iter1 = prev.find(key), iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				rBytes = iter2->second.gval - iter1->second.gval;

			key.sid.iid = IID_DISK(*idIter, DISK_T_W_CALLS);
			iter1 = prev.find(key), iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				wCalls = iter2->second.gval - iter1->second.gval;

			key.sid.iid = IID_NET(*idIter, DISK_T_W_BYTES);
			iter1 = prev.find(key), iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				wBytes = iter2->second.gval - iter1->second.gval;

			printf(",\"values\":{\"r-calls\":%ld,\"r-bytes\":%ld,\"w-calls\":%ld,\"w-bytes\":%ld}}", rCalls, rBytes, wCalls, wBytes);
		}
	}

	return;
}
Ejemplo n.º 4
0
void outputNetCombinedGauges(int gtype, const merged_gauge_map_t& prev, const merged_gauge_map_t& gauges,
			     bool& first, const std::tr1::unordered_set<int>& netIds)
{
	for (std::tr1::unordered_set<int>::const_iterator idIter = netIds.begin(); idIter != netIds.end(); ++idIter) {
		local_key_set_t keys;

		for (const_gauge_iterator iter = gauges.begin(); iter != gauges.end(); ++iter) {
			if (IID_IS4NET(iter->first.sid.iid) && IID2NETNO(iter->first.sid.iid) == *idIter) {
				local_key_t key = iter->first;
				key.sid.iid = 0;
				
				keys.insert(key);
			}
		}

		
		for (local_key_set_t::iterator iter = keys.begin(); iter != keys.end(); ++iter) {
			if (first) first = false; else printf(",");
			if (gtype == GT_PRODUCT) {
				// {pid,mid=0,usr|sys|idl|wt,host=0}
				printf("{\"gtype\":\"P\",\"pid\":%d,\"type\":\"net\"", iter->sid.pid);
			}
			else if (gtype == GT_MODULE) {
				// {pid,mid,usr|sys|idl|wt,host=0}
				printf("{\"gtype\":\"M\",\"pid\":%d,\"mid\":%d", iter->sid.pid, iter->sid.mid);
			}
			else if (gtype == GT_HOST) {
				// {pid=0,mid=0,usr|sys|idl|wt,host}
				// TODO: host-name, ip6
				char buf[128];
				if (iter->hip.ver == 4) inet_ntop(AF_INET, &iter->hip.ip.ip4, buf, sizeof buf);
				else if (iter->hip.ver == 6) inet_ntop(AF_INET6, &iter->hip.ip.ip6[0], buf, sizeof buf);
				printf("{\"gtype\":\"H\",\"ip\":\"%s\",\"host\":\"%s\"", buf, buf);
			}

			// TODO: get its name
			printf(",\"name\":\"net-%d\"", *idIter);
		
			int64_t inBytes = 0, inPkts = 0, outBytes = 0, outPkts = 0;
			local_key_t key = *iter; 

			key.sid.iid = IID_NET(*idIter, NET_T_IN_BYTES);
			const_gauge_iterator iter1 = prev.find(key), iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				inBytes = iter2->second.gval - iter1->second.gval;

			key.sid.iid = IID_NET(*idIter, NET_T_IN_PKTS);
			iter1 = prev.find(key), iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				inPkts = iter2->second.gval - iter1->second.gval;

			key.sid.iid = IID_NET(*idIter, NET_T_OUT_BYTES);
			iter1 = prev.find(key), iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				outBytes = iter2->second.gval - iter1->second.gval;

			key.sid.iid = IID_NET(*idIter, NET_T_OUT_PKTS);
			iter1 = prev.find(key), iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				outPkts = iter2->second.gval - iter1->second.gval;

			printf(",\"values\":{\"ib\":%ld,\"ip\":%ld,\"ob\":%ld,\"op\":%ld}}", inBytes,inPkts,outBytes,outPkts);
		}
	}

	return;
}
Ejemplo n.º 5
0
static void outputCpuCombinedGauges(int gtype, const merged_gauge_map_t& prev, const merged_gauge_map_t& gauges,
				    bool& first, std::tr1::unordered_set<int> cpuIds)
{
	for (std::tr1::unordered_set<int>::const_iterator idIter = cpuIds.begin(); idIter != cpuIds.end(); ++idIter) {
		local_key_set_t keys;

		for (const_gauge_iterator iter = gauges.begin(); iter != gauges.end(); ++iter) {
			if (IID_IS4CPU(iter->first.sid.iid) && IID2CPUNO(iter->first.sid.iid) == *idIter) {
				local_key_t key = iter->first;
				key.sid.iid = 0;

				keys.insert(key);
			}
		}

		for (local_key_set_t::iterator iter = keys.begin(); iter != keys.end(); ++iter) {
			if (first) first = false; else printf(",");
			if (gtype == GT_PRODUCT) {
				// {pid,mid=0,usr|sys|idl|wt,host=0}
				printf("{\"gtype\":\"P\",\"pid\":%d,\"type\":\"cpu\"", iter->sid.pid);
			}
			else if (gtype == GT_MODULE) {
				// {pid,mid,usr|sys|idl|wt,host=0}
				printf("{\"gtype\":\"M\",\"pid\":%d,\"mid\":%d", iter->sid.pid, iter->sid.mid);
			}
			else if (gtype == GT_HOST) {
				// {pid=0,mid=0,usr|sys|idl|wt,host}
				// TODO: host-name, and support ip6
				char buf[128];
				if (iter->hip.ver == 4) inet_ntop(AF_INET, &iter->hip.ip.ip4, buf, sizeof buf);
				else if (iter->hip.ver == 6) inet_ntop(AF_INET6, &iter->hip.ip.ip6[0], buf, sizeof buf);
				printf("{\"gtype\":\"H\",\"ip\":\"%s\",\"host\":\"%s\"", buf, buf);
			}

			if (*idIter == IID_CPU_TOTAL) printf(",\"name\":\"cpu\"");
			else printf(",\"name\":\"cpu-%d\"", *idIter);
		
			local_key_t key = *iter; 
			key.sid.iid = IID_CPU(*idIter, CPU_USR);
			int64_t usr = -1, sys = -1, idl = -1, wt = -1;
			const_gauge_iterator iter1 = prev.find(key), iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				usr = iter2->second.gval - iter1->second.gval;

			key.sid.iid = IID_CPU(*idIter, CPU_SYS);
			iter1 = prev.find(key); iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				sys = iter2->second.gval - iter1->second.gval;

			key.sid.iid = IID_CPU(*idIter, CPU_IDL);
			iter1 = prev.find(key); iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				idl = iter2->second.gval - iter1->second.gval;
			
			key.sid.iid = IID_CPU(*idIter, CPU_WT);
			iter1 = prev.find(key); iter2 = gauges.find(key);
			if (iter1 != prev.end() && iter2 != gauges.end())
				wt = iter2->second.gval - iter1->second.gval;

			if (usr == -1 || sys == -1 || idl == -1 || wt == -1) {
				printf(",\"values\":{}}");
			}
			else {
				// TODO: change to percent
				//int total = usr + sys + idl + wt;
				//int all = spanLength(spanUnit, spanCount) / 1000 * 100;
				//if (all % 100
				
				printf(",\"values\":{\"usr\":%ld,\"sys\":%ld,\"idl\":%ld,\"wt\":%ld}}", usr,sys,idl,wt);
			}
		}
	}
}
Ejemplo n.º 6
-1
inline void operator<< (object::with_zone& o, const std::tr1::unordered_set<T>& v)
{
	o.type = type::ARRAY;
	if(v.empty()) {
		o.via.array.ptr = NULL;
		o.via.array.size = 0;
	} else {
		object* p = (object*)o.zone->malloc(sizeof(object)*v.size());
		object* const pend = p + v.size();
		o.via.array.ptr = p;
		o.via.array.size = v.size();
		typename std::tr1::unordered_set<T>::const_iterator it(v.begin());
		do {
			*p = object(*it, o.zone);
			++p;
			++it;
		} while(p < pend);
	}
}