conga ./clustermon.spec.in.in ricci/modules/cl ...
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-10-09 19:58:30
Modified files:
. : clustermon.spec.in.in
ricci/modules/cluster: ClusterStatus.cpp ricci/modules/cluster/clumon/src/cim-provider: Makefile ricci/modules/cluster/clumon/src/common: Cluster.cpp ricci/modules/cluster/clumon/src/daemon: Makefile Monitor.cpp
Monitor.h main.cpp
ricci/modules/cluster/clumon/src/snmp-agent: Makefile
Log message:
use libcman wherever possible instead of fork/exec and parsing stdout
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/clustermon.spec.in.in.diff?cvsroot=cluster&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterStatus.cpp.diff?cvsroot=cluster&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/cim-provider/Makefile.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/common/Cluster.cpp.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Makefile.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp.diff?cvsroot=cluster&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Monitor.h.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/main.cpp.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/snmp-agent/Makefile.diff?cvsroot=cluster&r1=1.6&r2=1.7
clustermon.spec.in.in +1 -0
@@ -27,6 +27,7 @@ Source0: %{name}-%{version}.tar.gz Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: cman-devel BuildRequires: glibc-devel gcc-c++ libxml2-devel BuildRequires: openssl-devel dbus-devel pam-devel pkgconfig BuildRequires: net-snmp-devel tog-pegasus-devel
ricci/modules/cluster/ClusterStatus.cpp +2 -1
@@ -150,7 +150,8 @@ { XMLObject s(*iter); if (s.tag() == "service") - s.set_attr("vm", (is_service_vm(cluster_conf, s.get_attr("name"))) ? "true" : "false"); + s.set_attr("vm", (is_service_vm(cluster_conf, + s.get_attr("name"))) ? "true" : "false"); status_new.add_child(s); } return status_new;
ricci/modules/cluster/clumon/src/cim-provider/Makefile +2 -2
@@ -57,7 +57,7 @@ INCLUDE += -I ../include CXXFLAGS += $(PEGASUS_CXXFLAGS) -DPARANOIA=$(PARANOID) -LDFLAGS += -shared -ldl -lcrypt +LDFLAGS += -shared -ldl -lcrypt -lcman ifeq ($(PARANOID), 1) LDFLAGS += ${top_srcdir}/common/paranoid/*.o
@@ -88,7 +88,7 @@ rebuild: clean all $(TARGET): $(OBJECTS) - $(CXX) $(LDFLAGS) -o $@ $(OBJECTS) + $(CXX) -o $@ $(OBJECTS) $(LDFLAGS) $(TARGET_TEST): clusterCIM_test.* $(CXX) $(CXXFLAGS) -lpegcommon -lpegclient -lpthread -lcrypt -o $@ [email protected]
ricci/modules/cluster/clumon/src/common/Cluster.cpp +38 -0
@@ -24,6 +24,10 @@ #include <stdio.h> +extern "C" { +# include <libcman.h> +} + using namespace std; using namespace ClusterMonitoring;
@@ -65,6 +69,19 @@ unsigned int Cluster::votes() { + cman_handle_t ch = cman_init(NULL); + if (ch != NULL) { + char info[PIPE_BUF]; + cman_extra_info_t *cman_ei = (cman_extra_info_t *) info; + unsigned int total_votes = 0; + + if (cman_get_extra_info(ch, cman_ei, sizeof(info)) == 0) + total_votes = cman_ei->ei_total_votes; + cman_finish(ch); + if (total_votes > 0) + return (total_votes); + } + unsigned int votes = 0; for (map<String, counting_auto_ptr<Node> >::iterator iter = _nodes.begin() ;
@@ -81,6 +98,20 @@ unsigned int Cluster::minQuorum() { + cman_handle_t ch = cman_init(NULL); + if (ch != NULL) { + char info[PIPE_BUF]; + cman_extra_info_t *cman_ei = (cman_extra_info_t *) info; + int minq = -1; + + if (cman_get_extra_info(ch, cman_ei, sizeof(info)) == 0) + minq = cman_ei->ei_quorum; + cman_finish(ch); + + if (minq != -1) + return minq; + } + if (_minQuorum != 0) return _minQuorum; else {
@@ -101,6 +132,13 @@ bool Cluster::quorate() { + cman_handle_t ch = cman_init(NULL); + if (ch != NULL) { + int quorate = cman_is_quorate(ch); + cman_finish(ch); + return quorate; + } + return votes() >= minQuorum(); }
ricci/modules/cluster/clumon/src/daemon/Makefile +4 -2
@@ -20,7 +20,7 @@ Peer.o \ Communicator.o -INCLUDE += -I ../include +INCLUDE += -I../include CXXFLAGS += -DPARANOIA=$(PARANOID) LDFLAGS += ../common/*.o
@@ -30,6 +30,8 @@ LDFLAGS += ${top_srcdir}/common/*.o endif +LDFLAGS += -lcman + all: ${TARGET} install:
@@ -49,4 +51,4 @@ *.o: *.h $(TARGET): $(OBJECTS) - $(CXX) -o $@ $(LDFLAGS) $(OBJECTS) + $(CXX) -o $@ $(OBJECTS) $(LDFLAGS)
ricci/modules/cluster/clumon/src/daemon/Monitor.cpp +118 -96
276 lines not on this page · raw message
ricci/modules/cluster/clumon/src/daemon/Monitor.h +10 -2
@@ -35,11 +35,19 @@namespace ClusterMonitoring { +extern "C" { +# include <sys/socket.h> +# include <netdb.h> +# include <arpa/inet.h> +# include <net/if.h> +# include <ifaddrs.h> +# include <libcman.h> +} class Monitor : public Thread, public CommDP { public: - Monitor(unsigned short port); + Monitor(unsigned short port, const String& cluster_version); virtual ~Monitor(); String request(const String&);
@@ -74,12 +82,12 @@XMLObject parse_cluster_conf ();//bool clustered(); //bool quorate(); +String probe_quorum (); String nodename(const std::vector<String>& nodenames); std::vector<String> clustered_nodes(); std::vector<XMLObject> services_info(); String uptime() const; - String probe_quorum() const; };
ricci/modules/cluster/clumon/src/daemon/main.cpp +16 -2
@@ -27,6 +27,8 @@ #include <sys/poll.h> #include <errno.h> +#include <libcman.h> + typedef struct pollfd poll_fd; extern "C" {
@@ -71,9 +73,20 @@ bool debug = false, foreground = false; int v_level = -1; int rv; + String clu_version(""); - while ((rv = getopt(argc, argv, "fdv:")) != EOF) { + while ((rv = getopt(argc, argv, "c:fdv:")) != EOF) { switch (rv) { + case 'c': { + char *p; + long cv = strtol(optarg, &p, 10); + if (*p != '\0' || cv < 3 || cv > 5) { + fprintf(stderr, "Invalid cluster version: %s\n", optarg); + exit(-1); + } + clu_version = String(optarg); + } + case 'd': debug = true; break;
@@ -112,7 +125,8 @@ try { ServerSocket server(MONITORING_CLIENT_SOCKET); server.nonblocking(true); - Monitor monitor(COMMUNICATION_PORT); + + Monitor monitor(COMMUNICATION_PORT, clu_version); if (!foreground && (geteuid() == 0)) daemon_init(argv[0]);
ricci/modules/cluster/clumon/src/snmp-agent/Makefile +2 -0
@@ -27,6 +27,8 @@ LDFLAGS += ${top_srcdir}/common/*.o endif +LDFLAGS += -lcman + OBJECTS = clusterMonitorSnmp.o \ clusterMIB.o \ nodesMIB.o \