Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 1 | /* utility routines for printing common objects in the Osmocom world */ |
| 2 | |
| 3 | /* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org> |
| 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <stdint.h> |
| 24 | #include <inttypes.h> |
| 25 | |
Pablo Neira Ayuso | 8341934 | 2011-03-22 16:36:13 +0100 | [diff] [blame] | 26 | #include <osmocom/core/linuxlist.h> |
| 27 | #include <osmocom/core/talloc.h> |
| 28 | #include <osmocom/core/timer.h> |
| 29 | #include <osmocom/core/rate_ctr.h> |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 30 | |
| 31 | #include <osmocom/vty/vty.h> |
| 32 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 33 | /* \file utils.c */ |
| 34 | |
| 35 | /*! \addtogroup rate_ctr |
| 36 | * @{ |
| 37 | */ |
| 38 | |
| 39 | /*! \brief print a rate counter group to given VTY |
| 40 | * \param[in] vty The VTY to which it should be printed |
| 41 | * \param[in] prefix Any additional log prefix ahead of each line |
| 42 | * \param[in] ctrg Rate counter group to be printed |
| 43 | */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 44 | void vty_out_rate_ctr_group(struct vty *vty, const char *prefix, |
| 45 | struct rate_ctr_group *ctrg) |
| 46 | { |
| 47 | unsigned int i; |
| 48 | |
| 49 | vty_out(vty, "%s%s:%s", prefix, ctrg->desc->group_description, VTY_NEWLINE); |
| 50 | for (i = 0; i < ctrg->desc->num_ctr; i++) { |
| 51 | struct rate_ctr *ctr = &ctrg->ctr[i]; |
| 52 | vty_out(vty, " %s%s: %8" PRIu64 " " |
| 53 | "(%" PRIu64 "/s %" PRIu64 "/m %" PRIu64 "/h %" PRIu64 "/d)%s", |
| 54 | prefix, ctrg->desc->ctr_desc[i].description, ctr->current, |
| 55 | ctr->intv[RATE_CTR_INTV_SEC].rate, |
| 56 | ctr->intv[RATE_CTR_INTV_MIN].rate, |
| 57 | ctr->intv[RATE_CTR_INTV_HOUR].rate, |
| 58 | ctr->intv[RATE_CTR_INTV_DAY].rate, |
| 59 | VTY_NEWLINE); |
| 60 | }; |
| 61 | } |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 62 | |
| 63 | /*! }@ */ |