├── README.OpenCSW
├── prepare_source_tree.sh
├── example
├── Makefile.am
└── mod_example.c
├── conf.d
├── mod_io.conf
├── mod_multicpu.conf
└── mod_example.conf
├── Makefile.am
├── io
├── Makefile.am
└── mod_io.c
├── do-configure.csw
├── multicpu
├── Makefile.am
└── mod_multicpu.c
├── COPYING
├── configure.ac
└── gpl-3.0.txt
/README.OpenCSW:
--------------------------------------------------------------------------------
1 |
2 |
3 | To get all the tools needed for building:
4 |
5 | pkgutil -i gmake ginstall gmake automake autoconf libconfuse_dev \
6 | libapr_dev rsync gtar git autoconf m4 aclocal libtool gsed
7 |
8 | To prepare source tree:
9 |
10 | M4=/opt/csw/bin/gm4 MAKE=/opt/csw/bin/gmake autoreconf -i
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/prepare_source_tree.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 |
4 | # M4=/opt/csw/bin/gm4 MAKE=/opt/csw/bin/gmake autoreconf -i
5 |
6 |
7 | autoreconf --install
8 |
9 | #PREFIX=/usr
10 |
11 | #./configure --with-libapr=apr-1-config --with-libconfuse=/opt/confuse-2.6 --with-libganglia=/opt/ganglia-3.1 --enable-shared --disable-static
12 |
13 | ./configure --enable-shared --disable-static
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/example/Makefile.am:
--------------------------------------------------------------------------------
1 | AM_CFLAGS = -I$(top_builddir)/include -I$(top_builddir)/lib
2 |
3 | if STATIC_BUILD
4 |
5 | noinst_LTLIBRARIES = libmodexample.la
6 | libmodexample_la_SOURCES = mod_example.c
7 |
8 | else
9 |
10 | pkglib_LTLIBRARIES = modexample.la
11 | modexample_la_SOURCES = mod_example.c
12 | modexample_la_LDFLAGS = -module -avoid-version
13 |
14 | EXTRA_DIST = ../conf.d/mod_example.conf
15 |
16 | endif
17 |
18 | INCLUDES = @APR_INCLUDES@
19 |
20 | install:
21 | @echo
22 | @echo "Examples should be installed manually"
23 | @echo
24 |
25 |
--------------------------------------------------------------------------------
/conf.d/mod_io.conf:
--------------------------------------------------------------------------------
1 | modules {
2 | module {
3 | name = "io_module"
4 | path = "modio.so"
5 | }
6 | }
7 |
8 |
9 | #/* Multi CPU DSO metric */
10 | #/* Additional metrics should be added to the
11 | # collection group to represent each CPU
12 | # discovered on the system. See available
13 | # discovered metrics through ./gmond -m command. */
14 | collection_group {
15 | collect_every = 10
16 | time_threshold = 50
17 | metric {
18 | name_match = "io_([a-z_]+)_([a-z0-9]+)"
19 | value_threshold = 1.0
20 | title = "IO \\1 \\2"
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/Makefile.am:
--------------------------------------------------------------------------------
1 |
2 | DIST_SUBDIRS = example multicpu io
3 |
4 | AUTOMAKE_OPTIONS = foreign dist-tarZ
5 | ACLOCAL_AMFLAGS = -I m4
6 |
7 | if STATIC_BUILD
8 |
9 | else
10 |
11 | SUBDIRS = example multicpu io
12 |
13 | GCFLAGS = -D_LARGEFILE64_SOURCE
14 | GLDFLAGS = -export-dynamic
15 |
16 | install: install-recursive
17 | @rm -rf $(DESTDIR)$(pkglibdir)/*.a
18 | @rm -rf $(DESTDIR)$(pkglibdir)/*.la
19 |
20 | endif
21 |
22 | #EXTRA_DIST = ganglia-gmond-modules.spec
23 |
24 | EXTRA_DIST = README.OpenCSW prepare_source_tree.sh do-configure.csw
25 | EXTRA_DIST += COPYING gpl-3.0.txt
26 |
27 |
28 |
--------------------------------------------------------------------------------
/conf.d/mod_multicpu.conf:
--------------------------------------------------------------------------------
1 | modules {
2 | module {
3 | name = "multicpu_module"
4 | path = "modmulticpu.so"
5 | }
6 | }
7 |
8 |
9 | #/* Multi CPU DSO metric */
10 | #/* Additional metrics should be added to the
11 | # collection group to represent each CPU
12 | # discovered on the system. See available
13 | # discovered metrics through ./gmond -m command. */
14 | collection_group {
15 | collect_every = 10
16 | time_threshold = 50
17 | metric {
18 | name_match = "multicpu_([a-z]+)([0-9]+)"
19 | value_threshold = 1.0
20 | title = "CPU-\\2 \\1"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/io/Makefile.am:
--------------------------------------------------------------------------------
1 | AM_CFLAGS = -D_LARGEFILE64_SOURCE -I$(top_builddir)/include -I$(top_builddir)/libmetrics -I$(top_builddir)/lib
2 |
3 | if STATIC_BUILD
4 | noinst_LTLIBRARIES = libmodio.la
5 | libmodio_la_SOURCES = mod_io.c
6 | libmodio_la_LDFLAGS = -export-all-symbols
7 | else
8 | pkglib_LTLIBRARIES = modio.la
9 |
10 | modio_la_SOURCES = mod_io.c
11 | modio_la_LDFLAGS = -module -avoid-version
12 | #modio_la_LIBADD = $(top_builddir)/libmetrics/libmetrics.la
13 |
14 | EXTRA_DIST = ../conf.d/mod_io.conf
15 | endif
16 |
17 | INCLUDES = @APR_INCLUDES@
18 |
19 | pkglibdir = $(libdir)/ganglia
20 |
21 |
--------------------------------------------------------------------------------
/do-configure.csw:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | export PATH=/usr/ccs/bin:$PATH
4 |
5 | # CC=/opt/SUNWspro/bin/cc
6 | # CFLAGS='-xO3 -I/opt/csw/include'
7 |
8 | PATH=/usr/ccs/bin:$PATH \
9 | CC=/usr/bin/cc \
10 | MAKE=/opt/csw/bin/gmake \
11 | CFLAGS='-g -I/opt/csw/include' \
12 | LDFLAGS='-L/opt/csw/lib' \
13 | ./configure --prefix=/opt/csw --exec_prefix=/opt/csw --bindir=/opt/csw/bin --sbindir=/opt/csw/sbin --libexecdir=/opt/csw/libexec --datadir=/opt/csw/share --sysconfdir=/etc/opt/csw/ganglia --sharedstatedir=/opt/csw/share --localstatedir=/var/opt/csw --libdir=/opt/csw/lib --infodir=/opt/csw/share/info --includedir=/opt/csw/include --mandir=/opt/csw/share/man
14 |
15 |
--------------------------------------------------------------------------------
/multicpu/Makefile.am:
--------------------------------------------------------------------------------
1 | AM_CFLAGS = -D_LARGEFILE64_SOURCE -I$(top_builddir)/include -I$(top_builddir)/libmetrics -I$(top_builddir)/lib
2 |
3 | if STATIC_BUILD
4 | noinst_LTLIBRARIES = libmodmulticpu.la
5 | libmodmulticpu_la_SOURCES = mod_multicpu.c
6 | libmodmulticpu_la_LDFLAGS = -export-all-symbols
7 | else
8 | pkglib_LTLIBRARIES = modmulticpu.la
9 |
10 | modmulticpu_la_SOURCES = mod_multicpu.c
11 | modmulticpu_la_LDFLAGS = -module -avoid-version
12 | #modmulticpu_la_LIBADD = $(top_builddir)/libmetrics/libmetrics.la
13 |
14 | EXTRA_DIST = ../conf.d/mod_multicpu.conf
15 | endif
16 |
17 | INCLUDES = @APR_INCLUDES@
18 |
19 | pkglibdir = $(libdir)/ganglia
20 |
21 |
--------------------------------------------------------------------------------
/conf.d/mod_example.conf:
--------------------------------------------------------------------------------
1 | modules {
2 | module {
3 | name = "example_module"
4 | path = "modexample.so"
5 | params = "An extra raw parameter"
6 | param RandomMax {
7 | value = 75
8 | }
9 | param ConstantValue {
10 | value = 25
11 | }
12 | }
13 | }
14 |
15 |
16 | #/* Test DSO metric */
17 | collection_group {
18 | collect_every = 10
19 | time_threshold = 50
20 | metric {
21 | name = "Random_Numbers"
22 | title = "Random Numbers Metric"
23 | value_threshold = 1.0
24 | }
25 | }
26 |
27 | collection_group {
28 | collect_once = yes
29 | time_threshold = 20
30 | metric {
31 | name = "Constant_Number"
32 | title = "Constant Number Metric"
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | -----------------------------------------------------------------------------
2 | ganglia-modules-solaris: modules for collecting metrics on Solaris
3 | Copyright (C) 2011 Daniel Pocock
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | ----------------------------------------------------------------------------
19 |
20 | Exceptions to the license:
21 | - any code that is not marked explicitly or mentioned in this list
22 | of exceptions is copyright and licensed under the terms of the GPLv3
23 | as described above
24 | - the contents of the `example' directory (for building the
25 | example module) have been copied as-is from the main Ganglia
26 | distribution and retain the original BSD-like copyright
27 | - the modules implement the Ganglia metric module interface.
28 | Ganglia is distributed under a BSD-like license at http://ganglia.info
29 | The Ganglia copyright notice is applicable to the API:
30 | "Copyright (c) 2001 by Matt Massie and The Regents of the University
31 | of California. All rights reserved."
32 |
33 |
--------------------------------------------------------------------------------
/configure.ac:
--------------------------------------------------------------------------------
1 | dnl ganglia-modules-solaris: modules for collecting metrics on Solaris
2 | dnl Copyright (C) 2011 Daniel Pocock
3 | dnl
4 | dnl This program is free software: you can redistribute it and/or modify
5 | dnl it under the terms of the GNU General Public License as published by
6 | dnl the Free Software Foundation, either version 3 of the License, or
7 | dnl (at your option) any later version.
8 | dnl
9 | dnl This program is distributed in the hope that it will be useful,
10 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | dnl GNU General Public License for more details.
13 | dnl
14 | dnl You should have received a copy of the GNU General Public License
15 | dnl along with this program. If not, see .
16 |
17 | AC_INIT(ganglia-modules-solaris,1.0.1)
18 | AC_CONFIG_SRCDIR(example/mod_example.c)
19 | AM_INIT_AUTOMAKE
20 |
21 | AC_CONFIG_MACRO_DIR([m4])
22 |
23 | AC_CANONICAL_HOST
24 | AM_CONFIG_HEADER(config.h)
25 |
26 | dnl The following cpu_vendor_os string goes into config.h
27 | dnl
28 | AC_DEFINE_UNQUOTED(HOST_OS, "$HOST_OS", HOST_OS)
29 | AC_DEFINE_UNQUOTED(CPU_VENDOR_OS, "$HOST", CPU_VENDOR_OS)
30 | dnl AC_CYGWIN
31 |
32 | AC_ARG_ENABLE( static-build,
33 | [ --enable-static-build Generate objects for static linking to gmond ],
34 | [ enable_static_build=yes ],[ enable_static_build=no ])
35 |
36 | AM_CONDITIONAL(STATIC_BUILD, test x"$enable_static_build" = xyes)
37 |
38 | AC_PROG_CC
39 |
40 | AC_PROG_INSTALL
41 |
42 | AC_PROG_LIBTOOL
43 |
44 | dnl default VARSTATEDIR to /var/lib since that's the traditional location.
45 | dnl
46 | varstatedir="/var/lib"
47 |
48 | OS="unknown"
49 | EXPORT_SYMBOLS="-export-dynamic"
50 | case "$host" in
51 | *linux*)
52 | CFLAGS="$CFLAGS -D_REENTRANT"
53 | AC_DEFINE(LINUX, 1, LINUX)
54 | OS="linux"
55 | dnl
56 | dnl For fsuage.c - disk usage.
57 | dnl
58 | AC_DEFINE(STAT_STATVFS, 1, STAT_STATVFS)
59 | AC_DEFINE(SUPPORT_GEXEC, 1, SUPPORT_GEXEC)
60 | ;;
61 | *solaris*) AC_DEFINE(SUPPORT_GEXEC, 0, SUPPORT_GEXEC)
62 | CFLAGS="$CFLAGS -D__EXTENSIONS__ -DHAVE_STRERROR"
63 | if test x"$ac_cv_prog_cc_c99" = x -o x"$ac_cv_prog_cc_c99" = xno; then
64 | CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199506L"
65 | else
66 | CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L"
67 | fi
68 | if test x"$ac_cv_prog_gcc" != xyes; then
69 | LIBS="-lm $LIBS"
70 | fi
71 | AC_DEFINE(SOLARIS,1,SOLARIS)
72 | OS="solaris"
73 | ;;
74 | *cygwin*) LDFLAGS="-L/bin"
75 | EXPORT_SYMBOLS="-export-all-symbols"
76 | AC_DEFINE(CYGWIN, 1, CYGWIN)
77 | ;;
78 | esac
79 |
80 | AC_SUBST(OS)
81 |
82 | AC_SUBST(EXPORT_SYMBOLS)
83 | dnl Define VARSTATEDIR in config.h
84 | dnl
85 | AC_SUBST(varstatedir)
86 | AC_DEFINE_UNQUOTED(VARSTATEDIR, "$varstatedir", VARSTATEDIR)
87 |
88 | if test x"$libdir" = x"\${exec_prefix/lib"; then
89 | if test x"$exec_prefix" = xNONE; then
90 | if test x"$prefix" = xNONE; then
91 | exec_prefix="$ac_default_prefix"
92 | else
93 | exec_prefix="$prefix"
94 | fi
95 | fi
96 | cfg_libdir=`eval echo "$libdir"`
97 | fi
98 | AC_SUBST(cfg_libdir)
99 |
100 | ganglia_sysconfdir="${sysconfdir}/ganglia"
101 | AC_SUBST(ganglia_sysconfdir)
102 |
103 | #AC_OUTPUT(Makefile ganglia-gmond-modules.spec etc/Makefile etc/conf.d/module1.conf io/Makefile)
104 |
105 | AC_OUTPUT(Makefile example/Makefile multicpu/Makefile io/Makefile)
106 |
107 |
108 |
--------------------------------------------------------------------------------
/example/mod_example.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2007 Novell, Inc. 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 are met:
6 | *
7 | * - Redistributions of source code must retain the above copyright notice,
8 | * this list of conditions and the following disclaimer.
9 | *
10 | * - Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | *
14 | * - Neither the name of Novell, Inc. nor the names of its
15 | * contributors may be used to endorse or promote products derived from this
16 | * software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL Novell, Inc. OR THE CONTRIBUTORS
22 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 | * POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | * Author: Brad Nicholes (bnicholes novell.com)
31 | ******************************************************************************/
32 |
33 | /*
34 | * The ganglia metric "C" interface, required for building DSO modules.
35 | */
36 | #include
37 |
38 | #include
39 | #include
40 | #include
41 |
42 | /*
43 | * Declare ourselves so the configuration routines can find and know us.
44 | * We'll fill it in at the end of the module.
45 | */
46 | extern mmodule example_module;
47 |
48 | static unsigned int random_max = 50;
49 | static unsigned int constant_value = 20;
50 |
51 | static int ex_metric_init ( apr_pool_t *p )
52 | {
53 | const char* str_params = example_module.module_params;
54 | apr_array_header_t *list_params = example_module.module_params_list;
55 | mmparam *params;
56 | int i;
57 |
58 | srand(time(NULL)%99);
59 |
60 | /* Read the parameters from the gmond.conf file. */
61 | /* Single raw string parameter */
62 | if (str_params) {
63 | debug_msg("[mod_example]Received string params: %s", str_params);
64 | }
65 | /* Multiple name/value pair parameters. */
66 | if (list_params) {
67 | debug_msg("[mod_example]Received following params list: ");
68 | params = (mmparam*) list_params->elts;
69 | for(i=0; i< list_params->nelts; i++) {
70 | debug_msg("\tParam: %s = %s", params[i].name, params[i].value);
71 | if (!strcasecmp(params[i].name, "RandomMax")) {
72 | random_max = atoi(params[i].value);
73 | }
74 | if (!strcasecmp(params[i].name, "ConstantValue")) {
75 | constant_value = atoi(params[i].value);
76 | }
77 | }
78 | }
79 |
80 | /* Initialize the metadata storage for each of the metrics and then
81 | * store one or more key/value pairs. The define MGROUPS defines
82 | * the key for the grouping attribute. */
83 | MMETRIC_INIT_METADATA(&(example_module.metrics_info[0]),p);
84 | MMETRIC_ADD_METADATA(&(example_module.metrics_info[0]),MGROUP,"random");
85 | MMETRIC_ADD_METADATA(&(example_module.metrics_info[0]),MGROUP,"example");
86 | /*
87 | * Usually a metric will be part of one group, but you can add more
88 | * if needed as shown above where Random_Numbers is both in the random
89 | * and example groups.
90 | */
91 |
92 | MMETRIC_INIT_METADATA(&(example_module.metrics_info[1]),p);
93 | MMETRIC_ADD_METADATA(&(example_module.metrics_info[1]),MGROUP,"example");
94 |
95 | return 0;
96 | }
97 |
98 | static void ex_metric_cleanup ( void )
99 | {
100 | }
101 |
102 | static g_val_t ex_metric_handler ( int metric_index )
103 | {
104 | g_val_t val;
105 |
106 | /* The metric_index corresponds to the order in which
107 | the metrics appear in the metric_info array
108 | */
109 | switch (metric_index) {
110 | case 0:
111 | val.uint32 = rand()%random_max;
112 | break;
113 | case 1:
114 | val.uint32 = constant_value;
115 | break;
116 | default:
117 | val.uint32 = 0; /* default fallback */
118 | }
119 |
120 | return val;
121 | }
122 |
123 | static Ganglia_25metric ex_metric_info[] =
124 | {
125 | {0, "Random_Numbers", 90, GANGLIA_VALUE_UNSIGNED_INT, "Num", "both", "%u", UDP_HEADER_SIZE+8, "Example module metric (random numbers)"},
126 | {0, "Constant_Number", 90, GANGLIA_VALUE_UNSIGNED_INT, "Num", "zero", "%u", UDP_HEADER_SIZE+8, "Example module metric (constant number)"},
127 | {0, NULL}
128 | };
129 |
130 | mmodule example_module =
131 | {
132 | STD_MMODULE_STUFF,
133 | ex_metric_init,
134 | ex_metric_cleanup,
135 | ex_metric_info,
136 | ex_metric_handler,
137 | };
138 |
--------------------------------------------------------------------------------
/io/mod_io.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | *
3 | ganglia-modules-solaris: modules for collecting metrics on Solaris
4 | Copyright (C) 2011 Daniel Pocock
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 |
19 | ******************************************************************************/
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | /*
34 | * used for swap space determination - swapctl()
35 | * and anon.h has the data structure needed for swapctl to be useful
36 | */
37 |
38 | #include
39 | #include
40 | #include
41 | #include
42 |
43 | /*
44 | * we get the cpu struct from cpuvar, maybe other mojo too
45 | */
46 |
47 | #include
48 | #include
49 | #include
50 | #include
51 | /*
52 | * functions spackled in by swagner -- the CPU-percentage-specific code is
53 | * largely an imitation (if not a shameless copy) of the Solaris-specific
54 | * code for top.
55 | */
56 |
57 | /*
58 | * used for disk space determination - getmntent(), statvfs()
59 | */
60 |
61 | #include
62 | #include
63 |
64 | #include
65 |
66 | #include
67 | #include
68 | #include
69 | #include
70 |
71 | #include
72 | #include
73 |
74 | mmodule io_module;
75 |
76 | kstat_ctl_t *kc = NULL;
77 | int first_run = 2;
78 |
79 |
80 | apr_array_header_t *metric_info = NULL;
81 | apr_array_header_t *devices = NULL;
82 |
83 | /* struct k_metrics_struct {
84 | g_val_t nread; /* Bytes * /
85 | g_val_t read; /* Requests * /
86 | g_val_t nwrite; /* Bytes * /
87 | g_val_t write; /* Requests * /
88 | g_val_t rtime; /* Time spent servicing requests on run queue (nanoseconds) * /
89 | g_val_t wtime; /* Time spent servicing requests on wait queue (nanoseconds) * /
90 | }; */
91 |
92 | struct g_metrics_struct {
93 | g_val_t nread_rate; /* Bytes */
94 | g_val_t read_rate; /* Requests */
95 | g_val_t nwrite_rate; /* Bytes */
96 | g_val_t write_rate; /* Requests */
97 | g_val_t avg_svc_time; /* Avg time spent servicing requests on run queue (seconds) */
98 | g_val_t avg_wait_time; /* Avg time spent servicing requests on wait queue (seconds) */
99 | g_val_t io_time; /* time spent by requests in IO scheduler during sample period (seconds) */
100 | };
101 |
102 | typedef struct disk_data {
103 | kstat_io_t old_values;
104 | struct g_metrics_struct metriclist;
105 | struct timeval lasttime;
106 | unsigned long last_refresh;
107 | char *module_name;
108 | int ks_instance;
109 | kstat_t *ks;
110 | } disk_data_t;
111 |
112 | typedef g_val_t (*io_func_t)(disk_data_t *dev);
113 |
114 | typedef struct metric_spec {
115 | io_func_t io_func;
116 | const char *name;
117 | const char *units;
118 | const char *desc;
119 | const char *fmt;
120 | } metric_spec_t;
121 |
122 | u_longlong_t counter_diff(u_longlong_t new_val, u_longlong_t old_val) {
123 | register u_longlong_t delta = new_val - old_val;
124 | return delta;
125 | /* if (delta < 0) {
126 | /* this only happens when the counter wraps * /
127 | change = (u_longlong_t) ((u_longlong_t) new_val - (u_longlong_t) old_val);
128 | }
129 | return delta; */
130 | }
131 |
132 | double counter_rate(u_longlong_t new_val, u_longlong_t old_val,
133 | double time_diff) {
134 | return counter_diff(new_val, old_val) / time_diff;
135 | }
136 |
137 | /* time_diff is in seconds */
138 | void update_rates(kstat_io_t *old_values, kstat_io_t *new_values,
139 | struct g_metrics_struct *rates, double time_diff) {
140 |
141 | uint_t read_count;
142 | uint_t write_count;
143 | uint_t io_count;
144 | hrtime_t rtime_delta; /* ns */
145 | hrtime_t wtime_delta; /* ns */
146 |
147 | read_count = counter_diff(new_values->reads, old_values->reads);
148 | write_count = counter_diff(new_values->writes, old_values->writes);
149 | io_count = read_count + write_count;
150 |
151 | debug_msg("io: read_count = %d, write_count = %d, io_count = %d",
152 | read_count, write_count, io_count);
153 |
154 | rtime_delta = counter_diff(new_values->rtime, old_values->rtime);
155 | wtime_delta = counter_diff(new_values->wtime, old_values->wtime);
156 |
157 | rates->nread_rate.f = counter_rate(new_values->nread, old_values->nread,
158 | time_diff);
159 | rates->read_rate.f = read_count / time_diff;
160 | rates->nwrite_rate.f = counter_rate(new_values->nwritten,
161 | old_values->nwritten, time_diff);
162 | rates->write_rate.f = write_count / time_diff;
163 | rates->io_time.f = (rtime_delta + wtime_delta) * 1.0e-9;
164 |
165 | if (io_count > 0) {
166 | rates->avg_svc_time.f = rates->io_time.f / io_count;
167 | rates->avg_wait_time.f = 1.0e-9 * (wtime_delta / io_count);
168 | } else {
169 | rates->avg_svc_time.f = NAN;
170 | rates->avg_wait_time.f = NAN;
171 | }
172 |
173 | bcopy(new_values, old_values, sizeof(kstat_io_t));
174 | }
175 |
176 | void clear_ks_pointers() {
177 | int i;
178 | disk_data_t *dev;
179 | dev = (disk_data_t *)devices->elts;
180 | for(i = 0; i < devices->nelts; i++ ) {
181 | dev->ks = NULL;
182 | dev++;
183 | }
184 | }
185 |
186 | int get_kstat_io_values(disk_data_t *dev, kstat_io_t *kio) {
187 |
188 | if (kc == NULL) {
189 | kc = kstat_open();
190 | debug_msg("io: chain found, clearing pointers...");
191 | clear_ks_pointers();
192 | debug_msg("io: chain update handled");
193 | } else {
194 |
195 | if(kstat_chain_update(kc) != 0) {
196 | debug_msg("io: chain update detected, clearing pointers...");
197 | clear_ks_pointers();
198 | debug_msg("io: chain update handled");
199 | }
200 |
201 | }
202 |
203 |
204 | if (kc == NULL) {
205 | debug_msg("io: couldn't open kc...");
206 | err_ret("kstat_open() error");
207 | return NULL;
208 | }
209 |
210 | if(dev->ks == NULL) {
211 | dev->ks = kstat_lookup(kc, dev->module_name, dev->ks_instance, NULL);
212 |
213 | if (dev->ks == NULL) {
214 | return -1;
215 | }
216 |
217 | if (dev->ks->ks_type != KSTAT_TYPE_IO)
218 | return -1;
219 |
220 | }
221 |
222 | kstat_read(kc, dev->ks, kio);
223 |
224 | return 0;
225 | }
226 |
227 | int refresh_device_stats(disk_data_t *dev) {
228 |
229 | struct timeval thistime;
230 | kstat_io_t new_val;
231 | double timediff;
232 |
233 | if (dev == NULL)
234 | return -1;
235 |
236 | gettimeofday(&thistime, NULL);
237 | if (dev->lasttime.tv_sec)
238 | timediff = ((double) thistime.tv_sec * 1.0 + ((double) thistime.tv_usec
239 | * 1.0e-6)) - ((double) dev->lasttime.tv_sec * 1.0
240 | + ((double) dev->lasttime.tv_usec * 1.0e-6));
241 | else
242 | timediff = 1.0e7;
243 | if (timediff < 2.0)
244 | return 0;
245 |
246 | debug_msg("io: getting values for %s %d", dev->module_name,
247 | dev->ks_instance);
248 | if (get_kstat_io_values(dev, &new_val) != 0)
249 | return -1;
250 |
251 | gettimeofday(&thistime, NULL);
252 | if (dev->lasttime.tv_sec)
253 | timediff = ((double) thistime.tv_sec * 1.0 + ((double) thistime.tv_usec
254 | * 1.0e-6)) - ((double) dev->lasttime.tv_sec * 1.0
255 | + ((double) dev->lasttime.tv_usec * 1.0e-6));
256 | else
257 | timediff = 1.0e7;
258 | bcopy(&thistime, &dev->lasttime, sizeof(struct timeval));
259 |
260 | debug_msg("io: updating rates for %s %d (timediff=%f)", dev->module_name,
261 | dev->ks_instance, timediff);
262 | if(first_run > 0) {
263 | first_run--;
264 | dev->metriclist.avg_svc_time.f = NAN;
265 | dev->metriclist.avg_wait_time.f = NAN;
266 | dev->metriclist.io_time.f = NAN;
267 | dev->metriclist.nread_rate.f = NAN;
268 | dev->metriclist.nwrite_rate.f = NAN;
269 | dev->metriclist.read_rate.f = NAN;
270 | dev->metriclist.write_rate.f = NAN;
271 | bcopy(&new_val, &dev->old_values, sizeof(kstat_io_t));
272 | } else
273 | update_rates(&dev->old_values, &new_val, &dev->metriclist, timediff);
274 |
275 | return 0;
276 | }
277 |
278 | /*
279 | * Get the metric name and index from the original
280 | * metric name
281 | */
282 | void get_metric_name_cpu(char *metric, char *name, int *index) {
283 | /* The metric name contains both the name and the cpu id.
284 | Split the cpu id from the name so that we can use it to
285 | decide which metric handler to call and for which cpu.
286 | */
287 | size_t numIndex = strcspn(metric, "0123456789");
288 |
289 | if (numIndex > 0) {
290 | strncpy(name, metric, numIndex);
291 | name[numIndex] = '\0';
292 | *index = atoi(&metric[numIndex]);
293 | } else {
294 | *name = '\0';
295 | *index = 0;
296 | }
297 |
298 | return;
299 | }
300 |
301 | g_val_t io_nread_func(disk_data_t *dev) {
302 | g_val_t val;
303 | refresh_device_stats(dev);
304 | val.f = dev->metriclist.nread_rate.f;
305 | return val;
306 | }
307 |
308 | g_val_t io_nwrite_func(disk_data_t *dev) {
309 | g_val_t val;
310 | refresh_device_stats(dev);
311 | val.f = dev->metriclist.nwrite_rate.f;
312 | return val;
313 | }
314 |
315 | g_val_t io_reads_func(disk_data_t *dev) {
316 | g_val_t val;
317 | refresh_device_stats(dev);
318 | val.f = dev->metriclist.read_rate.f;
319 | return val;
320 | }
321 |
322 | g_val_t io_writes_func(disk_data_t *dev) {
323 | g_val_t val;
324 | refresh_device_stats(dev);
325 | val.f = dev->metriclist.write_rate.f;
326 | return val;
327 | }
328 |
329 | g_val_t io_avg_svc_time_func(disk_data_t *dev) {
330 | g_val_t val;
331 | refresh_device_stats(dev);
332 | val.f = dev->metriclist.avg_svc_time.f;
333 | return val;
334 | }
335 |
336 | g_val_t io_avg_wait_time_func(disk_data_t *dev) {
337 | g_val_t val;
338 | refresh_device_stats(dev);
339 | val.f = dev->metriclist.avg_wait_time.f;
340 | return val;
341 | }
342 |
343 | g_val_t io_aggregate_time_func(disk_data_t *dev) {
344 | g_val_t val;
345 | refresh_device_stats(dev);
346 | val.f = dev->metriclist.io_time.f;
347 | return val;
348 | }
349 |
350 | metric_spec_t metrics[] = {
351 | { io_nread_func, "nread", "bytes/sec", "bytes read", "%.1f" },
352 | { io_nwrite_func, "nwrite", "bytes/sec", "bytes written", "%.1f" },
353 | { io_reads_func, "reads", "reads/sec",
354 | "IO read operations", "%.1f" },
355 | { io_writes_func, "writes", "writes/sec",
356 | "IO write operations", "%.1f" },
357 | { io_avg_svc_time_func,
358 | "avg_svc_time", "s", "Average IO req. service time", "%.6f" },
359 | { io_avg_wait_time_func, "avg_wait_time", "s",
360 | "Average time IO reqs remain in wait queue", "%.6f" },
361 | { io_aggregate_time_func, "aggegate_time", "s",
362 | "Aggregate time spent by all requests in IO", "%.6f" },
363 | { NULL, NULL, NULL, NULL, NULL } };
364 |
365 | void init_metric_for_device(apr_pool_t *p, apr_array_header_t *ar, kstat_t *ks) {
366 | metric_spec_t *metric;
367 | Ganglia_25metric *gmi;
368 | char *metric_name;
369 |
370 | disk_data_t *dev;
371 |
372 | dev = apr_array_push(devices);
373 | bzero(dev, sizeof(disk_data_t));
374 |
375 | dev->module_name = apr_pstrdup(p, ks->ks_module);
376 | dev->ks_instance = ks->ks_instance;
377 | dev->ks = NULL;
378 |
379 | for (metric = metrics; metric->io_func != NULL; metric++) {
380 | gmi = apr_array_push(ar);
381 |
382 | /* gmi->key will be automatically assigned by gmond */
383 | metric_name = apr_psprintf(p, "io_%s_%s%d", metric->name,
384 | ks->ks_module, ks->ks_instance);
385 | debug_msg("io: creating metric %s", metric_name);
386 | gmi->name = metric_name;
387 | gmi->tmax = 90;
388 | gmi->type = GANGLIA_VALUE_FLOAT;
389 | gmi->units = apr_pstrdup(p, metric->units);
390 | gmi->slope = apr_pstrdup(p, "both");
391 | gmi->fmt = apr_pstrdup(p, metric->fmt);
392 | gmi->msg_size = UDP_HEADER_SIZE + 8;
393 | gmi->desc = apr_pstrdup(p, metric->desc);
394 | }
395 | }
396 |
397 | static int ex_metric_init(apr_pool_t *p) {
398 | int i;
399 | Ganglia_25metric *gmi;
400 | kstat_t *ksp;
401 | kstat_io_t kio;
402 |
403 | g_val_t val;
404 |
405 | apr_pool_t *pool;
406 |
407 | /* Allocate a pool that will be used by this module */
408 | apr_pool_create(&pool, p);
409 |
410 | metric_info = apr_array_make(pool, 2, sizeof(Ganglia_25metric));
411 | devices = apr_array_make(pool, 2, sizeof(disk_data_t));
412 |
413 | if (kc == NULL)
414 | kc = kstat_open();
415 | else
416 | kstat_chain_update(kc);
417 |
418 | if (kc == NULL) {
419 | debug_msg("io: couldn't open kc...");
420 | err_ret("kstat_open() error");
421 | return -1;
422 | }
423 |
424 | for (ksp = kc->kc_chain; ksp != NULL; ksp = ksp->ks_next) {
425 | if (ksp->ks_type == KSTAT_TYPE_IO) {
426 | init_metric_for_device(p, metric_info, ksp);
427 | }
428 | }
429 |
430 | /* Add a terminator to the array and replace the empty static metric definition
431 | array with the dynamic array that we just created
432 | */
433 | gmi = apr_array_push(metric_info);
434 | memset(gmi, 0, sizeof(*gmi));
435 |
436 | io_module.metrics_info = (Ganglia_25metric *) metric_info->elts;
437 |
438 | for (i = 0; io_module.metrics_info[i].name != NULL; i++) {
439 | /* Initialize the metadata storage for each of the metrics and then
440 | * store one or more key/value pairs. The define MGROUPS defines
441 | * the key for the grouping attribute. */
442 | MMETRIC_INIT_METADATA(&(io_module.metrics_info[i]), p);
443 | MMETRIC_ADD_METADATA(&(io_module.metrics_info[i]), MGROUP, "disk");
444 | }
445 |
446 | debug_msg("modio.c: metric_init() ok.");
447 | val.int32 = 0;
448 | /*
449 | * We need to make sure that every server thread gets their own copy of "kc".
450 | * The next metric that needs a kc-handle will reopen it for the server thread.
451 | */
452 | if (kc) {
453 | kstat_close(kc);
454 | kc = NULL;
455 | }
456 | return val.int32;
457 |
458 | }
459 |
460 | static void ex_metric_cleanup(void) {
461 | }
462 |
463 | static g_val_t ex_metric_handler(int metric_index) {
464 | g_val_t val;
465 | int dev_index;
466 | int _metric_index;
467 | char name[64];
468 | disk_data_t *_devices;
469 | disk_data_t *dev;
470 |
471 | dev_index = metric_index / 7;
472 | _metric_index = metric_index % 7;
473 |
474 | _devices = (disk_data_t *) devices->elts;
475 | dev = &_devices[dev_index];
476 | debug_msg("io: handling read for metric %d dev %d idx %d name = %s%d",
477 | metric_index, dev_index, _metric_index, dev->module_name,
478 | dev->ks_instance);
479 | val = metrics[_metric_index].io_func(dev);
480 |
481 | return val;
482 | }
483 |
484 | mmodule io_module = { STD_MMODULE_STUFF, ex_metric_init, ex_metric_cleanup,
485 | NULL, /* defined dynamically */
486 | ex_metric_handler, };
487 |
--------------------------------------------------------------------------------
/multicpu/mod_multicpu.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | *
3 | ganglia-modules-solaris: modules for collecting metrics on Solaris
4 | Copyright (C) 2011 Daniel Pocock
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 |
19 |
20 | ******************************************************************************/
21 |
22 |
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 |
35 | /*
36 | * used for swap space determination - swapctl()
37 | * and anon.h has the data structure needed for swapctl to be useful
38 | */
39 |
40 | #include
41 | #include
42 | #include
43 | #include
44 |
45 | /*
46 | * we get the cpu struct from cpuvar, maybe other mojo too
47 | */
48 |
49 | #include
50 | #include
51 | #include
52 | #include
53 | /*
54 | * functions spackled in by swagner -- the CPU-percentage-specific code is
55 | * largely an imitation (if not a shameless copy) of the Solaris-specific
56 | * code for top.
57 | */
58 |
59 | /*
60 | * used for disk space determination - getmntent(), statvfs()
61 | */
62 |
63 | #include
64 | #include
65 |
66 | #include
67 |
68 | #include
69 | #include
70 | #include
71 | #include
72 |
73 | #include
74 | #include
75 |
76 | mmodule multicpu_module;
77 |
78 | /* number of seconds to wait before refreshing/recomputing values off kstat */
79 |
80 | #define TICK_SECONDS 30
81 |
82 | #ifndef FSCALE
83 | #define FSHIFT 8 /* bits to right of fixed binary point */
84 | #define FSCALE (1<elts;
136 | return &_cpus[cpu_index];
137 | }
138 |
139 | int mcpu_get_kstat_val(g_val_t *val, char *km_name, char *ks_name, char *name) {
140 | /* Warning.. always assuming a KSTAT_DATA_ULONG here */
141 | kstat_t *ks;
142 | kstat_named_t *kn;
143 |
144 | /*
145 | * Get a kstat_ctl handle, or update the kstat chain.
146 | */
147 | if (kc == NULL)
148 | kc = kstat_open();
149 | else
150 | kstat_chain_update(kc);
151 |
152 | if (kc == NULL) {
153 | debug_msg("multicpu: couldn't open kc...");
154 | err_ret("mcpu_get_kstat_val() kstat_open() error");
155 | return -1;
156 | }
157 |
158 | debug_msg(
159 | "multicpu: Lookup up kstat: km (unix?)='%s', ks (system_misc?)='%s',kn (resulting metric?)='%s'",
160 | km_name, ks_name, name);
161 | debug_msg("multicpu: %s: kc is %p", name, kc);
162 | ks = kstat_lookup(kc, km_name, 0, ks_name);
163 | debug_msg("multicpu: %s: Just did kstat_lookup().", name);
164 |
165 | if (ks == NULL) {
166 | perror("ks");
167 | }
168 | debug_msg("multicpu: %s: Looked up.", name);
169 | if (kstat_read(kc, ks, 0) == -1) {
170 | perror("kstat_read");
171 | return -1;
172 | }
173 | kn = kstat_data_lookup(ks, name);
174 | if (kn == NULL) {
175 | err_ret("mcpu_get_kstat_val() kstat_data_lookup() kstat_read() error");
176 | return -1;
177 | }
178 | debug_msg("multicpu: %s: Kstat data type: %d, Value returned: %u, %d %u %d", name,
179 | (int) kn->data_type, (int) kn->value.ui32, (int) kn->value.l,
180 | kn->value.ul, kn->value.ui64);
181 | // ks = kstat_lookup(kc, "unix", 0, "system_misc");
182 |
183 | if (kn->value.ui32 == 0)
184 | val->uint32 = (unsigned long) kn->value.ul;
185 | else
186 | val->uint32 = (int) kn->value.ui32;
187 | sleep(0);
188 | debug_msg("multicpu: %s: Kernel close. Val returned: %d", name, val->uint32);
189 |
190 | return 0;
191 | }
192 |
193 | long mcpu_percentages(int cnt, int *out, register unsigned long *new,
194 | register unsigned long *old, unsigned long *diffs) {
195 | register int i;
196 | register long change;
197 | register long total_change;
198 | register unsigned long *dp;
199 | long half_total;
200 |
201 | /* initialization */
202 | total_change = 0;
203 | dp = diffs;
204 |
205 | /* calculate changes for each state and the overall change */
206 | for (i = 0; i < cnt; i++) {
207 | if ((change = *new - *old) < 0) {
208 | /* this only happens when the counter wraps */
209 | change = (int) ((unsigned long) *new - (unsigned long) *old);
210 | }
211 | total_change += (*dp++ = change);
212 | *old++ = *new++;
213 | }
214 |
215 | /* avoid divide by zero potential */
216 | if (total_change == 0) {
217 | total_change = 1;
218 | }
219 |
220 | /* calculate percentages based on overall change, rounding up */
221 | half_total = total_change / 2l;
222 | for (i = 0; i < cnt; i++) {
223 | *out++ = (int) ((*diffs++ * 1000 + half_total) / total_change);
224 | }
225 |
226 | /* return the total in case the caller wants to use it */
227 | return (total_change);
228 | }
229 |
230 | void clear_ks_pointers() {
231 | int i;
232 | cpu_data_t *cpu;
233 | cpu = (cpu_data_t *)cpus->elts;
234 | for(i = 0; i < cpus->nelts; i++ ) {
235 | cpu->ks = NULL;
236 | cpu++;
237 | }
238 | }
239 |
240 | int get_kstat_cpu_values(cpu_data_t *cpu, cpu_stat_t *cpuStats) {
241 |
242 | if (kc == NULL) {
243 | kc = kstat_open();
244 | clear_ks_pointers();
245 | } else {
246 |
247 | if(kstat_chain_update(kc) != 0) {
248 | clear_ks_pointers();
249 | }
250 |
251 | }
252 |
253 | if (kc == NULL) {
254 | debug_msg("multicpu: couldn't open kc...");
255 | err_ret("kstat_open() error");
256 | return NULL;
257 | }
258 |
259 | if(cpu->ks == NULL) {
260 | cpu->ks = kstat_lookup(kc, "cpu_stat", cpu->ks_instance, NULL);
261 |
262 | if (cpu->ks == NULL) {
263 | return -1;
264 | }
265 |
266 | if (cpu->ks->ks_type != KSTAT_TYPE_RAW)
267 | return -1;
268 |
269 | }
270 |
271 | kstat_read(kc, cpu->ks, cpuStats);
272 |
273 | return 0;
274 | }
275 |
276 | int mcpu_determine_cpu_percentages() {
277 |
278 | /* TODO:
279 | * - store an array of cpu_old values
280 | * - poll all CPUs together
281 | */
282 |
283 | /*
284 | * hopefully this doesn't get too confusing.
285 | * cpu_snap is a structure from and is the container into which
286 | * we read the current CPU metrics.
287 | * the static array "cpu_old" contains the last iteration's summed cycle
288 | * counts.
289 | * the array "cpu_now" contains the current iteration's summed cycle
290 | * counts.
291 | * "cpu_diff" holds the delta.
292 | * across CPUs of course. :)
293 | * buffers[0..2] holds past, present and diff info for the "other" CPU stats.
294 | */
295 |
296 | struct timeval thistime;
297 | double timediff;
298 |
299 | unsigned int ncpus;
300 | unsigned long diff_cycles = 0L;
301 | unsigned long time_delta = 0L;
302 | double alpha, beta; // lambda lambda lambda!!!
303 |
304 | unsigned long cpu_now[CPUSTATES];
305 | unsigned long cpu_diff[CPUSTATES];
306 |
307 | register int j;
308 | cpu_stat_t cpuKstats;
309 | processorid_t i;
310 | // int cpu_id = sysconf(_SC_NPROCESSORS_ONLN);
311 |
312 | cpu_data_t *cd;
313 |
314 | ncpus = metriclist.cpu_num.uint32;
315 |
316 | /*
317 | * Modified by Robert Petkus
318 | * Get stats only for online CPUs. Previously, gmond segfaulted if
319 | * the CPUs were not numbered sequentially; i.e., cpu0, cpu2, etc.
320 | * Tested on 64 bit Solaris 8 and 9 with GCC 3.3 and 3.3.2
321 | */
322 | //debug_msg("multicpu: processors online = %d", cpu_id);
323 | for (i = 0; i < cpus->nelts; i++) {
324 |
325 | /*
326 | * ripped from top by swagner in the hopes of getting
327 | * top-like CPU percentages ...
328 | */
329 | gettimeofday(&thistime, NULL);
330 |
331 | cd = get_mcpu(i);
332 |
333 | if (cd->lasttime.tv_sec)
334 | timediff = ((double) thistime.tv_sec * 1.0e7
335 | + ((double) thistime.tv_usec * 10.0))
336 | - ((double) cd->lasttime.tv_sec * 1.0e7
337 | + ((double) cd->lasttime.tv_usec * 10.0));
338 | else
339 | timediff = 1.0e7;
340 |
341 | debug_msg("multicpu: checking cpu %d, timediff = %f", i, timediff);
342 |
343 | /*
344 | * constants for exponential average. avg = alpha * new + beta * avg
345 | * The goal is 50% decay in 30 sec. However if the sample period
346 | * is greater than 30 sec, there's not a lot we can do.
347 | */
348 | if (timediff < 30.0e7) {
349 | alpha = 0.5 * (timediff / 30.0e7);
350 | beta = 1.0 - alpha;
351 | debug_msg(
352 | "multicpu: * * * * Setting alpha to %f and beta to %f because timediff = %d",
353 | alpha, beta, timediff);
354 | } else {
355 | alpha = 0.5;
356 | beta = 0.5;
357 | }
358 |
359 | cd->lasttime = thistime;
360 |
361 | /* END SECTION RIPPED BLATANTLY FROM TOP :) */
362 |
363 | if (first_run == 1) {
364 | debug_msg("multicpu: Initializing old read/write buffer... ");
365 | time_delta = 0L;
366 | }
367 |
368 |
369 | /*
370 | * Submitted by JB Kim
371 | * also skip the loop if CPU is "off-line"
372 | */
373 | int n = p_online(i, P_STATUS);
374 | if (n == 1)
375 | continue;
376 |
377 | if (n == -1 && errno == EINVAL)
378 | continue;
379 |
380 | for (j = 0; j < CPUSTATES; j++)
381 | cpu_now[j] = 0;
382 |
383 | if(get_kstat_cpu_values(cd, &cpuKstats) != 0) {
384 | perror("kstat_read");
385 | return -1;
386 | }
387 |
388 | /* copy up to the wait state counter, the last two we determine ourselves */
389 | for (j = 0; j < CPU_WAIT; j++) {
390 | cpu_now[j] = (unsigned long) cpuKstats.cpu_sysinfo.cpu[j];
391 | }
392 |
393 | cpu_now[CPUSTATE_IOWAIT]
394 | = (unsigned long) cpuKstats.cpu_sysinfo.wait[W_IO]
395 | + (unsigned long) cpuKstats.cpu_sysinfo.wait[W_PIO];
396 | cpu_now[CPUSTATE_SWAP]
397 | = (unsigned long) cpuKstats.cpu_sysinfo.wait[W_SWAP];
398 |
399 | time_delta = (time(NULL) - cd->last_refresh);
400 | if (time_delta == 0)
401 | time_delta = 1;
402 |
403 | debug_msg("multicpu: checking cpu %d, timediff = %f and time_delta = %ld", i, timediff/1.0e7, time_delta);
404 |
405 | /*
406 | * decay stuff
407 | * semi-stolen from top. :) added by swagner on 8/20/02
408 | */
409 | if (time_delta < 30) {
410 | alpha = 0.5 * (time_delta / 30);
411 | beta = 1.0 - alpha;
412 | } else {
413 | alpha = 0.5;
414 | beta = 0.5;
415 | }
416 |
417 | diff_cycles
418 | = mcpu_percentages(CPUSTATES, cd->cpu_states, cpu_now, cd->cpu_old, cpu_diff);
419 |
420 | debug_msg("multicpu: diffs are %d:%d %d:%d %d:%d %d:%d (aggregate: %d)",
421 | CPU_IDLE, cpu_diff[CPU_IDLE],
422 | CPU_USER, cpu_diff[CPU_USER],
423 | CPU_KERNEL, cpu_diff[CPU_KERNEL],
424 | CPU_WAIT, cpu_diff[CPU_WAIT],
425 | diff_cycles);
426 | debug_msg(
427 | "multicpu: ** ** ** ** ** Are percentages electric? Try %d%%, %d%% , %d%% , %d%% , %d%% (over %d cycles)",
428 | cd->cpu_states[0], cd->cpu_states[1], cd->cpu_states[2], cd->cpu_states[3],
429 | cd->cpu_states[4], diff_cycles);
430 |
431 |
432 | /*
433 | * i don't know how you folks do things in new york city, but around here folks
434 | * don't go around dividing by zero.
435 | */
436 | if (diff_cycles < 1) {
437 | debug_msg("multicpu: diff_cycles < 1 ... == %f %u!", diff_cycles, diff_cycles);
438 | diff_cycles = 1;
439 | }
440 |
441 | /*
442 | * could this be ANY HARDER TO READ? sorry. through hacking around i found
443 | * that explicitly casting everything as floats seems to work...
444 | */
445 | cd->metriclist.cpu_idle.f = (float) cd->cpu_states[CPUSTATE_IDLE] / 10;
446 | cd->metriclist.cpu_user.f = (float) cd->cpu_states[CPUSTATE_USER] / 10;
447 | cd->metriclist.cpu_system.f = (float) (cd->cpu_states[CPUSTATE_KERNEL]
448 | + cd->cpu_states[CPUSTATE_SWAP]) / 10;
449 | cd->metriclist.cpu_wio.f = (float) cd->cpu_states[CPUSTATE_IOWAIT] / 10;
450 |
451 | time(&cd->last_refresh);
452 | }
453 |
454 | return (0);
455 | }
456 |
457 | g_val_t mcpu_user_func(cpu_data_t *cd) {
458 | g_val_t val;
459 |
460 | if(cd == get_mcpu(0))
461 | mcpu_determine_cpu_percentages();
462 | val.f = cd->metriclist.cpu_user.f;
463 | return val;
464 | }
465 |
466 | /* FIXME: ? */
467 | g_val_t mcpu_nice_func(cpu_data_t *cd) {
468 | g_val_t val;
469 |
470 | val.f = 0.0; /* no more mr. nice procs ... */
471 |
472 | return val;
473 | }
474 |
475 | g_val_t mcpu_system_func(cpu_data_t *cd) {
476 | g_val_t val;
477 |
478 | val.f = cd->metriclist.cpu_system.f;
479 | return val;
480 | }
481 |
482 | g_val_t mcpu_idle_func(cpu_data_t *cd) {
483 | g_val_t val;
484 |
485 | /* mcpu_determine_cpu_percentages(); */
486 | val.f = cd->metriclist.cpu_idle.f;
487 | return val;
488 | }
489 |
490 | /* FIXME: always 0? */
491 | g_val_t mcpu_wio_func(cpu_data_t *cd) {
492 | g_val_t val;
493 |
494 | val.f = cd->metriclist.cpu_wio.f;
495 | return val;
496 | }
497 |
498 | apr_array_header_t *metric_info = NULL;
499 |
500 | typedef struct metric_spec {
501 | mcpu_func_t func;
502 | const char *name;
503 | const char *units;
504 | const char *desc;
505 | const char *fmt;
506 | } metric_spec_t;
507 |
508 | metric_spec_t my_metrics[] = {
509 | { mcpu_user_func, "multicpu_user", "%",
510 | "Percentage of CPU utilization that occurred while "
511 | "executing at the user level", "%.1f" },
512 | { mcpu_nice_func, "multicpu_nice", "%",
513 | "Percentage of CPU utilization that occurred while "
514 | "executing at the nice level", "%.1f" },
515 | { mcpu_system_func, "multicpu_system", "%",
516 | "Percentage of CPU utilization that occurred while "
517 | "executing at the system level", "%.1f" },
518 | { mcpu_idle_func, "multicpu_idle", "%",
519 | "Percentage of CPU utilization that occurred while "
520 | "executing at the idle level", "%.1f" },
521 | { mcpu_wio_func, "multicpu_wio", "%",
522 | "Percentage of CPU utilization that occurred while "
523 | "executing at the wio level", "%.1f" },
524 | { NULL, NULL, NULL, NULL, NULL} };
525 |
526 | void init_metrics_for_cpu(apr_pool_t *p, apr_array_header_t *ar,
527 | kstat_t *ks) {
528 | metric_spec_t *metric;
529 | Ganglia_25metric *gmi;
530 |
531 | cpu_data_t *cd;
532 |
533 | cd = apr_array_push(cpus);
534 | bzero(cd, sizeof(cpu_data_t));
535 | cd->ks = NULL;
536 | cd->ks_instance = ks->ks_instance;
537 |
538 | debug_msg("multicpu: init for cpu instance %d", ks->ks_instance);
539 | for (metric = my_metrics; metric->func != NULL; metric++) {
540 | gmi = apr_array_push(ar);
541 |
542 | /* gmi->key will be automatically assigned by gmond */
543 | gmi->name = apr_psprintf(p, "%s%d", metric->name, ks->ks_instance);
544 | gmi->tmax = 90;
545 | gmi->type = GANGLIA_VALUE_FLOAT;
546 | gmi->units = apr_pstrdup(p, metric->units);
547 | gmi->slope = apr_pstrdup(p, "both");
548 | gmi->fmt = apr_pstrdup(p, metric->fmt);
549 | gmi->msg_size = UDP_HEADER_SIZE + 8;
550 | gmi->desc = apr_pstrdup(p, metric->desc);
551 | }
552 | }
553 |
554 | static int ex_metric_init(apr_pool_t *p) {
555 | int i;
556 | kstat_t *ksp;
557 | Ganglia_25metric *gmi;
558 |
559 | g_val_t val;
560 |
561 | apr_pool_t *pool;
562 |
563 | /* Allocate a pool that will be used by this module */
564 | apr_pool_create(&pool, p);
565 |
566 | mcpu_get_kstat_val(&metriclist.cpu_num, "unix", "system_misc", "ncpus");
567 | debug_msg("metric_init: Assigning cpu_num value (%d) to ncpus.",
568 | (int) metriclist.cpu_num.uint32);
569 | g_ncpus = metriclist.cpu_num.uint32;
570 |
571 | cpus = apr_array_make(pool, g_ncpus, sizeof(cpu_data_t));
572 | metric_info = apr_array_make(pool, g_ncpus, sizeof(Ganglia_25metric));
573 |
574 | if (kc == NULL)
575 | kc = kstat_open();
576 | else
577 | kstat_chain_update(kc);
578 |
579 | if (kc == NULL) {
580 | debug_msg("multicpu: couldn't open kc...");
581 | err_ret("kstat_open() error");
582 | return -1;
583 | }
584 |
585 | for (ksp = kc->kc_chain; ksp != NULL; ksp = ksp->ks_next) {
586 | if (ksp->ks_type == KSTAT_TYPE_RAW &&
587 | (strcmp(ksp->ks_module, "cpu_stat") == 0)) {
588 | init_metrics_for_cpu(p, metric_info, ksp);
589 | }
590 | }
591 |
592 | /* Add a terminator to the array and replace the empty static metric definition
593 | array with the dynamic array that we just created
594 | */
595 | gmi = apr_array_push(metric_info);
596 | memset(gmi, 0, sizeof(*gmi));
597 |
598 | multicpu_module.metrics_info = (Ganglia_25metric *) metric_info->elts;
599 |
600 | for (i = 0; multicpu_module.metrics_info[i].name != NULL; i++) {
601 | /* Initialize the metadata storage for each of the metrics and then
602 | * store one or more key/value pairs. The define MGROUPS defines
603 | * the key for the grouping attribute. */
604 | MMETRIC_INIT_METADATA(&(multicpu_module.metrics_info[i]), p);
605 | MMETRIC_ADD_METADATA(&(multicpu_module.metrics_info[i]), MGROUP, "cpu");
606 | }
607 |
608 | debug_msg("modmulticpu.c: metric_init() ok.");
609 | val.int32 = 0;
610 | first_run = 0;
611 | /*
612 | * We need to make sure that every server thread gets their own copy of "kc".
613 | * The next metric that needs a kc-handle will reopen it for the server thread.
614 | */
615 | if (kc) {
616 | kstat_close(kc);
617 | kc = NULL;
618 | }
619 | return val.int32;
620 |
621 | }
622 |
623 | static void ex_metric_cleanup(void) {
624 | }
625 |
626 | static g_val_t ex_metric_handler(int metric_index) {
627 | g_val_t val;
628 | int cpu_index;
629 | int _metric_index;
630 | cpu_data_t *cpu;
631 |
632 | cpu_index = metric_index / 5;
633 | _metric_index = metric_index % 5;
634 |
635 | cpu = get_mcpu(cpu_index);
636 | debug_msg("multicpu: handling read for metric %d CPU %d idx %d name = %s%d",
637 | metric_index, cpu_index, _metric_index, "cpu_stat",
638 | cpu->ks_instance);
639 | val = my_metrics[_metric_index].func(cpu);
640 |
641 | return val;
642 | }
643 |
644 | mmodule multicpu_module = { STD_MMODULE_STUFF, ex_metric_init,
645 | ex_metric_cleanup, NULL, /* defined dynamically */
646 | ex_metric_handler, };
647 |
--------------------------------------------------------------------------------
/gpl-3.0.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------