1 /*  raritan-mib.c - data to monitor Raritan PDUs (Basic and Complex)
2  *
3  *  Copyright (C) 2008
4  *  			Arnaud Quette <ArnaudQuette@Eaton.com>
5  *
6  *  Sponsored by Eaton <http://www.eaton.com>
7  *   and MGE Office Protection Systems <http://www.mgeops.com>
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */
25 
26 #include "raritan-pdu-mib.h"
27 
28 #define RARITAN_MIB_VERSION	"0.5"
29 
30 /* Raritan MIB
31  * this one uses the same MIB as Eaton Revelation,
32  * but with a different entry point */
33 #define	RARITAN_BASE_OID					".1.3.6.1.4.1.13742"
34 #define RARITAN_SYSOID						RARITAN_BASE_OID
35 #define RARITAN_OID_MODEL_NAME				".1.3.6.1.4.1.13742.1.1.12.0"
36 
37 #define DO_OFF		0
38 #define DO_ON		1
39 #define DO_CYCLE	2
40 
41 static info_lkp_t outlet_status_info[] = {
42 	{ -1, "error" },
43 	{ 0, "off" },
44 	{ 1, "on" },
45 	{ 2, "cycling" }, /* transitional status */
46 	{ 0, NULL }
47 };
48 
49 /* Snmp2NUT lookup table for Raritan MIB */
50 static snmp_info_t raritan_mib[] = {
51 	/* Device page */
52 	{ "device.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Raritan",
53 		SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
54 	{ "device.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.12.0",
55 		"Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL },
56 	{ "device.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.2.0", "",
57 		SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL },
58 	{ "device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu",
59 		SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
60 	{ "device.macaddr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.6.0", "",
61 		SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL },
62 
63 	/* UPS page */
64 	{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Raritan",
65 		SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
66 	{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.12.0",
67 		"Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL },
68 	{ "ups.id", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.13.0",
69 		"unknown", SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL },
70 	{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.2.0", "",
71 		SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL },
72 	{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.1.0", "",
73 		SU_FLAG_STATIC | SU_FLAG_OK, NULL },
74 	{ "ups.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu",
75 		SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
76 	{ "ups.temperature", 0, 1, ".1.3.6.1.4.1.13742.1.3.1.5.0", NULL, 0, NULL, NULL },
77 
78 	/* Outlet page */
79 	{ "outlet.id", 0, 1, NULL, "0", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
80 	{ "outlet.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, NULL, "All outlets",
81 		SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
82 	{ "outlet.count", 0, 1, ".1.3.6.1.4.1.13742.1.2.1.0", "0", 0, NULL },
83 	{ "outlet.current", 0, 0.001, ".1.3.6.1.4.1.13742.1.3.1.1" ".0", NULL, 0, NULL, NULL },
84 	{ "outlet.voltage", 0, 0.001, ".1.3.6.1.4.1.13742.1.3.1.2" ".0", NULL, 0, NULL, NULL },
85 	{ "outlet.realpower", 0, 1.0, ".1.3.6.1.4.1.13742.1.3.1.3" ".0", NULL, 0, NULL, NULL },
86 	{ "outlet.power", 0, 1.0, ".1.3.6.1.4.1.13742.1.3.1.4" ".0", NULL, 0, NULL, NULL },
87 
88 	/* outlet template definition
89 	 * Caution: the index of the data start at 0, while the name is +1
90 	 * ie outlet.1 => <OID>.0 */
91 	{ "outlet.%i.switchable", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.1.%i", "yes", SU_FLAG_STATIC | SU_OUTLET, NULL, NULL },
92 	{ "outlet.%i.id", 0, 1, NULL, "%i", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK | SU_OUTLET, NULL, NULL },
93 	{ "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.2.2.1.2.%i", NULL, SU_OUTLET, NULL, NULL },
94 	{ "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", NULL, SU_FLAG_OK | SU_OUTLET, &outlet_status_info[0], NULL },
95 	{ "outlet.%i.current", 0, 0.001, ".1.3.6.1.4.1.13742.1.2.2.1.4.%i", NULL, SU_OUTLET, NULL, NULL },
96 	{ "outlet.%i.current.maximum", 0, 0.001, ".1.3.6.1.4.1.13742.1.2.2.1.5.%i", NULL, SU_OUTLET, NULL, NULL },
97 	{ "outlet.%i.realpower", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.7.%i", NULL, SU_OUTLET, NULL, NULL },
98 	{ "outlet.%i.voltage", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.6.%i", NULL, SU_OUTLET, NULL, NULL },
99 	{ "outlet.%i.powerfactor", 0, 0.01, ".1.3.6.1.4.1.13742.1.2.2.1.9.%i", NULL, SU_OUTLET, NULL, NULL },
100 	{ "outlet.%i.power", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.8.%i", NULL, SU_OUTLET, NULL, NULL },
101 
102 	/* FIXME:
103 	 * - delay for startup/shutdown sequence
104 	 * - support for Ambient page
105 		temperatureSensorCount" src="snmp:$sysoid.2.1.0
106 		ambient.temperature src="snmp:$sysoid.2.2.1.3.$indiceSensor => seems dumb!
107 		ambient.humidity src="snmp:$sysoid.2.4.1.3.$indiceSensor
108 	 */
109 
110 	/* instant commands. */
111 	/* Note that load.cycle might be replaced by / mapped on shutdown.reboot */
112 	/* no counterpart found!
113 	{ "outlet.load.off", 0, DO_OFF, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", NULL, SU_TYPE_CMD, NULL, NULL },
114 	{ "outlet.load.on", 0, DO_ON, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", NULL, SU_TYPE_CMD, NULL, NULL },
115 	{ "outlet.load.cycle", 0, DO_CYCLE, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", NULL, SU_TYPE_CMD, NULL, NULL }, */
116 	{ "outlet.%i.load.off", 0, DO_OFF, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL },
117 	{ "outlet.%i.load.on", 0, DO_ON, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL },
118 	{ "outlet.%i.load.cycle", 0, DO_CYCLE, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL },
119 
120 	/* end of structure. */
121 	{ NULL, 0, 0, NULL, NULL, 0, NULL, NULL }
122 };
123 
124 mib2nut_info_t	raritan = { "raritan", RARITAN_MIB_VERSION, NULL, RARITAN_OID_MODEL_NAME, raritan_mib, RARITAN_SYSOID };
125