Hi,

I want to use snmp_subagent on Heartbeat 2.0.6 without
using CRM v2-style configuration. I don't like the complexity
of CRM daemons and CIB XML configuration so I have disabled
CRM support  with configure options but CRM binaries still
compiled ???  --disabled-crm or --enable-crm=no same effect..

I want to use v1-style configuration but use hbagent anyway.
After some research I have found a post from Horms with
a patch from Takahiro Kurosawa. I have ported this patch
to Heartbeat 2.0.6 stable version.
http://lists.community.tummy.com/pipermail/linux-ha-dev/2005-August/011441.html

Could you include the patch in attachment in your next release or
put in the contrib directory of your archive ?

hbagent have some trouble accessing
"/opt/heartbeat/lib/hearbeat/ResourceManager"
Check grep -rn 'HA_LIBDIR"/heartbeat' *; grep -rn 'HALIB "/heartbeat' *;
grep -rn 'ResourceManager ' * 

#  So what is the right path ?
sprintf(getcmd, HALIB "/ResourceManager status %s", resource);
sprintf(getcmd, HALIB "/heartbeat/ResourceManager status %s", resource);
sprintf(getcmd, HA_LIBDIR "/heartbeat/ResourceManager status %s", resource);


# ha.cf
#
#  Linux High Availability
# Heartbeat 2 Configuration
# - Infomaniak Network SA -
#
# http://www.linux-ha.org/ha.cf

# Time in second
keepalive 300ms
deadtime 1200ms
warntime 600ms
initdead 45000ms

# Serial ports
baud 19200
serial /dev/ttyS0

# Broadcast interfaces
udpport 694
bcast eth1

# Test gateway and other node uplink
respawn hacluster /opt/heartbeat/lib/heartbeat/ipfail
ping_group nodes 000.000.000.002 000.000.000.003
ping 000.000.000.001

# Compression for messages over 2KB
compression zlib
compression_threshold 2

# Watchdog to reboot if no more beat stop
#watchdog /dev/watchdog

# Nodes in the cluster
node infomaniak3 infomaniak4

# Don't use new v2-style XML configuration -- I don't like it !!!
crm off

# Automatically fail back to the "primary" node
auto_failback on

# Realtime priority
realtime on
rtprio 5

# Use the ha-logd and reconnect after 60 seconds if the connection is broken
use_logd yes
conn_logd_time 60
debug 0

# Generation for communications
hbgenmethod file
uuidfrom file

# Core Dump
coredumps true

# SNMP AgentX -- MIBS=ALL snmpwalk -v2c localhost -c public LinuxHA
respawn root /opt/heartbeat/lib/heartbeat/hbagent -d

# EOF

./configure \
--prefix=/opt/heartbeat \
--bindir=/opt/heartbeat/bin \
--sbindir=/opt/heartbeat/bin \
--libexecdir=/opt/heartbeat/bin \
--datadir=/usr/share \
--sysconfdir=/opt/heartbeat/etc \
--sharedstatedir=/opt/heartbeat/etc \
--localstatedir=/var \
--libdir=/opt/heartbeat/lib \
--includedir=/opt/heartbeat/include \
--oldincludedir=/opt/heartbeat/include \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
--enable-fatal-warnings=yes \
--enable-no-long-long=yes \
--enable-ldirectord=yes \
--enable-bundled-ltdl=yes \
--enable-crm=no \
--enable-lrm=no \
--enable-mgmt=no \
--enable-snmp-subagent \
--with-uuid=any \
--with-mibsdir=/usr/share/snmp/mibs \
--with-initdir=/etc/init.d \
--with-group-name=haclient \
--with-group-id=104 \
--with-ccmuser-name=hacluster \
--with-ccmuser-id=1000 \
--with-start-init-priority=75 \
--with-stop-init-priority=5 \
--with-snmp-name=ucd-snmp-devel \
--with-ocf-root=/opt/heartbeat/etc/ocf

heartbeat configuration:
  Version              = "2.0.6"
  Executables          = "/opt/heartbeat/bin"
  Man pages            = "/usr/share/man"
  Libraries            = "/opt/heartbeat/lib"
  Header files         = "/opt/heartbeat/include"
  Data files           = "/usr/share"
  State information    = "/var"
  System configuration = "/opt/heartbeat/etc"
  Init (rc) scripts    = "/etc/init.d"
  Use system LTDL      = "no"
  HA group name        = "haclient"
  HA group id          = "104"
  HA user name         = "hacluster"
  HA user user id      = "1000"
  Build snmp subagent  = "yes"
  SNMP MIB directory   = "/usr/share/snmp/mibs"
  SNMP agent libraries = "-L/usr/lib -lnetsnmpagent -lnetsnmpmibs
-lnetsnmphelpers -lnetsnmp -lsensors -lm -ldl -lwrap -lwrap"
  SNMP libraries       = "-L/usr/lib -lnetsnmp -lm -lwrap"
  ucd_snmp_devel name  = ""
  Build New CRM        = "no"
  Build New LRM        = "no"
  Build Ldirectord     = "yes"
  Build CIM providers  = "no"
  CC_WARNINGS          = " -Wall -Wmissing-prototypes
-Wmissing-declarations -Wstrict-prototypes -Wpointer-arith
-Wwrite-strings -Wcast-qual -Wcast-align -Wbad-function-cast -Winline
-Wmissing-format-attribute -Wformat=2 -Wformat-security
-Wformat-nonliteral -Wno-long-long -Wno-strict-aliasing -Werror "
  Mangled CFLAGS       = "-O3 -fomit-frame-pointer -pipe   -Wall
-Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes
-Wpointer-arith -Wwrite-strings -Wcast-qual -Wcast-align
-Wbad-function-cast -Winline -Wmissing-format-attribute -Wformat=2
-Wformat-security -Wformat-nonliteral -Wno-long-long
-Wno-strict-aliasing -Werror  -ggdb3 -funsigned-char"
  Libraries            = "-lbz2 -lz -lxml2 -lc -luuid -lrt -ldl "

BEFORE THE PATCH

infomaniak3:/opt/heartbeat/lib/heartbeat$ ./SNMPAgentSanityCheck
hbagent: no process killed
/usr/sbin/snmpd
lha-snmpagent[25262]: 2006/07/21_18:28:09 debug: PID=25262
lha-snmpagent[25262]: 2006/07/21_18:28:09 debug: Signing in with heartbeat
lha-snmpagent[25262]: 2006/07/21_18:28:09 info: node 1: infomaniak4,
type: normal, status: active
lha-snmpagent[25262]: 2006/07/21_18:28:10 info: node 2: infomaniak3,
type: normal, status: active
node0 =
node1 =
name = infomaniak3, node0 =
name = imalwaysdead.com, node0 =
BasicSanityCheck for SNMP Subagent failed.
infomaniak3:/opt/heartbeat/lib/heartbeat$ lha-snmpagent[25262]:
2006/07/21_18:28:10 info: node 3: 000.000.000.000, type: ping, status: ping
lha-snmpagent[25262]: 2006/07/21_18:28:10 info: node 4: nodes, type:
ping, status: ping
lha-snmpagent[25262]: 2006/07/21_18:28:11 info: node: infomaniak4,
interface: eth1, status: up
lha-snmpagent[25262]: 2006/07/21_18:28:11 info: node: infomaniak4,
interface: /dev/ttyS0, status: up
lha-snmpagent[25262]: 2006/07/21_18:28:11 info: node: infomaniak3,
interface: eth1, status: up
lha-snmpagent[25262]: 2006/07/21_18:28:11 info: node: infomaniak3,
interface: /dev/ttyS0, status: dead
lha-snmpagent[25262]: 2006/07/21_18:28:11 info: node: 000.000.000.000,
interface: 000.000.000.000, status: up
lha-snmpagent[25262]: 2006/07/21_18:28:12 info: node: nodes, interface:
nodes, status: up
lha-snmpagent[25262]: 2006/07/21_18:28:12 WARN:
/opt/heartbeat/etc/ha.d/haresources syntax error?
lha-snmpagent[25262]: 2006/07/21_18:28:12 info: g_hash_table_insert hd =
[0x8059a60]
lha-snmpagent[25262]: 2006/07/21_18:28:12 ERROR: oc_ev_activate error [1]
lha-snmpagent[25262]: 2006/07/21_18:28:12 debug: Membership service
currently not available.  Will try again later. errno [2]
lha-snmpagent[25262]: 2006/07/21_18:28:12 info: sending hbagent trap.
status:1
lha-snmpagent[25262]: 2006/07/21_18:28:17 info: g_hash_table_insert hd =
[0x8071130]
lha-snmpagent[25262]: 2006/07/21_18:28:17 ERROR: oc_ev_activate error [1]
lha-snmpagent[25262]: 2006/07/21_18:28:17 debug: Membership service
currently not available.  Will try again later. errno [2]
lha-snmpagent[25262]: 2006/07/21_18:28:22 info: g_hash_table_insert hd =
[0x8078248]
lha-snmpagent[25262]: 2006/07/21_18:28:22 ERROR: oc_ev_activate error [1]
lha-snmpagent[25262]: 2006/07/21_18:28:22 debug: Membership service
currently not available.  Will try again later. errno [2]
lha-snmpagent[25262]: 2006/07/21_18:28:27 info: g_hash_table_insert hd =
[0x8077a90]
lha-snmpagent[25262]: 2006/07/21_18:28:27 ERROR: oc_ev_activate error [1]
lha-snmpagent[25262]: 2006/07/21_18:28:27 debug: Membership service
currently not available.  Will try again later. errno [2]

AFTER THE PATCH

infomaniak3:/opt/heartbeat/lib/heartbeat$ ./SNMPAgentSanityCheck
/usr/sbin/snmpd
lha-snmpagent[30669]: 2006/07/21_19:01:55 debug: PID=30669
lha-snmpagent[30669]: 2006/07/21_19:01:55 debug: Signing in with heartbeat
lha-snmpagent[30669]: 2006/07/21_19:01:56 info: node 1: infomaniak4,
type: normal, status: active
lha-snmpagent[30669]: 2006/07/21_19:01:56 info: node 2: infomaniak3,
type: normal, status: active
node0 =
lha-snmpagent[30669]: 2006/07/21_19:01:57 info: node 3: 000.000.000.000,
type: ping, status: ping
node1 =
name = infomaniak3, node0 =
name = imalwaysdead.com, node0 =
BasicSanityCheck for SNMP Subagent failed.
infomaniak3:/opt/heartbeat/lib/heartbeat$ lha-snmpagent[30669]:
2006/07/21_19:01:57 info: node 4: nodes, type: ping, status: ping
lha-snmpagent[30669]: 2006/07/21_19:01:57 info: node: infomaniak4,
interface: eth1, status: up
lha-snmpagent[30669]: 2006/07/21_19:01:57 info: node: infomaniak4,
interface: /dev/ttyS0, status: up
lha-snmpagent[30669]: 2006/07/21_19:01:58 info: node: infomaniak3,
interface: eth1, status: up
lha-snmpagent[30669]: 2006/07/21_19:01:58 info: node: infomaniak3,
interface: /dev/ttyS0, status: dead
lha-snmpagent[30669]: 2006/07/21_19:01:58 info: node: 000.000.000.000,
interface: 000.000.000.000, status: up
lha-snmpagent[30669]: 2006/07/21_19:01:58 info: node: nodes, interface:
nodes, status: up
lha-snmpagent[30669]: 2006/07/21_19:01:58 WARN:
/opt/heartbeat/etc/ha.d/haresources syntax error?
lha-snmpagent[30669]: 2006/07/21_19:01:58 info: sending hbagent trap.
status:1
2006/07/21_19:02:35 INFO: IPaddr Running OK
2006/07/21_19:02:35 INFO: IPaddr Resource is stopped
2006/07/21_19:02:35 INFO: IPaddr Running OK
2006/07/21_19:02:36 INFO: IPaddr Resource is stopped
2006/07/21_19:02:36 INFO: IPaddr Running OK
2006/07/21_19:02:36 INFO: IPaddr Resource is stopped
2006/07/21_19:02:36 INFO: IPaddr Running OK
2006/07/21_19:02:36 INFO: IPaddr Resource is stopped
2006/07/21_19:02:36 INFO: IPaddr Running OK
2006/07/21_19:02:36 INFO: IPaddr Resource is stopped
2006/07/21_19:02:39 INFO: IPaddr Running OK
2006/07/21_19:02:39 INFO: IPaddr Resource is stopped
2006/07/21_19:02:39 INFO: IPaddr Running OK
2006/07/21_19:02:39 INFO: IPaddr Resource is stopped
2006/07/21_19:02:39 INFO: IPaddr Running OK
2006/07/21_19:02:39 INFO: IPaddr Resource is stopped
2006/07/21_19:02:39 INFO: IPaddr Running OK
2006/07/21_19:02:39 INFO: IPaddr Resource is stopped
2006/07/21_19:02:39 INFO: IPaddr Running OK
2006/07/21_19:02:40 INFO: IPaddr Resource is stopped
2006/07/21_19:02:40 INFO: IPaddr Running OK
2006/07/21_19:02:40 INFO: IPaddr Resource is stopped
2006/07/21_19:02:40 INFO: IPaddr Running OK
2006/07/21_19:02:40 INFO: IPaddr Resource is stopped
2006/07/21_19:02:40 INFO: IPaddr Running OK
2006/07/21_19:02:40 INFO: IPaddr Resource is stopped
2006/07/21_19:02:40 INFO: IPaddr Running OK
2006/07/21_19:02:40 INFO: IPaddr Resource is stopped
2006/07/21_19:02:40 INFO: IPaddr Running OK
2006/07/21_19:02:41 INFO: IPaddr Resource is stopped



--

Infomaniak Network SA
Guy Baconniere <[EMAIL PROTECTED]>
Unix System Administrator
Certified Linux Engineer (RHCE, LPIC-2)
Avenue de la Praille 26
1227 Carouge (Geneva)
Switzerland (CH)
Phone +41 (0)22 820 3541
Fax +41 (0)22 820 3546
AS29222 / BACO-RIPE

--- snmp_subagent/hbagent.c	2005-12-26 03:25:45.000000000 +0100
+++ snmp_subagent/hbagent.c	2006-07-21 16:09:50.081208000 +0200
@@ -21,6 +21,8 @@
  *
  */
 
+#undef HBAGENT_USE_MEMBERSHIP
+
 #include <portability.h>
 
 #ifdef HAVE_CONFIG_H
@@ -77,8 +79,10 @@
 static unsigned long hbInitialized = 0;
 static ll_cluster_t * hb = NULL; /* heartbeat handle */
 static char * myid = NULL; /* my node id */
+#ifdef HBAGENT_USE_MEMBERSHIP
 static SaClmHandleT clm = 0;
 static unsigned long clmInitialized = 0;
+#endif
 
 static GPtrArray * gNodeTable = NULL;
 static GPtrArray * gIFTable = NULL;
@@ -91,9 +95,11 @@
 int get_heartbeat_fd(void);
 int handle_heartbeat_msg(void);
 
+#ifdef HBAGENT_USE_MEMBERSHIP
 int init_membership(void);
 int get_membership_fd(void);
 int handle_membership_msg(void);
+#endif
 
 int init_resource_table(void);
 
@@ -106,10 +112,14 @@
 
 int nodestatus_trap(const char * node, const char * status);
 int ifstatus_trap(const char * node, const char * lnk, const char * status);
+#ifdef HBAGENT_USE_MEMBERSHIP
 int membership_trap(const char * node, SaClmClusterChangesT status);
+#endif
 int hbagent_trap(int online, const char * node);
 
+#ifdef HBAGENT_USE_MEMBERSHIP
 int ping_membership(int * mem_fd);
+#endif
 
 uint32_t get_status_value(const char * status, const char * * status_array, uint32_t * value_array);
 
@@ -694,6 +704,7 @@
 	return HA_OK;
 }
 
+#ifdef HBAGENT_USE_MEMBERSHIP
 static void
 clm_track_cb(SaClmClusterNotificationT *nbuf, SaUint32T nitem,
 	SaUint32T nmem, SaUint64T nview, SaErrorT error)
@@ -844,6 +855,7 @@
 
 	return HA_OK;
 }
+#endif /* HBAGENT_USE_MEMBERSHIP */
 
 int
 init_resource_table(void)
@@ -932,7 +944,7 @@
     switch (attr) {
 	case RESOURCE_STATUS:
 	    resource = ((struct hb_rsinfo *) g_ptr_array_index(gResourceTable, index))->resource;
-	    sprintf(getcmd, HALIB "/ResourceManager status %s", resource);
+	    sprintf(getcmd, HALIB "/heartbeat/ResourceManager status %s", resource);
 	    rc = system(getcmd);
 	    /* cl_log(LOG_INFO, "resource [%s] status: [%d]", resource, WEXITSTATUS(rc)); */
 
@@ -1134,6 +1146,7 @@
 }
 
 
+#ifdef HBAGENT_USE_MEMBERSHIP
 int 
 membership_trap(const char * node, SaClmClusterChangesT status)
 {
@@ -1190,6 +1203,7 @@
 
     return HA_OK;
 }
+#endif /* HBAGENT_USE_MEMBERSHIP */
 
 static void
 usage(void)
@@ -1204,7 +1218,10 @@
 
 	fd_set fdset;
 	struct timeval tv, *tvp;
-	int flag, block = 0, numfds, hb_fd = 0, mem_fd = 0, debug = 0;
+	int flag, block = 0, numfds, hb_fd = 0, debug = 0;
+#ifdef HBAGENT_USE_MEMBERSHIP
+	int mem_fd = 0;
+#endif
 	int hb_already_dead = 0;
 
 	/* change this if you want to be a SNMP master agent */
@@ -1271,6 +1288,7 @@
 	    	cl_log(LOG_ERR, "resource table initialization failure.");
 	}
 
+#ifdef HBAGENT_USE_MEMBERSHIP
 	ret = init_membership();
 	mem_fd = get_membership_fd();
 
@@ -1284,6 +1302,7 @@
 	    	cl_log(LOG_DEBUG, "membership initialization failure.  You will not be able to view any membership information in this cluster.");
 	} 
 	*/
+#endif
 
 	init_LHAClusterInfo();
 	init_LHANodeTable();
@@ -1319,12 +1338,14 @@
                 FD_SET(hb_fd, &fdset);
 		numfds = hb_fd + 1;
 
+#ifdef HBAGENT_USE_MEMBERSHIP
 		if (clmInitialized) {
 			FD_SET(mem_fd, &fdset);
 
 			if (mem_fd > hb_fd)
 				numfds = mem_fd + 1;
 		}
+#endif
 
 		tv.tv_sec = DEFAULT_TIME_OUT;
 		tv.tv_usec = 0;
@@ -1347,7 +1368,9 @@
 			break;
 		} else if (ret == 0) {
 			/* timeout */
+#ifdef HBAGENT_USE_MEMBERSHIP
 			ping_membership(&mem_fd);
+#endif
 			snmp_timeout();
 			goto process_pending;
 		} 
@@ -1360,6 +1383,7 @@
 				hb_already_dead = 1;
 				break;
 			}
+#ifdef HBAGENT_USE_MEMBERSHIP
 		} else  if (clmInitialized && FD_ISSET(mem_fd, &fdset)) {
 		    	/* membership events */
 
@@ -1367,6 +1391,7 @@
 			    	cl_log(LOG_DEBUG, "unrecoverable membership error. quit now.");
 				break;
 			}
+#endif
 		} else {
 
 			/* snmp request */
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to