static void read_mem_stats(void)
{
	time_t nt;
	time(&nt);

	if((nt-scan[MEMORY_TYPE].last_read_sec)>=scan[MEMORY_TYPE].rate_sec)
	{
            devIocStatsGetMemUsage(&meminfo);
            devIocStatsGetWorkspaceUsage(&workspaceinfo);
            scan[MEMORY_TYPE].last_read_sec=nt;
        }
}
Ejemplo n.º 2
0
static void scan_time(int type)
{
    switch(type) {
      case MEMORY_TYPE:
      {
	memInfo   meminfo_local = {0.0,0.0,0.0,0.0,0.0,0.0};
	memInfo   workspaceinfo_local = {0.0,0.0,0.0,0.0,0.0,0.0};
	int       mbufnumber_local[2] = {0,0};
	ifErrInfo iferrors_local = {0,0};
        devIocStatsGetMemUsage(&meminfo_local);
        devIocStatsGetWorkspaceUsage(&workspaceinfo_local);
	devIocStatsGetClusterUsage(SYS_POOL, &mbufnumber_local[SYS_POOL]);
	devIocStatsGetClusterUsage(DATA_POOL, &mbufnumber_local[DATA_POOL]);
	devIocStatsGetIFErrors(&iferrors_local);
        epicsMutexLock(scan_mutex);
	meminfo               = meminfo_local;
	workspaceinfo         = workspaceinfo_local;
	mbufnumber[SYS_POOL]  = mbufnumber_local[SYS_POOL];
	mbufnumber[DATA_POOL] = mbufnumber_local[DATA_POOL];
	iferrors              = iferrors_local;
	devIocStatsGetClusterInfo(SYS_POOL, &clustinfo[SYS_POOL]);
	devIocStatsGetClusterInfo(DATA_POOL, &clustinfo[DATA_POOL]);
        epicsMutexUnlock(scan_mutex);
	break;
      }
      case LOAD_TYPE:
      {
	loadInfo loadinfo_local = {1,0.,0.};
	int      susptasknumber_local = 0;
        devIocStatsGetCpuUsage(&loadinfo_local);
        devIocStatsGetCpuUtilization(&loadinfo_local);
        devIocStatsGetSuspTasks(&susptasknumber_local);
        epicsMutexLock(scan_mutex);
	loadinfo       = loadinfo_local;
	susptasknumber = susptasknumber_local;
        epicsMutexUnlock(scan_mutex);
	break;
      }
      case FD_TYPE:
      {
	fdInfo   fdusage_local = {0,0};
        devIocStatsGetFDUsage(&fdusage_local);
        epicsMutexLock(scan_mutex);
	fdusage = fdusage_local;
        epicsMutexUnlock(scan_mutex);
	break;
      }
      case CA_TYPE:
      {
        unsigned cainfo_clients_local = 0;
        unsigned cainfo_connex_local  = 0;
	casStatsFetch(&cainfo_connex_local, &cainfo_clients_local);
        epicsMutexLock(scan_mutex);
        cainfo_clients = cainfo_clients_local;
        cainfo_connex  = cainfo_connex_local;
        epicsMutexUnlock(scan_mutex);
	break;
      }
      default:
        break;
    }
    scanIoRequest(scan[type].ioscan);
    if(scan[type].on)
		epicsTimerStartDelay(scan[type].wd, scan[type].rate_sec);
}