Hi,

On Wed, Dec 19, 2007 at 01:57:17PM +0900, Keisuke MORI wrote:
> Dejan,
> 
> Thank you for commiting the SNMP extention to the repository, but
> Would you please include the following patches along with it?
> 
> 1) SNMP: fix a problem on displaying an unmanaged group and to check it
>    in SNMPAgentSanityCheck.
> 
> 2) SNMP: the hbagent obeys to the syslog output policy.
>    (This one is the same one as I posted here at
>    http://www.gossamer-threads.com/lists/linuxha/dev/44440 )

Sure. Thanks for the patches.

Dejan

> These should be needed if the SNMP extention is going to be
> included in 2.1.3.
> I hope it isn't too late...
> 
> Regards,
> 
> Keisuke MORI
> NTT DATA Intellilink Corporation
> 

Content-Description: hbagentv2_unmanaged.patch
> diff -r b7dd4d1b5d08 snmp_subagent/SNMPAgentSanityCheck.in
> --- a/snmp_subagent/SNMPAgentSanityCheck.in   Wed Dec 19 13:14:14 2007 +0900
> +++ b/snmp_subagent/SNMPAgentSanityCheck.in   Wed Dec 19 13:23:50 2007 +0900
> @@ -59,6 +59,7 @@ sleep 3
>  
>  # start the linux-ha snmp subagent
>  @libdir@/heartbeat/hbagent -d &
> +HBAGENTPID=$!
>  sleep 5
>  
>  # get the nodename for node0 and node1
> @@ -112,6 +113,9 @@ RSC0TYPE="primitive(1)"
>  RSC0TYPE="primitive(1)"
>  RSC0NODE="$NODE0"
>  RSC0STATUS="started(2)"
> +RSC0ISMANAGED="managed(1)"
> +RSC0FAILCOUNT="0"
> +RSC0PARENT=""
>  cibadmin --cib_create -o resources \
>    -X '<primitive id="prmDummy" class="ocf" type="Dummy" 
> provider="heartbeat"/>'
>  sleep 3
> @@ -125,6 +129,12 @@ rsc0node=`snmpget -v2c localhost -c publ
>    | 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
> @@ -161,19 +171,45 @@ if test $ret = 0; then
>       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."
> -     exit 0
>  else 
>       echo "BasicSanityCheck for SNMP Subagent about CRM resources failed."
> -     exit 1
> -fi
> -
> -
> +fi
> +
> +kill $HBAGENTPID
>  if
>    [ -f $SNMPPIDFILE -a ! -z $SNMPPIDFILE ]
>  then
>    kill `cat $SNMPPIDFILE`
> -  rm $SNMPPIDFILE
> -fi
> +  rm -f $SNMPPIDFILE
> +fi
> +
> +exit $ret
> diff -r b7dd4d1b5d08 snmp_subagent/hbagentv2.c
> --- a/snmp_subagent/hbagentv2.c       Wed Dec 19 13:14:14 2007 +0900
> +++ b/snmp_subagent/hbagentv2.c       Wed Dec 19 13:23:50 2007 +0900
> @@ -69,7 +69,7 @@ init_resource_table_v2(void)
>   * Return the number of resources.
>   */
>  static int
> -update_resources_recursively(GListPtr reslist, int index)
> +update_resources_recursively(GListPtr reslist, GListPtr nodelist, int index)
>  {
>  
>      if (reslist == NULL) {
> @@ -82,7 +82,7 @@ update_resources_recursively(GListPtr re
>      slist_iter(rsc, resource_t, reslist, lpc1,
>      {
>          cl_log(LOG_DEBUG, "resource %s processing.", rsc->id);
> -        slist_iter(node, node_t, rsc->allowed_nodes, lpc2,
> +        slist_iter(node, node_t, nodelist, lpc2,
>          {
>              struct hb_rsinfov2 *rsinfo;
>              enum rsc_role_e rsstate;
> @@ -98,12 +98,19 @@ update_resources_recursively(GListPtr re
>  
>              /* using a temp var to suppress casting warning of the compiler 
> */
>              rsstate = rsc->fns->state(rsc, TRUE);
> -            if (pe_find_node_id(rsc->running_on, node->details->id) == NULL) 
> {
> -                /*
> -                 * if the resource is not running on current node,
> -                 * its status is "stopped(1)".
> -                 */
> -                rsstate = RSC_ROLE_STOPPED;
> +            {
> +                GListPtr running_on_nodes = NULL;
> +
> +                rsc->fns->location(rsc, &running_on_nodes, TRUE);
> +                if (pe_find_node_id(
> +                    running_on_nodes, node->details->id) == NULL) {
> +                    /*
> +                     * if the resource is not running on current node,
> +                     * its status is "stopped(1)".
> +                     */
> +                    rsstate = RSC_ROLE_STOPPED;
> +                }
> +               g_list_free(running_on_nodes);
>              }
>              rsinfo->status = RSC_ROLE_E2AGENTSTATUS(rsstate);
>              rsinfo->node = cl_strdup(node->details->uname);
> @@ -152,7 +159,8 @@ update_resources_recursively(GListPtr re
>          }); /* end slist_iter(node) */
>  
>          /* add resources recursively for group/clone/master */
> -        index = update_resources_recursively(rsc->fns->children(rsc), index);
> +        index = update_resources_recursively(rsc->fns->children(rsc),
> +            nodelist, index);
>  
>      }); /* end slist_iter(rsc) */
>  
> @@ -194,7 +202,7 @@ update_resource_table_v2(void)
>      /* parse cib xml info (cib_object). */
>      cluster_status(&data_set);
>  
> -    index = update_resources_recursively(data_set.resources, 1);
> +    index = update_resources_recursively(data_set.resources, data_set.nodes, 
> 1);
>      if (index == HA_FAIL) {
>          cl_log(LOG_ERR, "Update resources failed.");
>  

Content-Description: snmp_syslog.patch
> diff -r d739f7e38999 -r b7dd4d1b5d08 snmp_subagent/hbagent.c
> --- a/snmp_subagent/hbagent.c Tue Dec 18 10:12:39 2007 -0700
> +++ b/snmp_subagent/hbagent.c Wed Dec 19 13:14:14 2007 +0900
> @@ -564,7 +564,10 @@ init_heartbeat(void)
>       hb = NULL;
>  
>       cl_log_set_entity("lha-snmpagent");
> -     cl_log_set_facility(LOG_USER);
> +     cl_log_set_facility(HA_LOG_FACILITY);
> +
> +     /* Use logd if it's enabled by heartbeat */
> +     cl_inherit_logging_environment(0);
>  
>       hb = ll_cluster_new("heartbeat");
>  

> _______________________________________________________
> Linux-HA-Dev: [email protected]
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/


-- 
Dejan
_______________________________________________________
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