File: script_to_graph.html

package info (click to toggle)
cacti 0.8.6i-3
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 4,744 kB
  • ctags: 8,967
  • sloc: php: 39,760; sql: 2,306; xml: 678; sh: 487; perl: 133; makefile: 68
file content (566 lines) | stat: -rw-r--r-- 15,696 bytes parent folder | download | duplicates (2)
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
  <meta name="generator" content="HTML Tidy for Linux/x86 (vers 1st August 2004), see www.w3.org">

  <title>Simplest Method of Going from Script to Graph (Walkthrough)</title>
  <meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.79">
  <link rel="HOME" title="The Cacti Manual" href="index.html">
  <link rel="UP" title="How To" href="how_to.html">
  <link rel="PREVIOUS" title="How To" href="how_to.html">
  <link rel="NEXT" title="Frequently Asked Questions" href="faq.html">
  <link rel="STYLESHEET" type="text/css" href="manual.css">
</head>

<body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084" alink="#0000FF">
  <div class="NAVHEADER">
    <table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <th colspan="3" align="center">The Cacti Manual</th>
      </tr>

      <tr>
        <td width="10%" align="left" valign="bottom"><a href="how_to.html" accesskey="P">Prev</a></td>

        <td width="80%" align="center" valign="bottom">Chapter 13. How To</td>

        <td width="10%" align="right" valign="bottom"><a href="faq.html" accesskey="N">Next</a></td>
      </tr>
    </table>
    <hr align="left" width="100%">
  </div>

  <div class="SECT1">
    <h1 class="SECT1"><a name="SCRIPT_TO_GRAPH" id="SCRIPT_TO_GRAPH">Simplest Method of Going from Script to Graph (Walkthrough)</a></h1>

    <div class="AUTHORBLURB">
      <a name="AEN1528" id="AEN1528"></a>

      <p><b class="EMPHASIS">Written by Kevin der Kinderen, <a href="http://kdeuja.com/~kevin/" target="_top">http://kdeuja.com/~kevin/</a></b></p>
    </div>

    <p>This HOWTO walks you through the simplest steps of graphing the output of a single value from a script. As a new user of cacti, I had a difficult time understanding how to graph anything that wasn't canned with the original load. After a lot of playing around, I came up with these procedures which can be built upon for more sophisticated collections and graphs.</p>

    <p>I do not use templates in this HOWTO. Templates provide a significant advantage if you are graphing the output for multiple instances or creating graphs for multiple hosts. They help to maintain consistency and simplify setup.</p>

    <p>The example here is not realistic, but can be used and expanded upon as a model for creating your own graphs.</p>

    <p>I've not put a lot of explanations in the procedures. Refer to the Cacti manual for more details.</p>

    <p>Have a tested script ready to go. I used the following script located in <tt class="FILENAME">/home/cactiuser/bin</tt> called <tt class="FILENAME">random2.pl</tt>:</p>
    <pre class="PROGRAMLISTING">
#!/usr/bin/perl -w

print int(rand(10));
</pre>

    <p>This script simply prints out a random integer between 0 and 9 every time it's called.</p>

    <p><b>The minimal steps to create a graph from a script are simply:</b></p>

    <ol type="1">
      <li>
        <p>Create a Data Input Method to tell Cacti how to call the script and what to expect from it.</p>
      </li>

      <li>
        <p>Create a Data Source to tell cacti how and where the data will be stored.</p>
      </li>

      <li>
        <p>Create a Graph to tell cacti how the data will be presented in graph form.</p>
      </li>

      <li>
        <p>Add Graph to Graph View so you can view the graph.</p>
      </li>

      <li>
        <p>View the Graph</p>
      </li>
    </ol>

    <p><b>The details are below:</b></p>

    <ol type="1">
      <li>
        <p>Create Data Input Method</p>

        <ul>
          <li>
            <p>Click the <span class="GUILABEL">Console</span> tab at the top</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Data Input Methods</span> under <span class="GUILABEL">Management</span></p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Add</span></p>
          </li>

          <li>
            <p>Name: Random 2 Input</p>
          </li>

          <li>
            <p>Input Type: Script/Command</p>
          </li>

          <li>
            <p>Input String: /home/cactiuser/bin/random2.pl</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Create</span></p>
          </li>

          <li>
            <p>Should see "Save Successful." at the top of the page.</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Add</span> by Output Fields (there are no input fields for this example)</p>
          </li>

          <li>
            <p>Field [Output]: random_number</p>
          </li>

          <li>
            <p>Friendly Name: Random Number</p>
          </li>

          <li>
            <p>Update RRD File: checked</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Create</span></p>
          </li>

          <li>
            <p>Should see "Save Successful." and random_number listed under <span class="GUILABEL">Output Fields</span>.</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Save</span></p>
          </li>

          <li>
            <p>Should see "Save Successful." and Random Input listed in <span class="GUILABEL">Data Input Methods</span>.</p>
          </li>
        </ul>
      </li>

      <li>
        <p>Create a Data Source</p>

        <ul>
          <li>
            <p>Click <span class="GUILABEL">Data Sources</span> under <span class="GUILABEL">Management</span></p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Add</span> in the top right</p>
          </li>

          <li>
            <p>The <span class="GUILABEL">Data Template</span> Section should be None and None, we're not using templates for this example.</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Create</span>.</p>
          </li>

          <li>
            <p>Name: random2ds</p>
          </li>

          <li>
            <p>Data Source Path: blank (Cacti will fill this in)</p>
          </li>

          <li>
            <p>Data Input Source: Random 2 Input (this is the data input method you created in step 1)</p>
          </li>

          <li>
            <p>Highlight each of the Associated RRA's using control-click</p>
          </li>

          <li>
            <p>Step: 300 (300 seconds = 5 minutes)</p>
          </li>

          <li>
            <p>Data Source Active: checked</p>
          </li>

          <li>
            <p>Describe the Data Source Item inside the RRA by...</p>
          </li>

          <li>
            <p>Internal Data Source Name: random_number</p>
          </li>

          <li>
            <p>Minimum Value: 0</p>
          </li>

          <li>
            <p>Maximum Value: 0</p>
          </li>

          <li>
            <p>Data Source Type: GAUGE</p>
          </li>

          <li>
            <p>Heartbeat: 600</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Create</span></p>
          </li>

          <li>
            <p>Should see "Save Successful." at the top and the Data Source Path should now have a value (my example &lt;path_rra&gt;/random_number_286.rrd)</p>
          </li>

          <li>
            <p>Click Turn On Data Source Debugging Mode to see the results of this step.</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Save</span></p>
          </li>

          <li>
            <p>Should see "Save Successful" and your new Data Source listed.</p>
          </li>
        </ul>
      </li>

      <li>
        <p>Create Graph</p>

        <ul>
          <li>
            <p>Select <span class="GUILABEL">Graph Management</span> under <span class="GUILABEL">Management</span></p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Add</span></p>
          </li>

          <li>
            <p>Selected Graph Template: None</p>
          </li>

          <li>
            <p>Host: None</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Create</span></p>
          </li>

          <li>
            <p>Title: RANDOM NUMBERS</p>
          </li>

          <li>
            <p>Image Format: PNG</p>
          </li>

          <li>
            <p>Height: 120</p>
          </li>

          <li>
            <p>Width: 500</p>
          </li>

          <li>
            <p>Auto Scale: checked</p>
          </li>

          <li>
            <p>Auto Scale Options: Use --alt-autoscale-max</p>
          </li>

          <li>
            <p>Logarithmic Auto Scaling: unchecked</p>
          </li>

          <li>
            <p>Rigid Boundaries: unchecked</p>
          </li>

          <li>
            <p>Auto Padding: checked</p>
          </li>

          <li>
            <p>Allow Graph Export: checked</p>
          </li>

          <li>
            <p>Upper Limit: 100</p>
          </li>

          <li>
            <p>Lower Limit: 0</p>
          </li>

          <li>
            <p>Base Value: 1000</p>
          </li>

          <li>
            <p>Unit Value: blank</p>
          </li>

          <li>
            <p>Unit Exponent Value: 0</p>
          </li>

          <li>
            <p>Vertical Label: Random Number</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Create</span></p>
          </li>

          <li>
            <p>Should see "Save Successful."</p>
          </li>

          <li>
            <p>If you click "Turn On Graph Debug Mode." now you will see: "Error: can't make a graph without contents." We need to add Graph Items:</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Add</span> by <span class="GUILABEL">Graph Items</span></p>
          </li>

          <li>
            <p>Data Source: (from list) No Host - random2ds (random_number)</p>
          </li>

          <li>
            <p>Color: 0000FF (Blue)</p>
          </li>

          <li>
            <p>Graph Item Type: LINE2</p>
          </li>

          <li>
            <p>Consolidation Function: AVERAGE</p>
          </li>

          <li>
            <p>CDEF Function: None</p>
          </li>

          <li>
            <p>Value: blank</p>
          </li>

          <li>
            <p>GPRINT Type: Normal</p>
          </li>

          <li>
            <p>Text Format: blank</p>
          </li>

          <li>
            <p>Insert Hard Return: unchecked</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Create</span></p>
          </li>

          <li>
            <p>Should see "Save Successful.", Item #1 listed and a graph under debug (probably with nothing in it yet)</p>
          </li>

          <li>
            <p>To add a legend, click <span class="GUILABEL">Add</span> by <span class="GUILABEL">Graph Items</span> again</p>
          </li>

          <li>
            <p>Data Source: No Host - random2ds (random_number)</p>
          </li>

          <li>
            <p>Color: None</p>
          </li>

          <li>
            <p>Graph Item Type: GPRINT</p>
          </li>

          <li>
            <p>Consolidation Function: LAST</p>
          </li>

          <li>
            <p>CDEF Function: None</p>
          </li>

          <li>
            <p>Value: blank</p>
          </li>

          <li>
            <p>GPRINT Type: Normal</p>
          </li>

          <li>
            <p>Text Format: Cur:</p>
          </li>

          <li>
            <p>Insert Hard Return: unchecked</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Create</span></p>
          </li>

          <li>
            <p>Should see "Save Successful." and the graph will have a legend showing the current value. Note: your integer random number has been averaged over the past 5 minutes. At the bottom of the page, click save.</p>
          </li>

          <li>
            <p>At the bottom of the page, click <span class="GUILABEL">Save</span>.</p>
          </li>

          <li>
            <p>Should see "Save Successful." and your graph listed.</p>
          </li>
        </ul>
      </li>

      <li>
        <p>Add graph to the graph view</p>

        <ul>
          <li>
            <p>Click <span class="GUILABEL">Graph Trees</span> under <span class="GUILABEL">Management</span></p>
          </li>

          <li>
            <p>We'll create a tree called "test" to place our graph</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Add</span></p>
          </li>

          <li>
            <p>Name: test</p>
          </li>

          <li>
            <p>Should see "Save Successful"</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Add</span> beside <span class="GUILABEL">Tree Items</span> (to add our graph to this tree)</p>
          </li>

          <li>
            <p>Under Tree Items [graph]...</p>
          </li>

          <li>
            <p>Graph: RANDOM NUMBERS (we named this in step 3)</p>
          </li>

          <li>
            <p>Round Robin Archive: Daily (5 Minute Average)</p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Create</span></p>
          </li>

          <li>
            <p>Should see "Save Successful." and RANDOM NUMBERS listed under <span class="GUILABEL">Tree Items</span></p>
          </li>

          <li>
            <p>Click <span class="GUILABEL">Save</span></p>
          </li>

          <li>
            <p>Should see "Save Successful." and test listed under <span class="GUILABEL">Graph Trees</span></p>
          </li>
        </ul>
      </li>

      <li>
        <p>View Graph</p>

        <ul>
          <li>
            <p>Select <span class="GUILABEL">Graphs</span> tab</p>
          </li>

          <li>
            <p>Select tree view (Tree beside settings tab)</p>
          </li>

          <li>
            <p>Select test tree on left</p>
          </li>

          <li>
            <p>You may see "Random Graph" but no graph. It takes two or three polls (10 - 15 minutes) to see a graph. I believe poll 1 to create the rrd, poll 2 to get the first data point and poll 3 to have graphable points.</p>
          </li>

          <li>
            <p>While waiting, you can click the RANDOM NUMBERS graph. You'll see place holders for 4 graphs. Select [source] under Daily (5 Minute Average). You'll see the source for the call to rrdtool graph. Give it a sanity check.</p>
          </li>

          <li>
            <p>Now be patient. Hit your refresh button every few minutes. After the first poll I got a few empty graphs. A few minutes later data started showing up.</p>
          </li>
        </ul>
      </li>
    </ol>
  </div>

  <div class="NAVFOOTER">
    <hr align="left" width="100%">

    <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="33%" align="left" valign="top"><a href="how_to.html" accesskey="P">Prev</a></td>

        <td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td>

        <td width="33%" align="right" valign="top"><a href="faq.html" accesskey="N">Next</a></td>
      </tr>

      <tr>
        <td width="33%" align="left" valign="top">How To</td>

        <td width="34%" align="center" valign="top"><a href="how_to.html" accesskey="U">Up</a></td>

        <td width="33%" align="right" valign="top">Frequently Asked Questions</td>
      </tr>
    </table>
  </div>
</body>
</html>