1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2005 Cluster File Systems, Inc.
5 * Author: PJ Kirner <pjkirner@clusterfs.com>
7 * This file is part of Lustre, http://www.lustre.org.
9 * Lustre is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * Lustre is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Lustre; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #ifndef LUSTRE_SNMP_UTIL_H
24 #define LUSTRE_SNMP_UTIL_H
27 * Definitions of magic values
31 #define SYSKERNELVERSION 21
32 #define SYSHEALTHCHECK 22
37 #define OSDCOMMONNAME 32
38 #define OSDCAPACITY 33
39 #define OSDFREECAPACITY 34
41 #define OSDFREEOBJECTS 36
45 #define OSCCOMMONNAME 42
46 #define OSCOSTSERVERUUID 43
47 #define OSCCAPACITY 44
48 #define OSCFREECAPACITY 45
50 #define OSCFREEOBJECTS 47
54 #define MDDCOMMONNAME 52
55 #define MDDCAPACITY 53
56 #define MDDFREECAPACITY 54
58 #define MDDFREEFILES 56
59 #define MDSNBSAMPLEDREQ 57
63 #define MDCCOMMONNAME 62
64 #define MDCMDSSERVERUUID 63
65 #define MDCCAPACITY 64
66 #define MDCFREECAPACITY 65
68 #define MDCFREEOBJECTS 67
70 #define CLIMOUNTNUMBER 70
72 #define CLICOMMONNAME 72
74 #define CLIMDCCOMMONNAME 74
77 #define CLILOVCOMMONNAME 77
81 #define LOVCOMMONNAME 82
83 #define LOVNUMACTIVEOBD 84
84 #define LOVCAPACITY 85
85 #define LOVFREECAPACITY 86
87 #define LOVFREEFILES 88
88 #define LOVSTRIPECOUNT 89
89 #define LOVSTRIPEOFFSET 90
90 #define LOVSTRIPESIZE 91
91 #define LOVSTRIPETYPE 92
93 #define LDLMNUMBER 100
94 #define LDLMNAMESPACE 101
95 #define LDLMLOCKCOUNT 102
96 #define LDLMUNUSEDLOCKCOUNT 103
97 #define LDLMRESOURCECOUNT 104
99 /* Defining the proc paths for Lustre file system */
100 #define LUSTRE_PATH "/proc/fs/lustre/"
101 #define OSD_PATH LUSTRE_PATH "obdfilter/"
102 #define OSC_PATH LUSTRE_PATH "osc/"
103 #define MDS_PATH LUSTRE_PATH "mds/"
104 #define MDC_PATH LUSTRE_PATH "mdc/"
105 #define CLIENT_PATH LUSTRE_PATH "llite/"
106 #define LOV_PATH LUSTRE_PATH "lov/"
107 #define LDLM_PATH LUSTRE_PATH "ldlm/namespaces/"
108 #define FILEPATH_MDS_SERVER_STATS LUSTRE_PATH "mdt/MDS/mds/stats"
109 #define FILEPATH_MDS_SERVER_READPAGE_STATS LUSTRE_PATH "mdt/MDS/mds_readpage/stats"
110 #define FILEPATH_MDS_SERVER_SETATTR_STATS LUSTRE_PATH "mdt/MDS/mds_setattr/stats"
112 /* Common procfs file entries that are refrenced in mulitple locations*/
113 #define FILENAME_SYSHEALTHCHECK "health_check"
114 #define FILENAME_SYS_STATUS "/var/lustre/sysStatus"
116 #define FILENAME_NUM_REF "num_refs"
117 #define FILENAME_UUID "uuid"
118 #define FILENAME_COMMON_NAME "common_name"
119 #define FILENAME_KBYTES_TOTAL "kbytestotal"
120 #define FILENAME_KBYTES_FREE "kbytesfree"
121 #define FILENAME_FILES_TOTAL "filestotal"
122 #define FILENAME_FILES_FREE "filesfree"
123 #define STR_REQ_WAITIME "req_waittime"
125 /* strings which the file /var/lustre/sysStatus can hold */
126 #define STR_ONLINE "online"
127 #define STR_ONLINE_PENDING "online pending"
128 #define STR_OFFLINE "offline"
129 #define STR_OFFLINE_PENDING "offline pending"
132 /* Script required for starting/stopping lustre services */
133 #define LUSTRE_SERVICE "/etc/init.d/lustre"
135 #define MIN_LEN(val1,val2) (((val1)>(val2))?(val2):(val1))
137 /* The max size of a lustre procfs path name*/
138 #define MAX_PATH_SIZE 512
140 /* The max size of a string read from procfs */
141 #define MAX_LINE_SIZE 512
143 /* Types passed to get_file_list() */
147 /* Defining return values */
151 typedef struct counter64 counter64;
161 /* File operation related functions */
162 char *get_file_list(const char *dirname, int file_type, uint32_t *count);
163 extern int is_directory(const char *filename);
164 extern int read_string(const char *filepath, char *lustre_var,size_t var_size);
165 int read_counter64(const char *file_path, counter64 *c64,int factor);
166 int read_ulong(const char *file_path,unsigned long* valuep);
168 /* Start/Stop/Restart Lustre Services */
169 extern void lustrefs_ctrl(int command);
170 extern int get_sysstatus();
172 extern void report(const char *fmt, ...);
174 /* Table Driven SNMP OID Handler support*/
175 typedef unsigned char* (*f_oid_handler_t)(
176 const char* file_path,
181 int magic; /*The magic number*/
182 const char *name; /*The procfs name*/
183 f_oid_handler_t fhandler; /*The handler */
186 unsigned char* oid_table_ulong_handler(const char* file_path,size_t *var_len);
187 unsigned char* oid_table_c64_handler(const char* file_path,size_t *var_len);
188 unsigned char* oid_table_c64_kb_handler(const char* file_path,size_t *var_len);
189 unsigned char* oid_table_obj_name_handler(const char* file_path,size_t *var_len);
190 unsigned char* oid_table_string_handler(const char* file_path,size_t *var_len);
191 unsigned char* oid_table_is_directory_handler(const char* file_path,size_t *var_len);
193 var_genericTable(struct variable *vp,
198 WriteMethod **write_method,
200 struct oid_table *ptable);
202 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);
203 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);
205 #endif /* LUSTRE_SNMP_UTIL_H */