#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <ganglia.h> /* for the libgmond messaging */
#include <gm_metric.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <math.h>
#ifdef SOLARIS
#define fabsf(f) ((float)fabs(f))
#endif
#ifdef _AIX
#ifndef _AIX52
/* _AIX52 is defined on all versions of AIX >= 5.2
fabsf doesn't exist on versions prior to 5.2 */
#define fabsf(f) ((float)fabs(f))
#endif
#endif
#ifdef LINUX
#include <sys/utsname.h>
#endif
#include <zlib.h>
#include <apr.h>
#include <apr_strings.h>
#include <apr_hash.h>
#include <apr_time.h>
#include <apr_pools.h>
#include <apr_poll.h>
#include <apr_network_io.h>
#include <apr_signal.h>
#include <apr_thread_proc.h>
#include <apr_tables.h>
#include <apr_dso.h>
#include <apr_version.h>
#ifdef HAVE_LIBPCRE
#if defined (HAVE_PCRE_PCRE_H)
#include <pcre/pcre.h>
#else
#include <pcre.h>
#endif
#endif
#include "cmdline.h" /* generated by cmdline.sh which runs gengetopt */
#include "become_a_nobody.h"
#include "apr_net.h" /* our private network functions based on apr */
#include "dtd.h" /* the DTD definition for our XML */
#include "g25_config.h" /* for converting old file formats to new */
#include "update_pidfile.h"
#include "gm_scoreboard.h"
#include "ganglia_priv.h"
/* Specifies a single value metric callback */
#define CB_NOINDEX -1
/* If a bind fails, and retry_bind is true, this is the interval to sleep
before retry. Specified in seconds */
#define RETRY_BIND_DELAY 60
/* The key in the apr_socket_t struct where our gzipped data is stored */
#define GZIP_KEY "gzip"
/* When this gmond was started */
apr_time_t started;
/* My name */
char myname[APRMAXHOSTLEN+1];
/* The commandline options */
struct gengetopt_args_info args_info;
/* The configuration file */
cfg_t *config_file;
/* The debug level (in debug_msg.c) */
static int debug_level;
/* The global context */
apr_pool_t *global_context = NULL;
/* Deaf mode boolean */
int deaf;
/* Mute mode boolean */
int mute;
/* Allow extra data boolean */
int allow_extra_data;
/* last time we received any data */
apr_time_t udp_last_heard;
/* Cluster tag boolean */
int cluster_tag = 0;
/* This host's location */
char *host_location = NULL;
/* This host name, spoofed */
char *override_hostname = NULL;
/* This host ip, spoofed */
char *override_ip = NULL;
/* Tags */
char *tags = NULL;
/* Boolean. Will this host received gexec requests? */
int gexec_on = 0;
/* This is tweakable by globals{max_udp_msg_len=...} */
int max_udp_message_len = 1472;
/* The default configuration for gmond. Found in conf.c. */
extern char *default_gmond_configuration;
/* The number of seconds to hold "dead" hosts in the hosts hash */
int host_dmax = 0;
/* The number of seconds to wait for a message before considering it down */
int host_tmax = 20;
/* The amount of time between cleanups */
int cleanup_threshold = 300;
/* Time interval before send another metadata packet */
int send_metadata_interval = 0;
/* The directory where DSO modules are located */
char *module_dir = NULL;
/* The array for outgoing UDP message channels */
Ganglia_udp_send_channels udp_send_channels = NULL;
/* TODO: The array for outgoing TCP message channels (later) */
apr_array_header_t *tcp_send_array = NULL;
enum Ganglia_action_types {
GANGLIA_ACCESS_DENY = 0,
GANGLIA_ACCESS_ALLOW = 1
};
typedef enum Ganglia_action_types Ganglia_action_types;
/* This is the structure used for the access control lists */
struct Ganglia_access {
apr_ipsubnet_t *ipsub;
Ganglia_action_types action;
};
typedef struct Ganglia_access Ganglia_access;
struct Ganglia_acl {
apr_array_header_t *access_array;
Ganglia_action_types default_action;
};
typedef struct Ganglia_acl Ganglia_acl;
/* This is the channel definitions */
enum Ganglia_channel_types {
TCP_ACCEPT_CHANNEL,
UDP_RECV_CHANNEL
};
typedef enum Ganglia_channel_types Ganglia_channel_types;
struct Ganglia_channel {
Ganglia_channel_types type;
Ganglia_acl *acl;
int timeout;
int gzip_output;
};
typedef struct Ganglia_channel Ganglia_channel;
/* Two separate pollsets hold the tcp_accept and udp_recv channels */
apr_pollset_t *udp_listen_channels = NULL;
apr_pollset_t *tcp_listen_channels = NULL;
/* These are the TCP listen channels */
apr_socket_t **tcp_sockets = NULL;
/* These are the UDP sockets */
apr_socket_t **udp_recv_sockets = NULL;
/* The hash to hold the hosts (key = host IP) */
apr_hash_t *hosts = NULL;
apr_thread_mutex_t *hosts_mutex = NULL;
/* The "hosts" hash contains values of type "hostdata" */
#ifdef SFLOW
#include "sflow.h"
uint16_t sflow_udp_port = SFLOW_IANA_REGISTERED_PORT;
#endif
#include "gmond_internal.h"
/* This is the structure of the data save to each host->metric hash */
struct Ganglia_metadata {
/* The pool used for allocating memory */
apr_pool_t *pool;
/* The name of the metric */
char *name;
union {
/* The ganglia message */
Ganglia_metadata_msg f_message;
Ganglia_value_msg v_message;
} message_u;
/* Last heard from */
apr_time_t last_heard_from;
};
typedef struct Ganglia_metadata Ganglia_metadata;
/* The hash to hold the metrics available on this platform */
apr_hash_t *metric_callbacks = NULL;
/* The "metrics" hash contains values of type "Ganglia_metric_callback" */
/* This is where libmetrics meets gmond */
struct Ganglia_metric_callback {
char *name; /* metric name */
float value_threshold;/* the value threshold */
char *title; /* Altername metric name or short description */
Ganglia_25metric *info;/* the information about this metric */
metric_func_void cb; /* callback function (deprecated) */
metric_func cbindexed; /* multi-metric callback function */
g_val_t now; /* the current value */
g_val_t last; /* the last value */
Ganglia_value_msg msg; /* the message to send */
mmodule *modp; /* dynamic module info struct */
int multi_metric_index; /* index identifying which metric is wanted */
apr_time_t metadata_last_sent; /* when the metadata was last sent */
};
typedef struct Ganglia_metric_callback Ganglia_metric_callback;
/* This is the structure of a collection group */
struct Ganglia_collection_group {
apr_time_t next_collect; /* When to collect next */
apr_time_t next_send; /* When to send next (tmax) */
int once;
int collect_every;
int time_threshold;
apr_array_header_t *metric_array;
};
typedef struct Ganglia_collection_group Ganglia_collection_group;
/* This is the array of collection groups that we are processing... */
apr_array_header_t *collection_groups = NULL;
mmodule *metric_modules = NULL;
extern int daemon_proc; /* defined in error.c */
char **gmond_argv;
extern char **environ;
/* apr_socket_send can't assure all characters in buf been sent. */
static apr_status_t
socket_send_raw(apr_socket_t *sock, const char *buf, apr_size_t *len)
{
apr_size_t total = *len;
apr_size_t thisTime = total;
const char* p = buf;
apr_status_t ret;
for(ret=apr_socket_send(sock, p, &thisTime); ret == APR_SUCCESS;
ret=apr_socket_send(sock, p, &thisTime))
{
if(thisTime < total)
{
total -= thisTime;
p += thisTime;
thisTime = total;
}
else
break;
}
return ret;
}
/* wrap socket_send_raw with gzip deflate if enabled. */
static apr_status_t
socket_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
{
char outputbuffer[2048];
const int outputlen = sizeof(outputbuffer);
apr_size_t wlen;
apr_status_t ret;
z_stream *strm;
int z_ret;
ret = apr_socket_data_get((void**)&strm, GZIP_KEY, sock);
if (ret != APR_SUCCESS)
{
return ret;
}
if (!strm)
{
ret = socket_send_raw( sock, buf, len );
}
else
{
strm->next_in = (Bytef *)buf;
strm->avail_in = *len;
while( strm->avail_in )
{
strm->next_out = (Bytef *)outputbuffer;
strm->avail_out = outputlen;
z_ret
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
ganglia 3.7.2 基于centos7可安装rpm包(rpmbuild/RPMS/x86_64目录中) 配合ganglia-web-3.7.2.tar.gz使用 参考:https://blog.csdn.net/lswnew/article/details/79175539
资源推荐
资源详情
资源评论

















收起资源包目录





































































































共 725 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论

- love131358162018-11-27正好集群不能访问外网 需要

蜗牛756
- 粉丝: 8
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- MATLAB数据处理技术在光学领域屈光度计算中的应用与实现
- 网络营销的策略组合.pptx
- 海康威视嵌入式产品介绍.pptx
- 计算机网络试题及解答(最终).doc
- 高等数学第五节极限运算法则.ppt
- 浅析网络经济对财务管理的影响.doc
- 人工智能的发展历程.pdf
- 宁波大学通信工程专业培养方案及教学计划.doc
- 用matlab绘制logistic模型图.ppt
- 住房城乡建设项目管理办法.pdf
- (源码)基于Arduino的遥控车系统.zip
- 基于MATLAB的均匀与非均匀应变光纤光栅仿真分析系统 精选版
- 网络管理与维护案例教程第5章-网络安全管理.ppt
- 网络语言的特点及对青少年语言运用的影响和规范.doc
- 算法讲稿3动态规划.pptx
- 高中信息技术编制计算机程序解决问题学案.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
