/* * swrun_nlist.c: * hrSWRunTable data access: * nlist() interface */ #include #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #include #include #include #include #include #include #include "swrun_private.h" /* --------------------------------------------------------------------- */ void netsnmp_arch_swrun_init(void) { extern int _swrun_max; auto_nlist( PROC_SYMBOL, 0, 0); auto_nlist( NPROC_SYMBOL, (char *)&_swrun_max, sizeof(int)); return; } /* --------------------------------------------------------------------- */ int netsnmp_arch_swrun_container_load( netsnmp_container *container, u_int flags) { struct proc *proc_table; int proc_type_base; int nproc, i, rc; netsnmp_swrun_entry *entry; auto_nlist( NPROC_SYMBOL, (char *)&nproc, sizeof(int)); proc_table = (struct proc *) malloc(nproc*(sizeof(struct proc))); auto_nlist( PROC_SYMBOL, (char *)&proc_table_base, sizeof(int)); NETSNMP_KLOOKUP(proc_table_base, (char *)proc_table, nproc*(sizeof(struct proc))); for ( i=0 ; ihrSWRunName_len = snprintf(entry->hrSWRunName, sizeof(entry->hrSWRunName)-1, "%s", proc_table[i].???); entry->hrSWRunPath_len = snprintf(entry->hrSWRunPath, sizeof(entry->hrSWRunPath)-1, "%s", proc_table[i].???); entry->hrSWRunParameters_len = snprintf(entry->hrSWRunParameters, sizeof(entry->hrSWRunParameters)-1, "%s", ???); */ switch (proc_table[i].p_stat) { /* XXX - which names to use ?? */ case SACTIVE: case SRUN: case SONPROC: entry->hrSWRunStatus = HRSWRUNSTATUS_RUNNING; break; case SSWAP: case SSLEEP: case SWAIT: entry->hrSWRunStatus = HRSWRUNSTATUS_RUNNABLE; break; case SSTOP: entry->hrSWRunStatus = HRSWRUNSTATUS_NOTRUNNABLE; break; case SIDL: case SZOMB: default: entry->hrSWRunStatus = HRSWRUNSTATUS_INVALID; break; } entry->hrSWRunPerfCPU = (proc_table[i].p_utime.tv_sec * 100); entry->hrSWRunPerfCPU += (proc_table[i].p_utime.tv_usec / 10000); entry->hrSWRunPerfCPU += (proc_table[i].p_stime.tv_sec * 100); entry->hrSWRunPerfCPU += (proc_table[i].p_stime.tv_usec / 10000); /* or entry->hrSWRunPerfCPU = proc_table[i].p_time; */ } free(proc_table); DEBUGMSGTL(("swrun:load:arch"," loaded %d entries\n", CONTAINER_SIZE(container))); return 0; }