static long ai_init(int pass)
{
    long i;

    if (pass) return 0;

    /* Create timers */
    for (i = 0; i < TOTAL_TYPES; i++) {
        scanIoInit(&scan[i].ioscan);
        scan[i].wd = wdogCreate(scan_time, i);
        scan[i].total = 0;
        scan[i].on = 0;
        scan[i].rate_sec = parmTypes[i].scan_rate;
    }

    /* Init OSD stuff */
    scan_mutex = epicsMutexMustCreate();
    devIocStatsInitCpuUsage();
    devIocStatsInitCpuUtilization(&loadinfo);
    devIocStatsInitFDUsage();
    devIocStatsInitMemUsage();
    devIocStatsInitWorkspaceUsage();
    devIocStatsInitSuspTasks();
    devIocStatsInitIFErrors();
    /* Get initial values of a few things that don't change much */
    devIocStatsGetClusterInfo(SYS_POOL, &clustinfo[SYS_POOL]);
    devIocStatsGetClusterInfo(DATA_POOL, &clustinfo[DATA_POOL]);
    devIocStatsGetClusterUsage(SYS_POOL, &mbufnumber[SYS_POOL]);
    devIocStatsGetClusterUsage(DATA_POOL, &mbufnumber[DATA_POOL]);
    devIocStatsGetCpuUtilization(&loadinfo);
    devIocStatsGetIFErrors(&iferrors);
    devIocStatsGetFDUsage(&fdusage);

    /* Count EPICS records */
    if (pdbbase) {
        DBENTRY dbentry;
        long	  status;
        dbInitEntry(pdbbase,&dbentry);
        status = dbFirstRecordType(&dbentry);
        while (!status) {
            recordnumber += dbGetNRecords(&dbentry);
            status = dbNextRecordType(&dbentry);
        }
        dbFinishEntry(&dbentry);
    }
    return 0;
}
static long ai_init(int pass)
{
    long i;

    if (pass) return 0;

    /* Create timers */
    for (i = 0; i < TOTAL_TYPES; i++) {
        scanIoInit(&scan[i].ioscan);
        scan[i].wd = wdogCreate(scan_time, i);
        scan[i].total = 0;
        scan[i].on = 0;
        scan[i].rate_sec = scan_rate_sec[i];
        scan[i].last_read_sec = 1000000;
    }

    /* Init OSD stuff */
    devIocStatsInitCpuUsage();
    devIocStatsInitCpuUtilization(&loadinfo);
    devIocStatsInitFDUsage();
    devIocStatsInitMemUsage();
    devIocStatsInitWorkspaceUsage();
    devIocStatsInitSuspTasks();
    devIocStatsInitIFErrors();

    /* Count EPICS records */
    if (pdbbase) {
        DBENTRY dbentry;
        long	  status;
        dbInitEntry(pdbbase,&dbentry);
        status = dbFirstRecordType(&dbentry);
        while (!status) {
            recordnumber += dbGetNRecords(&dbentry);
            status = dbNextRecordType(&dbentry);
        }
        dbFinishEntry(&dbentry);
    }
    return 0;
}