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/
33 * Author: PJ Kirner <pjkirner@clusterfs.com>
36 #include <net-snmp/net-snmp-config.h>
37 #include <net-snmp/net-snmp-includes.h>
38 #include <net-snmp/agent/net-snmp-agent-includes.h>
39 #include <net-snmp/utilities.h>
41 #include "lustre-snmp.h"
43 #include <libcfs/util/param.h>
45 #define LNET_CHECK_INTERVAL 500
48 * clusterFileSystems_variables_oid:
49 * this is the top level oid that we want to register under. This
50 * is essentially a prefix, with the suffix appearing in the
55 oid clusterFileSystems_variables_oid[] = { 1,3,6,1,4,1,13140 };
59 * variable7 clusterFileSystems_variables:
60 * this variable defines function callbacks and type return information
61 * for the clusterFileSystems mib section
65 struct variable7 clusterFileSystems_variables[] = {
66 /* systemInformation 2.1.1. */
69 .type = ASN_OCTET_STR,
71 .findVar = var_clusterFileSystems,
73 .name = { 2, 1, 1, 1 }
76 .magic = SYSKERNELVERSION,
77 .type = ASN_OCTET_STR,
79 .findVar = var_clusterFileSystems,
81 .name = { 2, 1, 1, 2 }
84 .magic = SYSHEALTHCHECK,
85 .type = ASN_OCTET_STR,
87 .findVar = var_clusterFileSystems,
89 .name = { 2, 1, 1, 3 }
95 .findVar = var_clusterFileSystems,
97 .name = { 2, 1, 1, 4 }
100 /* objectStorageTargets 2.1.2 */
103 .type = ASN_UNSIGNED,
105 .findVar = var_clusterFileSystems,
107 .name = { 2, 1, 2, 1 }
110 /* objectStorageTargets.osdTable.osdEntry 2.1.2.2.1 */
113 .type = ASN_OCTET_STR,
115 .findVar = var_osdTable,
117 .name = { 2, 1, 2, 2, 1, 2 }
120 .magic = OSDCOMMONNAME,
121 .type = ASN_OCTET_STR,
123 .findVar = var_osdTable,
125 .name = { 2, 1, 2, 2, 1, 3 }
128 .magic = OSDCAPACITY,
129 .type = ASN_COUNTER64,
131 .findVar = var_osdTable,
133 .name = { 2, 1, 2, 2, 1, 4 }
136 .magic = OSDFREECAPACITY,
137 .type = ASN_COUNTER64,
139 .findVar = var_osdTable,
141 .name = { 2, 1, 2, 2, 1, 5 }
145 .type = ASN_COUNTER64,
147 .findVar = var_osdTable,
149 .name = { 2, 1, 2, 2, 1, 6 }
152 .magic = OSDFREEOBJECTS,
153 .type = ASN_COUNTER64,
155 .findVar = var_osdTable,
157 .name = { 2, 1, 2, 2, 1, 7 }
160 /* objectStorageClients 2.1.3 */
163 .type = ASN_UNSIGNED,
165 .findVar = var_clusterFileSystems,
167 .name = { 2, 1, 3, 1 }
170 /* objectStorageClients.oscTable.oscEntry 2.1.3.2.1 */
173 .type = ASN_OCTET_STR,
175 .findVar = var_oscTable,
177 .name = { 2, 1, 3, 2, 1, 2 }
180 .magic = OSCCOMMONNAME,
181 .type = ASN_OCTET_STR,
183 .findVar = var_oscTable,
185 .name = { 2, 1, 3, 2, 1, 3 }
188 .magic = OSCOSTSERVERUUID,
189 .type = ASN_OCTET_STR,
191 .findVar = var_oscTable,
193 .name = { 2, 1, 3, 2, 1, 4 }
196 .magic = OSCCAPACITY,
197 .type = ASN_COUNTER64,
199 .findVar = var_oscTable,
201 .name = { 2, 1, 3, 2, 1, 5 }
204 .magic = OSCFREECAPACITY,
205 .type = ASN_COUNTER64,
207 .findVar = var_oscTable,
209 .name = { 2, 1, 3, 2, 1, 6 }
213 .type = ASN_COUNTER64,
215 .findVar = var_oscTable,
217 .name = { 2, 1, 3, 2, 1, 7 }
220 .magic = OSCFREEOBJECTS,
221 .type = ASN_COUNTER64,
223 .findVar = var_oscTable,
225 .name = { 2, 1, 3, 2, 1, 8 }
229 /* metaDataServers 2.1.4 */
232 .type = ASN_UNSIGNED,
234 .findVar = var_clusterFileSystems,
236 .name = { 2, 1, 4, 1 }
239 /* metaDataServers.mddTable.mddEntry 2.1.4.2.1 */
242 .type = ASN_OCTET_STR,
244 .findVar = var_mdsTable,
246 .name = { 2, 1, 4, 2, 1, 2 }
249 .magic = MDDCOMMONNAME,
250 .type = ASN_OCTET_STR,
252 .findVar = var_mdsTable,
254 .name = { 2, 1, 4, 2, 1, 3 }
257 .magic = MDDCAPACITY,
258 .type = ASN_COUNTER64,
260 .findVar = var_mdsTable,
262 .name = { 2, 1, 4, 2, 1, 4 }
265 .magic = MDDFREECAPACITY,
266 .type = ASN_COUNTER64,
268 .findVar = var_mdsTable,
270 .name = { 2, 1, 4, 2, 1, 5 }
274 .type = ASN_COUNTER64,
276 .findVar = var_mdsTable,
278 .name = { 2, 1, 4, 2, 1, 6 }
281 .magic = MDDFREEFILES,
282 .type = ASN_COUNTER64,
284 .findVar = var_mdsTable,
286 .name = { 2, 1, 4, 2, 1, 7 }
289 .magic = MDSNBSAMPLEDREQ,
290 .type = ASN_COUNTER64,
292 .findVar = var_mdsNbSampledReq,
294 .name = { 2, 1, 4, 3 }
297 /* metaDataClients 2.1.5 */
300 .type = ASN_UNSIGNED,
302 .findVar = var_clusterFileSystems,
304 .name = { 2, 1, 5, 1 }
307 /* metaDataClients.mdcTable.mdcEntry 2.1.5.2.1 */
310 .type = ASN_OCTET_STR,
312 .findVar = var_mdcTable,
314 .name = { 2, 1, 5, 2, 1, 2 }
317 .magic = MDCCOMMONNAME,
318 .type = ASN_OCTET_STR,
320 .findVar = var_mdcTable,
322 .name = { 2, 1, 5, 2, 1, 3 }
325 .magic = MDCMDSSERVERUUID,
326 .type = ASN_OCTET_STR,
328 .findVar = var_mdcTable,
330 .name = { 2, 1, 5, 2, 1, 4 }
333 .magic = MDCCAPACITY,
334 .type = ASN_COUNTER64,
336 .findVar = var_mdcTable,
338 .name = { 2, 1, 5, 2, 1, 5 }
341 .magic = MDCFREECAPACITY,
342 .type = ASN_COUNTER64,
344 .findVar = var_mdcTable,
346 .name = { 2, 1, 5, 2, 1, 6 }
350 .type = ASN_COUNTER64,
352 .findVar = var_mdcTable,
354 .name = { 2, 1, 5, 2, 1, 7 }
357 .magic = MDCFREEOBJECTS,
358 .type = ASN_COUNTER64,
360 .findVar = var_mdcTable,
362 .name = { 2, 1, 5, 2, 1, 8 }
365 /* lustreClients 2.1.6 */
367 .magic = CLIMOUNTNUMBER,
368 .type = ASN_UNSIGNED,
370 .findVar = var_clusterFileSystems,
372 .name = { 2, 1, 6, 1 }
375 /* lustreClients.cliMountTable.cliMountEntry 2.1.6.2.1 */
378 .type = ASN_OCTET_STR,
380 .findVar = var_cliTable,
382 .name = { 2, 1, 6, 2, 1, 2 }
385 .magic = CLICOMMONNAME,
386 .type = ASN_OCTET_STR,
388 .findVar = var_cliTable,
390 .name = { 2, 1, 6, 2, 1, 3 }
394 .type = ASN_OCTET_STR,
396 .findVar = var_cliTable,
398 .name = { 2, 1, 6, 2, 1, 4 }
401 .magic = CLIMDCCOMMONNAME,
402 .type = ASN_OCTET_STR,
404 .findVar = var_cliTable,
406 .name = { 2, 1, 6, 2, 1, 5 }
412 .findVar = var_cliTable,
414 .name = { 2, 1, 6, 2, 1, 6 }
418 .type = ASN_OCTET_STR,
420 .findVar = var_cliTable,
422 .name = { 2, 1, 6, 2, 1, 7 }
425 .magic = CLILOVCOMMONNAME,
426 .type = ASN_OCTET_STR,
428 .findVar = var_cliTable,
430 .name = { 2, 1, 6, 2, 1, 8 }
433 /* logicalObjectVolume 2.1.7 */
436 .type = ASN_UNSIGNED,
438 .findVar = var_clusterFileSystems,
440 .name = { 2, 1, 7, 1 }
443 /* logicalObjectVolume.osdTable.lovTable 2.1.7.2.1 */
446 .type = ASN_OCTET_STR,
448 .findVar = var_lovTable,
450 .name = { 2, 1, 7, 2, 1, 2 }
453 .magic = LOVCOMMONNAME,
454 .type = ASN_OCTET_STR,
456 .findVar = var_lovTable,
458 .name = { 2, 1, 7, 2, 1, 3 }
462 .type = ASN_UNSIGNED,
464 .findVar = var_lovTable,
466 .name = { 2, 1, 7, 2, 1, 4 }
469 .magic = LOVNUMACTIVEOBD,
470 .type = ASN_UNSIGNED,
472 .findVar = var_lovTable,
474 .name = { 2, 1, 7, 2, 1, 5 }
477 .magic = LOVCAPACITY,
478 .type = ASN_COUNTER64,
480 .findVar = var_lovTable,
482 .name = { 2, 1, 7, 2, 1, 6 }
485 .magic = LOVFREECAPACITY,
486 .type = ASN_COUNTER64,
488 .findVar = var_lovTable,
490 .name = { 2, 1, 7, 2, 1, 7 }
494 .type = ASN_COUNTER64,
496 .findVar = var_lovTable,
498 .name = { 2, 1, 7, 2, 1, 8 }
501 .magic = LOVFREEFILES,
502 .type = ASN_COUNTER64,
504 .findVar = var_lovTable,
506 .name = { 2, 1, 7, 2, 1, 9 }
509 .magic = LOVSTRIPECOUNT,
510 .type = ASN_UNSIGNED,
512 .findVar = var_lovTable,
514 .name = { 2, 1, 7, 2, 1, 10}
517 .magic = LOVSTRIPEOFFSET,
518 .type = ASN_UNSIGNED,
520 .findVar = var_lovTable,
522 .name = { 2, 1, 7, 2, 1, 11}
525 .magic = LOVSTRIPESIZE,
526 .type = ASN_UNSIGNED,
528 .findVar = var_lovTable,
530 .name = { 2, 1, 7, 2, 1, 12}
533 .magic = LOVSTRIPETYPE,
534 .type = ASN_UNSIGNED,
536 .findVar = var_lovTable,
538 .name = { 2, 1, 7, 2, 1, 13}
541 /* lustreLDLM 2.1.8 */
544 .type = ASN_UNSIGNED,
546 .findVar = var_clusterFileSystems,
548 .name = { 2, 1, 8, 1 }
551 /* lustreLDLM.ldlmTable.ldlmEntry 2.1.8.2.1 */
553 .magic = LDLMNAMESPACE,
554 .type = ASN_OCTET_STR,
556 .findVar = var_ldlmTable,
558 .name = { 2, 1, 8, 2, 1, 2 }
561 .magic = LDLMLOCKCOUNT,
562 .type = ASN_UNSIGNED,
564 .findVar = var_ldlmTable,
566 .name = { 2, 1, 8, 2, 1, 3 }
569 .magic = LDLMUNUSEDLOCKCOUNT,
570 .type = ASN_UNSIGNED,
572 .findVar = var_ldlmTable,
574 .name = { 2, 1, 8, 2, 1, 4 }
577 .magic = LDLMRESOURCECOUNT,
578 .type = ASN_UNSIGNED,
580 .findVar = var_ldlmTable,
582 .name = { 2, 1, 8, 2, 1, 5 }
585 /* lnetInformation 2.1.9 */
587 .magic = LNETMSGSALLOC,
588 .type = ASN_UNSIGNED,
590 .findVar = var_lnetInformation,
592 .name = { 2, 1, 9, 1 }
595 .magic = LNETMSGSMAX,
596 .type = ASN_UNSIGNED,
598 .findVar = var_lnetInformation,
600 .name = { 2, 1, 9, 2 }
604 .type = ASN_UNSIGNED,
606 .findVar = var_lnetInformation,
608 .name = { 2, 1, 9, 3 }
611 .magic = LNETSENDCOUNT,
612 .type = ASN_UNSIGNED,
614 .findVar = var_lnetInformation,
616 .name = { 2, 1, 9, 4 }
619 .magic = LNETRECVCOUNT,
620 .type = ASN_UNSIGNED,
622 .findVar = var_lnetInformation,
624 .name = { 2, 1, 9, 5 }
627 .magic = LNETROUTECOUNT,
628 .type = ASN_UNSIGNED,
630 .findVar = var_lnetInformation,
632 .name = { 2, 1, 9, 6 }
635 .magic = LNETDROPCOUNT,
636 .type = ASN_UNSIGNED,
638 .findVar = var_lnetInformation,
640 .name = { 2, 1, 9, 7 }
643 .magic = LNETSENDBYTES,
644 .type = ASN_COUNTER64,
646 .findVar = var_lnetInformation,
648 .name = { 2, 1, 9, 8 }
651 .magic = LNETRECVBYTES,
652 .type = ASN_COUNTER64,
654 .findVar = var_lnetInformation,
656 .name = { 2, 1, 9, 9 }
659 .magic = LNETROUTEBYTES,
660 .type = ASN_COUNTER64,
662 .findVar = var_lnetInformation,
664 .name = { 2, 1, 9, 10 }
667 .magic = LNETDROPBYTES,
668 .type = ASN_COUNTER64,
670 .findVar = var_lnetInformation,
672 .name = { 2, 1, 9, 11 }
676 /*****************************************************************************
677 * Function: init_cfsNetSNMPPlugin
679 * Description: Called when the agent starts up
685 ****************************************************************************/
687 void init_lustresnmp(void) {
689 /* register ourselves with the agent to handle our mib tree */
690 REGISTER_MIB("clusterFileSystems",
691 clusterFileSystems_variables, variable7,
692 clusterFileSystems_variables_oid);
694 initialize_trap_handler();
696 DEBUGMSGTL(("lsnmpd", "%s %s\n", __func__, "Initialization Done"));
699 /*****************************************************************************
700 * Function: deinit_cfsNetSNMPPlugin
702 * Description: Called when the agent terminates up
708 ****************************************************************************/
710 void deinit_lustresnmp(void) {
712 /* deregister ourselves with the agent */
713 unregister_mib(clusterFileSystems_variables_oid,
714 sizeof(clusterFileSystems_variables_oid)/
715 sizeof(clusterFileSystems_variables_oid[0]));
717 terminate_trap_handler();
719 DEBUGMSGTL(("lsnmpd", "%s %s\n", __func__, "Termination Done"));
722 /*****************************************************************************
723 * Function: var_clusterFileSystems
725 ****************************************************************************/
727 var_clusterFileSystems(struct variable *vp,
732 WriteMethod **write_method)
736 /* variables we may use later */
737 static long long_ret;
738 static u_long ulong_ret;
739 static unsigned char string[SPRINT_MAX_LEN];
744 if (header_generic(vp,name,length,exact,var_len,write_method)
750 * this is where we do the value assignments for the mib results.
755 if (cfs_get_param_paths(&path, "version") != 0)
757 if( SUCCESS != read_string(path.gl_pathv[0], (char *)string,sizeof(string))){
758 cfs_free_param_data(&path);
761 cfs_free_param_data(&path);
762 *var_len = strlen((char *)string);
763 return (unsigned char *) string;
765 case SYSKERNELVERSION:
766 if (cfs_get_param_paths(&path, "kernel_version") != 0)
768 if( SUCCESS != read_string(path.gl_pathv[0], (char *)string,sizeof(string))){
769 cfs_free_param_data(&path);
772 cfs_free_param_data(&path);
773 *var_len = strlen((char *)string);
774 return (unsigned char *) string;
777 if (cfs_get_param_paths(&path, "health_check") != 0)
779 if( SUCCESS != read_string(path.gl_pathv[0], (char *)string,sizeof(string))){
780 cfs_free_param_data(&path);
783 cfs_free_param_data(&path);
784 *var_len = strlen((char*)string);
785 return (unsigned char *) string;
788 *write_method = write_sysStatus;
789 long_ret = (long) get_sysstatus();
790 if (long_ret != ERROR)
791 return (unsigned char *) &long_ret;
795 if (cfs_get_param_paths(&path, "obdfilter") != 0)
797 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
798 cfs_free_param_data(&path);
801 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
802 cfs_free_param_data(&path);
805 return (unsigned char *) &ulong_ret;
808 if (cfs_get_param_paths(&path, "osc") != 0)
810 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
811 cfs_free_param_data(&path);
814 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
815 cfs_free_param_data(&path);
818 return (unsigned char *) &ulong_ret;
821 if (cfs_get_param_paths(&path, "mds") != 0)
823 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
824 cfs_free_param_data(&path);
827 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
828 cfs_free_param_data(&path);
831 return (unsigned char *) &ulong_ret;
834 if (cfs_get_param_paths(&path, "mdc") != 0)
836 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
837 cfs_free_param_data(&path);
840 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
841 cfs_free_param_data(&path);
844 return (unsigned char *) &ulong_ret;
847 if (cfs_get_param_paths(&path, "llite") != 0)
849 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
850 cfs_free_param_data(&path);
853 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
854 cfs_free_param_data(&path);
857 return (unsigned char *) &ulong_ret;
860 if (cfs_get_param_paths(&path, "lov") != 0)
862 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
863 cfs_free_param_data(&path);
866 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
867 cfs_free_param_data(&path);
870 return (unsigned char *) &ulong_ret;
873 if (cfs_get_param_paths(&path, "ldlm/namespaces") != 0)
875 if( 0 == (dir_list = get_file_list(path.gl_pathv[0], DIR_TYPE, &num))){
876 cfs_free_param_data(&path);
879 DEBUGMSGTL(("lsnmpd","num(%s)=%d\n",path.gl_pathv[0],num));
880 cfs_free_param_data(&path);
883 return (unsigned char *) &ulong_ret;
891 struct oid_table osd_table[] = {
894 .name = FILENAME_UUID,
895 .fhandler = oid_table_string_handler
898 .magic = OSDCOMMONNAME,
900 .fhandler = oid_table_obj_name_handler
903 .magic = OSDCAPACITY,
904 .name = FILENAME_KBYTES_TOTAL,
905 .fhandler = oid_table_c64_kb_handler
908 .magic = OSDFREECAPACITY,
909 .name = FILENAME_KBYTES_FREE,
910 .fhandler = oid_table_c64_kb_handler
914 .name = FILENAME_FILES_TOTAL,
915 .fhandler = oid_table_c64_kb_handler
918 .magic = OSDFREEOBJECTS,
919 .name = FILENAME_FILES_FREE,
920 .fhandler = oid_table_c64_kb_handler
930 /*****************************************************************************
931 * Function: var_osdTable
933 ****************************************************************************/
935 var_osdTable(struct variable *vp,
940 WriteMethod **write_method)
942 unsigned char *table;
945 if (cfs_get_param_paths(&path, "obdfilter") != 0)
948 table = var_genericTable(vp,name,length,exact,var_len,write_method,
949 path.gl_pathv[0],osd_table);
950 cfs_free_param_data(&path);
954 struct oid_table osc_table[] = {
957 .name = FILENAME_UUID,
958 .fhandler = oid_table_string_handler
961 .magic = OSCCOMMONNAME,
963 .fhandler = oid_table_obj_name_handler
966 .magic = OSCOSTSERVERUUID,
967 .name = "ost_server_uuid",
968 .fhandler = oid_table_string_handler
971 .magic = OSCCAPACITY,
972 .name = FILENAME_KBYTES_TOTAL,
973 .fhandler = oid_table_c64_kb_handler
976 .magic = OSCFREECAPACITY,
977 .name = FILENAME_KBYTES_FREE,
978 .fhandler = oid_table_c64_kb_handler
982 .name = FILENAME_FILES_TOTAL,
983 .fhandler = oid_table_c64_kb_handler
986 .magic = OSCFREEOBJECTS,
987 .name = FILENAME_FILES_FREE,
988 .fhandler = oid_table_c64_kb_handler
997 /*****************************************************************************
998 * Function: var_oscTable
1000 ****************************************************************************/
1002 var_oscTable(struct variable *vp,
1007 WriteMethod **write_method)
1009 unsigned char *table;
1012 if (cfs_get_param_paths(&path, "osc") != 0)
1015 table = var_genericTable(vp,name,length,exact,var_len,write_method,
1016 path.gl_pathv[0],osd_table);
1017 cfs_free_param_data(&path);
1021 struct oid_table mds_table[] = {
1024 .name = FILENAME_UUID,
1025 .fhandler = oid_table_string_handler
1028 .magic = MDDCOMMONNAME,
1030 .fhandler = oid_table_obj_name_handler
1033 .magic = MDDCAPACITY,
1034 .name = FILENAME_KBYTES_TOTAL,
1035 .fhandler = oid_table_c64_kb_handler
1038 .magic = MDDFREECAPACITY,
1039 .name = FILENAME_KBYTES_FREE,
1040 .fhandler = oid_table_c64_kb_handler
1044 .name = FILENAME_FILES_TOTAL,
1045 .fhandler = oid_table_c64_kb_handler
1048 .magic = MDDFREEFILES,
1049 .name = FILENAME_FILES_FREE,
1050 .fhandler = oid_table_c64_kb_handler
1059 /*****************************************************************************
1060 * Function: var_mdsTable
1062 ****************************************************************************/
1064 var_mdsTable(struct variable *vp,
1069 WriteMethod **write_method)
1071 unsigned char *table;
1074 if (cfs_get_param_paths(&path, "mds") != 0)
1077 table = var_genericTable(vp,name,length,exact,var_len,write_method,
1078 path.gl_pathv[0],osd_table);
1079 cfs_free_param_data(&path);
1083 struct oid_table mdc_table[] = {
1086 .name = FILENAME_UUID,
1087 .fhandler = oid_table_string_handler
1090 .magic = MDCCOMMONNAME,
1092 .fhandler = oid_table_obj_name_handler
1095 .magic = MDCMDSSERVERUUID,
1096 .name = "mds_server_uuid",
1097 .fhandler = oid_table_string_handler
1100 .magic = MDCCAPACITY,
1101 .name = FILENAME_KBYTES_TOTAL,
1102 .fhandler = oid_table_c64_kb_handler
1105 .magic = MDCFREECAPACITY,
1106 .name = FILENAME_KBYTES_FREE,
1107 .fhandler = oid_table_c64_kb_handler
1110 .magic = MDCOBJECTS,
1111 .name = FILENAME_FILES_TOTAL,
1112 .fhandler = oid_table_c64_kb_handler
1115 .magic = MDCFREEOBJECTS,
1116 .name = FILENAME_FILES_FREE,
1117 .fhandler = oid_table_c64_kb_handler
1127 /*****************************************************************************
1128 * Function: var_mdcTable
1130 ****************************************************************************/
1132 var_mdcTable(struct variable *vp,
1137 WriteMethod **write_method)
1139 unsigned char *table;
1142 if (cfs_get_param_paths(&path, "mdc") != 0)
1145 table = var_genericTable(vp,name,length,exact,var_len,write_method,
1146 path.gl_pathv[0],osd_table);
1147 cfs_free_param_data(&path);
1151 struct oid_table cli_table[] = {
1154 .name = FILENAME_UUID,
1155 .fhandler = oid_table_string_handler
1158 .magic = CLICOMMONNAME,
1160 .fhandler = oid_table_obj_name_handler
1163 .magic = CLIMDCUUID,
1164 .name = "mdc/" FILENAME_UUID,
1165 .fhandler = oid_table_string_handler
1168 .magic = CLIMDCCOMMONNAME,
1169 .name = "mdc/" FILENAME_COMMON_NAME,
1170 .fhandler = oid_table_string_handler
1173 .magic = CLIUSESLOV,
1175 .fhandler = oid_table_is_directory_handler
1178 .magic = CLILOVUUID,
1179 .name = "lov/" FILENAME_UUID,
1180 .fhandler = oid_table_string_handler
1183 .magic = CLILOVCOMMONNAME,
1184 .name = "lov/" FILENAME_COMMON_NAME,
1185 .fhandler = oid_table_string_handler
1194 /*****************************************************************************
1195 * Function: var_cliTable
1197 ****************************************************************************/
1199 var_cliTable(struct variable *vp,
1204 WriteMethod **write_method)
1206 unsigned char *table;
1209 if (cfs_get_param_paths(&path, "llite") != 0)
1212 table = var_genericTable(vp,name,length,exact,var_len,write_method,
1213 path.gl_pathv[0],osd_table);
1214 cfs_free_param_data(&path);
1218 struct oid_table lov_table[] = {
1221 .name = FILENAME_UUID,
1222 .fhandler = oid_table_string_handler
1225 .magic = LOVCOMMONNAME,
1227 .fhandler = oid_table_obj_name_handler
1232 .fhandler = oid_table_ulong_handler
1235 .magic = LOVNUMACTIVEOBD,
1236 .name = "activeobd",
1237 .fhandler = oid_table_ulong_handler
1240 .magic = LOVCAPACITY,
1241 .name = FILENAME_KBYTES_TOTAL,
1242 .fhandler = oid_table_c64_kb_handler
1245 .magic = LOVFREECAPACITY,
1246 .name = FILENAME_KBYTES_FREE,
1247 .fhandler = oid_table_c64_kb_handler
1251 .name = FILENAME_FILES_TOTAL,
1252 .fhandler = oid_table_c64_kb_handler
1255 .magic = LOVFREEFILES,
1256 .name = FILENAME_FILES_FREE,
1257 .fhandler = oid_table_c64_kb_handler
1260 .magic = LOVSTRIPECOUNT,
1261 .name = "stripecount",
1262 .fhandler = oid_table_ulong_handler
1265 .magic = LOVSTRIPEOFFSET,
1266 .name = "stripeoffset",
1267 .fhandler = oid_table_ulong_handler
1270 .magic = LOVSTRIPESIZE,
1271 .name = "stripesize",
1272 .fhandler = oid_table_ulong_handler
1275 .magic = LOVSTRIPETYPE,
1276 .name = "stripetype",
1277 .fhandler = oid_table_ulong_handler
1287 /*****************************************************************************
1288 * Function: var_lovTable
1290 ****************************************************************************/
1292 var_lovTable(struct variable *vp,
1297 WriteMethod **write_method)
1299 unsigned char *table;
1302 if (cfs_get_param_paths(&path, "lov") != 0)
1305 table = var_genericTable(vp,name,length,exact,var_len,write_method,
1306 path.gl_pathv[0],osd_table);
1307 cfs_free_param_data(&path);
1311 struct oid_table ldlm_table[] = {
1313 .magic = LDLMNAMESPACE,
1315 .fhandler = oid_table_obj_name_handler
1318 .magic = LDLMLOCKCOUNT,
1319 .name = "lock_count",
1320 .fhandler = oid_table_ulong_handler
1323 .magic = LDLMUNUSEDLOCKCOUNT,
1324 .name = "lock_unused_count",
1325 .fhandler = oid_table_ulong_handler
1328 .magic = LDLMRESOURCECOUNT,
1329 .name = "resource_count",
1330 .fhandler = oid_table_ulong_handler
1340 /*****************************************************************************
1341 * Function: var_ldlmTable
1343 ****************************************************************************/
1345 var_ldlmTable(struct variable *vp,
1350 WriteMethod **write_method)
1352 unsigned char *table;
1355 if (cfs_get_param_paths(&path, "ldlm/namespaces") != 0)
1358 table = var_genericTable(vp,name,length,exact,var_len,write_method,
1359 path.gl_pathv[0],osd_table);
1360 cfs_free_param_data(&path);
1364 /*****************************************************************************
1365 * Function: var_lnetInformation
1367 ****************************************************************************/
1369 var_lnetInformation(struct variable *vp,
1374 WriteMethod **write_method)
1376 /* variables we may use later */
1377 static unsigned char string[SPRINT_MAX_LEN];
1378 static unsigned int i[7];
1379 static unsigned long long ull[4];
1380 static unsigned long next_update;
1381 static counter64 c64;
1382 static unsigned int c32;
1383 struct timeval current_tv;
1384 unsigned long current;
1387 /* Update at most every LNET_STATS_INTERVAL milliseconds */
1388 gettimeofday(¤t_tv, NULL);
1389 current = current_tv.tv_sec * 1000000 + current_tv.tv_usec;
1390 if (current >= next_update) {
1391 if (cfs_get_param_paths(&file_path, "stats") != 0)
1393 if (read_string(file_path.gl_pathv[0], (char *) string, sizeof(string))
1395 cfs_free_param_data(&file_path);
1398 cfs_free_param_data(&file_path);
1400 sscanf((char *) string,
1401 "%u %u %u %u %u %u %u %llu %llu %llu %llu",
1402 &i[0], &i[1], &i[2], &i[3], &i[4], &i[5], &i[6],
1403 &ull[0], &ull[1], &ull[2], &ull[3]);
1405 next_update = current + (LNET_CHECK_INTERVAL * 1000);
1408 if (header_generic(vp, name, length, exact, var_len, write_method)
1412 switch (vp->magic) {
1414 *var_len = sizeof(c32);
1416 return (unsigned char *) &c32;
1418 *var_len = sizeof(c32);
1420 return (unsigned char *) &c32;
1422 *var_len = sizeof(c32);
1424 return (unsigned char *) &c32;
1426 *var_len = sizeof(c32);
1428 return (unsigned char *) &c32;
1430 *var_len = sizeof(c32);
1432 return (unsigned char *) &c32;
1433 case LNETROUTECOUNT:
1434 *var_len = sizeof(c32);
1436 return (unsigned char *) &c32;
1438 *var_len = sizeof(c32);
1440 return (unsigned char *) &c32;
1442 convert_ull(&c64, ull[0], var_len);
1443 return (unsigned char *) &c64;
1445 convert_ull(&c64, ull[1], var_len);
1446 return (unsigned char *) &c64;
1447 case LNETROUTEBYTES:
1448 convert_ull(&c64, ull[2], var_len);
1449 return (unsigned char *) &c64;
1451 convert_ull(&c64, ull[3], var_len);
1452 return (unsigned char *) &c64;
1458 /*****************************************************************************
1459 * Function: var_mdsNbSampledReq
1461 ****************************************************************************/
1463 var_mdsNbSampledReq(struct variable *vp,
1468 WriteMethod **write_method)
1470 unsigned long long nb_sample=0,min=0,max=0,sum=0,sum_square=0;
1471 static counter64 c64;
1473 if (header_generic(vp,name,length,exact,var_len,write_method)
1477 if( mds_stats_values(STR_REQ_WAITIME,&nb_sample,&min,&max,&sum,&sum_square) == ERROR) return NULL;
1479 c64.low = (u_long) (0x0FFFFFFFF & nb_sample);
1481 c64.high = (u_long) (0x0FFFFFFFF & nb_sample);
1483 *var_len = sizeof(c64);
1484 return (unsigned char *) &c64;
1488 /*****************************************************************************
1489 * Function: write_sysStatus
1491 ****************************************************************************/
1493 write_sysStatus(int action,
1495 u_char var_val_type,
1501 static long *long_ret;
1508 if (var_val_type != ASN_INTEGER){
1509 fprintf(stderr, "write to sysStatus not ASN_INTEGER\n");
1510 return SNMP_ERR_WRONGTYPE;
1512 if (var_val_len > sizeof(long_ret)){
1513 fprintf(stderr,"write to sysStatus: bad length\n");
1514 return SNMP_ERR_WRONGLENGTH;
1516 if ((*var_val != ONLINE) &&
1517 (*var_val != OFFLINE) &&
1518 (*var_val != RESTART)){
1519 report("%s %s:line %d %s", __FILE__, __FUNCTION__, __LINE__,
1520 "sysStatus value is invalid.");
1521 return SNMP_ERR_WRONGVALUE;
1527 long_ret = (long *) var_val;
1534 /* Release any resources that have been allocated */
1539 /* The variable has been stored in long_ret for
1540 you to use, and you have just been asked to do something with
1541 it. Note that anything done here must be reversable in the UNDO case */
1542 new_value = *(int *) var_val;
1543 switch (new_value) {
1545 lustrefs_ctrl(ONLINE);
1549 lustrefs_ctrl(OFFLINE);
1553 lustrefs_ctrl(RESTART);
1563 /* Back out any changes made in the ACTION case */
1568 /* Things are working well, so it's now safe to make the change
1569 permanently. Make sure that anything done here can't fail! */
1572 return SNMP_ERR_NOERROR;