1 /* Copyright (c) 2003-2004 Roger Seguin <roger_seguin@msn.com> 2 * 3 * This program is free software; you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation; either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Library General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 */ 17 #ifndef _devperf_h 18 #define _devperf_h 19 20 #ifdef HAVE_CONFIG_H 21 #include <config.h> 22 #endif 23 24 #include <stdlib.h> 25 #include <unistd.h> 26 #include <inttypes.h> 27 28 29 enum { 30 NO_ERROR, 31 NO_EXTENDED_STATS 32 }; 33 34 35 typedef struct devperf_t { 36 uint64_t timestamp_ns; 37 uint64_t rbytes; /* Number of bytes read from the device */ 38 uint64_t wbytes; /* Number of bytes written to the device */ 39 uint64_t rbusy_ns; /* Device read busy time */ 40 uint64_t wbusy_ns; /* Device write busy time */ 41 int32_t qlen; /* Current queue length */ 42 } devperf_t; 43 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 int DevPerfInit (void); 50 /* Make required initialisations */ 51 /* Return 0 on success */ 52 53 int DevCheckStatAvailability (char const **StatisticsFile); 54 /* Check the availability of required kernel statistics */ 55 /* Get the statistics file name */ 56 /* Return 0 on success */ 57 58 int DevGetPerfData (const void *devid, 59 struct devperf_t *perf); 60 /* Get disk performance data stored by the kernel */ 61 /* Return 0 on success, -1 otherwise */ 62 63 #ifdef __cplusplus 64 } /* extern "C" */ 65 #endif 66 67 #endif /* _devperf_h */ 68