/usr/lib/heartbeat/SNMPAgentSanityCheck is in pacemaker-mgmt 2.0.0+hg1141-2.1ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | #!/bin/sh
#
# Copyright (C) 2002 Yixiong Zou (yixiong.zou@intel.com)
# Support: linux-ha-dev@lists.tummy.com
# License: GNU General Public License (GPL)
#
set +x
#
# BasicSanityCheck has to run as root.
#
# Perhaps a better way to do this is to use the cl_status command...
# -- AlanR
#
NODE0=`uname -n`
NODE1=imalwaysdead.com
# make sure the agent and the subagent are dead
killall -9 hbagent
killall -9 snmpd
# make sure the snmpd is running and agentX support is turned on
GenerateSNMPDConf() {
cat <<-! >$1
rocommunity public
master yes
trap2sink localhost
!
chmod 644 $1
}
which snmpd
ret=$?
if test $ret != 0
then echo "snmpd file is not in the path, skip agent test..."
exit $ret
fi
# start the snmpd manually with our own config file
SNMPDCONF=/var/run/testsnmpd.conf
SNMPPIDFILE=/var/run/testsnmpd.pid
SNMPD=`which snmpd`
GenerateSNMPDConf $SNMPDCONF
$SNMPD -C -c $SNMPDCONF -p $SNMPPIDFILE
#/etc/init.d/snmpd status
#ret=$?
#if test $ret != 0
# then echo "snmpd cannot be started correctly. skip agent test..."
# exit $ret
#else
# echo "snmpd is already running, good"
#fi
# we want to wait for a couple seconds to let the master agent fully
# ready before we start the subagent.
sleep 3
# start the linux-ha snmp subagent
/usr/lib/heartbeat/hbagent -d &
HBAGENTPID=$!
sleep 5
# get the nodename for node0 and node1
# node0 should be the value of the localhost
# node1 should be "ImAlwaysDead.com"
export MIBS=ALL
#snmpwalk -v2c localhost -c public LinuxHA
node0=`snmpget -v2c localhost -c public LHANodeName.1 | sed -ne 's/LINUX-HA-MIB::LHANodeName.1 = STRING: //p'`
echo node0 = $node0
node1=`snmpget -v2c localhost -c public LHANodeName.2 | sed -ne 's/LINUX-HA-MIB::LHANodeName.2 = STRING: //p'`
echo node1 = $node1
ret=1
ret2=1
for name in $NODE0 $NODE1; do
echo name = $name, node0 = $node0
if test "$node0" = "$name"; then
ret=0
echo "found $node0"
break
fi
done
if test $ret = 0; then
for name in $NODE0 $NODE1; do
echo name = $name, node1 = $node1
if test "$node1" = "$name"; then
ret2=0
echo "found $node1"
break
fi
done
fi
if test $ret2 = 0; then
echo "BasicSanityCheck for SNMP Subagent passed."
# exit 0
else
echo "BasicSanityCheck for SNMP Subagent failed."
# exit 1
fi
#
# BasicSanityCheck for SNMP Subagent about CRM resources.
#
# wait to let cib ready to execute variant_op
sleep 10
# add CRM resource.
RSC0NAME="prmDummy"
RSC0TYPE="primitive(1)"
RSC0NODE="$NODE0"
RSC0STATUS="started(2)"
RSC0ISMANAGED="managed(1)"
RSC0FAILCOUNT="0"
RSC0PARENT=""
# clear resources
cibadmin --cib_replace -X '<resources/>'
cibadmin --cib_create -o resources \
-X '<primitive id="prmDummy" class="ocf" type="Dummy" provider="heartbeat"/>'
sleep 3
# get resource's information with snmp subagent.
rsc0name=`snmpget -v2c localhost -c public LHAResourceName.1 \
| sed -ne 's/LINUX-HA-MIB::LHAResourceName.1 = STRING: //p'`
rsc0type=`snmpget -v2c localhost -c public LHAResourceType.1 \
| sed -ne 's/LINUX-HA-MIB::LHAResourceType.1 = INTEGER: //p'`
rsc0node=`snmpget -v2c localhost -c public LHAResourceNode.1 \
| sed -ne 's/LINUX-HA-MIB::LHAResourceNode.1 = STRING: //p'`
rsc0status=`snmpget -v2c localhost -c public LHAResourceStatus.1 \
| sed -ne 's/LINUX-HA-MIB::LHAResourceStatus.1 = INTEGER: //p'`
rsc0ismanaged=`snmpget -v2c localhost -c public LHAResourceIsManaged.1 \
| sed -ne 's/LINUX-HA-MIB::LHAResourceIsManaged.1 = INTEGER: //p'`
rsc0failcount=`snmpget -v2c localhost -c public LHAResourceFailCount.1 \
| sed -ne 's/LINUX-HA-MIB::LHAResourceFailCount.1 = INTEGER: //p'`
rsc0parent=`snmpget -v2c localhost -c public LHAResourceParent.1 \
| sed -ne 's/LINUX-HA-MIB::LHAResourceParent.1 = STRING: //p'`
# check for LHAResourceName
ret=0
echo "rsc0name = $rsc0name, RSC0NAME = $RSC0NAME"
if test "$rsc0name" != "$RSC0NAME"; then
echo "failed to get resource name." >&2
ret=1
fi
# check for LHAResourceType
if test $ret = 0; then
echo "rsc0type = $rsc0type, RSC0TYPE = $RSC0TYPE"
if test "$rsc0type" != "$RSC0TYPE"; then
echo "failed to get resource type." >&2
ret=1
fi
fi
# check for LHAResourceNode
if test $ret = 0; then
echo "rsc0node = $rsc0node, RSC0NODE = $RSC0NODE"
if test "$rsc0node" != "$RSC0NODE"; then
echo "failed to get resource node." >&2
ret=1
fi
fi
# check for LHAResourceStatus
if test $ret = 0; then
echo "rsc0status = $rsc0status, RSC0STATUS = $RSC0STATUS"
if test "$rsc0status" != "$RSC0STATUS"; then
echo "failed to get resource status." >&2
ret=1
fi
fi
# check for LHAResourceIsManaged
if test $ret = 0; then
echo "rsc0ismanaged = $rsc0ismanaged, RSC0ISMANAGED = $RSC0ISMANAGED"
if test "$rsc0ismanaged" != "$RSC0ISMANAGED"; then
echo "failed to get resource ismanaged." >&2
ret=1
fi
fi
# check for LHAResourceFailCount
if test $ret = 0; then
echo "rsc0failcount = $rsc0failcount, RSC0FAILCOUNT = $RSC0FAILCOUNT"
if test "$rsc0failcount" != "$RSC0FAILCOUNT"; then
echo "failed to get resource failcount." >&2
ret=1
fi
fi
# check for LHAResourceParent
if test $ret = 0; then
echo "rsc0parent = $rsc0parent, RSC0PARENT = $RSC0PARENT"
if test "$rsc0parent" != "$RSC0PARENT"; then
echo "failed to get resource parent." >&2
ret=1
fi
fi
# show the result.
if test $ret = 0; then
echo "BasicSanityCheck for SNMP Subagent about CRM resources passed."
else
echo "BasicSanityCheck for SNMP Subagent about CRM resources failed."
fi
kill $HBAGENTPID
if
[ -f $SNMPPIDFILE -a ! -z $SNMPPIDFILE ]
then
kill `cat $SNMPPIDFILE`
rm -f $SNMPPIDFILE
fi
# clear resources
cibadmin --cib_replace -X '<resources/>'
exit $ret
|