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/
29 * snmp/lustre-snmp-util.h
31 * Author: PJ Kirner <pjkirner@clusterfs.com>
34 #ifndef LUSTRE_SNMP_UTIL_H
35 #define LUSTRE_SNMP_UTIL_H
37 #include <libcfs/util/param.h>
40 * Definitions of magic values
44 #define SYSKERNELVERSION 21
45 #define SYSHEALTHCHECK 22
50 #define OSDCOMMONNAME 32
51 #define OSDCAPACITY 33
52 #define OSDFREECAPACITY 34
54 #define OSDFREEOBJECTS 36
58 #define OSCCOMMONNAME 42
59 #define OSCOSTSERVERUUID 43
60 #define OSCCAPACITY 44
61 #define OSCFREECAPACITY 45
63 #define OSCFREEOBJECTS 47
67 #define MDDCOMMONNAME 52
68 #define MDDCAPACITY 53
69 #define MDDFREECAPACITY 54
71 #define MDDFREEFILES 56
72 #define MDSNBSAMPLEDREQ 57
76 #define MDCCOMMONNAME 62
77 #define MDCMDSSERVERUUID 63
78 #define MDCCAPACITY 64
79 #define MDCFREECAPACITY 65
81 #define MDCFREEOBJECTS 67
83 #define CLIMOUNTNUMBER 70
85 #define CLICOMMONNAME 72
87 #define CLIMDCCOMMONNAME 74
90 #define CLILOVCOMMONNAME 77
94 #define LOVCOMMONNAME 82
96 #define LOVNUMACTIVEOBD 84
97 #define LOVCAPACITY 85
98 #define LOVFREECAPACITY 86
100 #define LOVFREEFILES 88
101 #define LOVSTRIPECOUNT 89
102 #define LOVSTRIPEOFFSET 90
103 #define LOVSTRIPESIZE 91
104 #define LOVSTRIPETYPE 92
106 #define LDLMNUMBER 100
107 #define LDLMNAMESPACE 101
108 #define LDLMLOCKCOUNT 102
109 #define LDLMUNUSEDLOCKCOUNT 103
110 #define LDLMRESOURCECOUNT 104
112 #define LNETNUMBER 110
113 #define LNETMSGSALLOC 111
114 #define LNETMSGSMAX 112
115 #define LNETERRORS 113
116 #define LNETSENDCOUNT 114
117 #define LNETRECVCOUNT 115
118 #define LNETROUTECOUNT 116
119 #define LNETDROPCOUNT 117
120 #define LNETSENDBYTES 118
121 #define LNETRECVBYTES 119
122 #define LNETROUTEBYTES 120
123 #define LNETDROPBYTES 121
125 /* Common procfs file entries that are refrenced in mulitple locations*/
126 #define FILENAME_SYS_STATUS "/var/lustre/sysStatus"
128 #define FILENAME_NUM_REF "num_refs"
129 #define FILENAME_UUID "uuid"
130 #define FILENAME_COMMON_NAME "common_name"
131 #define FILENAME_KBYTES_TOTAL "kbytestotal"
132 #define FILENAME_KBYTES_FREE "kbytesfree"
133 #define FILENAME_FILES_TOTAL "filestotal"
134 #define FILENAME_FILES_FREE "filesfree"
135 #define STR_REQ_WAITIME "req_waittime"
137 /* strings which the file /var/lustre/sysStatus can hold */
138 #define STR_ONLINE "online"
139 #define STR_ONLINE_PENDING "online pending"
140 #define STR_OFFLINE "offline"
141 #define STR_OFFLINE_PENDING "offline pending"
144 /* Script required for starting/stopping lustre services */
145 #define LUSTRE_SERVICE "/etc/init.d/lustre"
147 #define MIN_LEN(val1,val2) (((val1)>(val2))?(val2):(val1))
149 /* The max size of a lustre procfs path name*/
150 #define MAX_PATH_SIZE 512
152 /* The max size of a string read from procfs */
153 #define MAX_LINE_SIZE 512
155 /* Types passed to get_file_list() */
159 /* Defining return values */
163 typedef struct counter64 counter64;
173 /* File operation related functions */
174 char *get_file_list(const char *dirname, int file_type, uint32_t *count);
175 extern int is_directory(const char *filename);
176 extern int read_string(const char *filepath, char *lustre_var,size_t var_size);
177 int read_counter64(const char *file_path, counter64 *c64,int factor);
178 int read_ulong(const char *file_path,unsigned long* valuep);
180 /* Start/Stop/Restart Lustre Services */
181 extern void lustrefs_ctrl(int command);
182 extern int get_sysstatus();
184 extern void report(const char *fmt, ...);
186 /* Table Driven SNMP OID Handler support*/
187 typedef unsigned char* (*f_oid_handler_t)(
188 const char* file_path,
193 int magic; /*The magic number*/
194 const char *name; /*The procfs name*/
195 f_oid_handler_t fhandler; /*The handler */
198 unsigned char* oid_table_ulong_handler(const char* file_path,size_t *var_len);
199 unsigned char* oid_table_c64_handler(const char* file_path,size_t *var_len);
200 unsigned char* oid_table_c64_kb_handler(const char* file_path,size_t *var_len);
201 unsigned char* oid_table_obj_name_handler(const char* file_path,size_t *var_len);
202 unsigned char* oid_table_string_handler(const char* file_path,size_t *var_len);
203 unsigned char* oid_table_is_directory_handler(const char* file_path,size_t *var_len);
205 var_genericTable(struct variable *vp,
210 WriteMethod **write_method,
212 struct oid_table *ptable);
214 void convert_ull(counter64 *c64, unsigned long long ull, size_t *var_len);
215 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);
216 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);
218 /* export for net-snmp util-funcs */
219 int header_simple_table(struct variable *, oid *, size_t *,
221 WriteMethod ** write_method, int);
222 int header_generic(struct variable *, oid *, size_t *, int,
223 size_t *, WriteMethod **);
225 #endif /* LUSTRE_SNMP_UTIL_H */