Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | /* * linux/net/sunrpc/stats.c * * procfs-based user access to generic RPC statistics. The stats files * reside in /proc/net/rpc. * * The read routines assume that the buffer passed in is just big enough. * If you implement an RPC service that has its own stats routine which * appends the generic RPC stats, make sure you don't exceed the PAGE_SIZE * limit. * * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> */ #define __NO_VERSION__ #include <linux/module.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/proc_fs.h> #include <linux/sunrpc/clnt.h> #include <linux/sunrpc/svcsock.h> #define RPCDBG_FACILITY RPCDBG_MISC static struct proc_dir_entry *proc_net_rpc = NULL; /* * Get RPC client stats */ int rpc_proc_read(char *buffer, char **start, off_t offset, int count, int *eof, void *data) { struct rpc_stat *statp = (struct rpc_stat *) data; struct rpc_program *prog = statp->program; struct rpc_version *vers; int len, i, j; len = sprintf(buffer, "net %d %d %d %d\n", statp->netcnt, statp->netudpcnt, statp->nettcpcnt, statp->nettcpconn); len += sprintf(buffer + len, "rpc %d %d %d\n", statp->rpccnt, statp->rpcretrans, statp->rpcauthrefresh); for (i = 0; i < prog->nrvers; i++) { if (!(vers = prog->version[i])) continue; len += sprintf(buffer + len, "proc%d %d", vers->number, vers->nrprocs); for (j = 0; j < vers->nrprocs; j++) len += sprintf(buffer + len, " %d", vers->procs[j].p_count); buffer[len++] = '\n'; } if (offset >= len) { *start = buffer; *eof = 1; return 0; } *start = buffer + offset; if ((len -= offset) > count) return count; *eof = 1; return len; } /* * Get RPC server stats */ int svc_proc_read(char *buffer, char **start, off_t offset, int count, int *eof, void *data) { struct svc_stat *statp = (struct svc_stat *) data; struct svc_program *prog = statp->program; struct svc_procedure *proc; struct svc_version *vers; int len, i, j; len = sprintf(buffer, "net %d %d %d %d\n", statp->netcnt, statp->netudpcnt, statp->nettcpcnt, statp->nettcpconn); len += sprintf(buffer + len, "rpc %d %d %d %d %d\n", statp->rpccnt, statp->rpcbadfmt+statp->rpcbadauth+statp->rpcbadclnt, statp->rpcbadfmt, statp->rpcbadauth, statp->rpcbadclnt); for (i = 0; i < prog->pg_nvers; i++) { if (!(vers = prog->pg_vers[i]) || !(proc = vers->vs_proc)) continue; len += sprintf(buffer + len, "proc%d %d", i, vers->vs_nproc); for (j = 0; j < vers->vs_nproc; j++, proc++) len += sprintf(buffer + len, " %d", proc->pc_count); buffer[len++] = '\n'; } if (offset >= len) { *start = buffer; *eof = 1; return 0; } *start = buffer + offset; if ((len -= offset) > count) return count; *eof = 1; return len; } /* * Register/unregister RPC proc files */ static inline struct proc_dir_entry * do_register(const char *name, void *data, int issvc) { struct proc_dir_entry *ent; rpc_proc_init(); dprintk("RPC: registering /proc/net/rpc/%s\n", name); ent = create_proc_entry(name, 0, proc_net_rpc); ent->read_proc = issvc? svc_proc_read : rpc_proc_read; ent->data = data; return ent; } struct proc_dir_entry * rpc_proc_register(struct rpc_stat *statp) { return do_register(statp->program->name, statp, 0); } void rpc_proc_unregister(const char *name) { remove_proc_entry(name, proc_net_rpc); } struct proc_dir_entry * svc_proc_register(struct svc_stat *statp) { return do_register(statp->program->pg_name, statp, 1); } void svc_proc_unregister(const char *name) { remove_proc_entry(name, proc_net_rpc); } void rpc_proc_init(void) { dprintk("RPC: registering /proc/net/rpc\n"); if (!proc_net_rpc) { struct proc_dir_entry *ent; ent = create_proc_entry("net/rpc", S_IFDIR, 0); if (ent) { #ifdef MODULE ent->fill_inode = rpc_modcount; #endif proc_net_rpc = ent; } } #ifdef RPC_DEBUG rpc_register_sysctl(); #endif } void rpc_proc_exit(void) { dprintk("RPC: unregistering /proc/net/rpc\n"); if (proc_net_rpc) { proc_net_rpc = NULL; remove_proc_entry("net/rpc", 0); } #ifdef RPC_DEBUG rpc_unregister_sysctl(); #endif } #ifdef MODULE /* * This is called as the proc_dir_entry fill_inode function * when an inode is going into or out of service (fill == 1 * or 0 respectively). * * We use it here to keep the module from being unloaded * while /proc inodes are in use. */ void rpc_modcount(struct inode *inode, int fill) { if (fill) MOD_INC_USE_COUNT; else MOD_DEC_USE_COUNT; } int init_module(void) { rpc_proc_init(); return 0; } void cleanup_module(void) { rpc_proc_exit(); } #endif |