——》发送数据给nagios时,有个“nsca”守护进程,这是个使得nagios监控系统拥有“被动监控”能力的程序
更详细的见http://www.codelast.com/?p=2213
[原创]Nagios被动监测的实现-NSCA
*********************************************************************************************
一些具体的函数
——》memset:【使用说明】 The memset() function fills the first n bytes of the memory area pointed to by s with the constant byte c.
【函数头文件】 提示:在linux中可以在terminal中输入 "man memset"进行查询
#include<string.h>
void *memset(void *s, int c, size_t n);
http://blog.youkuaiyun.com/cclive1601/article/details/7869785
——》sprintf:http://blog.sina.com.cn/s/blog_3fa943920100rflt.html
由于sprintf 跟printf 在用法上几乎一样,只是打印的目的地不同而已,前者打印到字符串中,后者则直接在命令行上输出。
int sprintf( char *buffer, const char *format [, argument] ... );
如:
//把整数123 打印成一个字符串保存在s 中。
sprintf(s, "%d", 123); //产生"123"
APUE 5.11
——》fgets:Linux中的fgets函数的作用是从文件中读取一字符串,也可以从屏幕上输入一字符串(设置最后一个参数为stdin)
fgets()用来从参数stream所指的文件内读入字符并存到参数s所指的内存空间,直到出现换行字符、读到文件尾或是已读了size-1个字符,最后会加上NULL作为字符串结束。
include <stdio.h>
char *fgets(char *s, int size, FILE *stream);
APUE 5.7
——》load_modules()中的int (*mod_register)(struct module*);
函数定义:
void * dlopen( const char *pathname, intmode );
函数描述:
在dlopen的()函数以指定模式打开指定的动态连接库文件,并返回一个句柄给调用进程。使用dlclose()来卸载打开的库。
——》dlsym():http://blog.youkuaiyun.com/jernymy/article/details/6903683
dlsym()的函数原型是
void* dlsym(void* handle,const char* symbol)
该函数在<dlfcn.h>文件中。
handle是由dlopen打开动态链接库后返回的指针,symbol就是要求获取的函数的名称,函数返回值是void*,指向函数的地址,供调用使用
——》dlerror():http://blog.youkuaiyun.com/jernymy/article/details/6903683
包含头文件:
#include <dlfcn.h>
函数原型:
const char *dlerror(void);
函数描述:
当动态链接库操作函数执行失败时,dlerror可以返回出错信息,返回值为NULL时表示操作函数执行成功。
——》getopt_long函数:http://www.cnblogs.com/caosiyang/archive/2012/03/26/2417689.html
http://blog.youkuaiyun.com/mr_jj_lian/article/details/6835352
getopt_long是GNU C的一个常用函数,我们在linux下使用各种命令的时候经常会输入各种选项,长选项或短选项,因此GNU的家伙们就开发出来这样一个函数帮助我们处理选项。
int getopt(int argc, char * const argv[], const char *optstring)
int getopt_long(int argc, char * const argv[], const char *optstring, const struct option *longopts, int *longindex);
——》atoi函数:http://www.linuxidc.com/Linux/2012-06/61894.htm
1.函数功能:
把字符串转换成整型数.
2.原型:
int atoi(const char *nptr);
——》access函数:http://blog.sina.com.cn/s/blog_6a1837e90100uh5d.html
表头文件
定义函数
函数说明
——》strchr函数:http://blog.youkuaiyun.com/mcgrady_tracy/article/details/7613084
strchr函数用于在字符串s中搜索字符c,如果找到了字符c,则返回指向字符c的指针,如果没有找到则返回null。函数原型如下:
char *strchr(const char *s, int c)
——》strstr函数:http://blog.chinaunix.net/uid-23506752-id-2418190.html
strstr原型:extern char *strstr(char *haystack, char *needle); 用法:#include <string.h> 功能:从字符串haystack中寻找needle第一次出现的位置(不比较结束符NULL)。 说明:返回指向第一次出现needle位置的指针,如果没找到则返回NULL。
——》strtok函数:http://blog.youkuaiyun.com/jiji262/article/details/2461084
原型:char *strtok(char *s, char *delim);
功能:分解字符串为一组字符串。s为要分解的字符串,delim为分隔符字符串。
说明:首次调用时,s指向要分解的字符串,之后再次调用要把s设成NULL。
strtok在s中查找包含在delim中的字符并用NULL('/0')来替换,直到找遍整个字符串。
返回值:从s开头开始的一个个被分割的串。当没有被分割的串时则返回NULL。
所有delim中包含的字符都会被滤掉,并将被滤掉的地方设为一处分割的节点。
定义函数
| char * strncpy(char *dest,const char *src,size_t n); |
函数说明
| strncpy()会将参数src字符串拷贝前n个字符至参数dest所指的地址。<br> |
返回值
| 返回参数dest的字符串起始地址。<br> |