Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux-HA: Dev

[PATCH] Added support for different version of the MPC MIBs

 

 

Linux-HA dev RSS feed   Index | Next | Previous | View Threaded


chollya at satgate

Sep 9, 2009, 2:38 AM

Post #1 of 4 (1070 views)
Permalink
[PATCH] Added support for different version of the MPC MIBs

# HG changeset patch
# User Denis Chapligin <chollya [at] satgate>
# Date 1252489058 -10800
# Node ID 5d4dbc751c2141930af33adf6e5654282e339fa6
# Parent 3bd40c1bfba54a2d573ca2760c5bb784ce7bc3ef
Added support for different version of the MPC MIBs
Added README documentation
Outlet oids renamed to groups
Retrieval of number of groups is better documented now

diff -r 3bd40c1bfba5 -r 5d4dbc751c21 lib/plugins/stonith/README.wti_mpc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/plugins/stonith/README.wti_mpc Wed Sep 09 12:37:38 2009 +0300
@@ -0,0 +1,85 @@
+STONITH module for WTI MPC
+--------------------------
+
+
+****Introduction.
+
+wti_mpc module uses snmp for controlling the MPC power distribution unit. It has
+been tested with MPC-8H and MPC-18H and should be compatible with the whole
+MPC series:
+ * MPC-20*
+ * MPC-16*
+ * MPC-18*
+ * MPC-8*
+
+****Unit configuration.
+
+wti_mpc STONITH modules uses SNMP v1, therefore it should be configured on the
+device side. To do so, you should login to device, go to "Network
+configuration" (/N), select "SNMP access" (25) and turn it on (enable/1). At the
+SNMP access screnn set "Version" (2) to "V1/V2 Only", set "Read only" (3) to
+"No and set any "Community" (10) you want. You may also set other options as
+you need. You may check your setup by ussuing the following command:
+
+ snmpwalk -v1 -c <community> <host> .1.3.6.1.2.1.1.1.0
+
+and result should be something like this:
+
+ SNMPv2-MIB::sysDescr.0 = STRING: Linux 85.195.135.236 2.4.18_mvl30-cllf #1991 Sun Mar 16 14:39:29 PST 2008 ppc
+
+
+****Plugin configuration.
+
+ Plugin declares the following configuration variables:
+
+ *ipaddr - ip address or hostname of a MPC unit.
+ *port - ip port, should be 161, as MPC listens for incoming SNMP
+ packets on that port. It is made for future use actually.
+ *community - Community that you've specified on previous step.
+ *mib_version - Should be 3 for MPC devices with firmware version 1.62
+ and later. 1 is for firmware version 1.44 and below.
+ 2 is unused right now, if you have device, with mib V2
+ feel free to contact me and i'll add it.
+
+****MIB version issue
+
+ WTI guys have several time changed OIDs, used by MPC devices. I own two
+types of the devices:
+ *With firmware v 1.44 which is compatible with MIB version 1
+ *With firmware v 1.62 which is compatible with MIB version 3
+
+I suppose there are exist MIB v2, but i cannot find it and i'm not able
+to test it.
+Anyway, this plugin supports both V1 and V3 versions, and the correct version
+is selected by the "mib-version" configuration parameter. Default value is "1",
+so if you do not specify this parameter or assign a unsupported value to it,
+it will fall back to mib version 1.
+
+****Outlets and groups
+
+ MPC devices forces uniqie names of the outlets. This is a big problem
+for STONITH plugin, cause it uses nodes unames as outlet names, so in case
+you have a node with several power plugs, you should have set the node uname
+as name of all the plugs. The MPC device simply doesn't allows this.
+ So, this plugin works with a GROUPS instead of a PLUGS. You may give
+any unique names for your physical outlets on the MPC, but you MUST create
+a plug group, name it using node's uname and include plugs, corresponding to
+that particular node to this group. It should be done even for node with
+single power supply. Some example:
+
+ Let's pretend you have a node "atest", with two power cords, connected
+to plugs A1 and B1. You have to create a group ("Plug grouping parameters" (/G)
+-> Add Plug Group to directory (2)), name it "atest" ("Plug Group Name (1)) and
+assugn plugs A1 and B1 to that group ("Plug access" (2)). Now save your
+configuration and try to retrieve host list:
+
+ stonith -t wti_mpc ipaddr=<host> port=161 community=<community> mib-version=<version> -l
+
+result should be:
+
+ atest
+
+
+------------------
+(C) Denis Chapligin <chollya [at] satgate>, SatGate, 2009
+
diff -r 3bd40c1bfba5 -r 5d4dbc751c21 lib/plugins/stonith/wti_mpc.c
--- a/lib/plugins/stonith/wti_mpc.c Tue Sep 08 12:26:49 2009 +0200
+++ b/lib/plugins/stonith/wti_mpc.c Wed Sep 09 12:37:38 2009 +0300
@@ -1,5 +1,5 @@
/*
- * Stonith module for APC Masterswitch (SNMP)
+ * Stonith module for WTI MPC (SNMP)
* Copyright (c) 2001 Andreas Piesk <a.piesk [at] gmx>
* Mangled by Sun Jiang Dong <sunjd [at] cn>, IBM, 2005
*
@@ -139,9 +139,12 @@

/* oids */
#define OID_IDENT ".1.3.6.1.2.1.1.5.0"
-#define OID_NUM_OUTLETS ".1.3.6.1.4.1.2634.3.1.3.1.2.%u"
-#define OID_OUTLET_NAMES ".1.3.6.1.4.1.2634.3.1.3.1.2.%u"
-#define OID_OUTLET_STATE ".1.3.6.1.4.1.2634.3.1.3.1.3.%i"
+
+#define OID_GROUP_NAMES_V1 ".1.3.6.1.4.1.2634.3.1.3.1.2.%u"
+#define OID_GROUP_STATE_V1 ".1.3.6.1.4.1.2634.3.1.3.1.3.%i"
+
+#define OID_GROUP_NAMES_V3 ".1.3.6.1.4.1.2634.3.100.300.1.2.%u"
+#define OID_GROUP_STATE_V3 ".1.3.6.1.4.1.2634.3.100.300.1.3.%i"

#define MAX_OUTLETS 128

@@ -157,6 +160,7 @@
/* own defines */
#define MAX_STRING 128
#define ST_PORT "port"
+#define ST_MIBVERSION "mib-version"

/* structur of stonith object */
struct pluginDevice {
@@ -167,6 +171,7 @@
char * hostname; /* masterswitch's hostname */
/* or ip addr */
int port; /* snmp port */
+ int mib_version; /* mib version to use */
char * community; /* snmp community (r/w) */
int num_outlets; /* number of outlets */
};
@@ -193,11 +198,28 @@
XML_PORT_LONGDESC \
XML_PARAMETER_END

+#define XML_MIBVERSION_SHORTDESC \
+ XML_PARM_SHORTDESC_BEGIN("en") \
+ ST_MIBVERSION \
+ XML_PARM_SHORTDESC_END
+
+#define XML_MIBVERSION_LONGDESC \
+ XML_MIBVERSION_LONGDESC_BEGIN("en") \
+ "Version number of MPC MIB that we should use. Valid values are 1 (for 1.44 firmware) and 3 (for 1.62 firmware and later)" \
+ XML_PARM_LONGDESC_END
+
+#define XML_MIBVERSION_PARM \
+ XML_PARAMETER_BEGIN(ST_MIBVERSION, "string", "1") \
+ XML_PORT_SHORTDESC \
+ XML_PORT_LONGDESC \
+ XML_PARAMETER_END
+
static const char *apcmastersnmpXML =
XML_PARAMETERS_BEGIN
XML_IPADDR_PARM
XML_PORT_PARM
XML_COMMUNITY_PARM
+ XML_MIBVERSION_PARM
XML_PARAMETERS_END;

/*
@@ -444,7 +466,18 @@
for (j = 0; j < ad->num_outlets; ++j) {

/* prepare objname */
- snprintf(objname, MAX_STRING, OID_OUTLET_NAMES, j + 1);
+ switch (ad->mib_version) {
+ case 3:
+ snprintf(objname,MAX_STRING,OID_GROUP_NAMES_V3,j+1);
+ break;
+ case 1:
+ default:
+ snprintf(objname,MAX_STRING,OID_GROUP_NAMES_V1,j+1);
+ break;
+ }
+ if (Debug) {
+ LOG(PIL_DEBUG, "%s: using %s as group names oid", __FUNCTION__, objname);
+ }

/* read outlet name */
if ((outlet_name = MPC_read(ad->sptr, objname, ASN_OCTET_STR)) ==
@@ -514,7 +547,15 @@
for (outlet = 1; outlet <= ad->num_outlets; outlet++) {

/* prepare objname */
- snprintf(objname, MAX_STRING, OID_OUTLET_NAMES, outlet);
+ switch (ad->mib_version) {
+ case 3:
+ snprintf(objname,MAX_STRING,OID_GROUP_NAMES_V3,outlet);
+ break;
+ case 1:
+ default:
+ snprintf(objname,MAX_STRING,OID_GROUP_NAMES_V1,outlet);
+ break;
+ }

/* read outlet name */
if ((outlet_name = MPC_read(ad->sptr, objname, ASN_OCTET_STR))
@@ -567,7 +608,17 @@
/* Turn them all off */

/* prepare objnames */
- snprintf(objname, MAX_STRING, OID_OUTLET_STATE, found_outlet);
+
+ switch (ad->mib_version) {
+ case 3:
+ snprintf(objname,MAX_STRING,OID_GROUP_STATE_V3,found_outlet);
+ break;
+ case 1:
+ default:
+ snprintf(objname,MAX_STRING,OID_GROUP_STATE_V1,found_outlet);
+ break;
+ }
+
snprintf(value, MAX_STRING, "%i", req_oid);

/* send reboot cmd */
@@ -588,7 +639,7 @@
static const char **
wti_mpc_get_confignames(StonithPlugin * s)
{
- static const char * ret[] = {ST_IPADDR, ST_PORT, ST_COMMUNITY, NULL};
+ static const char * ret[] = {ST_IPADDR, ST_PORT, ST_COMMUNITY, ST_MIBVERSION, NULL};
return ret;
}

@@ -608,6 +659,7 @@
{ {ST_IPADDR, NULL}
, {ST_PORT, NULL}
, {ST_COMMUNITY, NULL}
+ , {ST_MIBVERSION, NULL}
, {NULL, NULL}
};

@@ -624,6 +676,8 @@
sd->port = atoi(namestocopy[1].s_value);
PluginImports->mfree(namestocopy[1].s_value);
sd->community = namestocopy[2].s_value;
+ sd->mib_version = atoi(namestocopy[3].s_value);
+ PluginImports->mfree(namestocopy[3].s_value);

/* try to resolve the hostname/ip-address */
if (gethostbyname(sd->hostname) != NULL) {
@@ -633,11 +687,27 @@
/* now try to get a snmp session */
if ((sd->sptr = MPC_open(sd->hostname, sd->port, sd->community)) != NULL) {

- /* ok, get the number of outlets from the mpc */
+ /* ok, get the number of groups from the mpc */
sd->num_outlets=0;
- /* We scan goup name from 1 to MAX_OUTLETS */
+ /* We scan goup names table starting from 1 to MAX_OUTLETS */
+ /* and increase num_outlet counter on every group entry with name */
+ /* first entry without name is the mark of the end of the group table */
for (mo=1;mo<MAX_OUTLETS;mo++) {
- snprintf(objname,MAX_STRING,OID_NUM_OUTLETS,mo);
+ switch (sd->mib_version) {
+ case 3:
+ snprintf(objname,MAX_STRING,OID_GROUP_NAMES_V3,mo);
+ break;
+ case 1:
+ default:
+ snprintf(objname,MAX_STRING,OID_GROUP_NAMES_V1,mo);
+ break;
+ }
+
+ if (Debug) {
+ LOG(PIL_DEBUG, "%s: used for groupTable retrieval: %s."
+ , __FUNCTION__, objname);
+ }
+
if ((i = MPC_read(sd->sptr, objname, ASN_OCTET_STR)) == NULL) {
LOG(PIL_CRIT
, "%s: cannot read number of outlets."
@@ -777,6 +847,7 @@
ad->sptr = NULL;
ad->hostname = NULL;
ad->community = NULL;
+ ad->mib_version=1;
ad->idinfo = DEVICE;
ad->sp.s_ops = &wti_mpcOps;

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


dejanmm at fastmail

Sep 9, 2009, 7:32 AM

Post #2 of 4 (1000 views)
Permalink
Re: [PATCH] Added support for different version of the MPC MIBs [In reply to]

Hi Denis,

The readme is very good and to the point. Excellent work.

It would be great if the plugin could lookup the firmware release
in wti_mpc_new() and decide which MIB version to use.

Many thanks for your work!

Cheers,

Dejan

On Wed, Sep 09, 2009 at 12:38:45PM +0300, Denis Chapligin wrote:
> # HG changeset patch
> # User Denis Chapligin <chollya [at] satgate>
> # Date 1252489058 -10800
> # Node ID 5d4dbc751c2141930af33adf6e5654282e339fa6
> # Parent 3bd40c1bfba54a2d573ca2760c5bb784ce7bc3ef
> Added support for different version of the MPC MIBs
> Added README documentation
> Outlet oids renamed to groups
> Retrieval of number of groups is better documented now
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


chollya at satgate

Sep 9, 2009, 8:05 AM

Post #3 of 4 (1001 views)
Permalink
Re: [PATCH] Added support for different version of the MPC MIBs [In reply to]

Hi Dejan,

On Wed, 9 Sep 2009 16:32:39 +0200
Dejan Muhamedagic <dejanmm [at] fastmail> wrote:

>
> It would be great if the plugin could lookup the firmware release
> in wti_mpc_new() and decide which MIB version to use.

I'm not sure if it is possible at all. There are exist sysDescr
variable, that identifies kernel version and build number and there are
no other ways, to retrieve other version information by SNMP (at least i
do not know proper oids). sysDescr contains string with the kernel
version, kernel build number and other stuff.
So i have to write a mapping between all possible sysDescr
strings (or kernel versions/builds) and firmware versions and this is
impossible. I know nothing about MIB v2 and can't find it on the WTI
website and i do not have all of the firmware builds. So it is
impossible to create such mapping.

On the other hand, we could try to ask the MPC device for every known
GROUP_NAMES oid for example, but this is unsafe. In the future same oids
could have different meanings, resulting in undefined behaviour of a
plugin. Not good :)

I even had idea to use mnemonic oid names from MIBs, but it means that
user should use the same firmware on all of his MPCs and this could be
quite unacceptable.

--
Denis Chapligin
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev [at] lists
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


dejanmm at fastmail

Sep 11, 2009, 3:12 AM

Post #4 of 4 (973 views)
Permalink
Re: [PATCH] Added support for different version of the MPC MIBs [In reply to]

Hi Denis,

On Wed, Sep 09, 2009 at 06:05:52PM +0300, Denis Chapligin wrote:
> Hi Dejan,
>
> On Wed, 9 Sep 2009 16:32:39 +0200
> Dejan Muhamedagic <dejanmm [at] fastmail> wrote:
>
> >
> > It would be great if the plugin could lookup the firmware release
> > in wti_mpc_new() and decide which MIB version to use.
>
> I'm not sure if it is possible at all. There are exist sysDescr
> variable, that identifies kernel version and build number and there are
> no other ways, to retrieve other version information by SNMP (at least i
> do not know proper oids). sysDescr contains string with the kernel
> version, kernel build number and other stuff.
> So i have to write a mapping between all possible sysDescr
> strings (or kernel versions/builds) and firmware versions and this is
> impossible. I know nothing about MIB v2 and can't find it on the WTI
> website and i do not have all of the firmware builds. So it is
> impossible to create such mapping.

Yes, and it would be a problem with future releases, etc.

> On the other hand, we could try to ask the MPC device for every known
> GROUP_NAMES oid for example, but this is unsafe. In the future same oids
> could have different meanings, resulting in undefined behaviour of a
> plugin. Not good :)

Right.

> I even had idea to use mnemonic oid names from MIBs, but it means that
> user should use the same firmware on all of his MPCs and this could be
> quite unacceptable.

Sure. Many thanks for investigating this further. Let's hope that
the users will read the instructions :)

Cheers,

Dejan

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

Linux-HA dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.