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
62 #define MDCCOMMONNAME 62
63 #define MDCMDSSERVERUUID 63
64 #define MDCCAPACITY 64
65 #define MDCFREECAPACITY 65
67 #define MDCFREEOBJECTS 67
69 #define CLIMOUNTNUMBER 70
71 #define CLICOMMONNAME 72
73 #define CLIMDCCOMMONNAME 74
76 #define CLILOVCOMMONNAME 77
80 #define LOVCOMMONNAME 82
82 #define LOVNUMACTIVEOBD 84
83 #define LOVCAPACITY 85
84 #define LOVFREECAPACITY 86
86 #define LOVFREEFILES 88
87 #define LOVSTRIPECOUNT 89
88 #define LOVSTRIPEOFFSET 90
89 #define LOVSTRIPESIZE 91
90 #define LOVSTRIPETYPE 92
92 #define LDLMNUMBER 100
93 #define LDLMNAMESPACE 101
94 #define LDLMLOCKCOUNT 102
95 #define LDLMUNUSEDLOCKCOUNT 103
96 #define LDLMRESOURCECOUNT 104
98 /* Defining the proc paths for Lustre file system */
99 #define LUSTRE_PATH "/proc/fs/lustre/"
100 #define OSD_PATH LUSTRE_PATH "obdfilter/"
101 #define OSC_PATH LUSTRE_PATH "osc/"
102 #define MDS_PATH LUSTRE_PATH "mds/"
103 #define MDC_PATH LUSTRE_PATH "mdc/"
104 #define CLIENT_PATH LUSTRE_PATH "llite/"
105 #define LOV_PATH LUSTRE_PATH "lov/"
106 #define LDLM_PATH LUSTRE_PATH "ldlm/namespaces/"
108 /* Common procfs file entries that are refrenced in mulitple locations*/
109 #define FILENAME_SYSHEALTHCHECK "health_check"
110 #define FILENAME_SYS_STATUS "/var/lustre/sysStatus"
112 #define FILENAME_NUM_REF "num_refs"
113 #define FILENAME_UUID "uuid"
114 #define FILENAME_COMMON_NAME "common_name"
115 #define FILENAME_KBYTES_TOTAL "kbytestotal"
116 #define FILENAME_KBYTES_FREE "kbytesfree"
117 #define FILENAME_FILES_TOTAL "filestotal"
118 #define FILENAME_FILES_FREE "filesfree"
120 /* strings which the file /var/lustre/sysStatus can hold */
121 #define STR_ONLINE "online"
122 #define STR_ONLINE_PENDING "online pending"
123 #define STR_OFFLINE "offline"
124 #define STR_OFFLINE_PENDING "offline pending"
127 /* Script required for starting/stopping lustre services */
128 #define LUSTRE_SERVICE "/etc/init.d/lustre"
130 #define MIN_LEN(val1,val2) (((val1)>(val2))?(val2):(val1))
132 /* The max size of a lustre procfs path name*/
133 #define MAX_PATH_SIZE 512
135 /* The max size of a string read from procfs */
136 #define MAX_LINE_SIZE 512
138 /* Types passed to get_file_list() */
142 /* Defining return values */
146 typedef struct counter64 counter64;
156 /* File operation related functions */
157 char *get_file_list(const char *dirname, int file_type, uint32_t *count);
158 extern int is_directory(const char *filename);
159 extern int read_string(const char *filepath, char *lustre_var,size_t var_size);
160 int read_counter64(const char *file_path, counter64 *c64,int factor);
161 int read_ulong(const char *file_path,unsigned long* valuep);
163 /* Start/Stop/Restart Lustre Services */
164 extern void lustrefs_ctrl(int command);
165 extern int get_sysstatus();
167 extern void report(const char *fmt, ...);
169 /* Table Driven SNMP OID Handler support*/
170 typedef unsigned char* (*f_oid_handler_t)(
171 const char* file_path,
176 int magic; /*The magic number*/
177 const char *name; /*The procfs name*/
178 f_oid_handler_t fhandler; /*The handler */
181 unsigned char* oid_table_ulong_handler(const char* file_path,size_t *var_len);
182 unsigned char* oid_table_c64_handler(const char* file_path,size_t *var_len);
183 unsigned char* oid_table_c64_kb_handler(const char* file_path,size_t *var_len);
184 unsigned char* oid_table_obj_name_handler(const char* file_path,size_t *var_len);
185 unsigned char* oid_table_string_handler(const char* file_path,size_t *var_len);
186 unsigned char* oid_table_is_directory_handler(const char* file_path,size_t *var_len);
188 var_genericTable(struct variable *vp,
193 WriteMethod **write_method,
195 struct oid_table *ptable);
197 #endif /* LUSTRE_SNMP_UTIL_H */