This repository has been archived by the owner on Nov 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
README
119 lines (74 loc) · 4.58 KB
/
README
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
This repository has moved to https://github.com/andrew-pickin/nagios2influx
nagios2influx takes Nagios performance data and writes it directly into InfluxDB's time sequence database in order that this data might be presented, for example using Grafana.
The motivation for this plugin came when I failed to to get other projects, based that were around the carbon/graphite interface, to work. I had no need for Graphite and thought there should be a simpler and more straight forward solution. I had previously used the nagiosgraph plugin (indeed still do) to display graphic historic data from Nagios. However I wanted to get the performance data into other dashboards where data is gathered from other sources, while still alowing me to use legecy systems of graphing. Further, I didn't want to create a separate service that could fail, I wanted something that would use Nagios's internal scheduler to operate.
Installation
============
Install nagios, influxdb and grafana.
The make file is capable of building RPM and Debian like packages, using
# make rpm
or
# make deb
as appropriate. (Note for the debian version you need to be root or sudo)
If you wish to install by hand here is the RPM manifest.
-rw-rw---- 1 nagios nagios /etc/nagios/nagios2influx.cfg
-rwxr-xr-x 1 root root /usr/bin/nagios-perf
-rwxr-xr-x 1 root root /usr/bin/nagios2influx
-rw-r--r-- 1 root root /usr/share/man/man1/nagios2influx.1.gz
-rw-r--r-- 1 root root /usr/share/man/man5/nagios2influx.cfg.5.gz
# sudo make install
Will install these files.
You can install the files anywhere you wish, but you will need to adjust configuration accordingly. YMMV.
Nagios Configuration
====================
Ensure that you have service checks producing performace data in the standard format.
Ensure that these service have process_perf_data=1
In nagios.cfg:
--------------
process_performance_data=1 # to enable processing
service_perfdata_command=process-service-perfdata # standard command to produce performance data
service_perfdata_file_processing_interval=120 # or adjust for you local setup
service_perfdata_file_processing_command=process-service-perfdata-file # Call nagios2influx on the datafile
In commands.cfg:
----------------
1. Confirm the defauls definition for process-service-perfdata
# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /var/nagios/service-perfdata.out
}
2. Add the definition for process-service-perfdata-file
define command{
command_name process-service-perfdata-file
command_line /usr/local/bin/nagios-perf > /tmp/nagios-perf 2>&1
}
Note: in this last step nagios-perf can be replaced by a direct call to nagios2influx, but calling the wrapper script means that changes can be made while adjusting the configuration without requiring to restart nagios, and aids debugging.
The above configuration will write a performace datafile into the location, and of the format expected by the default nagios2influx.cfg configuration. If you wish to change the location or format of this file then see the nagios2influx man pages on how change the configuration.
It is recommended that once you have grafana dashboards presenting data for each host, to add action_url properties to your host templates of the form:
action_url http://<grafana-server>:<grafana-port>/dashboard/db/$HOSTNAME$
Integration with nagiosgraph
============================
Install nagiosgraph as per standard instructions.
This results in:
nagios.cfg:
service_perfdata_file=/var/spool/nagios/perfdata.log
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$
command.cfg:
define command {
command_name process-service-perfdata-for-nagiosgraph
command_line /usr/libexec/nagiosgraph/insert.pl
}
In order for nagios2influx to process this file before insert.pl, make the following changes.
command.cfg:
define command {
command_name process-service-perfdata-for-nagiosgraph
command_line /usr/bin/nagios-perf > /tmp/nagios-perf 2>&1
}
nagios-perf:
#! /bin/bash
/usr/bin/nagios2influx -n
/usr/libexec/nagiosgraph/insert.pl
Note the -n option to nagios2influx
nagios2influx.cfg: change the following
perfdata=/var/spool/nagios/perfdata.log
perfdelimiter=\|\|
perfformat=time||tag=hostname||label||void||data