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.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * snmp/lustre-snmp-util.h
36 * Author: PJ Kirner <pjkirner@clusterfs.com>
39 #ifndef LUSTRE_SNMP_UTIL_H
40 #define LUSTRE_SNMP_UTIL_H
43 * Definitions of magic values
47 #define SYSKERNELVERSION 21
48 #define SYSHEALTHCHECK 22
53 #define OSDCOMMONNAME 32
54 #define OSDCAPACITY 33
55 #define OSDFREECAPACITY 34
57 #define OSDFREEOBJECTS 36
61 #define OSCCOMMONNAME 42
62 #define OSCOSTSERVERUUID 43
63 #define OSCCAPACITY 44
64 #define OSCFREECAPACITY 45
66 #define OSCFREEOBJECTS 47
70 #define MDDCOMMONNAME 52
71 #define MDDCAPACITY 53
72 #define MDDFREECAPACITY 54
74 #define MDDFREEFILES 56
75 #define MDSNBSAMPLEDREQ 57
79 #define MDCCOMMONNAME 62
80 #define MDCMDSSERVERUUID 63
81 #define MDCCAPACITY 64
82 #define MDCFREECAPACITY 65
84 #define MDCFREEOBJECTS 67
86 #define CLIMOUNTNUMBER 70
88 #define CLICOMMONNAME 72
90 #define CLIMDCCOMMONNAME 74
93 #define CLILOVCOMMONNAME 77
97 #define LOVCOMMONNAME 82
99 #define LOVNUMACTIVEOBD 84
100 #define LOVCAPACITY 85
101 #define LOVFREECAPACITY 86
103 #define LOVFREEFILES 88
104 #define LOVSTRIPECOUNT 89
105 #define LOVSTRIPEOFFSET 90
106 #define LOVSTRIPESIZE 91
107 #define LOVSTRIPETYPE 92
109 #define LDLMNUMBER 100
110 #define LDLMNAMESPACE 101
111 #define LDLMLOCKCOUNT 102
112 #define LDLMUNUSEDLOCKCOUNT 103
113 #define LDLMRESOURCECOUNT 104
115 /* Defining the proc paths for Lustre file system */
116 #define LUSTRE_PATH "/proc/fs/lustre/"
117 #define OSD_PATH LUSTRE_PATH "obdfilter/"
118 #define OSC_PATH LUSTRE_PATH "osc/"
119 #define MDS_PATH LUSTRE_PATH "mds/"
120 #define MDC_PATH LUSTRE_PATH "mdc/"
121 #define CLIENT_PATH LUSTRE_PATH "llite/"
122 #define LOV_PATH LUSTRE_PATH "lov/"
123 #define LDLM_PATH LUSTRE_PATH "ldlm/namespaces/"
124 #define FILEPATH_MDS_SERVER_STATS LUSTRE_PATH "mdt/MDS/mds/stats"
125 #define FILEPATH_MDS_SERVER_READPAGE_STATS LUSTRE_PATH "mdt/MDS/mds_readpage/stats"
126 #define FILEPATH_MDS_SERVER_SETATTR_STATS LUSTRE_PATH "mdt/MDS/mds_setattr/stats"
128 /* Common procfs file entries that are refrenced in mulitple locations*/
129 #define FILENAME_SYSHEALTHCHECK "health_check"
130 #define FILENAME_SYS_STATUS "/var/lustre/sysStatus"
132 #define FILENAME_NUM_REF "num_refs"
133 #define FILENAME_UUID "uuid"
134 #define FILENAME_COMMON_NAME "common_name"
135 #define FILENAME_KBYTES_TOTAL "kbytestotal"
136 #define FILENAME_KBYTES_FREE "kbytesfree"
137 #define FILENAME_FILES_TOTAL "filestotal"
138 #define FILENAME_FILES_FREE "filesfree"
139 #define STR_REQ_WAITIME "req_waittime"
141 /* strings which the file /var/lustre/sysStatus can hold */
142 #define STR_ONLINE "online"
143 #define STR_ONLINE_PENDING "online pending"
144 #define STR_OFFLINE "offline"
145 #define STR_OFFLINE_PENDING "offline pending"
148 /* Script required for starting/stopping lustre services */
149 #define LUSTRE_SERVICE "/etc/init.d/lustre"
151 #define MIN_LEN(val1,val2) (((val1)>(val2))?(val2):(val1))
153 /* The max size of a lustre procfs path name*/
154 #define MAX_PATH_SIZE 512
156 /* The max size of a string read from procfs */
157 #define MAX_LINE_SIZE 512
159 /* Types passed to get_file_list() */
163 /* Defining return values */
167 typedef struct counter64 counter64;
177 /* File operation related functions */
178 char *get_file_list(const char *dirname, int file_type, uint32_t *count);
179 extern int is_directory(const char *filename);
180 extern int read_string(const char *filepath, char *lustre_var,size_t var_size);
181 int read_counter64(const char *file_path, counter64 *c64,int factor);
182 int read_ulong(const char *file_path,unsigned long* valuep);
184 /* Start/Stop/Restart Lustre Services */
185 extern void lustrefs_ctrl(int command);
186 extern int get_sysstatus();
188 extern void report(const char *fmt, ...);
190 /* Table Driven SNMP OID Handler support*/
191 typedef unsigned char* (*f_oid_handler_t)(
192 const char* file_path,
197 int magic; /*The magic number*/
198 const char *name; /*The procfs name*/
199 f_oid_handler_t fhandler; /*The handler */
202 unsigned char* oid_table_ulong_handler(const char* file_path,size_t *var_len);
203 unsigned char* oid_table_c64_handler(const char* file_path,size_t *var_len);
204 unsigned char* oid_table_c64_kb_handler(const char* file_path,size_t *var_len);
205 unsigned char* oid_table_obj_name_handler(const char* file_path,size_t *var_len);
206 unsigned char* oid_table_string_handler(const char* file_path,size_t *var_len);
207 unsigned char* oid_table_is_directory_handler(const char* file_path,size_t *var_len);
209 var_genericTable(struct variable *vp,
214 WriteMethod **write_method,
216 struct oid_table *ptable);
218 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);
219 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);
221 /* export for net-snmp util-funcs */
222 int header_simple_table(struct variable *, oid *, size_t *,
224 WriteMethod ** write_method, int);
225 int header_generic(struct variable *, oid *, size_t *, int,
226 size_t *, WriteMethod **);
228 #endif /* LUSTRE_SNMP_UTIL_H */