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 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>How To</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="Help"
HREF="cacti_help.html"><LINK
REL="PREVIOUS"
TITLE="Help"
HREF="cacti_help.html"><LINK
REL="NEXT"
TITLE="Frequently Asked Questions"
HREF="faq.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="manual.css"></HEAD
><BODY
CLASS="CHAPTER"
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="cacti_help.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></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="CHAPTER"
><H1
><A
NAME="HOW_TO"
></A
>Chapter 16. How To</H1
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SCRIPT_TO_GRAPH"
>Simplest Method of Going from Script to Graph (Walkthrough)</A
></H1
><DIV
CLASS="AUTHORBLURB"
><A
NAME="AEN2080"
></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
></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
></P
><P
><B
>The details are below:</B
></P
><OL
TYPE="1"
><LI
><P
> Create Data Input Method
</P
><P
></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
><P
></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 <path_rra>/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
><P
></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 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
><P
></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
><P
></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
><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="cacti_help.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"
>Help</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="cacti_help.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Frequently Asked Questions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
|