1 /* 2 * Copyright (c) 2009 NLNet Labs. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 21 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 23 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 */ 26 27 #ifndef SIGNER_STATS_H 28 #define SIGNER_STATS_H 29 30 #include "config.h" 31 #include <ctype.h> 32 #include <stdint.h> 33 #include <time.h> 34 #ifdef HAVE_SYS_TYPES_H 35 # include <sys/types.h> 36 #endif 37 #ifdef HAVE_UNISTD_H 38 # include <unistd.h> 39 #endif 40 41 #include <ldns/ldns.h> 42 43 typedef struct stats_struct stats_type; 44 45 #include "locks.h" 46 47 /** 48 * Statistics structure. 49 */ 50 struct stats_struct { 51 uint32_t sort_count; 52 time_t sort_time; 53 int sort_done; 54 uint32_t nsec_count; 55 time_t nsec_time; 56 uint32_t sig_count; 57 uint32_t sig_soa_count; 58 uint32_t sig_reuse; 59 time_t sig_time; 60 time_t audit_time; 61 time_t start_time; 62 time_t end_time; 63 pthread_mutex_t stats_lock; 64 }; 65 66 /** 67 * Initialize statistics. 68 * \return the initialized stats; 69 * 70 */ 71 extern stats_type* stats_create(void); 72 73 /** 74 * Log statistics. 75 * \param[in] stats statistics 76 * \param[in] name zone name 77 * \param[in] serial serial 78 * \param[in] nsec_type NSEC or NSEC3 79 * 80 */ 81 extern void stats_log(stats_type* stats, const char* name, uint32_t serial, 82 ldns_rr_type nsec_type); 83 84 /** 85 * Clear statistics. 86 * \param[in] stats statistics to be cleared 87 * 88 */ 89 extern void stats_clear(stats_type* stats); 90 91 /** 92 * Clean up statistics. 93 * \param[in] stats statistics to be deleted 94 * 95 */ 96 extern void stats_cleanup(stats_type* stats); 97 98 #endif /* SIGNER_STATS_H */ 99