-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.html
1652 lines (1584 loc) · 67.2 KB
/
README.html
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
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" ?>
<!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">
<head>
<title>Nagiosgraph</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
<!-- INDEX BEGIN -->
<div name="index" class="index">
<p><a name="__index__"></a></p>
<ul>
<li><a href="#nagiosgraph">Nagiosgraph</a></li>
<li><a href="#copyright_and_license">Copyright and License</a></li>
<li><a href="#principles_of_operation">Principles of Operation</a></li>
<li><a href="#installation_preliminaries">Installation Preliminaries</a></li>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#layout_and_location">Layout and Location</a></li>
<li><a href="#installation_methods">Installation Methods</a></li>
<ul>
<li><a href="#manual_installation">Manual Installation</a></li>
<li><a href="#install_script">Install Script</a></li>
<li><a href="#installation_using_packages">Installation Using Packages</a></li>
</ul>
</ul>
<li><a href="#installing_nagiosgraph_files">Installing nagiosgraph Files</a></li>
<li><a href="#upgrade_notes">Upgrade Notes</a></li>
<li><a href="#configuring_data_processing">Configuring Data Processing</a></li>
<ul>
<li><a href="#batch_processing">Batch Processing</a></li>
<li><a href="#immediate_processing">Immediate Processing</a></li>
</ul>
<li><a href="#configuring_graphing_and_display">Configuring Graphing and Display</a></li>
<ul>
<li><a href="#graph_icons_and_links_in_nagios">Graph Icons and Links in Nagios</a></li>
<ul>
<li><a href="#for_nagios_2_6_and_earlier">For Nagios 2.6 and Earlier</a></li>
<li><a href="#for_nagios_2_9_and_nagios_3">For Nagios 2.9 and Nagios 3</a></li>
</ul>
<li><a href="#graphs_in_nagios_mouseovers">Graphs in Nagios Mouseovers</a></li>
<li><a href="#graphs_in_nagios_frames">Graphs in Nagios Frames</a></li>
</ul>
<li><a href="#customizing_the_graphs">Customizing the Graphs</a></li>
<li><a href="#adding_service_types">Adding Service Types</a></li>
<li><a href="#managing_data_and_rrd_files">Managing Data and RRD Files</a></li>
<li><a href="#managing_rrd_parameters">Managing RRD Parameters</a></li>
<li><a href="#configuring_access_controls">Configuring Access Controls</a></li>
<li><a href="#troubleshooting">Troubleshooting</a></li>
<li><a href="#internationalization">Internationalization</a></li>
<li><a href="#enumeration_of_files">Enumeration of Files</a></li>
<li><a href="#sample_installation_layouts">Sample Installation Layouts</a></li>
<li><a href="#sample_web_server_configuration">Sample Web Server Configuration</a></li>
<li><a href="#platform_specific_notes">Platform Specific Notes</a></li>
<ul>
<li><a href="#nagios_embedded_perl__epn_">Nagios Embedded PERL (ePN)</a></li>
<li><a href="#centos_5_and_nagiosgraph_0_9">CentOS 5 and Nagiosgraph 0.9</a></li>
<li><a href="#macosx_10_5_and_nagios_2_12">MacOSX 10.5 and Nagios 2.12</a></li>
<li><a href="#fedora_core_6_and_http_output_parsing">Fedora Core 6 and HTTP output parsing</a></li>
</ul>
<li><a href="#notes_for_developers">Notes For Developers</a></li>
<li><a href="#project_testing_code_summary">Project Testing/Code Summary</a></li>
</ul>
<hr name="index" />
</div>
<!-- INDEX END -->
<style>
h1,h2,h3,h4 {font-family: sans-serif;}
h1 {font-size:1.3em; padding-top:0.25em;}
h2 {font-size:1.1em; padding-top:0.1em;}
h3 {font-size:1em; padding-top:0.1em;}
h4 {font-size:1em; font-style:italic; padding-top:0.1em;}
hr {width:0;}
dt {font-family: sans-serif; font-size:0.85em;}
dd {font-size:0.85em;}
.index {
font-family: sans-serif;
font-size: 0.8em;
float: right;
border: 1px solid #aaaaaa;
background: #eeeeee;
margin-left: 30px;
margin-right: 10px;
padding-right: 20px;}
</style><p>
</p>
<hr />
<h1><a name="nagiosgraph">Nagiosgraph</a></h1>
<p>Nagiosgraph is an add-on to Nagios. Nagios monitors one or more services on
each host. nagiosgraph extracts information from the Nagios output, processes
it, then inserts it into one or more round-robin database (RRD) files. CGI
scripts display data from the RRD files as web pages. The CGI output can be
embedded directly into Nagios so that graphs show up like other trend reports.</p>
<p>Installation is a three-step process. First install the nagiosgraph files,
then configure Nagios for data collection, and finally customize the graphs
and links as needed. Installation can be done manually by copying files and
modifying configuration files, or automatically using the install.pl script.</p>
<p>The INSTALL file contains basic installation instructions.</p>
<p>This README file contains detailed instructions for installing, upgrading,
customizing, troubleshooting, and managing performance data.</p>
<p>Answers to frequently asked questions are at:</p>
<p><a href="https://sourceforge.net/apps/mediawiki/nagiosgraph">https://sourceforge.net/apps/mediawiki/nagiosgraph</a></p>
<p>For help, visit the forum at:</p>
<p><a href="http://sourceforge.net/projects/nagiosgraph/forums/forum/394748">http://sourceforge.net/projects/nagiosgraph/forums/forum/394748</a></p>
<p>
</p>
<hr />
<h1><a name="copyright_and_license">Copyright and License</a></h1>
<pre>
License: OSI Artistic License 2.0
<a href="http://www.opensource.org/licenses/artistic-license-2.0">http://www.opensource.org/licenses/artistic-license-2.0</a></pre>
<pre>
Author: (c) 2005 Soren Dossing
Author: (c) 2008 Alan Brenner, Ithaka Harbors
Author: (c) 2010 Matthew Wall</pre>
<pre>
Nagios is a registered trademark of Ethan Galstad.</pre>
<p>
</p>
<hr />
<h1><a name="principles_of_operation">Principles of Operation</a></h1>
<p>nagiosgraph is a simple interface between Nagios and RRD files.</p>
<p>nagiosgraph operates in two modes. One is to collect performance data
from Nagios servicechecks, and the other is to display graphs of
the performance data collected.</p>
<p>All the data collected are stored in RRD files using rrdtool. A file
called 'map' defines how to identify the data from Nagios and how to
store them in the RRD files. Nagios passes all the service data to a
nagiosgraph script called 'insert.pl'. This script uses the file 'map'
to determine how to name the data and into which RRD files to insert
the data. The map file also processes the data, for example by changing
units or applying scaling factors.</p>
<p>The 'map' file is actually perl code, that is eval'ed by 'insert.pl'.
The map file contains a general rule that will capture the performance
data from most plugins. However, it may be necessary to add entries to
match the output of some Nagios plugins. Several examples of servicechecks
are included in the distributed map file. Knowing perl regular expression
is helpful, but the examples supplied should cover most types of
performance data.</p>
<p>For graphing, nagiosgraph includes cgi scripts. 'show.cgi' looks up
performance data for a single host and service, and generates line
charts accordingly. Other scripts display all hosts for a specific
service, all services for a specific host, or arbitrary groups of hosts
and services. These run out-of-the-box with minimal configuration, or
they can be customized, using a configuration file or interactively.</p>
<p>Graphs can be integrated into Nagios using Nagios' extended information
for services and hosts. By specifying nagiosgraph cgi scripts in the
Nagios configuration, individual graphs and collections of graphs can be
linked directly to hosts and services in Nagios web pages.</p>
<p>By default, all available data for a servicecheck will be displayed in
the same graph. With extra configuration, either embedded in the url,
specified in a configuration file, or using controls in a web page, it is
possible to display less data or to split values into multiple graphs.
There is also a general method for specifying arbitrary RRD graph
options such as line style, color, and scaling for individual hosts or
services.</p>
<p>
</p>
<hr />
<h1><a name="installation_preliminaries">Installation Preliminaries</a></h1>
<p>Before installing, ensure that the prerequisite software has been installed
then decide upon a layout and location.</p>
<p>
</p>
<h2><a name="prerequisites">Prerequisites</a></h2>
<p>Nagiosgraph will not function without a working Nagios installation, so
first ensure that Nagios works. Version 3.2 or later is recommended, but
older versions will also work.</p>
<p>Nagiosgraph requires rrdtool. Version 1.4 or later is recommended, but
older versions will also work.</p>
<p>Nagiosgraph requires the CGI and RRDs perl modules. The RRDs perl module
is part of rrdtool but is often distributed as a separate package. The GD
perl module is optional, but recommended. The Nagios::Object perl module is
optional, but useful for automatic configuration of showgroup.cgi.</p>
<p>Debian/Ubuntu:</p>
<pre>
apt-get install libcgi-pm-perl librrds-perl
apt-get install libgd-gd2-perl libnagios-object-perl</pre>
<p>Redhat/Fedora/CentOS:</p>
<pre>
yum install perl-rrdtool perl-GD</pre>
<p>SUSE:</p>
<pre>
rrdtool, perl-GD</pre>
<p>Solaris:</p>
<pre>
rrdtool, gd</pre>
<p>FreeBSD:</p>
<pre>
rrdtool, gd</pre>
<p>OpenBSD:</p>
<pre>
p5-RRD, p5-GD</pre>
<p>The install.pl script includes an option to check for pre-requisites:</p>
<pre>
install.pl --check-prereq</pre>
<p>
</p>
<h2><a name="layout_and_location">Layout and Location</a></h2>
<p>There are two standard layouts: separate or overlay. The separated layout
has nagiosgraph and Nagios in separate directories. The overlay places
nagiosgraph components with Nagios components.</p>
<p>Nagios and nagiosgraph can be installed in just about any location, for
example /opt or /usr/local.</p>
<p>Redhat (Fedora, CentOS), SUSE, and Debian (Ubuntu) systems have their own
layouts. If you installed Nagios from a package, you can overlay nagiosgraph
or you can install nagiosgraph to its own standalone location.</p>
<p>When installing from source, the standalone layout is highly recommended
since it makes updates much easier.</p>
<p>Decide upon a location and layout before you start the installation.
Examples are in the Sample Installation Layouts section.</p>
<p>
</p>
<h2><a name="installation_methods">Installation Methods</a></h2>
<p>There are a few ways to install nagiosgraph: manual, script, and package.
On most systems the installation requires root permissions, so either do
the installation as root or preface commands with sudo.</p>
<p>
</p>
<h3><a name="manual_installation">Manual Installation</a></h3>
<p>Copy and edit files directly. Follow the recipe in the INSTALL file, or
the instructions in these sections of this file:</p>
<ul>
<li>
<p><a href="#installing_nagiosgraph_files">Installing nagiosgraph Files</a> - nagiosgraph installation</p>
</li>
<li>
<p><a href="#configuring_data_processing">Configuring Data Processing</a> - Nagios configuration</p>
</li>
<li>
<p><a href="#configuring_graphing_and_display">Configuring Graphing and Display</a> - Apache and Nagios configuration</p>
</li>
</ul>
<p>
</p>
<h3><a name="install_script">Install Script</a></h3>
<p>Run the install.pl script. It will prompt you for the parameters it
needs, then it will copy and configure nagiosgraph files. It will also
prompt you to modify apache and Nagios configuration files.</p>
<pre>
install.pl --prefix=/usr/local/nagiosgraph
install.pl --help</pre>
<p>
</p>
<h3><a name="installation_using_packages">Installation Using Packages</a></h3>
<p>The nagiosgraph packages assume that Nagios and apache were installed
from packages. Do not use a nagiosgraph package if you installed Nagios
or apache from source!</p>
<p>Debian, Ubuntu</p>
<pre>
dpkg -i nagiosgraph-x.y.z.deb</pre>
<p>Redhat, Fedora, CentOS, SUSE</p>
<pre>
rpm -i nagiosgraph-x.y.z.rpm</pre>
<p>
</p>
<hr />
<h1><a name="installing_nagiosgraph_files">Installing nagiosgraph Files</a></h1>
<p>These instructions assume a standalone layout, with Nagios at /usr/local/nagios
and nagiosgraph at /usr/local/nagiosgraph</p>
<ol>
<li>
<p>Create destination directories:</p>
<pre>
mkdir /usr/local/nagiosgraph
mkdir /usr/local/nagiosgraph/bin
mkdir /usr/local/nagiosgraph/cgi-bin
mkdir /usr/local/nagiosgraph/etc
mkdir /usr/local/nagiosgraph/share</pre>
</li>
<li>
<p>Extract nagiosgraph into a temporary location:</p>
<pre>
cd /tmp
tar xzvf nagiosgraph-x.y.z.tgz</pre>
</li>
<li>
<p>Copy the contents of etc into your preferred configuration location:</p>
<pre>
cp etc/* /usr/local/nagiosgraph/etc</pre>
</li>
<li>
<p>Edit the perl scripts in the cgi and lib directories, modifying the
"use lib" line to point to the directory from the previous step.</p>
<pre>
vi cgi/*.cgi lib/insert.pl</pre>
</li>
<li>
<p>Copy insert.pl to a location from which it can be executed:</p>
<pre>
cp lib/insert.pl /usr/local/nagiosgraph/bin</pre>
</li>
<li>
<p>Copy CGI scripts to a script directory served by the web server:</p>
<pre>
cp cgi/*.cgi /usr/local/nagiosgraph/cgi-bin</pre>
</li>
<li>
<p>Copy CSS and JavaScript files to a directory served by the web server:</p>
<pre>
cp share/nagiosgraph.css /usr/local/nagiosgraph/share
cp share/nagiosgraph.js /usr/local/nagiosgraph/share</pre>
</li>
<li>
<p>Edit nagiosgraph.conf. Set at least the following:</p>
<pre>
logfile = /var/log/nagiosgraph.log
cgilogfile = /var/log/nagiosgraph-cgi.log
perflog = /var/nagios/perfdata.log
rrddir = /var/nagios/rrd
mapfile = /usr/local/nagiosgraph/etc/map
nagiosgraphcgiurl = /nagiosgraph/cgi-bin
javascript = /nagiosgraph/nagiosgraph.js
stylesheet = /nagiosgraph/nagiosgraph.css</pre>
</li>
<li>
<p>Set permissions of "rrddir" (as defined in nagiosgraph.conf) so that
the *nagios* user can write to it and the *www* user can read it:</p>
<pre>
mkdir /var/nagios/rrd
chown nagios /var/nagios/rrd
chmod 755 /var/nagios/rrd</pre>
</li>
<li>
<p>Set permissions of "logfile" so that the *nagios* user can write to it:</p>
<pre>
touch /var/log/nagiosgraph.log
chown nagios /var/log/nagiosgraph.log
chmod 644 /var/log/nagiosgraph.log</pre>
</li>
<li>
<p>Set permissions of "cgilogfile" so that the *www* user can write to it:</p>
<pre>
touch /var/log/nagiosgraph-cgi.log
chown www /var/log/nagiosgraph-cgi.log
chmod 644 /var/log/nagiosgraph-cgi.log</pre>
</li>
<li>
<p>Ensure that the *nagios* user can create and delete perfdata files:</p>
<pre>
chown nagios /var/nagios
chmod 755 /var/nagios</pre>
</li>
</ol>
<p>
</p>
<hr />
<h1><a name="upgrade_notes">Upgrade Notes</a></h1>
<ul>
<li>
<p>Follow the steps for a new installation, but keep your customizations.
Your changes should be limited to the map file (map), configuration
files (nagiosgraph.conf and other .conf files), and the stylesheet
(nagiosgraph.css).</p>
</li>
<li>
<p>Use diff, or a similar tool, to update your nagiosgraph.conf with any new
fields from etc/nagiosgraph.conf</p>
</li>
<li>
<p>Use diff, or a similar tool, to update your nagiosgraph.css with changes
from share/nagiosgraph.css.</p>
</li>
<li>
<p>You may want to look at etc/map or the files in the examples directory
to see if there are any map rules or CSS useful to your configuration.</p>
</li>
<li>
<p>If you change from immediate processing to batch processing, be sure to
comment out service_perfdata_command in the Nagios configuration.</p>
</li>
<li>
<p>Be sure to install the nagiosgraph.js and nagiosgraph.css files, especially
if you are upgrading from nagiosgraph older than 1.2.</p>
</li>
<li>
<p>If you are upgrading from nagiosgraph 1.4.1 or earlier, move your service
and database/datasource labels from nagiosgraph.conf to labels.conf.</p>
</li>
<li>
<p>If you are upgrading from nagiosgraph 1.4.3 or earlier and you were using
nagios3 for the authzmethod, you must replace authz_nagios_cfg and
authz_cgi_cfg with authzfile. All of the Nagios authorization parameters
should be in the Nagios CGI configuration file (typically cgi.cfg).</p>
</li>
<li>
<p>If you are upgrading from nagiosgraph 1.4.3 or earlier, you might want to
add the generic map rule to the end of your map file. This rule will
catch performance data from any additional plugins you add. Using the
generic rule results in RRD files with the following structure, one file
per named performance data element, with one or more data sources:</p>
<pre>
host0/service___label (data[,warn][,crit][,min][,max])</pre>
</li>
<li>
<p>If you are upgrading from nagiosgraph 1.4.3 or earlier, you should make any
ignore map rules explicit. For example, in the map file change this:</p>
<pre>
/output:CHECK_NRPE: Socket timeout/
and return;</pre>
<p>to this:</p>
<pre>
/output:CHECK_NRPE: Socket timeout/
and return ('ignore');</pre>
</li>
</ul>
<p>
</p>
<hr />
<h1><a name="configuring_data_processing">Configuring Data Processing</a></h1>
<p>Before nagiosgraph can graph anything it must first collect data. There are
two ways to process data - batch and immediate. Batch processing is usually
appropriate for most Nagios deployments. Immediate processing typically
requires more CPU and I/O.</p>
<p>In batch processing, performance data are appended to a file, then Nagios
invokes insert.pl at a regular interval to update the RRD files.</p>
<p>In immediate processing, Nagios invokes insert.pl immediately after each
service check, thus updating the corresponding RRD files.</p>
<p>
</p>
<h2><a name="batch_processing">Batch Processing</a></h2>
<ol>
<li>
<p>In the Nagios configuration file (nagios.cfg) set:</p>
<pre>
process_performance_data=1
service_perfdata_file=/var/nagios/perfdata.log
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
service_perfdata_file_processing_command=process-service-perfdata</pre>
<p>Make sure that service_perfdata_command is either commented out
or not defined.</p>
<p>Make sure that location of service_perfdata_file matches that of perflog
defined in nagiosgraph.conf.</p>
</li>
<li>
<p>In the Nagios commands file (commands.cfg) define
the process-service-perfdata command:</p>
<pre>
define command {
command_name process-service-perfdata
command_line /usr/local/nagiosgraph/bin/insert.pl
}</pre>
<p>Make sure there is only one definition for process-service-perfdata.</p>
<p>Older versions of Nagios used checkcommands.cfg or misccommands.cfg.</p>
</li>
<li>
<p>Check the Nagios configuration</p>
<pre>
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg</pre>
</li>
<li>
<p>Restart Nagios</p>
<pre>
/etc/init.d/nagios restart</pre>
</li>
</ol>
<p>
</p>
<h2><a name="immediate_processing">Immediate Processing</a></h2>
<ol>
<li>
<p>In nagios.cfg:</p>
<pre>
process_performance_data=1
service_perfdata_command=process-service-perfdata</pre>
<p>Make sure that service_perfdata_file_processing_command is either
commented out or not defined.</p>
</li>
<li>
<p>In commands.cfg:</p>
<pre>
define command{
command_name process-service-perfdata
command_line /usr/local/nagiosgraph/bin/insert.pl "$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$"
}</pre>
</li>
<li>
<p>Check the Nagios configuration</p>
<pre>
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg</pre>
</li>
<li>
<p>Restart Nagios</p>
<pre>
/etc/init.d/nagios restart</pre>
</li>
</ol>
<p>
</p>
<hr />
<h1><a name="configuring_graphing_and_display">Configuring Graphing and Display</a></h1>
<p>First configure the web server to run the nagiosgraph CGI scripts. For
example, with Apache do something like this in the Apache configuration:</p>
<pre>
ScriptAlias /nagiosgraph/cgi-bin /usr/local/nagiosgraph/cgi-bin
<Directory "/usr/local/nagiosgraph/cgi-bin">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Alias /nagiosgraph "/usr/local/nagiosgraph/share"
<Directory "/usr/local/nagiosgraph/share">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory></pre>
<p>Restart the web server:</p>
<pre>
/etc/init.d/apache2 restart</pre>
<p>Verify that nagiosgraph is working by running showconfig.cgi</p>
<pre>
<a href="http://server/nagiosgraph/cgi-bin/showconfig.cgi">http://server/nagiosgraph/cgi-bin/showconfig.cgi</a></pre>
<p>Try graphing some data by running show.cgi</p>
<pre>
<a href="http://server/nagiosgraph/cgi-bin/show.cgi">http://server/nagiosgraph/cgi-bin/show.cgi</a></pre>
<p>This should display a web page with a list of your hosts and services.
Note that it might take a few minutes for data to collect, so at first the
list of hosts and services might be sparse and the graphs might be empty.</p>
<p>There are a few ways to embed graphs into Nagios. In the service and
host listings, Nagios will display graph icons that, when clicked, will
open a new web page with graphs. These icons are typically per-host
(linked to the showhost.cgi script) or per-host-service (linked to the
show.cgi script). Nagios will display graph data when the mouse is moved
over the graph icon for each host/service. Finally, graphs can be displayed
directly in the Nagios frames. The following sections explain how to do each
of these.</p>
<p>
</p>
<h2><a name="graph_icons_and_links_in_nagios">Graph Icons and Links in Nagios</a></h2>
<p>Links to graphs can be embedded in Nagios status pages using the notes or
actions fields. The specifics depend on the Nagios version as well as how
you have configured your host and service definitions. Nagios 2 uses the
serviceextinfo and hostextinfo construct. In Nagios 3 the nagiosgraph
additions go directly in the host and service definitions.</p>
<p>To display a graph icon instead of the Nagios action icon, replace
nagios/images/action.gif with graph.gif from the nagiosgraph distribution.</p>
<p>In its default configuration, Nagios will create a new window for each
action or notes link. To display graphs in the Nagios frame instead of
a new window, set action_url_target=main in the Nagios cgi.cfg file.</p>
<p>
</p>
<h3><a name="for_nagios_2_6_and_earlier">For Nagios 2.6 and Earlier</a></h3>
<p>If you have these lines in nagios.cfg, un-comment the 2 cfg_file= lines:</p>
<pre>
# Extended host/service info definitions are now stored along with
# other object definitions:
# cfg_file=/etc/nagios/hostextinfo.cfg
# cfg_file=/etc/nagios/serviceextinfo.cfg</pre>
<p>Otherwise, define in cgi.cfg the following:</p>
<pre>
xedtemplate_config_file=/usr/local/nagios/etc/serviceextinfo.cfg</pre>
<p>Edit/Create hostextinfo.cfg</p>
<pre>
define hostextinfo {
host_name your-host
action_url /nagiosgraph/cgi-bin/showhost.cgi?host=$HOSTNAME$
}</pre>
<p>This must be the host you will use in serviceextinfo.cfg</p>
<p>Edit/Create serviceextinfo.cfg</p>
<pre>
define serviceextinfo {
service_description DNS
hostgroup servers
notes_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
icon_image graph.gif
icon_image_alt View graphs
}</pre>
<p>
</p>
<h3><a name="for_nagios_2_9_and_nagios_3">For Nagios 2.9 and Nagios 3</a></h3>
<p>Use the action_url for any existing host or service definition. For example,</p>
<pre>
define service {
name NTP
use local-service
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
...
}</pre>
<pre>
define host {
host_name web-server
action_url /nagiosgraph/cgi-bin/showhost.cgi?host=$HOSTNAME$
...
}</pre>
<p>To apply graph links to multiple services, define a template such as this:</p>
<pre>
define service {
name graphed-service
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
register 0
}</pre>
<p>Then use it in services like this:</p>
<pre>
define service {
name NTP
use local-service,graphed-service
...
}</pre>
<p>
</p>
<h2><a name="graphs_in_nagios_mouseovers">Graphs in Nagios Mouseovers</a></h2>
<p>To display graphs as mouseovers for each host and/or service, do the following:</p>
<ol>
<li>
<p>Edit the file share/nagiosgraph.ssi to contain the URL to the nagiosgraph
javascript file (e.g. /nagiosgraph/nagiosgraph.js)</p>
</li>
<li>
<p>If you have not customized the Nagios SSI, copy share/nagiosgraph.ssi to
the Nagios ssi directory, and rename it so that Nagios will insert it into
each page. For example:</p>
<pre>
cp share/nagiosgraph.ssi /usr/local/nagios/share/ssi/common-header.ssi</pre>
<p>If you have customized Nagios SSI, add the contents of
share/nagiosgraph.ssi to your customized SSI header file.</p>
</li>
<li>
<p>Configure services to display graphs on mouseovers by adding some
JavaScript to action_url or notes_url. For example:</p>
<pre>
define service {
name NTP
use local-service
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
...
}</pre>
<p>This example displays a week of data in a popup with no legend:</p>
<pre>
define service {
name NTP
use local-service
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=week&rrdopts=-w+450+-j
...
}</pre>
</li>
</ol>
<p>You must restart Nagios for changes to service/host defintions to take effect.</p>
<p>If a service includes multiple data sources, use the datasetdb file (specified
in nagiosgraph.conf) to indicate which data sources should be displayed by
default for each service, or specify the data source(s) explicity in each
action_url.</p>
<p>
</p>
<h2><a name="graphs_in_nagios_frames">Graphs in Nagios Frames</a></h2>
<p>To embed nagiosgraph graphs directly into Nagios, do the following:</p>
<p>Modify side.php (e.g. /usr/local/nagios/share/side.php) by inserting
bullets under the 'Trends' heading:</p>
<pre>
<li><a href="<?php echo $cfg["cgi_base_url"];?>/trends.cgi" target="<?php echo $link_target;?>">Trends</a>
<ul>
<li><a href="<?php echo $cfg["cgi_base_url"];?>/show.cgi" target="<?php echo $link_target;?>">Graphs</a></li>
<li><a href="<?php echo $cfg["cgi_base_url"];?>/showhost.cgi" target="<?php echo $link_target;?>">Graphs by Host</a></li>
<li><a href="<?php echo $cfg["cgi_base_url"];?>/showservice.cgi" target="<?php echo $link_target;?>">Graphs by Service</a></li>
<li><a href="<?php echo $cfg["cgi_base_url"];?>/showgroup.cgi" target="<?php echo $link_target;?>">Graphs by Group</a></li>
</ul>
</li></pre>
<p>If you keep the nagiosgraph cgi scripts in a location different than
the Nagios cgi scripts, then use 'ng_cgi_base_url' rather than
'cgi_base_url' and make an entry in config.inc.php such as this:</p>
<pre>
$cfg['cgi_base_url']='/nagios/cgi-bin';
$cfg['ng_cgi_base_url']='/nagiosgraph/cgi-bin';</pre>
<p>Some Nagios installations have side.html instead of side.php:</p>
<pre>
<li><a href="/nagios/cgi-bin/trends.cgi" target="main">Trends</a>
<ul>
<li><a href="/nagiosgraph/cgi-bin/show.cgi" target="main">Graphs</a></li>
<li><a href="/nagiosgraph/cgi-bin/showhost.cgi" target="main">Graphs by Host</a></li>
<li><a href="/nagiosgraph/cgi-bin/showservice.cgi" target="main">Graphs by Service</a></li>
<li><a href="/nagiosgraph/cgi-bin/showgroup.cgi" target="main">Graphs by Group</a></li>
</ul>
</li></pre>
<p>
</p>
<hr />
<h1><a name="customizing_the_graphs">Customizing the Graphs</a></h1>
<p>The look and feel of nagiosgraph is controlled by the cascading style sheets
defined in nagiosgraph.css. The examples directory contains a stylesheet file
with sample style sheets for fixing the controls to the page, floating the
controls above the graphs, or hiding the controls altogether.</p>
<p>Graphs can be customized individually by specifying CGI arguments, or they
can be customized overall by specifying values in the configuration files.
Some parameters apply to each page, others apply to each service, and others
apply to each data source.</p>
<p>The following CGI arguments are recognized by show.cgi, showhost.cgi,
showservice.cgi, and showgroup.cgi:</p>
<dl>
<dt><strong><a name="hidengtitle" class="item">hidengtitle</a></strong></dt>
<dd>
<p>Do not display the nagiosgraph title in the page.</p>
</dd>
<dt><strong><a name="geom_wxh" class="item">geom=WxH</a></strong></dt>
<dd>
<p>Set the dimensions of all graphs to W pixels wide and H pixels tall.</p>
</dd>
<dt><strong><a name="showtitle" class="item">showtitle</a></strong></dt>
<dd>
<p>Display a title next to each graph.</p>
</dd>
<dt><strong><a name="showdesc" class="item">showdesc</a></strong></dt>
<dd>
<p>Display a description of data sources next to each graph.</p>
</dd>
<dt><strong><a name="showgraphtitle" class="item">showgraphtitle</a></strong></dt>
<dd>
<p>Display a title in each graph.</p>
</dd>
<dt><strong><a name="graphonly" class="item">graphonly</a></strong></dt>
<dd>
<p>Display only graph data, not axes, grid, or legend.</p>
</dd>
<dt><strong><a name="hidelegend" class="item">hidelegend</a></strong></dt>
<dd>
<p>Do not display the legend in each graph.</p>
</dd>
<dt><strong><a name="fixedscale" class="item">fixedscale</a></strong></dt>
<dd>
<p>Set the Y-axis to be in the same scale as the performance data. This is useful
to prevent a variety of vertical scales when autoscaling results in different
vertical scaling for each graph.</p>
</dd>
</dl>
<p>The following options are available via configuration files:</p>
<dl>
<dt><strong><a name="rrdopts" class="item">rrdopts</a></strong></dt>
<dd>
<p>Use the rrdopts option to specify custom RRD graphing options. These can be
specified for all graphs using rrdopts, or per-service using the rrdoptsfile.</p>
</dd>
<dt><strong><a name="lineformat" class="item">lineformat</a></strong></dt>
<dd>
<p>Use lineformat to control the line thickness and line color for individual data
sources. The alpha channel is respected if a recent version of rrdtool is
installed.</p>
</dd>
<dt><strong><a name="plotas_plotasline1_plotasline2_plotasline3_plotasarea_plotastick" class="item">plotas, plotasLINE1, plotasLINE2, plotasLINE3, plotasAREA, plotasTICK</a></strong></dt>
<dd>
<p>Use plotas to control the line thickness/style for individual data sources.</p>
</dd>
<dt><strong><a name="stack" class="item">stack</a></strong></dt>
<dd>
<p>Create stacked area graphs using the stack directive for individual data
sources, the STACK directive in lineformat, or by adjusting the alpha
channel in specified colors.</p>
</dd>
</dl>
<p>Some services emit multiple data sources with big differences in magnitude.
Others emit data with different units. In such cases, split the data
into seperate graphs by specifying one or more data sources. For example,
for the NTP service, jitter and offset are typically in the same range,
while stratum is orders of magnitude larger. So we specify two
different graphs:</p>
<pre>
show.cgi?host=HOST&service=NTP&db=ntp,jitter&db=ntp,offset
show.cgi?host=HOST&service=NTP&db=ntp,stratum</pre>
<p>This assumes that jitter, offset, and stratum are all stored in a
single RRD file using a map entry such as:</p>
<pre>
/output:NTP.*Offset ([-.0-9]+).*jitter ([-.0-9]+).*stratum (\d+)/
and push @s, [ 'ntp',
[ 'offset', GAUGE, $1 ],
[ 'jitter', GAUGE, $2/1000 ],
[ 'stratum', GAUGE, $3+1 ] ];</pre>
<p>Data are identified by host, service, database, and data source. It is
possible to graph all sources from a single database, a single source
from a database, selected sources from a single database, or selected
sources from multiple databases. In each case, the host and service
must match. For example:</p>
<pre>
showgraph.cgi?host=HOST&service=SERVICE&db=loss
showgraph.cgi?hsot=HOST&service=SERVICE&db=loss,losspct
showgraph.cgi?host=HOST&service=SERVICE&db=ntp,jitter,offset
showgraph.cgi?host=HOST&service=SERVICE&db=loss,losspct&db=rta,rta</pre>
<p>These options apply to showgraph.cgi, show.cgi, and showservice.cgi and
in the configuration files hostdb.conf, groupdb.conf, and datasetdb.conf.</p>
<p>Use URLs as canned queries. For example, define a 'temperatures'
group in the groupdb.conf file that combines temperature data from
multiple hosts and service types, then create a link to that group:</p>
<pre>
<a href="http://server/cgi-bin/showgroup.cgi?group=temperatures">http://server/cgi-bin/showgroup.cgi?group=temperatures</a></pre>
<p>See the configuration files for more options and examples.</p>
<p>
</p>
<hr />
<h1><a name="adding_service_types">Adding Service Types</a></h1>
<p>Service types are added by creating rules in the 'map' file. The map file
determines how data from Nagios will be stored. Each rule determines how
output and performance data should be recorded.</p>
<p>The map file contains regular expressions to identify service types
and define content in RRD files. All entries are written in perl, so
editing, adding or deleting entries requires some perl programming
knowledge. Knowledge of RRD is also helpful.</p>
<p>There has to be one entry for each type of service. The map file included
with nagiosgraph has several examples for cpu, memory, disk, network etc.
Most examples identify data from either Nagios output or Nagios perfdata
then define a number of RRD data sources. There is also a generic rule
that will capture output from any plugin that adheres to the Nagios standards
for plugin performance data.</p>
<p>insert.pl receives data from Nagios. It formats data into a string consisting
of four lines of text. This string might look like this:</p>
<pre>
hostname:host0
servicedesc:ping
output:PING OK - Packet loss = 0%, RTA = 0.00 ms
perfdata:</pre>
<p>Or like this:</p>
<pre>
hostname:host0
servicedesc:CPU Load
output:OK - load average: 0.06, 0.12, 0.10
perfdata:load1=0;15;30;0 load5=0;10;25;0 load15=0;5;20;0</pre>
<p>The official perfdata format is a space-delimited list of qualified
name-value pairs with this format:</p>
<pre>
name=value[units];[warn];[crit];[min];[max]</pre>
<p>where units is one of:</p>
<pre>
- unitless
s,us,ms - time
% - percentage
B,KB,MB,GB,TB,PB - bytes
c - counter</pre>
<p>However, the perfdata is not always set, and the format of perfdata varies
a great deal from plugin to plugin. So depending on type of service, the
most useful data can be in either the output or perfdata line.</p>
<p>For the ping example above, data can be extracted from the output line
with a regular expression like this:</p>
<pre>
/output:PING.*?(\d+)%.+?([.\d]+)\sms/</pre>
<p>In this case, two values are extracted and available in $1 and $2. We can
then create a data structure describing the content of the database. The
general format is</p>
<pre>
[ db-name,
[ DS-name, TYPE, DS-value ],
[ DS-name, TYPE, DS-value ],
...
]</pre>
<p>Where DS name is the name that will be assigned to a line showing on RRD
graphs. Each DS name must be no longer than 19 characters and must contain
only the characters A-Z, a-z, 0-9, or underscore. TYPE is either GAUGE or
DERIVE. the DS value is the data extracted in the regular expression. The
DS value can be an expression, for example to normalize to SI units.</p>
<p>Each database definition must be added to the @s array.</p>
<p>So the complete code to define and insert into an RRD file for the
PING example above, becomes:</p>
<pre>
/output:PING.*?(\d+)%.+?([.\d]+)\sms/
and push @s, [ ping,
[ losspct, GAUGE, $1 ],
[ rta, GAUGE, $2/1000 ] ];</pre>
<p>In this case the database name is called 'ping' and the DS-names stored
are losspct and rta. The Nagios output reports round trip time in
milliseconds, so the value is divided by 1000 to convert to seconds.
The type for each DS is GAUGE.</p>
<p>Be careful about the database names and DS names. In the code example
above the names are barewords, which only works as long as the don't
conflict with perl functions or subroutines. For example the word 'sleep'
will not work without quoting.</p>
<p>A safer version of the above example is</p>
<pre>
/output:PING.*?(\d+)%.+?([.\d]+)\sms/
and push @s, [ 'ping',
[ 'losspct', 'GAUGE', $1 ],
[ 'rta', 'GAUGE', $2/1000 ] ];</pre>
<p>After editing the map file, the syntax can be checked with</p>
<pre>
perl -c map</pre>
<p>Again a word of caution. If the map file has syntax errors, nothing will be
inserted into RRD files until the file is fixed. So do not edit production
map files. Instead do something like this:</p>
<pre>
cp map map.edit
vi map.edit
perl -c map.edit
mv map.edit map</pre>
<p>Use testentry.pl to test a rule before putting it into production. First run
the Nagios check command from the command line to see what is returned. Copy
this output and paste it into testentry.pl. Paste the rule into testentry.pl.
Run testentry.pl to see how the output will be handled.</p>
<p>Changes to the map file generally do not require a restart of Nagios.</p>
<p>It may take awhile for data from a map entry to show up in an RRD file.
This is partly due to the service check scheduling in Nagios, and partly
due to the perfdata buffering of service_perfdata_file_processing_interval</p>
<p>Increase debug level in nagiosgraph.conf to see what is happening.
The debug_insert parameter determines the log level for collecting data.
Output will go to the nagiosgraph log file. Keep an eye on the log file;
it can grow big. Perhaps rotate it, or decrease log level when everything
works.</p>
<p>Share your work. If you have a good map file entry for standard Nagios
plugins, then please post it on the forum.</p>
<p>
</p>
<hr />
<h1><a name="managing_data_and_rrd_files">Managing Data and RRD Files</a></h1>
<p>nagiosgraph saves data in RRD files in the rrddir directory (specified in
nagiosgraph.conf). By default, nagiosgraph uses a directory for each host,
and the RRD files are named based on the service description (from Nagios)
and the data names (from the map file). For example, the default
configuration for the PING service results in RRD files like this:</p>
<pre>
/var/nagiosgraph/rrd/host/PING___pingloss.rrd
/var/nagiosgraph/rrd/host/PING___pingrta.rrd</pre>
<p>Older versions of nagiosgraph kept all RRD files in a single directory.
This is controlled by the dbseparator variable in nagiosgraph.conf.</p>
<p>Use the 'dump' and 'restore' options to rrdtool if you need to restructure
RRD files. You might want to split data from a single RRD file into
multiple files, or you might want to combine data from multiple RRD files
into a single file. Or you might simply want to change the name of a
data source. The dump option will emit data in XML format:</p>
<pre>
rrdtool dump service___db.rrd > service_db.xml</pre>
<p>You can modify the XML with any text editor, then convert to RRD format:</p>
<pre>
rrdtool restore service_db.xml service___db-new.rrd</pre>
<p>Unfortunately the RRD file schema is not dynamic. If an RRD file is created
with 2 data sources, more data sources cannot be added automatically. For
example, you start recording UPS temperature to an RRD file using the
following map rule:</p>
<pre>
/perfdata:temperature=([.\d]+)/
and push @s, [ 'temp',
[ 'temperature', GAUGE, $1 ] ];</pre>
<p>Later you decide to include critical and warning temperatures using this
map rule:</p>
<pre>
/perfdata:temperature=([.\d]+);([.\d]+);([.\d]+)/
and push @s, [ 'temp',
[ 'temperature', GAUGE, $1 ],
[ 'warn', GAUGE, $2 ],
[ 'crit', GAUGE, $3 ] ];</pre>
<p>The new rule will still record temperature, but critical and warning values
will be discarded, because they are not defined in the RRD file. You must do
a dump/edit/restore on the RRD file if you want to add critical/warning while
maintaining existing temperature data. Alternatively you can simply delete
the existing RRD file and let the new map rule create the new RRD file.</p>
<p>What is the 'right' way to configure RRD files? Should all data from a single
service go into a single RRD file? Should each RRD file contain a single set
of data? Some best practices have evolved over the past 10 years, but as of
this writing (febrary 2010) there is no single 'right' way.</p>
<p>Some people prefer to put all data from a single service into a single RRD
file, even if the data have different units. For example, for the PING
service their RRD files look something like this:</p>
<pre>
PING___ping.rrd (losspct, losswarn, losscrit, rta, rtawarn, rtacrit)</pre>
<p>Others prefer a separate file for each data source:</p>
<pre>
PING___losspct.rrd (losspct)
PING___losswarn.rrd (losswarn)
PING___losscrit.rrd (losscrit)
PING___rta.rrd (rta)
PING___rtawarn.rrd (rtawarn)
PING___rtacrit.rrd (rtacrit)</pre>
<p>And others prefer something in between:</p>
<pre>
PING___loss.rrd (losspct, losswarn, losscrit)
PING___rta.rrd (rta, rtawarn, rtacrit)</pre>
<p>It is a good idea to plan your configuration before you start recording data.
Although it is possible to reconfigure data after the RRD files are full,
doing so is somewhat tedious, especially for large numbers of hosts/services.</p>
<p>The 1.4.4 release of nagiosgraph added a generic map rule that matches any
standard performance data. This rule puts the data into RRD files using this
structure:</p>
<pre>