nfs-ganesha 1.4
|
00001 /* 00002 * Copyright IBM Corporation, 2011 00003 * Contributor: Frank Filz <ffilzlnx@us.ibm.com> 00004 * 00005 * -------------------------- 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 3 of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 * 00021 * 00022 */ 00023 00024 #ifdef HAVE_CONFIG_H 00025 #include "config.h" 00026 #endif 00027 00028 #ifdef _SOLARIS 00029 #include "solaris_port.h" 00030 #endif 00031 00032 #include <stdio.h> 00033 #include <string.h> 00034 #include <pthread.h> 00035 #include <sys/stat.h> 00036 #include <time.h> 00037 00038 /* function name resolution */ 00039 #include "nfs_stat.h" 00040 00041 #include "nfs_core.h" 00042 #include "nfs_stat.h" 00043 #include "nfs_exports.h" 00044 #include "external_tools.h" 00045 #include "snmp_adm.h" 00046 00047 #include "common_utils.h" 00048 #include "log.h" 00049 00050 int worker_delay_time = 0; 00051 int next_worker_delay_time = 0; 00052 00053 int getErrInjectInteger(snmp_adm_type_union * param, void *opt) 00054 { 00055 long option = (long)opt; 00056 00057 switch(option) 00058 { 00059 case 0: param->integer = worker_delay_time; break; 00060 case 1: param->integer = next_worker_delay_time; break; 00061 default: return 1; 00062 } 00063 00064 return 0; 00065 } 00066 00067 int setErrInjectInteger(const snmp_adm_type_union * param, void *opt) 00068 { 00069 long option = (long)opt; 00070 00071 switch(option) 00072 { 00073 case 0: worker_delay_time = param->integer; break; 00074 case 1: next_worker_delay_time = param->integer; break; 00075 default: return 1; 00076 } 00077 00078 return 0; 00079 } 00080 00081 static register_get_set snmp_error_injection[] = { 00082 00083 {"worker_delay", "Delay for each request processed by worker threads", SNMP_ADM_INTEGER, SNMP_ADM_ACCESS_RW, 00084 getErrInjectInteger, setErrInjectInteger, (void *)0}, 00085 {"next_worker_delay", "Delay for next request processed by worker threads", SNMP_ADM_INTEGER, SNMP_ADM_ACCESS_RW, 00086 getErrInjectInteger, setErrInjectInteger, (void *)1}, 00087 }; 00088 00089 #define SNMPADM_ERROR_INJECTION_COUNT 2 00090 00091 int init_error_injector() 00092 { 00093 if(snmp_adm_register_get_set_function(INJECT_OID, snmp_error_injection, 00094 SNMPADM_ERROR_INJECTION_COUNT)) 00095 { 00096 LogCrit(COMPONENT_INIT, "Error registering error injection to SNMP"); 00097 return 2; 00098 } 00099 00100 return 0; 00101 }