4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
38 * Author: PJ Kirner <pjkirner@clusterfs.com>
41 #include <net-snmp/net-snmp-config.h>
42 #include <net-snmp/net-snmp-includes.h>
43 #include <net-snmp/agent/net-snmp-agent-includes.h>
44 #include <net-snmp/utilities.h>
46 #include "lustre-snmp.h"
48 #include <libcfs/util/param.h>
50 #define LNET_CHECK_INTERVAL 500
53 * clusterFileSystems_variables_oid:
54 * this is the top level oid that we want to register under. This
55 * is essentially a prefix, with the suffix appearing in the
60 oid clusterFileSystems_variables_oid[] = { 1,3,6,1,4,1,13140 };
64 * variable7 clusterFileSystems_variables:
65 * this variable defines function callbacks and type return information
66 * for the clusterFileSystems mib section
70 struct variable7 clusterFileSystems_variables[] = {
71 /* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
73 /* sytemInformation 2.1.1. */
74 { SYSVERSION , ASN_OCTET_STR , RONLY , var_clusterFileSystems, 4, { 2,1,1,1 } },
75 { SYSKERNELVERSION , ASN_OCTET_STR , RONLY , var_clusterFileSystems, 4, { 2,1,1,2 } },
76 { SYSHEALTHCHECK , ASN_OCTET_STR , RONLY , var_clusterFileSystems, 4, { 2,1,1,3 } },
77 { SYSSTATUS , ASN_INTEGER , RWRITE, var_clusterFileSystems, 4, { 2,1,1,4 } },
79 /* objectStorageTargets 2.1.2 */
80 { OSDNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,2,1 } },
82 /* objectStorageTargets.osdTable.osdEntry 2.1.2.2.1 */
83 { OSDUUID , ASN_OCTET_STR , RONLY , var_osdTable, 6, { 2,1,2,2,1,2 } },
84 { OSDCOMMONNAME , ASN_OCTET_STR , RONLY , var_osdTable, 6, { 2,1,2,2,1,3 } },
85 { OSDCAPACITY , ASN_COUNTER64 , RONLY , var_osdTable, 6, { 2,1,2,2,1,4 } },
86 { OSDFREECAPACITY , ASN_COUNTER64 , RONLY , var_osdTable, 6, { 2,1,2,2,1,5 } },
87 { OSDOBJECTS , ASN_COUNTER64 , RONLY , var_osdTable, 6, { 2,1,2,2,1,6 } },
88 { OSDFREEOBJECTS , ASN_COUNTER64 , RONLY , var_osdTable, 6, { 2,1,2,2,1,7 } },
90 /* objectStorageClients 2.1.3 */
91 { OSCNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,3,1 } },
93 /* objectStorageClients.oscTable.oscEntry 2.1.3.2.1 */
94 { OSCUUID , ASN_OCTET_STR , RONLY , var_oscTable, 6, { 2,1,3,2,1,2 } },
95 { OSCCOMMONNAME , ASN_OCTET_STR , RONLY , var_oscTable, 6, { 2,1,3,2,1,3 } },
96 { OSCOSTSERVERUUID , ASN_OCTET_STR , RONLY , var_oscTable, 6, { 2,1,3,2,1,4 } },
97 { OSCCAPACITY , ASN_COUNTER64 , RONLY , var_oscTable, 6, { 2,1,3,2,1,5 } },
98 { OSCFREECAPACITY , ASN_COUNTER64 , RONLY , var_oscTable, 6, { 2,1,3,2,1,6 } },
99 { OSCOBJECTS , ASN_COUNTER64 , RONLY , var_oscTable, 6, { 2,1,3,2,1,7 } },
100 { OSCFREEOBJECTS , ASN_COUNTER64 , RONLY , var_oscTable, 6, { 2,1,3,2,1,8 } },
103 /* metaDataServers 2.1.4 */
104 { MDDNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,4,1 } },
106 /* metaDataServers.mddTable.mddEntry 2.1.4.2.1 */
107 { MDDUUID , ASN_OCTET_STR , RONLY , var_mdsTable, 6, { 2,1,4,2,1,2 } },
108 { MDDCOMMONNAME , ASN_OCTET_STR , RONLY , var_mdsTable, 6, { 2,1,4,2,1,3 } },
109 { MDDCAPACITY , ASN_COUNTER64 , RONLY , var_mdsTable, 6, { 2,1,4,2,1,4 } },
110 { MDDFREECAPACITY , ASN_COUNTER64 , RONLY , var_mdsTable, 6, { 2,1,4,2,1,5 } },
111 { MDDFILES , ASN_COUNTER64 , RONLY , var_mdsTable, 6, { 2,1,4,2,1,6 } },
112 { MDDFREEFILES , ASN_COUNTER64 , RONLY , var_mdsTable, 6, { 2,1,4,2,1,7 } },
113 { MDSNBSAMPLEDREQ , ASN_COUNTER64 , RONLY , var_mdsNbSampledReq, 4, { 2,1,4,3 } },
115 /* metaDataClients 2.1.5 */
116 { MDCNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,5,1 } },
118 /* metaDataClients.mdcTable.mdcEntry 2.1.5.2.1 */
119 { MDCUUID , ASN_OCTET_STR , RONLY , var_mdcTable, 6, { 2,1,5,2,1,2 } },
120 { MDCCOMMONNAME , ASN_OCTET_STR , RONLY , var_mdcTable, 6, { 2,1,5,2,1,3 } },
121 { MDCMDSSERVERUUID , ASN_OCTET_STR , RONLY , var_mdcTable, 6, { 2,1,5,2,1,4 } },
122 { MDCCAPACITY , ASN_COUNTER64 , RONLY , var_mdcTable, 6, { 2,1,5,2,1,5 } },
123 { MDCFREECAPACITY , ASN_COUNTER64 , RONLY , var_mdcTable, 6, { 2,1,5,2,1,6 } },
124 { MDCOBJECTS , ASN_COUNTER64 , RONLY , var_mdcTable, 6, { 2,1,5,2,1,7 } },
125 { MDCFREEOBJECTS , ASN_COUNTER64 , RONLY , var_mdcTable, 6, { 2,1,5,2,1,8 } },
127 /* lustreClients 2.1.6 */
128 { CLIMOUNTNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,6,1 } },
130 /* lustreClients.cliMountTable.cliMountEntry 2.1.6.2.1 */
131 { CLIUUID , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,2 } },
132 { CLICOMMONNAME , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,3 } },
133 { CLIMDCUUID , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,4 } },
134 { CLIMDCCOMMONNAME , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,5 } },
135 { CLIUSESLOV , ASN_INTEGER , RONLY , var_cliTable, 6, { 2,1,6,2,1,6 } },
136 { CLILOVUUID , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,7 } },
137 { CLILOVCOMMONNAME , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,8 } },
139 /* logicalObjectVolume 2.1.7 */
140 { LOVNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,7,1 } },
142 /* logicalObjectVolume.osdTable.lovTable 2.1.7.2.1 */
143 { LOVUUID , ASN_OCTET_STR , RONLY , var_lovTable, 6, { 2,1,7,2,1,2 } },
144 { LOVCOMMONNAME , ASN_OCTET_STR , RONLY , var_lovTable, 6, { 2,1,7,2,1,3 } },
145 { LOVNUMOBD , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,4 } },
146 { LOVNUMACTIVEOBD , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,5 } },
147 { LOVCAPACITY , ASN_COUNTER64 , RONLY , var_lovTable, 6, { 2,1,7,2,1,6 } },
148 { LOVFREECAPACITY , ASN_COUNTER64 , RONLY , var_lovTable, 6, { 2,1,7,2,1,7 } },
149 { LOVFILES , ASN_COUNTER64 , RONLY , var_lovTable, 6, { 2,1,7,2,1,8 } },
150 { LOVFREEFILES , ASN_COUNTER64 , RONLY , var_lovTable, 6, { 2,1,7,2,1,9 } },
151 { LOVSTRIPECOUNT , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,10} },
152 { LOVSTRIPEOFFSET , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,11} },
153 { LOVSTRIPESIZE , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,12} },
154 { LOVSTRIPETYPE , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,13} },
156 /* lustreLDLM 2.1.8 */
157 { LDLMNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,8,1 } },
159 /* lustreLDLM.ldlmTable.ldlmEntry 2.1.8.2.1 */
160 { LDLMNAMESPACE , ASN_OCTET_STR , RONLY , var_ldlmTable, 6, { 2,1,8,2,1,2 } },
161 { LDLMLOCKCOUNT , ASN_UNSIGNED , RONLY , var_ldlmTable, 6, { 2,1,8,2,1,3 } },
162 { LDLMUNUSEDLOCKCOUNT , ASN_UNSIGNED , RONLY , var_ldlmTable, 6, { 2,1,8,2,1,4 } },
163 { LDLMRESOURCECOUNT , ASN_UNSIGNED , RONLY , var_ldlmTable, 6, { 2,1,8,2,1,5 } },
165 /* lnetInformation 2.1.9 */
166 { LNETMSGSALLOC, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,1 } },
167 { LNETMSGSMAX, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,2 } },
168 { LNETERRORS, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,3 } },
169 { LNETSENDCOUNT, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,4 } },
170 { LNETRECVCOUNT, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,5 } },
171 { LNETROUTECOUNT, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,6 } },
172 { LNETDROPCOUNT, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,7 } },
173 { LNETSENDBYTES, ASN_COUNTER64, RONLY, var_lnetInformation, 4, { 2,1,9,8 } },
174 { LNETRECVBYTES, ASN_COUNTER64, RONLY, var_lnetInformation, 4, { 2,1,9,9 } },
175 { LNETROUTEBYTES, ASN_COUNTER64, RONLY, var_lnetInformation, 4, { 2,1,9,10 } },
176 { LNETDROPBYTES, ASN_COUNTER64, RONLY, var_lnetInformation, 4, { 2,1,9,11 } },
179 /*****************************************************************************
180 * Function: init_cfsNetSNMPPlugin
182 * Description: Called when the agent starts up
188 ****************************************************************************/
190 void init_lustresnmp(void) {
192 /* register ourselves with the agent to handle our mib tree */
193 REGISTER_MIB("clusterFileSystems",
194 clusterFileSystems_variables, variable7,
195 clusterFileSystems_variables_oid);
197 initialize_trap_handler();
199 DEBUGMSGTL(("lsnmpd", "%s %s\n", __func__, "Initialization Done"));
202 /*****************************************************************************
203 * Function: deinit_cfsNetSNMPPlugin
205 * Description: Called when the agent terminates up
211 ****************************************************************************/
213 void deinit_lustresnmp(void) {
215 /* deregister ourselves with the agent */
216 unregister_mib(clusterFileSystems_variables_oid,
217 sizeof(clusterFileSystems_variables_oid)/
218 sizeof(clusterFileSystems_variables_oid));
220 terminate_trap_handler();
222 DEBUGMSGTL(("lsnmpd", "%s %s\n", __func__, "Termination Done"));
225 /*****************************************************************************
226 * Function: var_clusterFileSystems
228 ****************************************************************************/
230 var_clusterFileSystems(struct variable *vp,
235 WriteMethod **write_method)
239 /* variables we may use later */
240 static long long_ret;
241 static u_long ulong_ret;
242 static unsigned char string[SPRINT_MAX_LEN];
247 if (header_generic(vp,name,length,exact,var_len,write_method)
253 * this is where we do the value assignments for the mib results.
258 if (cfs_get_param_paths(&path, "version") != 0)
260 if( SUCCESS != read_string(path.gl_pathv[0], (char *)string,sizeof(string))){
261 cfs_free_param_data(&path);
264 cfs_free_param_data(&path);
265 *var_len = strlen((char *)string);
266 return (unsigned char *) string;
268 case SYSKERNELVERSION:
269 if (cfs_get_param_paths(&path, "kernel_version") != 0)
271 if( SUCCESS != read_string(path.gl_pathv[0], (char *)string,sizeof(string))){
272 cfs_free_param_data(&path);
275 cfs_free_param_data(&path);
276 *var_len = strlen((char *)string);
277 return (unsigned char *) string;
280 if (cfs_get_param_paths(&path, "health_check") != 0)
282 if( SUCCESS != read_string(path.gl_pathv[0], (char *)string,sizeof(string))){
283 cfs_free_param_data(&path);
286 cfs_free_param_data(&path);
287 *var_len = strlen((char*)string);
288 return (unsigned char *) string;
291 *write_method = write_sysStatus;
292 long_ret = (long) get_sysstatus();
293 if (long_ret != ERROR)
294 return (unsigned char *) &long_ret;
298 if (cfs_get_param_paths(&path, "obdfilter") != 0)
300 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
301 cfs_free_param_data(&path);
304 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
305 cfs_free_param_data(&path);
308 return (unsigned char *) &ulong_ret;
311 if (cfs_get_param_paths(&path, "osc") != 0)
313 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
314 cfs_free_param_data(&path);
317 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
318 cfs_free_param_data(&path);
321 return (unsigned char *) &ulong_ret;
324 if (cfs_get_param_paths(&path, "mds") != 0)
326 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
327 cfs_free_param_data(&path);
330 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
331 cfs_free_param_data(&path);
334 return (unsigned char *) &ulong_ret;
337 if (cfs_get_param_paths(&path, "mdc") != 0)
339 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
340 cfs_free_param_data(&path);
343 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
344 cfs_free_param_data(&path);
347 return (unsigned char *) &ulong_ret;
350 if (cfs_get_param_paths(&path, "llite") != 0)
352 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
353 cfs_free_param_data(&path);
356 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
357 cfs_free_param_data(&path);
360 return (unsigned char *) &ulong_ret;
363 if (cfs_get_param_paths(&path, "lov") != 0)
365 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
366 cfs_free_param_data(&path);
369 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
370 cfs_free_param_data(&path);
373 return (unsigned char *) &ulong_ret;
376 if (cfs_get_param_paths(&path, "ldlm/namespaces") != 0)
378 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
379 cfs_free_param_data(&path);
382 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
383 cfs_free_param_data(&path);
386 return (unsigned char *) &ulong_ret;
394 struct oid_table osd_table[] =
396 { OSDUUID,FILENAME_UUID,oid_table_string_handler},
397 { OSDCOMMONNAME,0,oid_table_obj_name_handler},
398 { OSDCAPACITY,FILENAME_KBYTES_TOTAL, oid_table_c64_kb_handler},
399 { OSDFREECAPACITY,FILENAME_KBYTES_FREE, oid_table_c64_kb_handler},
400 { OSDOBJECTS,FILENAME_FILES_TOTAL, oid_table_c64_kb_handler},
401 { OSDFREEOBJECTS,FILENAME_FILES_FREE, oid_table_c64_kb_handler},
402 { 0,0,0 } /*End of table*/
406 /*****************************************************************************
407 * Function: var_osdTable
409 ****************************************************************************/
411 var_osdTable(struct variable *vp,
416 WriteMethod **write_method)
418 unsigned char *table;
421 if (cfs_get_param_paths(&path, "obdfilter") != 0)
424 table = var_genericTable(vp,name,length,exact,var_len,write_method,
425 path.gl_pathv[0],osd_table);
426 cfs_free_param_data(&path);
430 struct oid_table osc_table[] =
432 { OSCUUID,FILENAME_UUID,oid_table_string_handler},
433 { OSCCOMMONNAME,0,oid_table_obj_name_handler},
434 { OSCOSTSERVERUUID,"ost_server_uuid",oid_table_string_handler},
435 { OSCCAPACITY,FILENAME_KBYTES_TOTAL, oid_table_c64_kb_handler},
436 { OSCFREECAPACITY,FILENAME_KBYTES_FREE, oid_table_c64_kb_handler},
437 { OSCOBJECTS,FILENAME_FILES_TOTAL, oid_table_c64_kb_handler},
438 { OSCFREEOBJECTS,FILENAME_FILES_FREE, oid_table_c64_kb_handler},
439 { 0,0,0 } /*End of table*/
442 /*****************************************************************************
443 * Function: var_oscTable
445 ****************************************************************************/
447 var_oscTable(struct variable *vp,
452 WriteMethod **write_method)
454 unsigned char *table;
457 if (cfs_get_param_paths(&path, "osc") != 0)
460 table = var_genericTable(vp,name,length,exact,var_len,write_method,
461 path.gl_pathv[0],osd_table);
462 cfs_free_param_data(&path);
466 struct oid_table mds_table[] =
468 { MDDUUID,FILENAME_UUID,oid_table_string_handler},
469 { MDDCOMMONNAME,0,oid_table_obj_name_handler},
470 { MDDCAPACITY,FILENAME_KBYTES_TOTAL, oid_table_c64_kb_handler},
471 { MDDFREECAPACITY,FILENAME_KBYTES_FREE, oid_table_c64_kb_handler},
472 { MDDFILES,FILENAME_FILES_TOTAL, oid_table_c64_kb_handler},
473 { MDDFREEFILES,FILENAME_FILES_FREE, oid_table_c64_kb_handler},
474 { 0,0,0 } /*End of table*/
477 /*****************************************************************************
478 * Function: var_mdsTable
480 ****************************************************************************/
482 var_mdsTable(struct variable *vp,
487 WriteMethod **write_method)
489 unsigned char *table;
492 if (cfs_get_param_paths(&path, "mds") != 0)
495 table = var_genericTable(vp,name,length,exact,var_len,write_method,
496 path.gl_pathv[0],osd_table);
497 cfs_free_param_data(&path);
501 struct oid_table mdc_table[] =
503 { MDCUUID,FILENAME_UUID,oid_table_string_handler},
504 { MDCCOMMONNAME,0,oid_table_obj_name_handler},
505 { MDCMDSSERVERUUID,"mds_server_uuid",oid_table_string_handler},
506 { MDCCAPACITY,FILENAME_KBYTES_TOTAL, oid_table_c64_kb_handler},
507 { MDCFREECAPACITY,FILENAME_KBYTES_FREE, oid_table_c64_kb_handler},
508 { MDCOBJECTS,FILENAME_FILES_TOTAL, oid_table_c64_kb_handler},
509 { MDCFREEOBJECTS,FILENAME_FILES_FREE, oid_table_c64_kb_handler},
510 { 0,0,0 } /*End of table*/
514 /*****************************************************************************
515 * Function: var_mdcTable
517 ****************************************************************************/
519 var_mdcTable(struct variable *vp,
524 WriteMethod **write_method)
526 unsigned char *table;
529 if (cfs_get_param_paths(&path, "mdc") != 0)
532 table = var_genericTable(vp,name,length,exact,var_len,write_method,
533 path.gl_pathv[0],osd_table);
534 cfs_free_param_data(&path);
538 struct oid_table cli_table[] =
540 { CLIUUID,FILENAME_UUID,oid_table_string_handler},
541 { CLICOMMONNAME,0,oid_table_obj_name_handler},
542 { CLIMDCUUID,"mdc/" FILENAME_UUID,oid_table_string_handler},
543 { CLIMDCCOMMONNAME,"mdc/" FILENAME_COMMON_NAME,oid_table_string_handler},
544 { CLIUSESLOV,"lov/",oid_table_is_directory_handler},
545 { CLILOVUUID,"lov/" FILENAME_UUID,oid_table_string_handler},
546 { CLILOVCOMMONNAME,"lov/" FILENAME_COMMON_NAME,oid_table_string_handler},
547 { 0,0,0 } /*End of table*/
550 /*****************************************************************************
551 * Function: var_cliTable
553 ****************************************************************************/
555 var_cliTable(struct variable *vp,
560 WriteMethod **write_method)
562 unsigned char *table;
565 if (cfs_get_param_paths(&path, "llite") != 0)
568 table = var_genericTable(vp,name,length,exact,var_len,write_method,
569 path.gl_pathv[0],osd_table);
570 cfs_free_param_data(&path);
574 struct oid_table lov_table[] =
576 { LOVUUID,FILENAME_UUID,oid_table_string_handler},
577 { LOVCOMMONNAME,0,oid_table_obj_name_handler},
578 { LOVNUMOBD,"numobd", oid_table_ulong_handler},
579 { LOVNUMACTIVEOBD,"activeobd", oid_table_ulong_handler},
580 { LOVCAPACITY,FILENAME_KBYTES_TOTAL, oid_table_c64_kb_handler},
581 { LOVFREECAPACITY,FILENAME_KBYTES_FREE, oid_table_c64_kb_handler},
582 { LOVFILES,FILENAME_FILES_TOTAL, oid_table_c64_kb_handler},
583 { LOVFREEFILES,FILENAME_FILES_FREE, oid_table_c64_kb_handler},
584 { LOVSTRIPECOUNT,"stripecount", oid_table_ulong_handler},
585 { LOVSTRIPEOFFSET,"stripeoffset", oid_table_ulong_handler},
586 { LOVSTRIPESIZE,"stripesize", oid_table_ulong_handler},
587 { LOVSTRIPETYPE,"stripetype", oid_table_ulong_handler},
588 { 0,0,0 } /*End of table*/
592 /*****************************************************************************
593 * Function: var_lovTable
595 ****************************************************************************/
597 var_lovTable(struct variable *vp,
602 WriteMethod **write_method)
604 unsigned char *table;
607 if (cfs_get_param_paths(&path, "lov") != 0)
610 table = var_genericTable(vp,name,length,exact,var_len,write_method,
611 path.gl_pathv[0],osd_table);
612 cfs_free_param_data(&path);
616 struct oid_table ldlm_table[] =
618 { LDLMNAMESPACE,0,oid_table_obj_name_handler},
619 { LDLMLOCKCOUNT,"lock_count", oid_table_ulong_handler},
620 { LDLMUNUSEDLOCKCOUNT,"lock_unused_count", oid_table_ulong_handler},
621 { LDLMRESOURCECOUNT,"resource_count", oid_table_ulong_handler},
622 { 0,0,0 } /*End of table*/
626 /*****************************************************************************
627 * Function: var_ldlmTable
629 ****************************************************************************/
631 var_ldlmTable(struct variable *vp,
636 WriteMethod **write_method)
638 unsigned char *table;
641 if (cfs_get_param_paths(&path, "ldlm/namespaces") != 0)
644 table = var_genericTable(vp,name,length,exact,var_len,write_method,
645 path.gl_pathv[0],osd_table);
646 cfs_free_param_data(&path);
650 /*****************************************************************************
651 * Function: var_lnetInformation
653 ****************************************************************************/
655 var_lnetInformation(struct variable *vp,
660 WriteMethod **write_method)
662 /* variables we may use later */
663 static unsigned char string[SPRINT_MAX_LEN];
664 static unsigned int i[7];
665 static unsigned long long ull[4];
666 static unsigned long next_update;
667 static counter64 c64;
668 static unsigned int c32;
669 struct timeval current_tv;
670 unsigned long current;
673 /* Update at most every LNET_STATS_INTERVAL milliseconds */
674 gettimeofday(¤t_tv, NULL);
675 current = current_tv.tv_sec * 1000000 + current_tv.tv_usec;
676 if (current >= next_update) {
677 if (cfs_get_param_paths(&file_path, "stats") != 0)
679 if (read_string(file_path.gl_pathv[0], (char *) string, sizeof(string))
681 cfs_free_param_data(&file_path);
684 cfs_free_param_data(&file_path);
686 sscanf((char *) string,
687 "%u %u %u %u %u %u %u %llu %llu %llu %llu",
688 &i[0], &i[1], &i[2], &i[3], &i[4], &i[5], &i[6],
689 &ull[0], &ull[1], &ull[2], &ull[3]);
691 next_update = current + (LNET_CHECK_INTERVAL * 1000);
694 if (header_generic(vp, name, length, exact, var_len, write_method)
700 *var_len = sizeof(c32);
702 return (unsigned char *) &c32;
704 *var_len = sizeof(c32);
706 return (unsigned char *) &c32;
708 *var_len = sizeof(c32);
710 return (unsigned char *) &c32;
712 *var_len = sizeof(c32);
714 return (unsigned char *) &c32;
716 *var_len = sizeof(c32);
718 return (unsigned char *) &c32;
720 *var_len = sizeof(c32);
722 return (unsigned char *) &c32;
724 *var_len = sizeof(c32);
726 return (unsigned char *) &c32;
728 convert_ull(&c64, ull[0], var_len);
729 return (unsigned char *) &c64;
731 convert_ull(&c64, ull[1], var_len);
732 return (unsigned char *) &c64;
734 convert_ull(&c64, ull[2], var_len);
735 return (unsigned char *) &c64;
737 convert_ull(&c64, ull[3], var_len);
738 return (unsigned char *) &c64;
744 /*****************************************************************************
745 * Function: var_mdsNbSampledReq
747 ****************************************************************************/
749 var_mdsNbSampledReq(struct variable *vp,
754 WriteMethod **write_method)
756 unsigned long long nb_sample=0,min=0,max=0,sum=0,sum_square=0;
757 static counter64 c64;
759 if (header_generic(vp,name,length,exact,var_len,write_method)
763 if( mds_stats_values(STR_REQ_WAITIME,&nb_sample,&min,&max,&sum,&sum_square) == ERROR) return NULL;
765 c64.low = (u_long) (0x0FFFFFFFF & nb_sample);
767 c64.high = (u_long) (0x0FFFFFFFF & nb_sample);
769 *var_len = sizeof(c64);
770 return (unsigned char *) &c64;
774 /*****************************************************************************
775 * Function: write_sysStatus
777 ****************************************************************************/
779 write_sysStatus(int action,
787 static long *long_ret;
794 if (var_val_type != ASN_INTEGER){
795 fprintf(stderr, "write to sysStatus not ASN_INTEGER\n");
796 return SNMP_ERR_WRONGTYPE;
798 if (var_val_len > sizeof(long_ret)){
799 fprintf(stderr,"write to sysStatus: bad length\n");
800 return SNMP_ERR_WRONGLENGTH;
802 if ((*var_val != ONLINE) &&
803 (*var_val != OFFLINE) &&
804 (*var_val != RESTART)){
805 report("%s %s:line %d %s", __FILE__, __FUNCTION__, __LINE__,
806 "sysStatus value is invalid.");
807 return SNMP_ERR_WRONGVALUE;
813 long_ret = (long *) var_val;
820 /* Release any resources that have been allocated */
825 /* The variable has been stored in long_ret for
826 you to use, and you have just been asked to do something with
827 it. Note that anything done here must be reversable in the UNDO case */
828 new_value = *(int *) var_val;
831 lustrefs_ctrl(ONLINE);
835 lustrefs_ctrl(OFFLINE);
839 lustrefs_ctrl(RESTART);
849 /* Back out any changes made in the ACTION case */
854 /* Things are working well, so it's now safe to make the change
855 permanently. Make sure that anything done here can't fail! */
858 return SNMP_ERR_NOERROR;