summaryrefslogtreecommitdiff
path: root/index.html
blob: 54c9623c37af11e337b771c64f8ef43372235a9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />

        <title>Jarmon - customisable, Javascript generated charts from
        Collectd RRD data</title>

        <link rel="stylesheet" type="text/css" href="assets/css/style.css" />
        <link rel="stylesheet" type="text/css" href="assets/css/tabs-no-images.css" />
        <link rel="stylesheet" type="text/css" href="assets/css/jquerytools.dateinput.skin1.css" />

        <script type="text/javascript" src="assets/js/dependencies.js"></script>

        <script type="text/javascript" src="jarmon.js"></script>
        <script type="text/javascript" src="docs/jarmon_example_recipes.js"></script>
        <script type="text/javascript">
        // Recipes for the charts on this page
        var application_recipes = [
            {
                title: 'Jarmon Webserver TCP Stats',
                data: [
                    ['tcpconns-8080-local/tcp_connections-CLOSE_WAIT.rrd', 0, 'CLOSE_WAIT', ''],
                    ['tcpconns-8080-local/tcp_connections-SYN_RECV.rrd', 0, 'SYN_RECV', ''],
                    ['tcpconns-8080-local/tcp_connections-TIME_WAIT.rrd', 0, 'TIME_WAIT', ''],
                    ['tcpconns-8080-local/tcp_connections-CLOSED.rrd', 0, 'CLOSED', ''],
                    ['tcpconns-8080-local/tcp_connections-FIN_WAIT2.rrd', 0, 'FIN_WAIT2', ''],
                    ['tcpconns-8080-local/tcp_connections-FIN_WAIT1.rrd', 0, 'FIN_WAIT1', ''],
                    ['tcpconns-8080-local/tcp_connections-ESTABLISHED.rrd', 0, 'ESTABLISHED', ''],
                    ['tcpconns-8080-local/tcp_connections-LAST_ACK.rrd', 0, 'LAST_ACK', ''],
                    ['tcpconns-8080-local/tcp_connections-LISTEN.rrd', 0, 'LISTEN', ''],
                    ['tcpconns-8080-local/tcp_connections-SYN_SENT.rrd', 0, 'SYN_SENT', ''],
                    ['tcpconns-8080-local/tcp_connections-CLOSING.rrd', 0, 'CLOSING', '']
                ],
                options: jQuery.extend(true, {}, jarmon.Chart.BASE_OPTIONS, jarmon.Chart.STACKED_OPTIONS)
            },
        ];


        function initialiseCharts(rrdUrlList) {
            /**
             * Setup chart date range controls and all charts
             **/

            // Extract the chart template from the page
            var chartTemplate = $('.chart-container').remove();

            function templateFactory(parentEl) {
                return function() {
                    // The chart template must be appended to the page early, so
                    // that flot can calculate chart dimensions etc.
                    return chartTemplate.clone().appendTo(parentEl);
                }
            }

            var cc = new jarmon.ChartCoordinator($('.chartRangeControl'));
            var t;
            // Initialise tabs and update charts when tab is clicked
            $(".css-tabs:first").bind('click', function(i) {
                // XXX: Hack to give the tab just enough time to become visible
                // so that flot can calculate chart dimensions.
                window.clearTimeout(t);
                t = window.setTimeout(function() { cc.update(); }, 100);
            });

            cc.charts = [].concat(
                jarmon.Chart.fromRecipe(
                    rrdUrlList,
                    [].concat(
                        jarmon.COLLECTD_RECIPES.cpu,
                        jarmon.COLLECTD_RECIPES.memory,
                        jarmon.COLLECTD_RECIPES.load),
                    templateFactory('.system-charts')),
                jarmon.Chart.fromRecipe(
                    rrdUrlList,
                    jarmon.COLLECTD_RECIPES.interface,
                    templateFactory('.network-charts')),
                jarmon.Chart.fromRecipe(
                    rrdUrlList,
                    jarmon.COLLECTD_RECIPES.dns,
                    templateFactory('.dns-charts')),
                jarmon.Chart.fromRecipe(
                    rrdUrlList,
                    application_recipes,
                    templateFactory('.application-charts'))
            );

            // Show a loading icon when a chart is being redrawn
            $('.chart-container').live('chart_loading', function(e) {
                $(this).find('.title').addClass('loading');
            });

            $('.chart-container').live('chart_loaded', function(e) {
                $(this).find('.title').removeClass('loading');
            });

            // Initialise all the charts
            cc.init();
        }

        $(function() {

            // Add dhtml calendars to the date input fields
            $(".timerange_control.custom input")
                .dateinput({
                    'format': 'dd mmm yyyy 00:00:00',
                    'max': +1,
                    'css': {'input': 'jquerytools_date'}})
                .bind('onBeforeShow', function(e) {
                    $(this).data('dateinput').setValue(new Date(this.value));
                });
            $(".timerange_control.custom input").bind('onHide',
                function(e) {
                    $(this).trigger('change');
                });

            $(":date[name=from_custom]").data("dateinput").change(function() {
                $(":date[name=to_custom]").data("dateinput").setMin(this.getValue(), true);
            });
            $(":date[name=to_custom]").data("dateinput").change(function() {
                $(":date[name=from_custom]").data("dateinput").setMax(this.getValue(), true);
            });

            // Setup dhtml tabs
            $(".css-tabs").tabs(".css-panes > div", {history: true});

            // Download a list of available rrd files and use it to generate
            // any viable chart recipes

            // Dynamically generated list of rrd urls
            //$.getJSON('rrd_finder.rpy', initialiseCharts);

            // A static json file containing a list of rrd urls
            $.getJSON('rrd_list.json', initialiseCharts);

        });
        </script>
    </head>

    <body>
        <div class="chartRangeControl">
            <form>
                <div>
                    <span class="timerange_control custom">
                        <input name="from_custom" type="text"
                               title="Time range start - click to choose a custom start time" />
                        <input name="to_custom" type="text"
                               title="Time range end - click to choose a custom end time" />
                    </span>
                    <span class="timerange_control standard">
                        <select name="from_standard"
                                title="Time range shortcuts - click to select an alternative time range" >
                            <option>custom</option>
                        </select>
                    </span>
                    <input name="from" type="hidden"  />
                    <input name="to" type="hidden"  />
                    <select name="tzoffset"
                            title="Timezone offset - click to choose a custom timezone offset" ></select>
                    <input name="action" value="Update" type="button"
                           title="Graph update - click to update all graphs" />
                </div>
                <div class="range-preview"
                     title="Time range preview - click and drag to select a custom timerange" ></div>
            </form>
            <ul class="css-tabs">
                <li><a href="#system">System</a></li>
                <li><a href="#network">Network</a></li>
                <li><a href="#dns">DNS</a></li>
                <li><a href="#application">Application</a></li>
            </ul>
            <div class="css-panes charts">
                <div class="system-charts"></div>
                <div class="network-charts"></div>
                <div class="dns-charts"></div>
                <div class="application-charts"></div>
            </div>
            <div class="chart-container">
                <h2 class="title"></h2>
                <div class="chart"></div>
            </div>
        </div>
    </body>
</html>