Initial import
This commit is contained in:
2
include/bmon/.gitignore
vendored
Normal file
2
include/bmon/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
defs.h*
|
||||
stamp-h1
|
138
include/bmon/attr.h
Normal file
138
include/bmon/attr.h
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* bmon/attr.h Attributes
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_ATTR_H_
|
||||
#define __BMON_ATTR_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
#include <bmon/unit.h>
|
||||
|
||||
struct element;
|
||||
|
||||
struct rate
|
||||
{
|
||||
/* Total value of attribute with eventual overflows accumulated. */
|
||||
uint64_t r_total;
|
||||
|
||||
/* Current value of counter */
|
||||
uint64_t r_current;
|
||||
|
||||
/* Value of r_current at last read */
|
||||
uint64_t r_prev;
|
||||
|
||||
/* Rate per second calculated every `rate_interval' */
|
||||
float r_rate;
|
||||
|
||||
/* Time of last calculation */
|
||||
timestamp_t r_last_calc;
|
||||
};
|
||||
|
||||
enum {
|
||||
ATTR_TYPE_UNSPEC,
|
||||
ATTR_TYPE_COUNTER,
|
||||
ATTR_TYPE_RATE,
|
||||
ATTR_TYPE_PERCENT,
|
||||
};
|
||||
|
||||
struct attr_def {
|
||||
int ad_id;
|
||||
char * ad_name;
|
||||
char * ad_description;
|
||||
int ad_type;
|
||||
int ad_flags;
|
||||
struct unit * ad_unit;
|
||||
|
||||
struct list_head ad_list;
|
||||
};
|
||||
|
||||
struct attr_map {
|
||||
const char * name;
|
||||
const char * description;
|
||||
const char * unit;
|
||||
int attrid,
|
||||
type,
|
||||
rxid,
|
||||
txid,
|
||||
flags;
|
||||
};
|
||||
|
||||
extern int attr_def_add(const char *, const char *,
|
||||
struct unit *, int, int);
|
||||
extern struct attr_def * attr_def_lookup(const char *);
|
||||
extern struct attr_def * attr_def_lookup_id(int);
|
||||
|
||||
extern int attr_map_load(struct attr_map *map, size_t size);
|
||||
|
||||
#define ATTR_FORCE_HISTORY 0x01 /* collect history */
|
||||
#define ATTR_IGNORE_OVERFLOWS 0x02
|
||||
#define ATTR_TRUE_64BIT 0x04
|
||||
#define ATTR_RX_ENABLED 0x08 /* has RX counter */
|
||||
#define ATTR_TX_ENABLED 0x10 /* has TX counter */
|
||||
#define ATTR_DOING_HISTORY 0x20 /* history collected */
|
||||
|
||||
struct attr
|
||||
{
|
||||
struct rate a_rx_rate,
|
||||
a_tx_rate;
|
||||
|
||||
uint8_t a_flags;
|
||||
struct attr_def * a_def;
|
||||
timestamp_t a_last_update;
|
||||
|
||||
struct list_head a_history_list;
|
||||
|
||||
struct list_head a_list;
|
||||
struct list_head a_sort_list;
|
||||
};
|
||||
|
||||
extern struct attr * attr_lookup(const struct element *, int);
|
||||
extern void attr_update(struct element *, int,
|
||||
uint64_t, uint64_t , int );
|
||||
extern void attr_notify_update(struct attr *,
|
||||
timestamp_t *);
|
||||
extern void attr_free(struct attr *);
|
||||
|
||||
extern void attr_rate2float(struct attr *,
|
||||
double *, char **, int *,
|
||||
double *, char **, int *);
|
||||
|
||||
extern void attr_calc_usage(struct attr *, float *, float *,
|
||||
uint64_t, uint64_t);
|
||||
|
||||
#define ATTR_HASH_SIZE 32
|
||||
|
||||
#define UPDATE_FLAG_RX 0x01
|
||||
#define UPDATE_FLAG_TX 0x02
|
||||
#define UPDATE_FLAG_64BIT 0x04
|
||||
|
||||
extern struct attr * attr_select_first(void);
|
||||
extern struct attr * attr_select_last(void);
|
||||
extern struct attr * attr_select_next(void);
|
||||
extern struct attr * attr_select_prev(void);
|
||||
extern struct attr * attr_current(void);
|
||||
|
||||
extern void attr_start_collecting_history(struct attr *);
|
||||
|
||||
#endif
|
82
include/bmon/bmon.h
Normal file
82
include/bmon/bmon.h
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* bmon.h All-include Header
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_BMON_H_
|
||||
#define __BMON_BMON_H_
|
||||
|
||||
#include <bmon/config.h>
|
||||
#include <bmon/list.h>
|
||||
|
||||
extern int start_time;
|
||||
|
||||
typedef struct timestamp_s
|
||||
{
|
||||
int64_t tv_sec;
|
||||
int64_t tv_usec;
|
||||
} timestamp_t;
|
||||
|
||||
typedef struct xdate_s
|
||||
{
|
||||
struct tm d_tm;
|
||||
unsigned int d_usec;
|
||||
} xdate_t;
|
||||
|
||||
enum {
|
||||
EMPTY_LIST = 1,
|
||||
END_OF_LIST = 2
|
||||
};
|
||||
|
||||
#define BUG() \
|
||||
do { \
|
||||
fprintf(stderr, "BUG: %s:%d\n", __FILE__, __LINE__); \
|
||||
assert(0); \
|
||||
exit(EINVAL); \
|
||||
} while (0);
|
||||
|
||||
#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
|
||||
|
||||
#if defined __GNUC__
|
||||
#define __init __attribute__ ((constructor))
|
||||
#define __exit __attribute__ ((destructor))
|
||||
#else
|
||||
#define __init
|
||||
#define __exit
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DBG(FMT, ARG...) \
|
||||
do { \
|
||||
fprintf(stderr, \
|
||||
"[DBG] %20s:%-4u %s: " FMT "\n", \
|
||||
__FILE__, __LINE__, \
|
||||
__PRETTY_FUNCTION__, ##ARG); \
|
||||
} while (0)
|
||||
#else
|
||||
#define DBG(FMT, ARG...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif
|
35
include/bmon/compile-fixes.h
Normal file
35
include/bmon/compile-fixes.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* compile_fixes.h
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_COMPILE_FIXES_H_
|
||||
#define __BMON_COMPILE_FIXES_H_
|
||||
|
||||
#include <bmon/defs.h>
|
||||
|
||||
#ifndef HAVE_SUSECONDS_T
|
||||
typedef long suseconds_t;
|
||||
#endif
|
||||
|
||||
#endif
|
91
include/bmon/conf.h
Normal file
91
include/bmon/conf.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* conf.h Config Crap
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_CONF_H_
|
||||
#define __BMON_CONF_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
|
||||
extern cfg_t *cfg;
|
||||
|
||||
extern float cfg_read_interval;
|
||||
extern float cfg_rate_interval;
|
||||
extern float cfg_rate_variance;
|
||||
extern float cfg_history_variance;
|
||||
extern int cfg_show_all;
|
||||
extern int cfg_unit_exp;
|
||||
|
||||
extern void conf_init_pre(void);
|
||||
extern void conf_init_post(void);
|
||||
extern void configfile_read(void);
|
||||
extern void set_configfile(const char *);
|
||||
|
||||
extern unsigned int get_lifecycles(void);
|
||||
|
||||
extern void conf_set_float(const char *, double);
|
||||
extern double conf_get_float(const char *);
|
||||
extern void conf_set_int(const char *, long);
|
||||
extern long conf_get_int(const char *);
|
||||
extern void conf_set_string(const char *, const char *);
|
||||
extern const char * conf_get_string(const char *);
|
||||
|
||||
typedef struct tv_s
|
||||
{
|
||||
char * tv_type;
|
||||
char * tv_value;
|
||||
struct list_head tv_list;
|
||||
} tv_t;
|
||||
|
||||
typedef struct module_conf_s
|
||||
{
|
||||
char * m_name;
|
||||
struct list_head m_attrs;
|
||||
struct list_head m_list;
|
||||
} module_conf_t;
|
||||
|
||||
extern int parse_module_param(const char *, struct list_head *);
|
||||
|
||||
enum {
|
||||
LAYOUT_UNSPEC,
|
||||
LAYOUT_DEFAULT,
|
||||
LAYOUT_STATUSBAR,
|
||||
LAYOUT_HEADER,
|
||||
LAYOUT_LIST,
|
||||
LAYOUT_SELECTED,
|
||||
__LAYOUT_MAX
|
||||
};
|
||||
|
||||
#define LAYOUT_MAX (__LAYOUT_MAX - 1)
|
||||
|
||||
struct layout
|
||||
{
|
||||
int l_fg,
|
||||
l_bg,
|
||||
l_attr;
|
||||
};
|
||||
|
||||
extern struct layout cfg_layout[];
|
||||
|
||||
#endif
|
158
include/bmon/config.h
Normal file
158
include/bmon/config.h
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* config.h Global Config
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_CONFIG_H_
|
||||
#define __BMON_CONFIG_H_
|
||||
|
||||
#include <bmon/defs.h>
|
||||
#include <bmon/compile-fixes.h>
|
||||
|
||||
#if STDC_HEADERS != 1
|
||||
#error "*** ERROR: ANSI C headers required for compilation ***"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <signal.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/file.h>
|
||||
#include <assert.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/wait.h>
|
||||
#include <dirent.h>
|
||||
#include <values.h>
|
||||
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VFORK_H
|
||||
#include <vfork.h>
|
||||
#endif
|
||||
|
||||
#if !HAVE_WORKING_VFORK
|
||||
#define vfork fork
|
||||
#endif
|
||||
|
||||
#if defined HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#elif defined HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#else
|
||||
#error "*** ERROR: No string header file found ***"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_INITTYPES_H
|
||||
#include <inittypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#if defined HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined HAVE_SYS_UTSNAME_H
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
#if defined HAVE_NCURSESW_CURSES_H
|
||||
# include <ncursesw/curses.h>
|
||||
#elif defined HAVE_NCURSESW_H
|
||||
# include <ncursesw.h>
|
||||
#elif defined HAVE_NCURSES_CURSES_H
|
||||
# include <ncurses/curses.h>
|
||||
#elif defined HAVE_NCURSES_H
|
||||
# include <ncurses.h>
|
||||
#elif defined HAVE_CURSES_H
|
||||
# include <curses.h>
|
||||
#else
|
||||
# error "SysV or X/Open-compatible Curses header file required"
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#if defined HAVE_NETINET6_IN6_H
|
||||
#include <netinet6/in6.h>
|
||||
#endif
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <confuse.h>
|
||||
|
||||
#ifndef IFNAMSIZ
|
||||
#define IFNAMSIZ 16
|
||||
#endif
|
||||
|
||||
#ifndef SCNu64
|
||||
#define SCNu64 "llu"
|
||||
#endif
|
||||
|
||||
#ifndef PRIu64
|
||||
#define PRIu64 "llu"
|
||||
#endif
|
||||
|
||||
#ifndef PRId64
|
||||
#define PRId64 "lld"
|
||||
#endif
|
||||
|
||||
#ifndef PRIX64
|
||||
#define PRIX64 "X"
|
||||
#endif
|
||||
|
||||
#define DEFAULT_GROUP "intf"
|
||||
|
||||
#endif
|
246
include/bmon/defs.h.in
Normal file
246
include/bmon/defs.h.in
Normal file
@ -0,0 +1,246 @@
|
||||
/* include/bmon/defs.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* enable debugging */
|
||||
#undef DEBUG
|
||||
|
||||
/* no overflow workaround */
|
||||
#undef DISABLE_OVERFLOW_WORKAROUND
|
||||
|
||||
/* Define to 1 if you have the `atexit' function. */
|
||||
#undef HAVE_ATEXIT
|
||||
|
||||
/* have curses */
|
||||
#undef HAVE_CURSES
|
||||
|
||||
/* Define to 1 if library supports color (enhanced functions) */
|
||||
#undef HAVE_CURSES_COLOR
|
||||
|
||||
/* Define to 1 if library supports X/Open Enhanced functions */
|
||||
#undef HAVE_CURSES_ENHANCED
|
||||
|
||||
/* Define to 1 if <curses.h> is present */
|
||||
#undef HAVE_CURSES_H
|
||||
|
||||
/* Define to 1 if library supports certain obsolete features */
|
||||
#undef HAVE_CURSES_OBSOLETE
|
||||
|
||||
/* Define to 1 if you have the <dirent.h> header file. */
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define to 1 if you have the `getdate' function. */
|
||||
#undef HAVE_GETDATE
|
||||
|
||||
/* Define to 1 if you have the <getopt.h> header file. */
|
||||
#undef HAVE_GETOPT_H
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#undef HAVE_LIBM
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* have ncurses */
|
||||
#undef HAVE_NCURSES
|
||||
|
||||
/* Define to 1 if the NcursesW library is present */
|
||||
#undef HAVE_NCURSESW
|
||||
|
||||
/* Define to 1 if <ncursesw/curses.h> is present */
|
||||
#undef HAVE_NCURSESW_CURSES_H
|
||||
|
||||
/* Define to 1 if <ncursesw.h> is present */
|
||||
#undef HAVE_NCURSESW_H
|
||||
|
||||
/* Define to 1 if <ncurses/curses.h> is present */
|
||||
#undef HAVE_NCURSES_CURSES_H
|
||||
|
||||
/* Define to 1 if <ncurses.h> is present */
|
||||
#undef HAVE_NCURSES_H
|
||||
|
||||
/* Define to 1 if you have the <ncurses/ncurses.h> header file. */
|
||||
#undef HAVE_NCURSES_NCURSES_H
|
||||
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define to 1 if you have the <netinet6/in6.h> header file. */
|
||||
#undef HAVE_NETINET6_IN6_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the `pow' function. */
|
||||
#undef HAVE_POW
|
||||
|
||||
/* have redrawwin */
|
||||
#undef HAVE_REDRAWWIN
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#undef HAVE_SOCKET
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
#undef HAVE_STRNCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
#undef HAVE_STRTOL
|
||||
|
||||
/* Define to 1 if the system has the type `suseconds_t'. */
|
||||
#undef HAVE_SUSECONDS_T
|
||||
|
||||
/* Define to 1 if you have the <sysctl/ioctl.h> header file. */
|
||||
#undef HAVE_SYSCTL_IOCTL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <sys/sockio.h> header file. */
|
||||
#undef HAVE_SYS_SOCKIO_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <sys/utsname.h> header file. */
|
||||
#undef HAVE_SYS_UTSNAME_H
|
||||
|
||||
/* Define to 1 if you have the `uname' function. */
|
||||
#undef HAVE_UNAME
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* have udc */
|
||||
#undef HAVE_USE_DEFAULT_COLORS
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#undef HAVE_VFORK
|
||||
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#undef HAVE_WORKING_FORK
|
||||
|
||||
/* Define to 1 if `vfork' works. */
|
||||
#undef HAVE_WORKING_VFORK
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* operating system */
|
||||
#undef SYS_BSD
|
||||
|
||||
/* operating system */
|
||||
#undef SYS_LINUX
|
||||
|
||||
/* operating system */
|
||||
#undef SYS_OTHER
|
||||
|
||||
/* operating system */
|
||||
#undef SYS_SUNOS
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
#undef vfork
|
130
include/bmon/element.h
Normal file
130
include/bmon/element.h
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* bmon/element.h Elements
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_ELEMENT_H_
|
||||
#define __BMON_ELEMENT_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
#include <bmon/group.h>
|
||||
#include <bmon/attr.h>
|
||||
|
||||
#define MAX_GRAPHS 32
|
||||
#define IFNAME_MAX 32
|
||||
|
||||
struct policy
|
||||
{
|
||||
char * p_rule;
|
||||
struct list_head p_list;
|
||||
};
|
||||
|
||||
struct element_cfg;
|
||||
|
||||
struct info
|
||||
{
|
||||
char * i_name;
|
||||
char * i_value;
|
||||
struct list_head i_list;
|
||||
};
|
||||
|
||||
struct element
|
||||
{
|
||||
char * e_name;
|
||||
char * e_description;
|
||||
uint32_t e_id;
|
||||
uint32_t e_flags;
|
||||
unsigned int e_lifecycles;
|
||||
unsigned int e_level; /* recursion level */
|
||||
|
||||
struct element * e_parent;
|
||||
struct element_group * e_group;
|
||||
|
||||
struct list_head e_list;
|
||||
struct list_head e_childs;
|
||||
|
||||
unsigned int e_nattrs;
|
||||
struct list_head e_attrhash[ATTR_HASH_SIZE];
|
||||
struct list_head e_attr_sorted;
|
||||
|
||||
unsigned int e_ninfo;
|
||||
struct list_head e_info_list;
|
||||
|
||||
struct attr_def * e_key_attr[__GT_MAX];
|
||||
struct attr_def * e_usage_attr;
|
||||
|
||||
float e_rx_usage,
|
||||
e_tx_usage;
|
||||
|
||||
struct element_cfg * e_cfg;
|
||||
|
||||
struct attr * e_current_attr;
|
||||
};
|
||||
|
||||
#define ELEMENT_CREAT (1 << 0)
|
||||
|
||||
extern struct element * element_lookup(struct element_group *,
|
||||
const char *, uint32_t,
|
||||
struct element *, int);
|
||||
|
||||
extern void element_free(struct element *);
|
||||
|
||||
extern void element_reset_update_flag(struct element_group *,
|
||||
struct element *,
|
||||
void *);
|
||||
extern void element_notify_update(struct element *,
|
||||
timestamp_t *);
|
||||
extern void element_lifesign(struct element *, int);
|
||||
extern void element_check_if_dead(struct element_group *,
|
||||
struct element *, void *);
|
||||
|
||||
extern int element_set_key_attr(struct element *, const char *, const char *);
|
||||
extern int element_set_usage_attr(struct element *, const char *);
|
||||
|
||||
#define ELEMENT_FLAG_FOLDED (1 << 0)
|
||||
#define ELEMENT_FLAG_UPDATED (1 << 1)
|
||||
#define ELEMENT_FLAG_EXCLUDE (1 << 2)
|
||||
#define ELEMENT_FLAG_CREATED (1 << 3)
|
||||
|
||||
extern void element_foreach_attr(struct element *,
|
||||
void (*cb)(struct element *,
|
||||
struct attr *, void *),
|
||||
void *);
|
||||
|
||||
extern struct element * element_current(void);
|
||||
extern struct element * element_select_first(void);
|
||||
extern struct element * element_select_last(void);
|
||||
extern struct element * element_select_next(void);
|
||||
extern struct element * element_select_prev(void);
|
||||
|
||||
extern int element_allowed(const char *, struct element_cfg *);
|
||||
extern void element_parse_policy(const char *);
|
||||
|
||||
extern void element_update_info(struct element *,
|
||||
const char *,
|
||||
const char *);
|
||||
|
||||
extern void element_set_txmax(struct element *, uint64_t);
|
||||
extern void element_set_rxmax(struct element *, uint64_t);
|
||||
|
||||
#endif
|
53
include/bmon/element_cfg.h
Normal file
53
include/bmon/element_cfg.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* element_cfg.h Element Configuration
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_ELEMENT_CFG_H_
|
||||
#define __BMON_ELEMENT_CFG_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
#include <bmon/conf.h>
|
||||
|
||||
#define ELEMENT_CFG_SHOW (1 << 0)
|
||||
#define ELEMENT_CFG_HIDE (1 << 1)
|
||||
|
||||
struct element_cfg
|
||||
{
|
||||
char * ec_name; /* Name of element config */
|
||||
char * ec_parent; /* Name of parent */
|
||||
char * ec_description; /* Human readable description */
|
||||
uint64_t ec_rxmax; /* Maximum RX value expected */
|
||||
uint64_t ec_txmax; /* Minimum TX value expected */
|
||||
unsigned int ec_flags; /* Flags */
|
||||
|
||||
struct list_head ec_list; /* Internal, do not modify */
|
||||
int ec_refcnt; /* Internal, do not modify */
|
||||
};
|
||||
|
||||
extern struct element_cfg * element_cfg_alloc(const char *);
|
||||
extern struct element_cfg * element_cfg_create(const char *);
|
||||
extern void element_cfg_free(struct element_cfg *);
|
||||
extern struct element_cfg * element_cfg_lookup(const char *);
|
||||
|
||||
#endif
|
72
include/bmon/graph.h
Normal file
72
include/bmon/graph.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* bmon/graph.h Graph creation utility
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_GRAPH_H_
|
||||
#define __BMON_GRAPH_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
#include <bmon/unit.h>
|
||||
|
||||
struct history;
|
||||
|
||||
struct graph_cfg {
|
||||
int gc_height,
|
||||
gc_width,
|
||||
gc_flags;
|
||||
|
||||
char gc_background,
|
||||
gc_foreground,
|
||||
gc_noise,
|
||||
gc_unknown;
|
||||
|
||||
struct unit * gc_unit;
|
||||
};
|
||||
|
||||
struct graph_table {
|
||||
char * gt_table;
|
||||
char * gt_y_unit;
|
||||
float * gt_scale;
|
||||
};
|
||||
|
||||
struct graph {
|
||||
struct graph_cfg g_cfg;
|
||||
struct graph_table g_rx,
|
||||
g_tx;
|
||||
|
||||
struct list_head g_list;
|
||||
};
|
||||
|
||||
extern void graph_free(struct graph *);
|
||||
extern struct graph * graph_alloc(struct history *, struct graph_cfg *);
|
||||
extern void graph_refill(struct graph *, struct history *);
|
||||
|
||||
extern size_t graph_row_size(struct graph_cfg *);
|
||||
|
||||
extern void new_graph(void);
|
||||
extern void del_graph(void);
|
||||
extern int next_graph(void);
|
||||
extern int prev_graph(void);
|
||||
|
||||
#endif
|
100
include/bmon/group.h
Normal file
100
include/bmon/group.h
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* bmon/group.h Group Management
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_GROUP_H_
|
||||
#define __BMON_GROUP_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
|
||||
struct element;
|
||||
|
||||
enum {
|
||||
GT_MAJOR,
|
||||
GT_MINOR,
|
||||
__GT_MAX,
|
||||
};
|
||||
|
||||
#define GT_MAX (__GT_MAX - 1)
|
||||
|
||||
#define GROUP_COL_MAX (__GT_MAX * 2)
|
||||
|
||||
struct group_hdr
|
||||
{
|
||||
char * gh_name;
|
||||
char * gh_title;
|
||||
char * gh_column[GROUP_COL_MAX];
|
||||
struct list_head gh_list;
|
||||
};
|
||||
|
||||
extern struct group_hdr * group_lookup_hdr(const char *);
|
||||
extern int group_new_hdr(const char *, const char *,
|
||||
const char *, const char *,
|
||||
const char *, const char *);
|
||||
extern int group_new_derived_hdr(const char *,
|
||||
const char *,
|
||||
const char *);
|
||||
|
||||
struct element_group
|
||||
{
|
||||
char * g_name;
|
||||
struct group_hdr * g_hdr;
|
||||
|
||||
struct list_head g_elements;
|
||||
unsigned int g_nelements;
|
||||
|
||||
/* Currently selected element in this group */
|
||||
struct element * g_current;
|
||||
|
||||
struct list_head g_list;
|
||||
};
|
||||
|
||||
#define GROUP_CREATE 1
|
||||
|
||||
extern struct element_group * group_lookup(const char *, int);
|
||||
extern void reset_update_flags(void);
|
||||
extern void free_unused_elements(void);
|
||||
extern void calc_rates(void);
|
||||
|
||||
extern void group_foreach(
|
||||
void (*cb)(struct element_group *,
|
||||
void *),
|
||||
void *);
|
||||
extern void group_foreach_recursive(
|
||||
void (*cb)(struct element_group *,
|
||||
struct element *, void *),
|
||||
void *);
|
||||
|
||||
extern void group_foreach_element(struct element_group *,
|
||||
void (*cb)(struct element_group *,
|
||||
struct element *, void *),
|
||||
void *);
|
||||
|
||||
extern struct element_group * group_current(void);
|
||||
extern struct element_group * group_select_first(void);
|
||||
extern struct element_group * group_select_last(void);
|
||||
extern struct element_group * group_select_next(void);
|
||||
extern struct element_group * group_select_prev(void);
|
||||
|
||||
#endif
|
93
include/bmon/history.h
Normal file
93
include/bmon/history.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* bmon/history.h History Management
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_HISTORY_H_
|
||||
#define __BMON_HISTORY_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
#include <bmon/attr.h>
|
||||
|
||||
#define HISTORY_UNKNOWN ((uint64_t) -1)
|
||||
#define HBEAT_TRIGGER 60.0f
|
||||
|
||||
enum {
|
||||
HISTORY_TYPE_8 = 1,
|
||||
HISTORY_TYPE_16 = 2,
|
||||
HISTORY_TYPE_32 = 4,
|
||||
HISTORY_TYPE_64 = 8,
|
||||
};
|
||||
|
||||
struct history_def
|
||||
{
|
||||
char * hd_name;
|
||||
int hd_size,
|
||||
hd_type;
|
||||
float hd_interval;
|
||||
|
||||
struct list_head hd_list;
|
||||
};
|
||||
|
||||
struct history_store
|
||||
{
|
||||
/* TODO? store error ratio? */
|
||||
void * hs_data;
|
||||
uint64_t hs_prev_total;
|
||||
};
|
||||
|
||||
struct history
|
||||
{
|
||||
/* index to current entry in data array */
|
||||
int h_index;
|
||||
struct history_def * h_definition;
|
||||
/* time of last history update */
|
||||
timestamp_t h_last_update;
|
||||
struct list_head h_list;
|
||||
|
||||
float h_min_interval,
|
||||
h_max_interval;
|
||||
|
||||
struct history_store h_rx,
|
||||
h_tx;
|
||||
|
||||
};
|
||||
|
||||
extern struct history_def * history_def_lookup(const char *);
|
||||
extern struct history_def * history_def_alloc(const char *);
|
||||
|
||||
extern uint64_t history_data(struct history *,
|
||||
struct history_store *, int);
|
||||
extern void history_update(struct attr *,
|
||||
struct history *, timestamp_t *);
|
||||
extern struct history * history_alloc(struct history_def *);
|
||||
extern void history_free(struct history *);
|
||||
extern void history_attach(struct attr *);
|
||||
|
||||
extern struct history_def * history_select_first(void);
|
||||
extern struct history_def * history_select_last(void);
|
||||
extern struct history_def * history_select_next(void);
|
||||
extern struct history_def * history_select_prev(void);
|
||||
extern struct history_def * history_current(void);
|
||||
|
||||
#endif
|
42
include/bmon/info.h
Normal file
42
include/bmon/info.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* bmon/info.h Info Attributes
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_INFO_H_
|
||||
#define __BMON_INFO_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
#include <bmon/unit.h>
|
||||
|
||||
struct element;
|
||||
|
||||
struct info
|
||||
{
|
||||
char * i_name;
|
||||
char * i_value;
|
||||
|
||||
struct list_head i_list;
|
||||
};
|
||||
|
||||
#endif
|
52
include/bmon/input.h
Normal file
52
include/bmon/input.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* input.h Input API
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_INPUT_H_
|
||||
#define __BMON_INPUT_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
#include <bmon/conf.h>
|
||||
#include <bmon/module.h>
|
||||
|
||||
extern int input_set(const char *);
|
||||
extern void input_register(struct bmon_module *);
|
||||
extern void input_read(void);
|
||||
|
||||
struct reader_timing
|
||||
{
|
||||
timestamp_t rt_last_read; /* timestamp taken before read */
|
||||
timestamp_t rt_next_read; /* estimated next read */
|
||||
|
||||
struct {
|
||||
float v_error;
|
||||
float v_max;
|
||||
float v_min;
|
||||
float v_total;
|
||||
} rt_variance;
|
||||
};
|
||||
|
||||
extern struct reader_timing rtiming;
|
||||
|
||||
#endif
|
93
include/bmon/list.h
Normal file
93
include/bmon/list.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* bmon/list.h Kernel List Implementation
|
||||
*
|
||||
* Copied and adapted from the kernel sources
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BMON_LIST_H_
|
||||
#define BMON_LIST_H_
|
||||
|
||||
struct list_head
|
||||
{
|
||||
struct list_head * next;
|
||||
struct list_head * prev;
|
||||
};
|
||||
|
||||
static inline void INIT_LIST_HEAD(struct list_head *list)
|
||||
{
|
||||
list->next = list;
|
||||
list->prev = list;
|
||||
}
|
||||
|
||||
static inline void __list_add(struct list_head *obj, struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
prev->next = obj;
|
||||
obj->prev = prev;
|
||||
next->prev = obj;
|
||||
obj->next = next;
|
||||
}
|
||||
|
||||
static inline void list_add_tail(struct list_head *obj, struct list_head *head)
|
||||
{
|
||||
__list_add(obj, head->prev, head);
|
||||
}
|
||||
|
||||
static inline void list_add_head(struct list_head *obj, struct list_head *head)
|
||||
{
|
||||
__list_add(obj, head, head->next);
|
||||
}
|
||||
|
||||
static inline void list_del(struct list_head *obj)
|
||||
{
|
||||
obj->next->prev = obj->prev;
|
||||
obj->prev->next = obj->next;
|
||||
}
|
||||
|
||||
static inline int list_empty(struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - ((size_t) &((type *)0)->member));})
|
||||
|
||||
#define list_entry(ptr, type, member) \
|
||||
container_of(ptr, type, member)
|
||||
|
||||
#define list_at_tail(pos, head, member) \
|
||||
((pos)->member.next == (head))
|
||||
|
||||
#define list_at_head(pos, head, member) \
|
||||
((pos)->member.prev == (head))
|
||||
|
||||
#define LIST_SELF(name) { &(name), &(name) }
|
||||
|
||||
#define LIST_HEAD(name) \
|
||||
struct list_head name = { &(name), &(name) }
|
||||
|
||||
#define list_first_entry(head, type, member) \
|
||||
list_entry((head)->next, type, member)
|
||||
|
||||
#define list_for_each_entry(pos, head, member) \
|
||||
for (pos = list_entry((head)->next, typeof(*pos), member); \
|
||||
&(pos)->member != (head); \
|
||||
(pos) = list_entry((pos)->member.next, typeof(*(pos)), member))
|
||||
|
||||
#define list_for_each_entry_reverse(pos, head, member) \
|
||||
for (pos = list_entry((head)->prev, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.prev, typeof(*pos), member))
|
||||
|
||||
#define list_for_each_entry_safe(pos, n, head, member) \
|
||||
for (pos = list_entry((head)->next, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&(pos)->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, typeof(*n), member))
|
||||
|
||||
#define init_list_head(head) \
|
||||
do { (head)->next = (head); (head)->prev = (head); } while (0)
|
||||
|
||||
#endif
|
75
include/bmon/module.h
Normal file
75
include/bmon/module.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* module.h Module API
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_MODULE_H_
|
||||
#define __BMON_MODULE_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
#include <bmon/conf.h>
|
||||
|
||||
#define BMON_MODULE_ENABLED 1
|
||||
#define BMON_MODULE_DEFAULT 2
|
||||
|
||||
struct bmon_module
|
||||
{
|
||||
char * m_name;
|
||||
|
||||
int (*m_init)(void);
|
||||
int (*m_probe)(void);
|
||||
void (*m_shutdown)(void);
|
||||
|
||||
void (*m_parse_opt)(const char *, const char *);
|
||||
|
||||
void (*m_pre)(void);
|
||||
void (*m_do)(void);
|
||||
void (*m_post)(void);
|
||||
|
||||
int m_flags;
|
||||
struct list_head m_list;
|
||||
};
|
||||
|
||||
struct bmon_subsys
|
||||
{
|
||||
char * s_name;
|
||||
int s_nmod;
|
||||
struct list_head s_mod_list;
|
||||
|
||||
void (*s_activate_default)(void);
|
||||
|
||||
struct list_head s_list;
|
||||
};
|
||||
|
||||
extern void module_foreach_run_enabled_pre(struct bmon_subsys *);
|
||||
extern void module_foreach_run_enabled(struct bmon_subsys *);
|
||||
extern void module_foreach_run_enabled_post(struct bmon_subsys *);
|
||||
|
||||
extern void module_register(struct bmon_subsys *, struct bmon_module *);
|
||||
extern int module_set(struct bmon_subsys *, const char *);
|
||||
|
||||
extern void module_init(void);
|
||||
extern void module_shutdown(void);
|
||||
extern void module_register_subsys(struct bmon_subsys *);
|
||||
|
||||
#endif
|
39
include/bmon/output.h
Normal file
39
include/bmon/output.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* output.h Output API
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_OUTPUT_H_
|
||||
#define __BMON_OUTPUT_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
#include <bmon/conf.h>
|
||||
#include <bmon/module.h>
|
||||
|
||||
extern void output_register(struct bmon_module *);
|
||||
extern int output_set(const char *);
|
||||
extern void output_pre(void);
|
||||
extern void output_draw(void);
|
||||
extern void output_post(void);
|
||||
|
||||
#endif
|
68
include/bmon/unit.h
Normal file
68
include/bmon/unit.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* bmon/unit.h Units
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_UNIT_H_
|
||||
#define __BMON_UNIT_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
|
||||
#define DYNAMIC_EXP (-1)
|
||||
|
||||
enum {
|
||||
UNIT_DEFAULT,
|
||||
UNIT_SI,
|
||||
__UNIT_MAX,
|
||||
};
|
||||
|
||||
#define UNIT_MAX (__UNIT_MAX - 1)
|
||||
|
||||
#define UNIT_BYTE "byte"
|
||||
#define UNIT_NUMBER "number"
|
||||
|
||||
struct fraction {
|
||||
uint64_t f_divisor;
|
||||
char * f_name;
|
||||
|
||||
struct list_head f_list;
|
||||
};
|
||||
|
||||
struct unit {
|
||||
char * u_name;
|
||||
struct list_head u_div[__UNIT_MAX];
|
||||
|
||||
struct list_head u_list;
|
||||
};
|
||||
|
||||
extern struct unit * unit_lookup(const char *);
|
||||
extern struct unit * unit_add(const char *name);
|
||||
extern void unit_add_div(struct unit *, int, const char *, float);
|
||||
extern uint64_t unit_divisor(uint64_t, struct unit *, char **, int *);
|
||||
extern double unit_value2str(uint64_t, struct unit *, char **, int *);
|
||||
extern void fraction_free(struct fraction *);
|
||||
|
||||
extern char * unit_bytes2str(uint64_t, char *, size_t);
|
||||
extern char * unit_bit2str(uint64_t, char *, size_t);
|
||||
|
||||
#endif
|
102
include/bmon/utils.h
Normal file
102
include/bmon/utils.h
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* utils.h General purpose utilities
|
||||
*
|
||||
* Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
|
||||
* Copyright (c) 2013 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __BMON_UTILS_H_
|
||||
#define __BMON_UTILS_H_
|
||||
|
||||
#include <bmon/bmon.h>
|
||||
|
||||
extern void * xcalloc(size_t, size_t);
|
||||
extern void * xrealloc(void *, size_t);
|
||||
extern void xfree(void *);
|
||||
extern void quit (const char *, ...);
|
||||
|
||||
extern float timestamp_to_float(timestamp_t *);
|
||||
extern int64_t timestamp_to_int(timestamp_t *);
|
||||
|
||||
extern void float_to_timestamp(timestamp_t *, float);
|
||||
extern void int_to_timestamp(timestamp_t *, int);
|
||||
|
||||
extern void timestamp_add(timestamp_t *, timestamp_t *, timestamp_t *);
|
||||
extern void timestamp_sub(timestamp_t *, timestamp_t *, timestamp_t *);
|
||||
|
||||
extern int timestamp_le(timestamp_t *, timestamp_t *);
|
||||
extern int timestamp_is_negative(timestamp_t *ts);
|
||||
|
||||
extern void update_timestamp(timestamp_t *);
|
||||
extern void copy_timestamp(timestamp_t *, timestamp_t *);
|
||||
|
||||
extern float timestamp_diff(timestamp_t *, timestamp_t *);
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define xntohll(N) (N)
|
||||
#define xhtonll(N) (N)
|
||||
#else
|
||||
#define xntohll(N) ((((uint64_t) ntohl(N)) << 32) + ntohl((N) >> 32))
|
||||
#define xhtonll(N) ((((uint64_t) htonl(N)) << 32) + htonl((N) >> 32))
|
||||
#endif
|
||||
|
||||
enum {
|
||||
U_NUMBER,
|
||||
U_BYTES,
|
||||
U_BITS
|
||||
};
|
||||
|
||||
extern float read_delta;
|
||||
|
||||
|
||||
const char * xinet_ntop(struct sockaddr *, char *, socklen_t);
|
||||
|
||||
|
||||
extern float time_diff(timestamp_t *, timestamp_t *);
|
||||
extern float diff_now(timestamp_t *);
|
||||
|
||||
extern uint64_t parse_size(const char *);
|
||||
|
||||
extern int parse_date(const char *str, xdate_t *dst);
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
extern char *strdup(const char *);
|
||||
#endif
|
||||
|
||||
extern char * timestamp2str(timestamp_t *ts, char *buf, size_t len);
|
||||
|
||||
static inline char *xstrncat(char *dest, const char *src, size_t n)
|
||||
{
|
||||
return strncat(dest, src, n - strlen(dest) - 1);
|
||||
}
|
||||
|
||||
static inline void xdate_to_ts(timestamp_t *dst, xdate_t *src)
|
||||
{
|
||||
dst->tv_sec = mktime(&src->d_tm);
|
||||
dst->tv_usec = src->d_usec;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user