Skip to content
Browse files

*** empty log message ***

  • Loading branch information...
1 parent 6fe30d6 commit 106ae59e065b41532d61ebcd7060a0c39fdb4c48 massie committed Dec 14, 2004
Showing with 152 additions and 183 deletions.
  1. +0 −3 monitor-core/gmond/conf.c
  2. +14 −32 monitor-core/gmond/gmond.c
  3. +0 −1 monitor-core/lib/Makefile.am
  4. +28 −86 monitor-core/lib/apr_net.c
  5. +110 −61 monitor-core/lib/protocol.x
View
3 monitor-core/gmond/conf.c
@@ -1,9 +1,6 @@
#include <stdio.h>
#include "conf.h"
-#include "protocol.h"
-
-
extern cfg_t *config_file;
/* This function is necessary only because I need
View
46 monitor-core/gmond/gmond.c
@@ -375,12 +375,11 @@ poll_udp_recv_channels(apr_interval_time_t timeout)
for(i=0; i< num; i++)
{
apr_socket_t *socket;
- char buf[max_udp_message_len];
- apr_size_t len = max_udp_message_len;
apr_sockaddr_t *remotesa = NULL;
char *protocol, remoteip[256];
apr_ipsubnet_t *ipsub;
- hostdata_t *hostdata = NULL;
+ char buf[max_udp_message_len];
+ apr_size_t len = max_udp_message_len;
socket = descs[i].desc.s;
/* We could also use the apr_socket_data_get/set() functions
@@ -389,7 +388,6 @@ poll_udp_recv_channels(apr_interval_time_t timeout)
apr_socket_addr_get(&remotesa, APR_REMOTE, socket);
-
/* Grab the data */
status = apr_socket_recvfrom(remotesa, socket, 0, buf, &len);
if(status != APR_SUCCESS)
@@ -413,52 +411,36 @@ poll_udp_recv_channels(apr_interval_time_t timeout)
}
}
- /* Grab this host's data */
- hostdata = find_host_data( remoteip, remotesa );
- if(!hostdata)
- {
- continue;
- }
-
- fprintf(stderr,"Got a message from %s that is %d bytes long\n",
- hostdata->hostname, len);
-
-#if 0
if(!strcasecmp(protocol, "xdr"))
{
XDR x;
- gangliaMessage *msg = malloc(sizeof(gangliaMessage));
+ gangliaMessage msg;
+ hostdata_t *hostdata = NULL;
+ gangliaOldMetric *old_metric;
/* Create the XDR receive stream */
xdrmem_create(&x, buf, max_udp_message_len, XDR_DECODE);
- /* Flush the data in the (last) received gangliaMessage
- * TODO: Free memory from xdr_string calls XDR_FREE */
- memset( &hdr, 0, sizeof(gangliaMessageHeader));
+ /* Flush the data */
+ memset( &msg, 0, sizeof(gangliaMessage));
/* Read the gangliaMessage from the stream */
- if(!xdr_gangliaMessageHeader(&x, &hdr))
+ if(!xdr_gangliaMessage(&x, &msg))
{
continue;
}
- fprintf(stderr,"hdr.index=%d ", hdr.index);
- if(hdr.index<1024)
- {
- /* This is a 2.5.x data source */
- fprintf(stderr,"2.5.x data source\n");
- }
- else
+ /* Check if this is an old metric format */
+ old_metric = gangliaOldMetric_get( msg.format );
+ if(old_metric)
{
- fprintf(stderr,"new data source\n");
+ /* Move this data into a newer format (later) */
+ fprintf(stderr,"Got a %s message from %s\n", old_metric->name, remoteip);
}
-
-
+
/* If I want to find out how much data I decoded
decoded = xdr_getpos(&x); */
}
-#endif
-
}
}
}
View
1 monitor-core/lib/Makefile.am
@@ -22,6 +22,5 @@ libganglia_la_LDFLAGS = \
-export-dynamic
noinst_LIBRARIES = libgetopthelper.a
-# libdnet.a
# A little helper for getopt functions
libgetopthelper_a_SOURCES = getopt1.c getopt.c getopt_init.c getopt.h
View
114 monitor-core/lib/apr_net.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <apr_strings.h>
#include "apr_network_io.h"
#include "apr_arch_networkio.h"
@@ -12,7 +13,6 @@
#include <sys/sockio.h> /* for SIOCGIFADDR */
#endif
-
/* This function is copied directly from the
* apr_sockaddr_ip_get() function and modified to take a static
* buffer instead of needing to malloc memory from a pool */
@@ -165,86 +165,6 @@ create_tcp_server(apr_pool_t *context, apr_port_t port, char *bind)
return sock;
}
-#if 0
-#include <netinet/in.h>
-static int is_multicast(apr_sockaddr_t *address)
-{
- switch (address->family)
- {
- case AF_INET:
- return IN_MULTICAST(ntohl(*(long *)&addr->sin);
-
-#ifdef AF_INET6
- case AF_INET6:
- return IN6_IS_ADDR_MULTICAST(&addr->sin6);
-#endif
- }
-
- return 0;
-}
-#endif
-
-#if 0
-static int
-mcast_set_if(apr_socket_t *sock, apr_sockaddr_t **sa, const char *ifname)
-{
- switch ( (*sa)->sa.sin.sin_family ) {
- case AF_INET: {
- struct in_addr inaddr;
- struct ifreq ifreq;
-
- if (ifname)
- {
- strncpy(ifreq.ifr_name, ifname, IFNAMSIZ);
- if (ioctl(sock->socketdes, SIOCGIFADDR, &ifreq) < 0)
- return(-1);
- memcpy(&inaddr,
- &((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr,
- sizeof(struct in_addr));
- }
- else
- {
- inaddr.s_addr = htonl(INADDR_ANY); /* remove prev. set default */
- }
-
- return(setsockopt(sock->socketdes, IPPROTO_IP, IP_MULTICAST_IF,
- &inaddr, sizeof(struct in_addr)));
- }
-
-#ifdef AF_INET6
- case AF_INET6: {
- u_int index;
-
- if ( (index = ifindex) == 0) {
- if (ifname == NULL) {
- errno = EINVAL; /* must supply either index or name */
- return(-1);
- }
- if ( (index = if_nametoindex(ifname)) == 0) {
- errno = ENXIO; /* i/f name not found */
- return(-1);
- }
- }
- return(setsockopt(sock->socketdes, IPPROTO_IPV6, IPV6_MULTICAST_IF,
- &index, sizeof(index)));
- }
-#endif
-
- default:
- errno = EPROTONOSUPPORT;
- return(-1);
- }
-}
-#endif
-
-static int
-set_interface( apr_socket_t *sock, struct ifreq *ifreq, char *ifname )
-{
- memset(ifreq, 0, sizeof(struct ifreq));
- strncpy(ifreq->ifr_name, ifname, IFNAMSIZ);
- return ioctl(sock->socketdes, SIOCGIFADDR, ifreq);
-}
-
static int
mcast_set_ttl(apr_socket_t *socket, int val)
{
@@ -308,13 +228,16 @@ mcast_join( apr_pool_t *context, apr_socket_t *sock, char *mcast_channel, apr_po
memset(&ifreq,0, sizeof(ifreq));
if(ifname)
{
- if(set_interface(sock, ifreq, ifname) == -1)
+ memset(ifreq, 0, sizeof(struct ifreq));
+ strncpy(ifreq->ifr_name, ifname, IFNAMSIZ);
+ if(ioctl(sock->socketdes, SIOCGIFADDR, ifreq) == -1)
{
return APR_EGENERAL;
}
}
else
{
+ /* wildcard address (let the kernel decide) */
mreq->imr_interface.s_addr = htonl(INADDR_ANY);
}
@@ -376,13 +299,32 @@ apr_socket_t *
create_mcast_server(apr_pool_t *context, char *mcast_ip, apr_port_t port, char *bind, char *interface)
{
apr_status_t status;
- /* i think we might want to check that bind and interface are sane later...
- * might request to bind to an address that doesn't match the interface */
+ /* NOTE: If bind is set to mcast_ip in the configuration file, then we will bind the
+ * the multicast address to the socket as well as the port and prevent any
+ * datagrams that might be delivered to this port from being processed. Otherwise,
+ * packets destined to the same port (but a different multicast/unicast channel) will be
+ * processed. */
apr_socket_t *socket = create_udp_server(context, port, bind);
if(!socket)
{
return NULL;
}
- status = mcast_join(context, socket, mcast_ip, port, interface );
- return status == APR_SUCCESS? socket : NULL;
+
+ /* TODO: We can probe for a list of interfaces and perform multiple join calls for the same
+ * socket to have it listen for multicast traffic on all interfaces (important for
+ * multihomed machines). */
+ if(interface && !apr_strnatcasecmp(interface, "ALL"))
+ {
+ /* for(each interface)
+ * {
+ * mcast_join(...);
+ * }
+ */
+ }
+ else
+ {
+ status = mcast_join(context, socket, mcast_ip, port, interface );
+ }
+
+ return status == APR_SUCCESS? socket: NULL;
}
View
171 monitor-core/lib/protocol.x
@@ -1,5 +1,9 @@
enum gangliaValueTypes {
+ GANGLIA_VALUE_UNKNOWN,
GANGLIA_VALUE_STRING,
+ GANGLIA_VALUE_UNSIGNED_SHORT,
+ GANGLIA_VALUE_SIGNED_SHORT,
+ GANGLIA_VALUE_UNSIGNED_INT,
GANGLIA_VALUE_INT,
GANGLIA_VALUE_FLOAT,
GANGLIA_VALUE_DOUBLE
@@ -42,56 +46,46 @@ enum gangliaDataState {
GANGLIA_METRIC_TIME_THRESHOLD, /* slope != "zero" here down */
GANGLIA_METRIC_VALUE_THRESHOLD,
GANGLIA_METRIC_WARNING,
- GANGLIA_METRIC_ALERT
+ GANGLIA_METRIC_ALERT,
+ GANGLIA_METRIC_UNKNOWN_OLD_FORMAT
};
-struct gangliaNetinfo {
+struct gangliaMessageHeader {
gangliaHostinfo *host;
gangliaMsginfo *msg;
};
-struct gangliaMessageHeader {
- unsigned int index;
-};
-
struct gangliaMessageBody {
unsigned int source_instance;
- gangliaNetinfo *net;
gangliaDataState state;
unsigned int age;
unsigned int step;
string units<>;
gangliaMetric metrics<>;
};
-struct gangliaMessage {
- gangliaMessageHeader hdr;
- gangliaMessageBody bdy;
+struct gangliaFormat_1 {
+ gangliaMessageHeader *hdr;
+ gangliaMessageBody *bdy;
};
/* 2.5.x compatibility..... */
-const MAXSTRINGLEN = 1400;
-/* For gmetric messages */
-const MAXTYPELEN = 16;
-/*
- * Max multicast message: 1500 bytes (Ethernet max frame size)
- * minus 20 bytes for IPv4 header, minus 8 bytes for UDP header.
- */
-const MAXMCASTMSG = 1472;
-const FRAMESIZE = 1400;
-const MAXUNITSLEN = 16;
-
struct gmetricMessage {
- opaque type<MAXTYPELEN>;
- opaque name<MAXMCASTMSG>;
- opaque values<FRAMESIZE>;
- opaque units<MAXUNITSLEN>;
+ opaque type<>;
+ opaque name<>;
+ opaque values<>;
+ opaque units<>;
unsigned int slope;
unsigned int tmax;
unsigned int dmax;
};
-enum gangliaMetricIndex {
+/* This is based on the old key_metrics.h file given #ifdef LINUX.
+ All other operating system metric keys have been placed at the end
+ of the list. This breaks backward compatibility for those platforms
+ unfortunately.
+*/
+enum gangliaFormats {
metric_user_defined,
metric_cpu_num,
metric_cpu_speed,
@@ -121,33 +115,26 @@ enum gangliaMetricIndex {
metric_heartbeat,
metric_mtu,
metric_location,
- metric_cpu_wio,
- metric_bread_sec,
- metric_bwrite_sec,
- metric_lread_sec,
- metric_lwrite_sec,
- metric_phread_sec,
- metric_phwrite_sec,
- metric_rcache,
- metric_wcache,
- metric_bytes_in,
metric_bytes_out,
+ metric_bytes_in,
metric_pkts_in,
metric_pkts_out,
metric_disk_total,
metric_disk_free,
metric_part_max_used,
- metric_cpu_intr,
- metric_cpu_ssys,
- metric_cpu_wait,
- metric_mem_arm,
- metric_mem_rm,
- metric_mem_avm,
- metric_mem_vm,
- max_num_25_metric_keys
+ GANGLIA_NUM_OLD_METRICS, /* this should always directly follow the last 25 metric */
+
+ GANGLIA_FORMAT_1 = 2874789, /* give a little space for old metrics in case they are modified */
+
+ /* insert new formats here. */
+
+ GANGLIA_NUM_FORMATS /* this should always be the last entry */
};
-union ganglia25Message switch (gangliaMetricIndex metric) {
+union gangliaMessage switch (gangliaFormats format) {
+ case GANGLIA_FORMAT_1:
+ gangliaFormat_1 *format_1;
+
/* 2.5.x sources... */
case metric_user_defined:
gmetricMessage gmetric;
@@ -169,10 +156,6 @@ union ganglia25Message switch (gangliaMetricIndex metric) {
case metric_swap_free: /* xdr_u_int */
case metric_heartbeat: /* xdr_u_int */
case metric_mtu: /* xdr_u_int */
- case metric_mem_arm: /* xdr_u_int */
- case metric_mem_rm: /* xdr_u_int */
- case metric_mem_avm: /* xdr_u_int */
- case metric_mem_vm: /* xdr_u_int */
unsigned int u_int;
case metric_machine_type: /* xdr_string */
@@ -190,23 +173,11 @@ union ganglia25Message switch (gangliaMetricIndex metric) {
case metric_load_one: /* xdr_float */
case metric_load_five: /* xdr_float */
case metric_load_fifteen: /* xdr_float */
- case metric_cpu_wio: /* xdr_float */
- case metric_bread_sec: /* xdr_float */
- case metric_bwrite_sec: /* xdr_float */
- case metric_lread_sec: /* xdr_float */
- case metric_lwrite_sec: /* xdr_float */
- case metric_phread_sec: /* xdr_float */
- case metric_phwrite_sec: /* xdr_float */
- case metric_rcache: /* xdr_float */
- case metric_wcache: /* xdr_float */
case metric_bytes_in: /* xdr_float */
case metric_bytes_out: /* xdr_float */
case metric_pkts_in: /* xdr_float */
case metric_pkts_out: /* xdr_float */
case metric_part_max_used: /* xdr_float */
- case metric_cpu_intr: /* xdr_float */
- case metric_cpu_ssys: /* xdr_float */
- case metric_cpu_wait: /* xdr_float */
float f;
case metric_disk_total: /* xdr_double */
@@ -216,3 +187,81 @@ union ganglia25Message switch (gangliaMetricIndex metric) {
default:
void;
};
+
+#ifdef RPC_HDR
+%
+%
+%struct gangliaOldMetric /* this is for limited 2.5.x compatibility ... */
+%{
+% int key; /* the unique key for this metric.
+% matches position in metric array and enum. */
+% const char name[16]; /* the name of the metric */
+% int step; /* how often is the metric collected */
+% gangliaValueTypes type; /* the type of data to expect */
+% char units[32]; /* units the value are in */
+%};
+%typedef struct gangliaOldMetric gangliaOldMetric;
+%
+% gangliaOldMetric *gangliaOldMetric_get( int key );
+%
+#endif
+#ifdef RPC_XDR
+%
+% gangliaOldMetric *
+% gangliaOldMetric_get( int key )
+% {
+% static gangliaOldMetric gangliaOldMetricArray[GANGLIA_NUM_OLD_METRICS] = {
+% { metric_user_defined, "gmetric", 0, GANGLIA_VALUE_UNKNOWN, "" },
+% { metric_cpu_num, "cpu_num", -1, GANGLIA_VALUE_UNSIGNED_SHORT, "CPUs" },
+% { metric_cpu_speed, "cpu_speed", -1, GANGLIA_VALUE_UNSIGNED_INT, "MHz" },
+% { metric_mem_total, "mem_total", -1, GANGLIA_VALUE_UNSIGNED_INT, "KB" },
+% { metric_swap_total, "swap_total", -1, GANGLIA_VALUE_UNSIGNED_INT, "KB" },
+% { metric_boottime, "boottime", -1, GANGLIA_VALUE_UNSIGNED_INT, "s" },
+% { metric_sys_clock, "sys_clock", -1, GANGLIA_VALUE_UNSIGNED_INT, "s" },
+% { metric_machine_type, "machine_type", -1, GANGLIA_VALUE_STRING, "" },
+% { metric_os_name, "os_name", -1, GANGLIA_VALUE_STRING, "" },
+% { metric_os_release, "os_release", -1, GANGLIA_VALUE_STRING, "" },
+% { metric_cpu_user, "cpu_user", 20, GANGLIA_VALUE_FLOAT, "%" },
+% { metric_cpu_nice, "cpu_nice", 20, GANGLIA_VALUE_FLOAT, "%" },
+% { metric_cpu_system, "cpu_system", 20, GANGLIA_VALUE_FLOAT, "%" },
+% { metric_cpu_idle, "cpu_idle", 20, GANGLIA_VALUE_FLOAT, "%" },
+% { metric_cpu_aidle, "cpu_aidle", 950, GANGLIA_VALUE_FLOAT, "%" },
+% { metric_load_one, "load_one", 20, GANGLIA_VALUE_FLOAT, "" },
+% { metric_load_five, "load_five", 40, GANGLIA_VALUE_FLOAT, "" },
+% { metric_load_fifteen, "load_fifteen", 80, GANGLIA_VALUE_FLOAT, "" },
+% { metric_proc_run, "proc_run", 80, GANGLIA_VALUE_UNSIGNED_INT, "" },
+% { metric_proc_total, "proc_total", 80, GANGLIA_VALUE_UNSIGNED_INT, "" },
+% { metric_mem_free, "mem_free", 40, GANGLIA_VALUE_UNSIGNED_INT, "KB" },
+% { metric_mem_shared, "mem_shared", 40, GANGLIA_VALUE_UNSIGNED_INT, "KB" },
+% { metric_mem_buffers, "mem_buffers", 40, GANGLIA_VALUE_UNSIGNED_INT, "KB" },
+% { metric_mem_cached, "mem_cached", 40, GANGLIA_VALUE_UNSIGNED_INT, "KB" },
+% { metric_swap_free, "swap_free", 40, GANGLIA_VALUE_UNSIGNED_INT, "KB" },
+% { metric_gexec, "gexec", -1, GANGLIA_VALUE_STRING, "" },
+% { metric_heartbeat, "heartbeat", -1, GANGLIA_VALUE_UNSIGNED_INT, "" },
+% { metric_mtu, "mtu", 1200, GANGLIA_VALUE_UNSIGNED_INT, "" },
+% { metric_location, "location", -1, GANGLIA_VALUE_STRING, "(x,y,z)" },
+% { metric_bytes_out, "bytes_out", 40, GANGLIA_VALUE_FLOAT, "bytes/sec" },
+% { metric_bytes_in, "bytes_in", 40, GANGLIA_VALUE_FLOAT, "bytes/sec" },
+% { metric_pkts_in, "pkts_in", 40, GANGLIA_VALUE_FLOAT, "packets/sec"},
+% { metric_pkts_out, "pkts_out", 40, GANGLIA_VALUE_FLOAT, "packets/sec"},
+% { metric_disk_total, "disk_total", 3600, GANGLIA_VALUE_DOUBLE, "GB" },
+% { metric_disk_free, "disk_free", 40, GANGLIA_VALUE_DOUBLE, "GB" },
+% { metric_part_max_used,"part_max_used", 40, GANGLIA_VALUE_FLOAT, "%" }
+% };
+%
+% if(key < 0 || key >= GANGLIA_NUM_OLD_METRICS)
+% {
+% return NULL;
+% }
+% return &gangliaOldMetricArray[key];
+% }
+#endif
+
+
+
+
+
+
+
+
+

0 comments on commit 106ae59

Please sign in to comment.
Something went wrong with that request. Please try again.