您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sysctlnametomib函数代码示例

51自学网 2021-06-03 08:38:05
  C++
这篇教程C++ sysctlnametomib函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中sysctlnametomib函数的典型用法代码示例。如果您正苦于以下问题:C++ sysctlnametomib函数的具体用法?C++ sysctlnametomib怎么用?C++ sysctlnametomib使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了sysctlnametomib函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: initsyscall

intinitsyscall(void){    static char name[] = "name";    hertz = stathz ? stathz : hz;    syscall_order(name);    /* drvinit gets number of cpus! */    drvinit(1);    counts_mib_len = __arraycount(counts_mib);    if (sysctlnametomib("kern.syscalls.counts", counts_mib,                        &counts_mib_len))        counts_mib_len = 0;    times_mib_len = __arraycount(times_mib);    if (sysctlnametomib("kern.syscalls.times", times_mib, &times_mib_len))        times_mib_len = 0;    getinfo(&s2, SHOW_COUNTS | SHOW_TIMES);    s1 = s2;    return(1);}
开发者ID:ryo,项目名称:netbsd-src,代码行数:26,


示例2: acline_init

/* * Try to use ACPI to find the AC line status.  If this fails, fall back * to APM.  If nothing succeeds, we'll just run in default mode. */static voidacline_init(void){	acline_mib_len = 4;	acline_status = SRC_UNKNOWN;	if (sysctlnametomib(ACPIAC, acline_mib, &acline_mib_len) == 0) {		acline_mode = ac_sysctl;		if (vflag)			warnx("using sysctl for AC line status");#if __powerpc__	} else if (sysctlnametomib(PMUAC, acline_mib, &acline_mib_len) == 0) {		acline_mode = ac_sysctl;		if (vflag)			warnx("using sysctl for AC line status");#endif#ifdef USE_APM	} else if ((apm_fd = open(APMDEV, O_RDONLY)) >= 0) {		if (vflag)			warnx("using APM for AC line status");		acline_mode = ac_apm;#endif	} else {		warnx("unable to determine AC line status");		acline_mode = ac_none;	}}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:31,


示例3: tish_uname

static int tish_uname(char * argv[]){    char * arg = argv[1];    int mib[2];    int len;    size_t str_len;    char type[20];    char rele[40] = "";    char vers[40] = "";    len = sysctlnametomib("kern.ostype", mib, num_elem(mib));    str_len = sizeof(type);    sysctl(mib, len, &type, &str_len, 0, 0);    if (arg && !strcmp(arg, "-a")) {        len = sysctlnametomib("kern.osrelease", mib, num_elem(mib));        str_len = sizeof(rele);        sysctl(mib, len, &rele, &str_len, 0, 0);        len = sysctlnametomib("kern.version", mib, num_elem(mib));        str_len = sizeof(vers);        sysctl(mib, len, &vers, &str_len, 0, 0);    }    printf("%s %s %s/n", type, rele, vers);    return 0;}
开发者ID:htchiang,项目名称:zeke,代码行数:28,


示例4: ProcessList_new

ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {   FreeBSDProcessList* fpl = calloc(1, sizeof(FreeBSDProcessList));   ProcessList* pl = (ProcessList*) fpl;   ProcessList_init(pl, Class(FreeBSDProcess), usersTable, pidWhiteList, userId);   int cpus = 1;   size_t sizeof_cpus = sizeof(cpus);   int err = sysctlbyname("hw.ncpu", &cpus, &sizeof_cpus, NULL, 0);   if (err) cpus = 1;   pl->cpuCount = MAX(cpus, 1);   CPUData* tmp_cpus = (CPUData*) realloc(fpl->cpus, cpus * sizeof(CPUData));   assert(tmp_cpus != NULL);   fpl->cpus = tmp_cpus;   for (int i = 0; i < cpus; i++) {      fpl->cpus[i].totalTime = 1;      fpl->cpus[i].totalPeriod = 1;   }      size_t len;   len = 4; sysctlnametomib("vm.stats.vm.v_wire_count",  MIB_vm_stats_vm_v_wire_count, &len);   len = 4; sysctlnametomib("vm.stats.vm.v_cache_count", MIB_vm_stats_vm_v_cache_count, &len);   len = 2; sysctlnametomib("hw.physmem",                MIB_hw_physmem, &len);   pageSizeKb = PAGE_SIZE_KB;         fpl->kd = kvm_open(NULL, "/dev/null", NULL, 0, NULL);   assert(fpl->kd);   return pl;}
开发者ID:tijko,项目名称:htop,代码行数:30,


示例5: sg_swap_init_comp

static sg_errorsg_swap_init_comp(unsigned id) {	ssize_t pagesize;#if defined(HAVE_STRUCT_XSWDEV)	size_t len = lengthof(swapinfo_mib);#endif	GLOBAL_SET_ID(swap,id);	if((pagesize = sg_get_sys_page_size()) == -1) {		RETURN_WITH_SET_ERROR_WITH_ERRNO("swap", SG_ERROR_SYSCONF, "_SC_PAGESIZE");	}#if defined(HAVE_STRUCT_XSWDEV)	if( sysctlnametomib("vm.swap_info", swapinfo_mib, &len) < 0 ) {		if( sysctlnametomib("vm.swap_info_array", swapinfo_mib, &len) < 0 ) {			RETURN_WITH_SET_ERROR_WITH_ERRNO("mem", SG_ERROR_SYSCTLNAMETOMIB, "vm.swap_info + vm.swap_info_array");		}		else {			swapinfo_array = true;			swapinfo_sysctl_name = "vm.swap_info_array";		}	}	else {		swapinfo_array = false;		swapinfo_sysctl_name = "vm.swap_info";	}#endif	return SG_ERROR_NONE;}
开发者ID:RsrchBoy,项目名称:dpkg-libstatgrab,代码行数:30,


示例6: coretemp_init_substrate

/** Initialize hardware counters, setup the function vector table * and get hardware information, this routine is called when the * PAPI process is initialized (IE PAPI_library_init) */int coretemp_init_substrate (){	int ret;	int i;	int mib[4];	size_t len;	char tmp[128];	SUBDBG("coretemp_init_substrate.../n");	/* Count the number of cores (counters) that have sensors allocated */	i = 0;	CORETEMP_NUM_EVENTS = 0;	sprintf (tmp, "dev.coretemp.%d.%%driver", i);	len = 4;	ret = sysctlnametomib (tmp, mib, &len);	while (ret != -1)	{		CORETEMP_NUM_EVENTS++;		i++;		sprintf (tmp, "dev.coretemp.%d.%%driver", i);		len = 4;		ret = sysctlnametomib (tmp, mib, &len);	}	/* Allocate memory for the our event table */	coretemp_native_table = (coretemp_native_event_entry_t *)		papi_malloc (sizeof (coretemp_native_event_entry_t) * CORETEMP_NUM_EVENTS);	if (coretemp_native_table == NULL)	{		perror( "malloc():Could not get memory for coretemp events table" );		return EXIT_FAILURE;	}	/* Allocate native events internal structures */	for (i = 0; i < CORETEMP_NUM_EVENTS; i++)	{		/* Event name */		sprintf (coretemp_native_table[i].name, "CORETEMP_CPU_%d", i);		/* Event description */		sprintf (coretemp_native_table[i].description, "CPU On-Die Thermal Sensor #%d", i);		/* Event extra bits -> save MIB to faster access later */		sprintf (tmp, "dev.cpu.%d.temperature", i);		len = 4;		if (sysctlnametomib (tmp, coretemp_native_table[i].resources.mib, &len) == -1)			return PAPI_ESBSTR;		coretemp_native_table[i].resources.selector = i+1;	}	return PAPI_OK;}
开发者ID:naps62,项目名称:CPD_PAPI,代码行数:58,


示例7: getSysvmswapfree

/* could have used kvm_getswapinfo() here for deeper backward-compatibility, but * the use of the kvm library seems to be deprecated in favour of sysctl, so that * is preferred here.  Thanks to Hubert Chu for contributing this. */int getSysvmswapfree(struct xswdev *xswtotal){    int mib[CTL_MAXNAME];    int n;    size_t size;    struct xswdev xsw;    xswtotal->xsw_nblks = 0;    xswtotal->xsw_used = 0;    size_t mibsize = sizeof(mib) / sizeof(mib[0]);    if (sysctlnametomib("vm.swap_info", mib, &mibsize) == -1) {        return NO;    }    for (n=0; ; ++n) {        mib[mibsize] = n;        size = sizeof(xsw);        if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, 0) == -1) {            break;        }        xswtotal->xsw_nblks += xsw.xsw_nblks;        xswtotal->xsw_used += xsw.xsw_used;    }    return YES;}
开发者ID:CumulusNetworks,项目名称:host-sflow,代码行数:29,


示例8: sg_mem_init_comp

static sg_errorsg_mem_init_comp(unsigned id) {	ssize_t pagesize;#if defined(HAVE_STRUCT_VMTOTAL) && /    !(defined(HAVE_STRUCT_UVMEXP_SYSCTL) && defined(VM_UVMEXP2)) && /    !(defined(HAVE_STRUCT_UVMEXP) && defined(VM_UVMEXP)) && /    !defined(DARWIN)	size_t len = lengthof(vmtotal_mib);#endif	GLOBAL_SET_ID(mem,id);#if defined(HAVE_STRUCT_VMTOTAL) && /    !(defined(HAVE_STRUCT_UVMEXP_SYSCTL) && defined(VM_UVMEXP2)) && /    !(defined(HAVE_STRUCT_UVMEXP) && defined(VM_UVMEXP)) && /    !defined(DARWIN)	if( -1 == sysctlnametomib( "vm.vmtotal", vmtotal_mib, &len ) ) {		RETURN_WITH_SET_ERROR_WITH_ERRNO("mem", SG_ERROR_SYSCTLNAMETOMIB, "vm.vmtotal");	}#endif	if((pagesize = sg_get_sys_page_size()) == -1) {		RETURN_WITH_SET_ERROR_WITH_ERRNO("mem", SG_ERROR_SYSCONF, "_SC_PAGESIZE");	}#if defined(HAVE_HOST_STATISTICS) || defined(HAVE_HOST_STATISTICS64)	self_host_port = mach_host_self();#endif	return SG_ERROR_NONE;}
开发者ID:JohnLyman,项目名称:libstatgrab,代码行数:30,


示例9: cpu_type_for_pid

/* * Return the CPU type of the process. */static int cpu_type_for_pid(pid_t pid, cpu_type_t *cputype) {     int res = -1;     static int mib[CTL_MAXNAME];     static size_t miblen = 0;          *cputype = 0;          if (miblen == 0)     {          miblen = CTL_MAXNAME;          res = sysctlnametomib("sysctl.proc_cputype", mib, &miblen);          if (res != 0)          {               miblen = 0;          }     }     if (miblen > 0)     {          mib[miblen] = pid;          size_t len = sizeof(*cputype);          res = sysctl(mib, miblen + 1, cputype, &len, NULL, 0);     }     return res;}
开发者ID:alfishe,项目名称:Tasks-Explorer,代码行数:31,


示例10: NumSystemCores

int NumSystemCores() {    if (PbrtOptions.nCores > 0) return PbrtOptions.nCores;#ifdef WIN32    SYSTEM_INFO sysinfo;    GetSystemInfo(&sysinfo);    return sysinfo.dwNumberOfProcessors;#elif defined(__linux__)    return sysconf(_SC_NPROCESSORS_ONLN);#else    // mac/bsds#ifdef __OpenBSD__    int mib[2] = { CTL_HW, HW_NCPU };#else    int mib[2];    mib[0] = CTL_HW;    size_t length = 2;    if (sysctlnametomib("hw.logicalcpu", mib, &length) == -1) {        Error("sysctlnametomib() filed.  Guessing 2 CPU cores.");        return 2;    }    Assert(length == 2);#endif    int nCores = 0;    size_t size = sizeof(nCores);    /* get the number of CPUs from the system */    if (sysctl(mib, 2, &nCores, &size, NULL, 0) == -1) {        Error("sysctl() to find number of cores present failed");        return 2;    }    return nCores;#endif}
开发者ID:joohaeng,项目名称:pbrt-v2,代码行数:33,


示例11: lNumCPUCores

/** Figure out how many CPU cores there are in the system */static intlNumCPUCores() {#if defined(__linux__)    return sysconf(_SC_NPROCESSORS_ONLN);#else    // Mac    int mib[2];    mib[0] = CTL_HW;    size_t length = 2;    if (sysctlnametomib("hw.logicalcpu", mib, &length) == -1) {        fprintf(stderr, "sysctlnametomib() filed.  Guessing 2 cores.");        return 2;    }    assert(length == 2);    int nCores = 0;    size_t size = sizeof(nCores);    if (sysctl(mib, 2, &nCores, &size, NULL, 0) == -1) {        fprintf(stderr, "sysctl() to find number of cores present failed.  Guessing 2.");        return 2;    }    return nCores;#endif}
开发者ID:texane,项目名称:ispc,代码行数:27,


示例12: used_system_cpu_sysdep

/** * This routine returns system/user CPU time in use. * @return: true if successful, false if failed */boolean_t used_system_cpu_sysdep(SystemInfo_T *si) {        int    mib[2];        long   cp_time[CPUSTATES];        long   total_new = 0;        long   total;        size_t len;        len = sizeof(mib);        if (sysctlnametomib("kern.cp_time", mib, &len) == -1) {                LogError("system statistic error -- cannot get cpu time handler: %s/n", STRERROR);                return false;        }        len = sizeof(cp_time);        if (sysctl(mib, 2, &cp_time, &len, NULL, 0) == -1) {                LogError("system statistic error -- cannot get cpu time: %s/n", STRERROR);                return false;        }        for (int i = 0; i < CPUSTATES; i++)                total_new += cp_time[i];        total     = total_new - total_old;        total_old = total_new;        si->total_cpu_user_percent = (total > 0) ? (100. * (double)(cp_time[CP_USER] - cpu_user_old) / total) : -1.;        si->total_cpu_syst_percent = (total > 0) ? (100. * (double)(cp_time[CP_SYS] - cpu_syst_old) / total) : -1.;        si->total_cpu_wait_percent = 0.; /* there is no wait statistic available */        cpu_user_old = cp_time[CP_USER];        cpu_syst_old = cp_time[CP_SYS];        return true;}
开发者ID:ClearwaterCore,项目名称:clearwater-monit,代码行数:38,


示例13: tish_ikut

static int tish_ikut(char * argv[]){    int mib_test[5];    int mib_cur[5];    int mib_next[5];    size_t len_cur, len_next;    const int one = 1;    const size_t len_test = sysctlnametomib("debug.test", mib_test,            num_elem(mib_test));    printf("     /n"); /* Hack */    print_mib_name(mib_test, len_test);    memcpy(mib_cur, mib_test, len_test * sizeof(int));    len_cur = len_test;    while ((len_next = sizeof(mib_next)),           sysctlgetnext(mib_cur, len_cur, mib_next, &len_next) == 0) {        if (!sysctltstmib(mib_next, mib_test, len_test)) {            printf("End of tests/n");            break; /* EOF debug.test */        }        memcpy(mib_cur, mib_next, len_next * sizeof(int));        len_cur = len_next;        print_mib_name(mib_cur, len_cur);        sysctl(mib_cur, len_cur, 0, 0, (void *)(&one), sizeof(one));    }    return 0;}
开发者ID:htchiang,项目名称:zeke,代码行数:32,


示例14: metric_init

/* * This function is called only once by the gmond.  Use to  * initialize data structures, etc or just return SYNAPSE_SUCCESS; */g_val_tmetric_init(void){   g_val_t val;   /*    * Try to use the vm.swap_info sysctl to gather swap data.  If it    * isn't implemented, fall back to trying to old kvm based interface.    */   mibswap_size = MIB_SWAPINFO_SIZE;   if (sysctlnametomib("vm.swap_info", mibswap, &mibswap_size) == -1) {      kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "metric_init()");   } else {      /*       * RELEASE versions of DragonFlyBSD with the swap mib have a version       * of libkvm that doesn't need root for simple proc access so we       * just open /dev/null to give us a working handle here.       */      kd = kvm_open(_PATH_DEVNULL, NULL, NULL, O_RDONLY, "metric_init()");      use_vm_swap_info = 1;   }   pagesize = getpagesize();   /* Initalize some counters */   get_netbw(NULL, NULL, NULL, NULL);   cpu_state(-1);   val.int32 = SYNAPSE_SUCCESS;   return val;}
开发者ID:AsherBond,项目名称:monitor-core,代码行数:34,


示例15: getset_parm

static int getset_parm(char * arg){    char * name;    char * value;    char * rest;    int mib[CTL_MAXNAME];    char fmt[5];    unsigned int kind;    int ctltype;    size_t dlen;    name = strtok_r(arg, "=", &rest);    value = strtok_r(0, "=", &rest);    if (!name) {        printf("Invalid argument/n");        errno = EINVAL;        return -1;    }    const int mib_len = sysctlnametomib(name, mib, num_elem(mib));    if (mib_len < 0) {        printf("Node not found/n");        return -1;    }    printf("%s = ", name);    if (sysctloidfmt(mib, mib_len, fmt, &kind)) {        printf("Invalid node/n");        return -1;    }    if (sysctl(mib, mib_len, 0, &dlen, 0, 0)) {        printf("Invalid node/n");        return -1;    }    ctltype = (kind & CTLTYPE);    switch (ctltype) {    case CTLTYPE_STRING:        return getset_svalue(mib, mib_len, dlen, value, strnlen(value, 80));    case CTLTYPE_INT:    case CTLTYPE_UINT:        return getset_ivalue(mib, mib_len, dlen, value, sizeof(int));    case CTLTYPE_LONG:    case CTLTYPE_ULONG:    case CTLTYPE_S64:    case CTLTYPE_U64:        printf("Data type not supported yet/n");        break;    }    return 0;}
开发者ID:htchiang,项目名称:zeke,代码行数:58,


示例16: SYSTEM_SWAP_SIZE

int	SYSTEM_SWAP_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result){/* *  FreeBSD 7.0 i386 */#ifdef XSWDEV_VERSION	/* defined in <vm/vm_param.h> */	char		*swapdev, *mode;	int		mib[16], *mib_dev;	size_t		sz, mib_sz;	struct xswdev	xsw;	zbx_uint64_t	total = 0, used = 0;	if (2 < request->nparam)		return SYSINFO_RET_FAIL;	swapdev = get_rparam(request, 0);	mode = get_rparam(request, 1);	sz = ARRSIZE(mib);	if (-1 == sysctlnametomib("vm.swap_info", mib, &sz))		return FAIL;	mib_sz = sz + 1;	mib_dev = &(mib[sz]);	*mib_dev = 0;	sz = sizeof(xsw);	while (-1 != sysctl(mib, mib_sz, &xsw, &sz, NULL, 0))	{		if (NULL == swapdev || '/0' == *swapdev || 0 == strcmp(swapdev, "all")	/* default parameter */				|| 0 == strcmp(swapdev, devname(xsw.xsw_dev, S_IFCHR)))		{			total += (zbx_uint64_t)xsw.xsw_nblks;			used += (zbx_uint64_t)xsw.xsw_used;		}		(*mib_dev)++;	}	if (NULL == mode || '/0' == *mode || 0 == strcmp(mode, "free"))	/* default parameter */		SET_UI64_RESULT(result, (total - used) * getpagesize());	else if (0 == strcmp(mode, "total"))		SET_UI64_RESULT(result, total * getpagesize());	else if (0 == strcmp(mode, "used"))		SET_UI64_RESULT(result, used * getpagesize());	else if (0 == strcmp(mode, "pfree"))		SET_DBL_RESULT(result, total ? ((double)(total - used) * 100.0 / (double)total) : 0.0);	else if (0 == strcmp(mode, "pused"))		SET_DBL_RESULT(result, total ? ((double)used * 100.0 / (double)total) : 0.0);	else		return SYSINFO_RET_FAIL;	return SYSINFO_RET_OK;#else	return SYSINFO_RET_FAIL;#endif}
开发者ID:Metalaria,项目名称:Zabbix_,代码行数:57,


示例17: sysctlbyname

int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, const void *newp, size_t newlen) {    int mib[CTL_MAXNAME + 2]; // +2 because most of the relevant code I've seen uses +2 as well    size_t miblen = CTL_MAXNAME + 2;    if(sysctlnametomib(name, mib, &miblen) == -1)        return -1;    return sysctl(mib, miblen, oldp, oldlenp, newp, newlen);}
开发者ID:NecroGankedd,项目名称:libnx,代码行数:9,


示例18: used_system_memory_sysdep

/** * This routine returns kbyte of real memory in use. * @return: TRUE if successful, FALSE if failed (or not available) */int used_system_memory_sysdep(SystemInfo_T *si) {  int                mib[16];  size_t             len;  struct vmtotal     vm;#if (__FreeBSD_version > 500000)  int                n = 0;  int                pagesize = getpagesize();  size_t             miblen;  struct xswdev      xsw;  unsigned long long total = 0ULL;  unsigned long long used  = 0ULL;#endif  /* Memory */  memset(mib, 0, sizeof(mib));  mib[0] = CTL_VM;  mib[1] = VM_METER;  len    = sizeof(struct vmtotal);  if (sysctl(mib, 2, &vm, &len, NULL, 0) == -1) {    LogError("system statistic error -- cannot get real memory usage: %s/n", STRERROR);    return FALSE;  }  si->total_mem_kbyte = (unsigned long)(vm.t_arm * pagesize_kbyte);  /* Swap */#if (__FreeBSD_version > 500000)  memset(mib, 0, sizeof(mib));  miblen = sizeof(mib) / sizeof(mib[0]);  if (sysctlnametomib("vm.swap_info", mib, &miblen) == -1) {    LogError("system statistic error -- cannot get swap usage: %s/n", STRERROR);    si->swap_kbyte_max = 0;    return FALSE;  }  while (TRUE) {    mib[miblen] = n;    len = sizeof(struct xswdev);    if (sysctl(mib, miblen + 1, &xsw, &len, NULL, 0) == -1)      break;    if (xsw.xsw_version != XSWDEV_VERSION) {      LogError("system statistic error -- cannot get swap usage: xswdev version mismatch/n");      si->swap_kbyte_max = 0;      return FALSE;    }    total += xsw.xsw_nblks;    used  += xsw.xsw_used;    n++;  }  si->swap_kbyte_max   = (unsigned long)(double)total * (double)pagesize / 1024.;  si->total_swap_kbyte = (unsigned long)(double)used  * (double)pagesize / 1024.;#else  /* Not implemented - FreeBSD <= 5.x doesn't have vm.swap_info MIB and uses kvm instead. As such FreeBSD version is obsolete, no need to implement unless somebody will ask for it. */  DEBUG("system statistic -- swap usage monitoring not implemented in FreeBSD <= 5.x/n");  si->swap_kbyte_max = 0;#endif  return TRUE;}
开发者ID:KISSMonX,项目名称:monit,代码行数:61,


示例19: getSysctlMib

static Mib* getSysctlMib(char* nameFmt, int n) {	char name[128];	sprintf(name, nameFmt, n);	Mib* mib = calloc(1, sizeof(Mib));	if (mib == NULL) error(__LINE__);	mib->len = 16;	if (sysctlnametomib(name, mib->mib, &mib->len)) errorM(__LINE__,name);	return mib;}
开发者ID:mizukusak,项目名称:kotemaru,代码行数:10,


示例20: genControlInfoFromName

void genControlInfoFromName(const std::string& name, QueryData& results,                    const std::map<std::string, std::string>& config) {  int request[CTL_DEBUG_MAXID + 2] = {0};  size_t oid_size = CTL_DEBUG_MAXID;  if (sysctlnametomib(name.c_str(), request, &oid_size) != 0) {    // MIB lookup failed.    return;  }  genControlInfo((int*)request, oid_size, results, config);}
开发者ID:1514louluo,项目名称:osquery,代码行数:11,


示例21: npe_setifname

static voidnpe_setifname(struct npestatfoo *wf0, const char *ifname){	struct npestatfoo_p *wf = (struct npestatfoo_p *) wf0;	size_t len;	snprintf(wf->oid, sizeof(wf->oid), "dev.npe.%s.stats", ifname+3);	len = 4;	if (sysctlnametomib(wf->oid, wf->mib, &len) < 0)		err(1, "sysctlnametomib: %s", wf->oid);}
开发者ID:coyizumi,项目名称:cs111,代码行数:11,


示例22: sysctlnametomib

	long SysInfo::GetCPUCount()	{		int mib[4];		int ncpu;		size_t len = 4;		sysctlnametomib("hw.ncpu", mib, &len);		size_t len2 = sizeof(ncpu);		sysctl(mib, len, &ncpu, &len2, NULL, 0);		return ncpu;	}
开发者ID:Antares84,项目名称:arcemu,代码行数:12,


示例23: used_system_memory_sysdep

/** * This routine returns kbyte of real memory in use. * @return: true if successful, false if failed (or not available) */boolean_t used_system_memory_sysdep(SystemInfo_T *si) {        /* Memory */        size_t len = sizeof(unsigned int);        unsigned int active;        if (sysctlbyname("vm.stats.vm.v_active_count", &active, &len, NULL, 0) == -1) {                LogError("system statistic error -- cannot get for active memory usage: %s/n", STRERROR);                return false;        }        if (len != sizeof(unsigned int)) {                LogError("system statistic error -- active memory usage statics error/n");                return false;        }        unsigned int wired;        if (sysctlbyname("vm.stats.vm.v_wire_count", &wired, &len, NULL, 0) == -1) {                LogError("system statistic error -- cannot get for wired memory usage: %s/n", STRERROR);                return false;        }        if (len != sizeof(unsigned int)) {                LogError("system statistic error -- wired memory usage statics error/n");                return false;        }        si->total_mem_kbyte = (active + wired) * pagesize_kbyte;        /* Swap */        int mib[16] = {};        unsigned long long total = 0ULL;        unsigned long long used  = 0ULL;        size_t miblen = sizeof(mib) / sizeof(mib[0]);        if (sysctlnametomib("vm.swap_info", mib, &miblen) == -1) {                LogError("system statistic error -- cannot get swap usage: %s/n", STRERROR);                si->swap_kbyte_max = 0;                return false;        }        int n = 0;        while (true) {                struct xswdev xsw;                mib[miblen] = n;                len = sizeof(struct xswdev);                if (sysctl(mib, miblen + 1, &xsw, &len, NULL, 0) == -1)                        break;                if (xsw.xsw_version != XSWDEV_VERSION) {                        LogError("system statistic error -- cannot get swap usage: xswdev version mismatch/n");                        si->swap_kbyte_max = 0;                        return false;                }                total += xsw.xsw_nblks;                used  += xsw.xsw_used;                n++;        }        si->swap_kbyte_max = total * pagesize_kbyte;        si->total_swap_kbyte = used * pagesize_kbyte;        return true;}
开发者ID:Nejuf,项目名称:monit,代码行数:57,


示例24: sysctlbyname

intsysctlbyname(const char *name, void *oldp, size_t *oldlenp,    const void *newp, size_t newlen){	int real_oid[CTL_MAXNAME+2];	size_t oidlen;	oidlen = sizeof(real_oid) / sizeof(int);	if (sysctlnametomib(name, real_oid, &oidlen) < 0)		return (-1);	return (sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen));}
开发者ID:ele7enxxh,项目名称:dtrace-pf,代码行数:12,


示例25: sysctlPresent

bool sysctlPresent(QString sysctlName){    int mib[64];    size_t len = sysctlName.split(".").size();    if (len>=64)        return false;    if (sysctlnametomib(sysctlName.toLocal8Bit(), mib, &len) < 0)    {        return false;    }    return true;}
开发者ID:yurkis,项目名称:pcbsd,代码行数:13,


示例26: mac_is_present

/* * Simply test whether the TrustedBSD/MAC MIB tree is present; if so, * return 1 to indicate that the system has MAC enabled overall or for * a given policy. */intmac_is_present(const char *policyname){	int mib[5];	size_t siz;	char *mibname;	int error;	if (policyname != NULL) {		if (policyname[strcspn(policyname, ".=")] != '/0') {			errno = EINVAL;			return (-1);		}		mibname = malloc(sizeof("security.mac.") - 1 +		    strlen(policyname) + sizeof(".enabled"));		if (mibname == NULL)			return (-1);		strcpy(mibname, "security.mac.");		strcat(mibname, policyname);		strcat(mibname, ".enabled");		siz = 5;		error = sysctlnametomib(mibname, mib, &siz);		free(mibname);	} else {		siz = 3;		error = sysctlnametomib("security.mac", mib, &siz);	}	if (error == -1) {		switch (errno) {		case ENOTDIR:		case ENOENT:			return (0);		default:			return (error);		}	}	return (1);}
开发者ID:2asoft,项目名称:freebsd,代码行数:43,


示例27: coretemp_init

/** This is called whenever a thread is initialized */int coretemp_init (hwd_context_t * ctx){	int mib[4];	size_t len;	UNREFERENCED(ctx);	SUBDBG("coretemp_init %p.../n", ctx);	len = 4;	if (sysctlnametomib ("dev.coretemp.0.%driver", mib, &len) == -1)		return PAPI_ESBSTR;	return PAPI_OK;}
开发者ID:naps62,项目名称:CPD_PAPI,代码行数:15,



注:本文中的sysctlnametomib函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ sysdev_class_register函数代码示例
C++ sysctlbyname函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。