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.
27 * This file is part of Lustre, http://www.lustre.org/
28 * Lustre is a trademark of Sun Microsystems, Inc.
30 * snmp/lustre-snmp-util.h
32 * Author: PJ Kirner <pjkirner@clusterfs.com>
35 #ifndef LUSTRE_SNMP_UTIL_H
36 #define LUSTRE_SNMP_UTIL_H
38 #include <libcfs/util/param.h>
41 * Definitions of magic values
45 #define SYSKERNELVERSION 21
46 #define SYSHEALTHCHECK 22
51 #define OSDCOMMONNAME 32
52 #define OSDCAPACITY 33
53 #define OSDFREECAPACITY 34
55 #define OSDFREEOBJECTS 36
59 #define OSCCOMMONNAME 42
60 #define OSCOSTSERVERUUID 43
61 #define OSCCAPACITY 44
62 #define OSCFREECAPACITY 45
64 #define OSCFREEOBJECTS 47
68 #define MDDCOMMONNAME 52
69 #define MDDCAPACITY 53
70 #define MDDFREECAPACITY 54
72 #define MDDFREEFILES 56
73 #define MDSNBSAMPLEDREQ 57
77 #define MDCCOMMONNAME 62
78 #define MDCMDSSERVERUUID 63
79 #define MDCCAPACITY 64
80 #define MDCFREECAPACITY 65
82 #define MDCFREEOBJECTS 67
84 #define CLIMOUNTNUMBER 70
86 #define CLICOMMONNAME 72
88 #define CLIMDCCOMMONNAME 74
91 #define CLILOVCOMMONNAME 77
95 #define LOVCOMMONNAME 82
97 #define LOVNUMACTIVEOBD 84
98 #define LOVCAPACITY 85
99 #define LOVFREECAPACITY 86
101 #define LOVFREEFILES 88
102 #define LOVSTRIPECOUNT 89
103 #define LOVSTRIPEOFFSET 90
104 #define LOVSTRIPESIZE 91
105 #define LOVSTRIPETYPE 92
107 #define LDLMNUMBER 100
108 #define LDLMNAMESPACE 101
109 #define LDLMLOCKCOUNT 102
110 #define LDLMUNUSEDLOCKCOUNT 103
111 #define LDLMRESOURCECOUNT 104
113 #define LNETNUMBER 110
114 #define LNETMSGSALLOC 111
115 #define LNETMSGSMAX 112
116 #define LNETERRORS 113
117 #define LNETSENDCOUNT 114
118 #define LNETRECVCOUNT 115
119 #define LNETROUTECOUNT 116
120 #define LNETDROPCOUNT 117
121 #define LNETSENDBYTES 118
122 #define LNETRECVBYTES 119
123 #define LNETROUTEBYTES 120
124 #define LNETDROPBYTES 121
126 /* Common procfs file entries that are refrenced in mulitple locations*/
127 #define FILENAME_SYS_STATUS "/var/lustre/sysStatus"
129 #define FILENAME_NUM_REF "num_refs"
130 #define FILENAME_UUID "uuid"
131 #define FILENAME_COMMON_NAME "common_name"
132 #define FILENAME_KBYTES_TOTAL "kbytestotal"
133 #define FILENAME_KBYTES_FREE "kbytesfree"
134 #define FILENAME_FILES_TOTAL "filestotal"
135 #define FILENAME_FILES_FREE "filesfree"
136 #define STR_REQ_WAITIME "req_waittime"
138 /* strings which the file /var/lustre/sysStatus can hold */
139 #define STR_ONLINE "online"
140 #define STR_ONLINE_PENDING "online pending"
141 #define STR_OFFLINE "offline"
142 #define STR_OFFLINE_PENDING "offline pending"
145 /* Script required for starting/stopping lustre services */
146 #define LUSTRE_SERVICE "/etc/init.d/lustre"
148 #define MIN_LEN(val1,val2) (((val1)>(val2))?(val2):(val1))
150 /* The max size of a lustre procfs path name*/
151 #define MAX_PATH_SIZE 512
153 /* The max size of a string read from procfs */
154 #define MAX_LINE_SIZE 512
156 /* Types passed to get_file_list() */
160 /* Defining return values */
164 typedef struct counter64 counter64;
174 /* File operation related functions */
175 char *get_file_list(const char *dirname, int file_type, uint32_t *count);
176 extern int is_directory(const char *filename);
177 extern int read_string(const char *filepath, char *lustre_var,size_t var_size);
178 int read_counter64(const char *file_path, counter64 *c64,int factor);
179 int read_ulong(const char *file_path,unsigned long* valuep);
181 /* Start/Stop/Restart Lustre Services */
182 extern void lustrefs_ctrl(int command);
183 extern int get_sysstatus();
185 extern void report(const char *fmt, ...);
187 /* Table Driven SNMP OID Handler support*/
188 typedef unsigned char* (*f_oid_handler_t)(
189 const char* file_path,
194 int magic; /*The magic number*/
195 const char *name; /*The procfs name*/
196 f_oid_handler_t fhandler; /*The handler */
199 unsigned char* oid_table_ulong_handler(const char* file_path,size_t *var_len);
200 unsigned char* oid_table_c64_handler(const char* file_path,size_t *var_len);
201 unsigned char* oid_table_c64_kb_handler(const char* file_path,size_t *var_len);
202 unsigned char* oid_table_obj_name_handler(const char* file_path,size_t *var_len);
203 unsigned char* oid_table_string_handler(const char* file_path,size_t *var_len);
204 unsigned char* oid_table_is_directory_handler(const char* file_path,size_t *var_len);
206 var_genericTable(struct variable *vp,
211 WriteMethod **write_method,
213 struct oid_table *ptable);
215 void convert_ull(counter64 *c64, unsigned long long ull, size_t *var_len);
216 int stats_values(char * filepath,char * name_value, unsigned long long * nb_sample, unsigned long long * min, unsigned long long * max, unsigned long long * sum, unsigned long long * sum_square);
217 extern int mds_stats_values(char * name_value, unsigned long long * nb_sample, unsigned long long * min, unsigned long long * max, unsigned long long * sum, unsigned long long * sum_square);
219 /* export for net-snmp util-funcs */
220 int header_simple_table(struct variable *, oid *, size_t *,
222 WriteMethod ** write_method, int);
223 int header_generic(struct variable *, oid *, size_t *, int,
224 size_t *, WriteMethod **);
226 #endif /* LUSTRE_SNMP_UTIL_H */