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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
34 * Author: PJ Kirner <pjkirner@clusterfs.com>
37 #include <net-snmp/net-snmp-config.h>
38 #include <net-snmp/net-snmp-includes.h>
39 #include <net-snmp/agent/net-snmp-agent-includes.h>
40 #include <net-snmp/utilities.h>
42 #include "lustre-snmp.h"
44 #include <libcfs/util/param.h>
46 #define LNET_CHECK_INTERVAL 500
49 * clusterFileSystems_variables_oid:
50 * this is the top level oid that we want to register under. This
51 * is essentially a prefix, with the suffix appearing in the
56 oid clusterFileSystems_variables_oid[] = { 1,3,6,1,4,1,13140 };
60 * variable7 clusterFileSystems_variables:
61 * this variable defines function callbacks and type return information
62 * for the clusterFileSystems mib section
66 struct variable7 clusterFileSystems_variables[] = {
67 /* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
69 /* sytemInformation 2.1.1. */
70 { SYSVERSION , ASN_OCTET_STR , RONLY , var_clusterFileSystems, 4, { 2,1,1,1 } },
71 { SYSKERNELVERSION , ASN_OCTET_STR , RONLY , var_clusterFileSystems, 4, { 2,1,1,2 } },
72 { SYSHEALTHCHECK , ASN_OCTET_STR , RONLY , var_clusterFileSystems, 4, { 2,1,1,3 } },
73 { SYSSTATUS , ASN_INTEGER , RWRITE, var_clusterFileSystems, 4, { 2,1,1,4 } },
75 /* objectStorageTargets 2.1.2 */
76 { OSDNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,2,1 } },
78 /* objectStorageTargets.osdTable.osdEntry 2.1.2.2.1 */
79 { OSDUUID , ASN_OCTET_STR , RONLY , var_osdTable, 6, { 2,1,2,2,1,2 } },
80 { OSDCOMMONNAME , ASN_OCTET_STR , RONLY , var_osdTable, 6, { 2,1,2,2,1,3 } },
81 { OSDCAPACITY , ASN_COUNTER64 , RONLY , var_osdTable, 6, { 2,1,2,2,1,4 } },
82 { OSDFREECAPACITY , ASN_COUNTER64 , RONLY , var_osdTable, 6, { 2,1,2,2,1,5 } },
83 { OSDOBJECTS , ASN_COUNTER64 , RONLY , var_osdTable, 6, { 2,1,2,2,1,6 } },
84 { OSDFREEOBJECTS , ASN_COUNTER64 , RONLY , var_osdTable, 6, { 2,1,2,2,1,7 } },
86 /* objectStorageClients 2.1.3 */
87 { OSCNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,3,1 } },
89 /* objectStorageClients.oscTable.oscEntry 2.1.3.2.1 */
90 { OSCUUID , ASN_OCTET_STR , RONLY , var_oscTable, 6, { 2,1,3,2,1,2 } },
91 { OSCCOMMONNAME , ASN_OCTET_STR , RONLY , var_oscTable, 6, { 2,1,3,2,1,3 } },
92 { OSCOSTSERVERUUID , ASN_OCTET_STR , RONLY , var_oscTable, 6, { 2,1,3,2,1,4 } },
93 { OSCCAPACITY , ASN_COUNTER64 , RONLY , var_oscTable, 6, { 2,1,3,2,1,5 } },
94 { OSCFREECAPACITY , ASN_COUNTER64 , RONLY , var_oscTable, 6, { 2,1,3,2,1,6 } },
95 { OSCOBJECTS , ASN_COUNTER64 , RONLY , var_oscTable, 6, { 2,1,3,2,1,7 } },
96 { OSCFREEOBJECTS , ASN_COUNTER64 , RONLY , var_oscTable, 6, { 2,1,3,2,1,8 } },
99 /* metaDataServers 2.1.4 */
100 { MDDNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,4,1 } },
102 /* metaDataServers.mddTable.mddEntry 2.1.4.2.1 */
103 { MDDUUID , ASN_OCTET_STR , RONLY , var_mdsTable, 6, { 2,1,4,2,1,2 } },
104 { MDDCOMMONNAME , ASN_OCTET_STR , RONLY , var_mdsTable, 6, { 2,1,4,2,1,3 } },
105 { MDDCAPACITY , ASN_COUNTER64 , RONLY , var_mdsTable, 6, { 2,1,4,2,1,4 } },
106 { MDDFREECAPACITY , ASN_COUNTER64 , RONLY , var_mdsTable, 6, { 2,1,4,2,1,5 } },
107 { MDDFILES , ASN_COUNTER64 , RONLY , var_mdsTable, 6, { 2,1,4,2,1,6 } },
108 { MDDFREEFILES , ASN_COUNTER64 , RONLY , var_mdsTable, 6, { 2,1,4,2,1,7 } },
109 { MDSNBSAMPLEDREQ , ASN_COUNTER64 , RONLY , var_mdsNbSampledReq, 4, { 2,1,4,3 } },
111 /* metaDataClients 2.1.5 */
112 { MDCNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,5,1 } },
114 /* metaDataClients.mdcTable.mdcEntry 2.1.5.2.1 */
115 { MDCUUID , ASN_OCTET_STR , RONLY , var_mdcTable, 6, { 2,1,5,2,1,2 } },
116 { MDCCOMMONNAME , ASN_OCTET_STR , RONLY , var_mdcTable, 6, { 2,1,5,2,1,3 } },
117 { MDCMDSSERVERUUID , ASN_OCTET_STR , RONLY , var_mdcTable, 6, { 2,1,5,2,1,4 } },
118 { MDCCAPACITY , ASN_COUNTER64 , RONLY , var_mdcTable, 6, { 2,1,5,2,1,5 } },
119 { MDCFREECAPACITY , ASN_COUNTER64 , RONLY , var_mdcTable, 6, { 2,1,5,2,1,6 } },
120 { MDCOBJECTS , ASN_COUNTER64 , RONLY , var_mdcTable, 6, { 2,1,5,2,1,7 } },
121 { MDCFREEOBJECTS , ASN_COUNTER64 , RONLY , var_mdcTable, 6, { 2,1,5,2,1,8 } },
123 /* lustreClients 2.1.6 */
124 { CLIMOUNTNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,6,1 } },
126 /* lustreClients.cliMountTable.cliMountEntry 2.1.6.2.1 */
127 { CLIUUID , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,2 } },
128 { CLICOMMONNAME , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,3 } },
129 { CLIMDCUUID , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,4 } },
130 { CLIMDCCOMMONNAME , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,5 } },
131 { CLIUSESLOV , ASN_INTEGER , RONLY , var_cliTable, 6, { 2,1,6,2,1,6 } },
132 { CLILOVUUID , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,7 } },
133 { CLILOVCOMMONNAME , ASN_OCTET_STR , RONLY , var_cliTable, 6, { 2,1,6,2,1,8 } },
135 /* logicalObjectVolume 2.1.7 */
136 { LOVNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,7,1 } },
138 /* logicalObjectVolume.osdTable.lovTable 2.1.7.2.1 */
139 { LOVUUID , ASN_OCTET_STR , RONLY , var_lovTable, 6, { 2,1,7,2,1,2 } },
140 { LOVCOMMONNAME , ASN_OCTET_STR , RONLY , var_lovTable, 6, { 2,1,7,2,1,3 } },
141 { LOVNUMOBD , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,4 } },
142 { LOVNUMACTIVEOBD , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,5 } },
143 { LOVCAPACITY , ASN_COUNTER64 , RONLY , var_lovTable, 6, { 2,1,7,2,1,6 } },
144 { LOVFREECAPACITY , ASN_COUNTER64 , RONLY , var_lovTable, 6, { 2,1,7,2,1,7 } },
145 { LOVFILES , ASN_COUNTER64 , RONLY , var_lovTable, 6, { 2,1,7,2,1,8 } },
146 { LOVFREEFILES , ASN_COUNTER64 , RONLY , var_lovTable, 6, { 2,1,7,2,1,9 } },
147 { LOVSTRIPECOUNT , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,10} },
148 { LOVSTRIPEOFFSET , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,11} },
149 { LOVSTRIPESIZE , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,12} },
150 { LOVSTRIPETYPE , ASN_UNSIGNED , RONLY , var_lovTable, 6, { 2,1,7,2,1,13} },
152 /* lustreLDLM 2.1.8 */
153 { LDLMNUMBER , ASN_UNSIGNED , RONLY , var_clusterFileSystems, 4, { 2,1,8,1 } },
155 /* lustreLDLM.ldlmTable.ldlmEntry 2.1.8.2.1 */
156 { LDLMNAMESPACE , ASN_OCTET_STR , RONLY , var_ldlmTable, 6, { 2,1,8,2,1,2 } },
157 { LDLMLOCKCOUNT , ASN_UNSIGNED , RONLY , var_ldlmTable, 6, { 2,1,8,2,1,3 } },
158 { LDLMUNUSEDLOCKCOUNT , ASN_UNSIGNED , RONLY , var_ldlmTable, 6, { 2,1,8,2,1,4 } },
159 { LDLMRESOURCECOUNT , ASN_UNSIGNED , RONLY , var_ldlmTable, 6, { 2,1,8,2,1,5 } },
161 /* lnetInformation 2.1.9 */
162 { LNETMSGSALLOC, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,1 } },
163 { LNETMSGSMAX, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,2 } },
164 { LNETERRORS, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,3 } },
165 { LNETSENDCOUNT, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,4 } },
166 { LNETRECVCOUNT, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,5 } },
167 { LNETROUTECOUNT, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,6 } },
168 { LNETDROPCOUNT, ASN_UNSIGNED, RONLY, var_lnetInformation, 4, { 2,1,9,7 } },
169 { LNETSENDBYTES, ASN_COUNTER64, RONLY, var_lnetInformation, 4, { 2,1,9,8 } },
170 { LNETRECVBYTES, ASN_COUNTER64, RONLY, var_lnetInformation, 4, { 2,1,9,9 } },
171 { LNETROUTEBYTES, ASN_COUNTER64, RONLY, var_lnetInformation, 4, { 2,1,9,10 } },
172 { LNETDROPBYTES, ASN_COUNTER64, RONLY, var_lnetInformation, 4, { 2,1,9,11 } },
175 /*****************************************************************************
176 * Function: init_cfsNetSNMPPlugin
178 * Description: Called when the agent starts up
184 ****************************************************************************/
186 void init_lustresnmp(void) {
188 /* register ourselves with the agent to handle our mib tree */
189 REGISTER_MIB("clusterFileSystems",
190 clusterFileSystems_variables, variable7,
191 clusterFileSystems_variables_oid);
193 initialize_trap_handler();
195 DEBUGMSGTL(("lsnmpd", "%s %s\n", __func__, "Initialization Done"));
198 /*****************************************************************************
199 * Function: deinit_cfsNetSNMPPlugin
201 * Description: Called when the agent terminates up
207 ****************************************************************************/
209 void deinit_lustresnmp(void) {
211 /* deregister ourselves with the agent */
212 unregister_mib(clusterFileSystems_variables_oid,
213 sizeof(clusterFileSystems_variables_oid)/
214 sizeof(clusterFileSystems_variables_oid));
216 terminate_trap_handler();
218 DEBUGMSGTL(("lsnmpd", "%s %s\n", __func__, "Termination Done"));
221 /*****************************************************************************
222 * Function: var_clusterFileSystems
224 ****************************************************************************/
226 var_clusterFileSystems(struct variable *vp,
231 WriteMethod **write_method)
235 /* variables we may use later */
236 static long long_ret;
237 static u_long ulong_ret;
238 static unsigned char string[SPRINT_MAX_LEN];
243 if (header_generic(vp,name,length,exact,var_len,write_method)
249 * this is where we do the value assignments for the mib results.
254 if (cfs_get_param_paths(&path, "version") != 0)
256 if( SUCCESS != read_string(path.gl_pathv[0], (char *)string,sizeof(string))){
257 cfs_free_param_data(&path);
260 cfs_free_param_data(&path);
261 *var_len = strlen((char *)string);
262 return (unsigned char *) string;
264 case SYSKERNELVERSION:
265 if (cfs_get_param_paths(&path, "kernel_version") != 0)
267 if( SUCCESS != read_string(path.gl_pathv[0], (char *)string,sizeof(string))){
268 cfs_free_param_data(&path);
271 cfs_free_param_data(&path);
272 *var_len = strlen((char *)string);
273 return (unsigned char *) string;
276 if (cfs_get_param_paths(&path, "health_check") != 0)
278 if( SUCCESS != read_string(path.gl_pathv[0], (char *)string,sizeof(string))){
279 cfs_free_param_data(&path);
282 cfs_free_param_data(&path);
283 *var_len = strlen((char*)string);
284 return (unsigned char *) string;
287 *write_method = write_sysStatus;
288 long_ret = (long) get_sysstatus();
289 if (long_ret != ERROR)
290 return (unsigned char *) &long_ret;
294 if (cfs_get_param_paths(&path, "obdfilter") != 0)
296 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
297 cfs_free_param_data(&path);
300 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
301 cfs_free_param_data(&path);
304 return (unsigned char *) &ulong_ret;
307 if (cfs_get_param_paths(&path, "osc") != 0)
309 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
310 cfs_free_param_data(&path);
313 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
314 cfs_free_param_data(&path);
317 return (unsigned char *) &ulong_ret;
320 if (cfs_get_param_paths(&path, "mds") != 0)
322 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
323 cfs_free_param_data(&path);
326 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
327 cfs_free_param_data(&path);
330 return (unsigned char *) &ulong_ret;
333 if (cfs_get_param_paths(&path, "mdc") != 0)
335 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
336 cfs_free_param_data(&path);
339 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
340 cfs_free_param_data(&path);
343 return (unsigned char *) &ulong_ret;
346 if (cfs_get_param_paths(&path, "llite") != 0)
348 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
349 cfs_free_param_data(&path);
352 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
353 cfs_free_param_data(&path);
356 return (unsigned char *) &ulong_ret;
359 if (cfs_get_param_paths(&path, "lov") != 0)
361 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
362 cfs_free_param_data(&path);
365 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
366 cfs_free_param_data(&path);
369 return (unsigned char *) &ulong_ret;
372 if (cfs_get_param_paths(&path, "ldlm/namespaces") != 0)
374 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
375 cfs_free_param_data(&path);
378 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
379 cfs_free_param_data(&path);
382 return (unsigned char *) &ulong_ret;
390 struct oid_table osd_table[] =
392 { OSDUUID,FILENAME_UUID,oid_table_string_handler},
393 { OSDCOMMONNAME,0,oid_table_obj_name_handler},
394 { OSDCAPACITY,FILENAME_KBYTES_TOTAL, oid_table_c64_kb_handler},
395 { OSDFREECAPACITY,FILENAME_KBYTES_FREE, oid_table_c64_kb_handler},
396 { OSDOBJECTS,FILENAME_FILES_TOTAL, oid_table_c64_kb_handler},
397 { OSDFREEOBJECTS,FILENAME_FILES_FREE, oid_table_c64_kb_handler},
398 { 0,0,0 } /*End of table*/
402 /*****************************************************************************
403 * Function: var_osdTable
405 ****************************************************************************/
407 var_osdTable(struct variable *vp,
412 WriteMethod **write_method)
414 unsigned char *table;
417 if (cfs_get_param_paths(&path, "obdfilter") != 0)
420 table = var_genericTable(vp,name,length,exact,var_len,write_method,
421 path.gl_pathv[0],osd_table);
422 cfs_free_param_data(&path);
426 struct oid_table osc_table[] =
428 { OSCUUID,FILENAME_UUID,oid_table_string_handler},
429 { OSCCOMMONNAME,0,oid_table_obj_name_handler},
430 { OSCOSTSERVERUUID,"ost_server_uuid",oid_table_string_handler},
431 { OSCCAPACITY,FILENAME_KBYTES_TOTAL, oid_table_c64_kb_handler},
432 { OSCFREECAPACITY,FILENAME_KBYTES_FREE, oid_table_c64_kb_handler},
433 { OSCOBJECTS,FILENAME_FILES_TOTAL, oid_table_c64_kb_handler},
434 { OSCFREEOBJECTS,FILENAME_FILES_FREE, oid_table_c64_kb_handler},
435 { 0,0,0 } /*End of table*/
438 /*****************************************************************************
439 * Function: var_oscTable
441 ****************************************************************************/
443 var_oscTable(struct variable *vp,
448 WriteMethod **write_method)
450 unsigned char *table;
453 if (cfs_get_param_paths(&path, "osc") != 0)
456 table = var_genericTable(vp,name,length,exact,var_len,write_method,
457 path.gl_pathv[0],osd_table);
458 cfs_free_param_data(&path);
462 struct oid_table mds_table[] =
464 { MDDUUID,FILENAME_UUID,oid_table_string_handler},
465 { MDDCOMMONNAME,0,oid_table_obj_name_handler},
466 { MDDCAPACITY,FILENAME_KBYTES_TOTAL, oid_table_c64_kb_handler},
467 { MDDFREECAPACITY,FILENAME_KBYTES_FREE, oid_table_c64_kb_handler},
468 { MDDFILES,FILENAME_FILES_TOTAL, oid_table_c64_kb_handler},
469 { MDDFREEFILES,FILENAME_FILES_FREE, oid_table_c64_kb_handler},
470 { 0,0,0 } /*End of table*/
473 /*****************************************************************************
474 * Function: var_mdsTable
476 ****************************************************************************/
478 var_mdsTable(struct variable *vp,
483 WriteMethod **write_method)
485 unsigned char *table;
488 if (cfs_get_param_paths(&path, "mds") != 0)
491 table = var_genericTable(vp,name,length,exact,var_len,write_method,
492 path.gl_pathv[0],osd_table);
493 cfs_free_param_data(&path);
497 struct oid_table mdc_table[] =
499 { MDCUUID,FILENAME_UUID,oid_table_string_handler},
500 { MDCCOMMONNAME,0,oid_table_obj_name_handler},
501 { MDCMDSSERVERUUID,"mds_server_uuid",oid_table_string_handler},
502 { MDCCAPACITY,FILENAME_KBYTES_TOTAL, oid_table_c64_kb_handler},
503 { MDCFREECAPACITY,FILENAME_KBYTES_FREE, oid_table_c64_kb_handler},
504 { MDCOBJECTS,FILENAME_FILES_TOTAL, oid_table_c64_kb_handler},
505 { MDCFREEOBJECTS,FILENAME_FILES_FREE, oid_table_c64_kb_handler},
506 { 0,0,0 } /*End of table*/
510 /*****************************************************************************
511 * Function: var_mdcTable
513 ****************************************************************************/
515 var_mdcTable(struct variable *vp,
520 WriteMethod **write_method)
522 unsigned char *table;
525 if (cfs_get_param_paths(&path, "mdc") != 0)
528 table = var_genericTable(vp,name,length,exact,var_len,write_method,
529 path.gl_pathv[0],osd_table);
530 cfs_free_param_data(&path);
534 struct oid_table cli_table[] =
536 { CLIUUID,FILENAME_UUID,oid_table_string_handler},
537 { CLICOMMONNAME,0,oid_table_obj_name_handler},
538 { CLIMDCUUID,"mdc/" FILENAME_UUID,oid_table_string_handler},
539 { CLIMDCCOMMONNAME,"mdc/" FILENAME_COMMON_NAME,oid_table_string_handler},
540 { CLIUSESLOV,"lov/",oid_table_is_directory_handler},
541 { CLILOVUUID,"lov/" FILENAME_UUID,oid_table_string_handler},
542 { CLILOVCOMMONNAME,"lov/" FILENAME_COMMON_NAME,oid_table_string_handler},
543 { 0,0,0 } /*End of table*/
546 /*****************************************************************************
547 * Function: var_cliTable
549 ****************************************************************************/
551 var_cliTable(struct variable *vp,
556 WriteMethod **write_method)
558 unsigned char *table;
561 if (cfs_get_param_paths(&path, "llite") != 0)
564 table = var_genericTable(vp,name,length,exact,var_len,write_method,
565 path.gl_pathv[0],osd_table);
566 cfs_free_param_data(&path);
570 struct oid_table lov_table[] =
572 { LOVUUID,FILENAME_UUID,oid_table_string_handler},
573 { LOVCOMMONNAME,0,oid_table_obj_name_handler},
574 { LOVNUMOBD,"numobd", oid_table_ulong_handler},
575 { LOVNUMACTIVEOBD,"activeobd", oid_table_ulong_handler},
576 { LOVCAPACITY,FILENAME_KBYTES_TOTAL, oid_table_c64_kb_handler},
577 { LOVFREECAPACITY,FILENAME_KBYTES_FREE, oid_table_c64_kb_handler},
578 { LOVFILES,FILENAME_FILES_TOTAL, oid_table_c64_kb_handler},
579 { LOVFREEFILES,FILENAME_FILES_FREE, oid_table_c64_kb_handler},
580 { LOVSTRIPECOUNT,"stripecount", oid_table_ulong_handler},
581 { LOVSTRIPEOFFSET,"stripeoffset", oid_table_ulong_handler},
582 { LOVSTRIPESIZE,"stripesize", oid_table_ulong_handler},
583 { LOVSTRIPETYPE,"stripetype", oid_table_ulong_handler},
584 { 0,0,0 } /*End of table*/
588 /*****************************************************************************
589 * Function: var_lovTable
591 ****************************************************************************/
593 var_lovTable(struct variable *vp,
598 WriteMethod **write_method)
600 unsigned char *table;
603 if (cfs_get_param_paths(&path, "lov") != 0)
606 table = var_genericTable(vp,name,length,exact,var_len,write_method,
607 path.gl_pathv[0],osd_table);
608 cfs_free_param_data(&path);
612 struct oid_table ldlm_table[] =
614 { LDLMNAMESPACE,0,oid_table_obj_name_handler},
615 { LDLMLOCKCOUNT,"lock_count", oid_table_ulong_handler},
616 { LDLMUNUSEDLOCKCOUNT,"lock_unused_count", oid_table_ulong_handler},
617 { LDLMRESOURCECOUNT,"resource_count", oid_table_ulong_handler},
618 { 0,0,0 } /*End of table*/
622 /*****************************************************************************
623 * Function: var_ldlmTable
625 ****************************************************************************/
627 var_ldlmTable(struct variable *vp,
632 WriteMethod **write_method)
634 unsigned char *table;
637 if (cfs_get_param_paths(&path, "ldlm/namespaces") != 0)
640 table = var_genericTable(vp,name,length,exact,var_len,write_method,
641 path.gl_pathv[0],osd_table);
642 cfs_free_param_data(&path);
646 /*****************************************************************************
647 * Function: var_lnetInformation
649 ****************************************************************************/
651 var_lnetInformation(struct variable *vp,
656 WriteMethod **write_method)
658 /* variables we may use later */
659 static unsigned char string[SPRINT_MAX_LEN];
660 static unsigned int i[7];
661 static unsigned long long ull[4];
662 static unsigned long next_update;
663 static counter64 c64;
664 static unsigned int c32;
665 struct timeval current_tv;
666 unsigned long current;
669 /* Update at most every LNET_STATS_INTERVAL milliseconds */
670 gettimeofday(¤t_tv, NULL);
671 current = current_tv.tv_sec * 1000000 + current_tv.tv_usec;
672 if (current >= next_update) {
673 if (cfs_get_param_paths(&file_path, "stats") != 0)
675 if (read_string(file_path.gl_pathv[0], (char *) string, sizeof(string))
677 cfs_free_param_data(&file_path);
680 cfs_free_param_data(&file_path);
682 sscanf((char *) string,
683 "%u %u %u %u %u %u %u %llu %llu %llu %llu",
684 &i[0], &i[1], &i[2], &i[3], &i[4], &i[5], &i[6],
685 &ull[0], &ull[1], &ull[2], &ull[3]);
687 next_update = current + (LNET_CHECK_INTERVAL * 1000);
690 if (header_generic(vp, name, length, exact, var_len, write_method)
696 *var_len = sizeof(c32);
698 return (unsigned char *) &c32;
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 convert_ull(&c64, ull[0], var_len);
725 return (unsigned char *) &c64;
727 convert_ull(&c64, ull[1], var_len);
728 return (unsigned char *) &c64;
730 convert_ull(&c64, ull[2], var_len);
731 return (unsigned char *) &c64;
733 convert_ull(&c64, ull[3], var_len);
734 return (unsigned char *) &c64;
740 /*****************************************************************************
741 * Function: var_mdsNbSampledReq
743 ****************************************************************************/
745 var_mdsNbSampledReq(struct variable *vp,
750 WriteMethod **write_method)
752 unsigned long long nb_sample=0,min=0,max=0,sum=0,sum_square=0;
753 static counter64 c64;
755 if (header_generic(vp,name,length,exact,var_len,write_method)
759 if( mds_stats_values(STR_REQ_WAITIME,&nb_sample,&min,&max,&sum,&sum_square) == ERROR) return NULL;
761 c64.low = (u_long) (0x0FFFFFFFF & nb_sample);
763 c64.high = (u_long) (0x0FFFFFFFF & nb_sample);
765 *var_len = sizeof(c64);
766 return (unsigned char *) &c64;
770 /*****************************************************************************
771 * Function: write_sysStatus
773 ****************************************************************************/
775 write_sysStatus(int action,
783 static long *long_ret;
790 if (var_val_type != ASN_INTEGER){
791 fprintf(stderr, "write to sysStatus not ASN_INTEGER\n");
792 return SNMP_ERR_WRONGTYPE;
794 if (var_val_len > sizeof(long_ret)){
795 fprintf(stderr,"write to sysStatus: bad length\n");
796 return SNMP_ERR_WRONGLENGTH;
798 if ((*var_val != ONLINE) &&
799 (*var_val != OFFLINE) &&
800 (*var_val != RESTART)){
801 report("%s %s:line %d %s", __FILE__, __FUNCTION__, __LINE__,
802 "sysStatus value is invalid.");
803 return SNMP_ERR_WRONGVALUE;
809 long_ret = (long *) var_val;
816 /* Release any resources that have been allocated */
821 /* The variable has been stored in long_ret for
822 you to use, and you have just been asked to do something with
823 it. Note that anything done here must be reversable in the UNDO case */
824 new_value = *(int *) var_val;
827 lustrefs_ctrl(ONLINE);
831 lustrefs_ctrl(OFFLINE);
835 lustrefs_ctrl(RESTART);
845 /* Back out any changes made in the ACTION case */
850 /* Things are working well, so it's now safe to make the change
851 permanently. Make sure that anything done here can't fail! */
854 return SNMP_ERR_NOERROR;