Установка Nagiosgraph в Unix/Linux

Установка Nagiosgraph в Unix/Linux

nagiosgraph — это утилита которая анализирует выходные и производительные данных из плагинов Nagios и хранит данные в RRD файлах. nagiosgraph создает диаграммы и генерирует HTML-страницы. И в своей статье «Установка Nagiosgraph в Unix/Linux» я расскажу как установить Nagiosgraph в Unix/Linux

Процесс установки и готовый скрипт приведен в статье:

Установка Nagios с nginx в CentOS

Установка Nagiosgraph в Unix/Linux

Можно установить данной ПО несколькими способами.

Для начала, устанавливаем все необходимые для работы библиотеки:

# yum install perl-GD php-gd rrdtool-perl rrdtool-php rrdtool perl-CGI perl-Time-HiRes perl-Nagios-Plugin perl-CPAN -y

И еще вот эти:

# cpan Nagios::Config -y && perl -MCPAN -e 'install Nagios::Config'  && perl -MCPAN -e 'install Module::Build'

Затем, переходим в нужный каталог и скачиваем nagiosgraph (на момент написание статьи — самая последняя версия данной утилиты),  так же, я распакую архив:

# cd /usr/local/src && wget http://jaist.dl.sourceforge.net/project/nagiosgraph/nagiosgraph/1.5.2/nagiosgraph-1.5.2.tar.gz && gunzip nagiosgraph-* && tar xvf nagiosgraph-*

Удалим ненужное:

# rm -f /usr/local/src/nagiosgraph-*.tar

1. Полу-автоматическом режиме.

Переходим в каталог и проверяем что все с конфигурацией нормально:

# cd nagiosgraph-* && ./install.pl --check-prereq

Вывод:

[root@localhost src]# cd /usr/local/src/nagiosgraph-* && ./install.pl --check-prereq
checking required PERL modules
  Carp...1.11
  CGI...3.51
  Data::Dumper...2.124
  Digest::MD5...2.39
  File::Basename...2.77
  File::Find...1.14
  MIME::Base64...3.08
  POSIX...1.17
  RRDs...1.3008
  Time::HiRes...1.9721
checking optional PERL modules
  GD...2.44
  Nagios::Config...36
checking nagios installation
  found nagios exectuable at /usr/local/nagios/bin/nagios
  found nagios init script at /etc/init.d/nagios
checking web server installation
  found apache executable at /usr/sbin/httpd
  found apache init script at /etc/init.d/httpd
[root@localhost nagiosgraph-1.5.2]#

И выполняем установку:

# ./install.pl --layout overlay --install

Вывод:

[root@localhost nagiosgraph-1.5.2]# cd /usr/local/src/nagiosgraph-* && ./install.pl --layout overlay --install
checking required PERL modules
  Carp...1.11
  CGI...3.51
  Data::Dumper...2.124
  Digest::MD5...2.39
  File::Basename...2.77
  File::Find...1.14
  MIME::Base64...3.08
  POSIX...1.17
  RRDs...1.3008
  Time::HiRes...1.9721
checking optional PERL modules
  GD...2.44
  Nagios::Config...36
checking nagios installation
  found nagios exectuable at /usr/local/nagios/bin/nagios
  found nagios init script at /etc/init.d/nagios
checking web server installation
  found apache executable at /usr/sbin/httpd
  found apache init script at /etc/init.d/httpd
Destination directory (prefix)? [/usr/local/nagiosgraph] /usr/local/nagios
Location of configuration files (etc-dir)? [/usr/local/nagios/etc/nagiosgraph] 
Location of executables? [/usr/local/nagios/libexec] 
Location of CGI scripts? [/usr/local/nagios/sbin] 
Location of documentation (doc-dir)? [/usr/local/nagios/docs/nagiosgraph] 
Location of examples? [/usr/local/nagios/docs/nagiosgraph/examples] 
Location of CSS and JavaScript files? [/usr/local/nagios/share] 
Location of utilities? [/usr/local/nagios/docs/nagiosgraph/util] 
Location of state files (var-dir)? [/var/nagios] 
Location of RRD files? [/var/nagios/rrd] 
Location of log files (log-dir)? [/var/nagios] 
Path of log file? [/var/nagios/nagiosgraph.log] 
Path of CGI log file? [/var/nagios/nagiosgraph-cgi.log] 
Base URL? [/nagios] 
URL of CGI scripts? [/nagios/cgi-bin] 
URL of CSS file? [/nagios/nagiosgraph.css] 
URL of JavaScript file? [/nagios/nagiosgraph.js] 
URL of Nagios CGI scripts? [/nagios/cgi-bin] 
Path of Nagios performance data file? [/tmp/perfdata.log] 
username or userid of Nagios user? [nagios] 
username or userid of web server user? [apache] nginx
Modify the Nagios configuration? [n] n
Modify the Apache configuration? [n] n
configuration:
  ng_prefix            /usr/local/nagios
  ng_etc_dir           /usr/local/nagios/etc/nagiosgraph
  ng_bin_dir           /usr/local/nagios/libexec
  ng_cgi_dir           /usr/local/nagios/sbin
  ng_doc_dir           /usr/local/nagios/docs/nagiosgraph
  ng_examples_dir      /usr/local/nagios/docs/nagiosgraph/examples
  ng_www_dir           /usr/local/nagios/share
  ng_util_dir          /usr/local/nagios/docs/nagiosgraph/util
  ng_var_dir           /var/nagios
  ng_rrd_dir           /var/nagios/rrd
  ng_log_dir           /var/nagios
  ng_log_file          /var/nagios/nagiosgraph.log
  ng_cgilog_file       /var/nagios/nagiosgraph-cgi.log
  ng_url               /nagios
  ng_cgi_url           /nagios/cgi-bin
  ng_css_url           /nagios/nagiosgraph.css
  ng_js_url            /nagios/nagiosgraph.js
  nagios_cgi_url       /nagios/cgi-bin
  nagios_perfdata_file /tmp/perfdata.log
  nagios_user          nagios
  www_user             nginx
  modify_nagios_config n
  nagios_config_file   
  nagios_commands_file 
  modify_apache_config n
  apache_config_dir    
  apache_config_file   
Continue with this configuration? [y] y
mkdir /usr/local/nagios
mkdir /usr/local/nagios/etc/nagiosgraph
copy etc/labels.conf to /usr/local/nagios/etc/nagiosgraph/labels.conf
copy etc/access.conf to /usr/local/nagios/etc/nagiosgraph/access.conf
copy etc/datasetdb.conf to /usr/local/nagios/etc/nagiosgraph/datasetdb.conf
copy etc/nagiosgraph.conf to /usr/local/nagios/etc/nagiosgraph/nagiosgraph.conf
copy etc/hostdb.conf to /usr/local/nagios/etc/nagiosgraph/hostdb.conf
copy etc/servdb.conf to /usr/local/nagios/etc/nagiosgraph/servdb.conf
copy etc/groupdb.conf to /usr/local/nagios/etc/nagiosgraph/groupdb.conf
copy etc/nagiosgraph_es.conf to /usr/local/nagios/etc/nagiosgraph/nagiosgraph_es.conf
copy etc/rrdopts.conf to /usr/local/nagios/etc/nagiosgraph/rrdopts.conf
copy etc/nagiosgraph_fr.conf to /usr/local/nagios/etc/nagiosgraph/nagiosgraph_fr.conf
copy etc/nagiosgraph_de.conf to /usr/local/nagios/etc/nagiosgraph/nagiosgraph_de.conf
copy etc/map to /usr/local/nagios/etc/nagiosgraph/map
copy etc/ngshared.pm to /usr/local/nagios/etc/nagiosgraph
replace text in /usr/local/nagios/etc/nagiosgraph/nagiosgraph.conf
move /usr/local/nagios/etc/nagiosgraph/nagiosgraph.conf-bak to /usr/local/nagios/etc/nagiosgraph/nagiosgraph.conf
write stub to /usr/local/nagios/etc/nagiosgraph/nagiosgraph-nagios.cfg
write stub to /usr/local/nagios/etc/nagiosgraph/nagiosgraph-commands.cfg
write stub to /usr/local/nagios/etc/nagiosgraph/nagiosgraph-apache.conf
mkdir /usr/local/nagios/sbin
copy cgi/showhost.cgi to /usr/local/nagios/sbin
replace text in /usr/local/nagios/sbin/showhost.cgi
move /usr/local/nagios/sbin/showhost.cgi-bak to /usr/local/nagios/sbin/showhost.cgi
chmod 755 on /usr/local/nagios/sbin/showhost.cgi
copy cgi/testcolor.cgi to /usr/local/nagios/sbin
replace text in /usr/local/nagios/sbin/testcolor.cgi
move /usr/local/nagios/sbin/testcolor.cgi-bak to /usr/local/nagios/sbin/testcolor.cgi
chmod 755 on /usr/local/nagios/sbin/testcolor.cgi
copy cgi/showservice.cgi to /usr/local/nagios/sbin
replace text in /usr/local/nagios/sbin/showservice.cgi
move /usr/local/nagios/sbin/showservice.cgi-bak to /usr/local/nagios/sbin/showservice.cgi
chmod 755 on /usr/local/nagios/sbin/showservice.cgi
copy cgi/showgraph.cgi to /usr/local/nagios/sbin
replace text in /usr/local/nagios/sbin/showgraph.cgi
move /usr/local/nagios/sbin/showgraph.cgi-bak to /usr/local/nagios/sbin/showgraph.cgi
chmod 755 on /usr/local/nagios/sbin/showgraph.cgi
copy cgi/show.cgi to /usr/local/nagios/sbin
replace text in /usr/local/nagios/sbin/show.cgi
move /usr/local/nagios/sbin/show.cgi-bak to /usr/local/nagios/sbin/show.cgi
chmod 755 on /usr/local/nagios/sbin/show.cgi
copy cgi/showgroup.cgi to /usr/local/nagios/sbin
replace text in /usr/local/nagios/sbin/showgroup.cgi
move /usr/local/nagios/sbin/showgroup.cgi-bak to /usr/local/nagios/sbin/showgroup.cgi
chmod 755 on /usr/local/nagios/sbin/showgroup.cgi
copy cgi/showconfig.cgi to /usr/local/nagios/sbin
replace text in /usr/local/nagios/sbin/showconfig.cgi
move /usr/local/nagios/sbin/showconfig.cgi-bak to /usr/local/nagios/sbin/showconfig.cgi
chmod 755 on /usr/local/nagios/sbin/showconfig.cgi
copy cgi/export.cgi to /usr/local/nagios/sbin
replace text in /usr/local/nagios/sbin/export.cgi
move /usr/local/nagios/sbin/export.cgi-bak to /usr/local/nagios/sbin/export.cgi
chmod 755 on /usr/local/nagios/sbin/export.cgi
mkdir /usr/local/nagios/libexec
copy lib/insert.pl to /usr/local/nagios/libexec
replace text in /usr/local/nagios/libexec/insert.pl
move /usr/local/nagios/libexec/insert.pl-bak to /usr/local/nagios/libexec/insert.pl
chmod 755 on /usr/local/nagios/libexec/insert.pl
mkdir /usr/local/nagios/share
copy share/nagiosgraph.css to /usr/local/nagios/share/nagiosgraph.css
copy share/nagiosgraph.js to /usr/local/nagios/share
mkdir /usr/local/nagios/docs/nagiosgraph
copy AUTHORS to /usr/local/nagios/docs/nagiosgraph
copy CHANGELOG to /usr/local/nagios/docs/nagiosgraph
copy INSTALL to /usr/local/nagios/docs/nagiosgraph
copy README to /usr/local/nagios/docs/nagiosgraph
copy TODO to /usr/local/nagios/docs/nagiosgraph
mkdir /usr/local/nagios/docs/nagiosgraph/examples
copy examples/nagiosgraph.1.css to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/map_1_3 to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/nagiosgraph-nagios.cfg to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/nagiosgraph-commands.cfg to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/map_1_4_5 to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/map_mwall to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/nagiosgraph-apache.conf to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/nagiosgraph-logrotate to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/map_minimal to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/map_1_4_4 to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/graphed-host.cfg to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/graphed-service.cfg to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/map_1_4_3 to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/nagiosgraph.2.css to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/insert.sh to /usr/local/nagios/docs/nagiosgraph/examples
copy examples/map_examples to /usr/local/nagios/docs/nagiosgraph/examples
copy share/graph.gif to /usr/local/nagios/docs/nagiosgraph/examples
copy share/nagiosgraph.ssi to /usr/local/nagios/docs/nagiosgraph/examples
mkdir /usr/local/nagios/docs/nagiosgraph/util
copy utils/testentry.pl to /usr/local/nagios/docs/nagiosgraph/util
copy utils/flat2hier.pl to /usr/local/nagios/docs/nagiosgraph/util
chmod 755 on /usr/local/nagios/docs/nagiosgraph/util/testentry.pl
chmod 755 on /usr/local/nagios/docs/nagiosgraph/util/flat2hier.pl
mkdir /var/nagios/rrd
chmod 755 on /var/nagios/rrd
chown nagios,- on /var/nagios/rrd
touching /var/nagios/nagiosgraph.log
chmod 644 on /var/nagios/nagiosgraph.log
chown nagios,- on /var/nagios/nagiosgraph.log
touching /var/nagios/nagiosgraph-cgi.log
chmod 644 on /var/nagios/nagiosgraph-cgi.log
chown nginx,- on /var/nagios/nagiosgraph-cgi.log

  To complete the installation, do the following:

  * In the nagios configuration file (nagios.cfg),
    add these lines:

# process nagios performance data using nagiosgraph
process_performance_data=1
service_perfdata_file=/tmp/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-for-nagiosgraph


  * In the nagios commands file (command.cfg),
    add these lines:

# command to process nagios performance data for nagiosgraph
define command {
  command_name process-service-perfdata-for-nagiosgraph
  command_line /usr/local/nagios/libexec/insert.pl
}


  * In the apache configuration file (httpd.conf),
    add this line:

include /usr/local/nagios/etc/nagiosgraph/nagiosgraph-apache.conf

  * Check the nagios configuration:

/usr/local/nagios/bin/nagios -v /path/to/nagios.cfg

  * Restart nagios to start data collection:

/etc/init.d/nagios restart

  * Restart apache to enable display of graphs:

/etc/init.d/httpd restart

  * To enable graph links and mouseovers, see README sections:
       Displaying Per-Service and Per-Host Graph Icons and Links
       Displaying Graphs in Nagios Mouseovers

[root@localhost nagiosgraph-1.5.2]# 

В ходе установки, будут спрашивать что и куда установить.

2. Вручную.

После того как скачали и распаковали архив, все данные нужно раскидать (переместить ) в соответствующие папки. И так, начнем выполнение этого.

# mkdir -p /usr/local/nagios/etc/nagiosgraph

Скопируем конфиг-файлы:

# cp -r /usr/local/src/nagiosgraph-*/etc/* /usr/local/nagios/etc/nagiosgraph

Так же, скопируем остальные файлы:

# cp /usr/local/src/nagiosgraph-*/lib/insert.pl /usr/local/nagios/libexec
# cp /usr/local/src/nagiosgraph-*/cgi/*.cgi /usr/local/nagios/sbin/
# cp /usr/local/src/nagiosgraph-*/share/nagiosgraph.css /usr/local/nagios/share/stylesheets/
# cp /usr/local/src/nagiosgraph-*/share/nagiosgraph.js /usr/local/nagios/share/js
# cp /usr/local/src/nagiosgraph-*/share/nagiosgraph.ssi /usr/local/nagios/share/ssi/common-header.ssi
# mv /usr/local/nagios/share/images/action.gif /usr/local/nagios/share/images/action.gif_origin
# cp -i /usr/local/src/nagiosgraph-*/share/graph.gif /usr/local/nagios/share/images/action.gif
# cp /usr/local/src/nagiosgraph-*/share/nagiosgraph.ssi /usr/local/nagios/share/ssi/common-header.ssi

Отредактируем следующий конфиг-фал:

# vim /usr/local/nagios/etc/nagiosgraph/nagiosgraph.conf

И приводим к такому виду:

[...]
# Location of output from nagiosgraph data processing
logfile = /usr/local/nagios/var/nagiosgraph.log

# Location of output from nagiosgraph CGI scripts
cgilogfile = /usr/local/nagios/var/nagiosgraph-cgi.log

# Location of nagios performance data log file.
perflog = /usr/local/nagios/var/perfdata.log

# Directory in which to store RRD files
rrddir = /usr/local/nagios/var/rrd

# File containing regular expressions to identify service and perf data
mapfile = /usr/local/nagios/etc/nagiosgraph/map

# Nagiosgraph CGI URL.
nagiosgraphcgiurl = /nagios/cgi-bin

# Nagios CGI URL. If the Nagiosgraph CGI scripts are in a directory other
# than the Nagios CGI directory, then specify the Nagios CGI URL here.
#nagioscgiurl = /nagios/cgi-bin

# JavaScript: URL to the nagiosgraph javascript file.
javascript = /js/nagiosgraph.js

# Stylesheet: URL to the nagiosgraph stylesheet.
stylesheet = /stylesheets/nagiosgraph.css
[...]

Выставляем пермишены:

# chown nagios:nagios /usr/local/nagios/etc/nagiosgraph
# chown nagios:nagios /usr/local/nagios/sbin
# chown nagios:nagios /usr/local/nagios/libexec/insert.pl
# chown nagios:nagios /usr/local/nagios/share/stylesheets/nagiosgraph.css /usr/local/nagios/share/js/nagiosgraph.js
# chown nagios:nagios /usr/local/nagios/share/ssi/common-header.ssi

Создаем папку и назначаем права:

# mkdir /usr/local/nagios/var/rrd
# chown nagios:nginx /usr/local/nagios/var/rrd
# chmod 755 /usr/local/nagios/var/rrd

Откроем конфиг от nagios:

# vim  /usr/local/nagios/etc/nagios.cfg

И пропишем (я вставил в самый конец файла):

process_performance_data=1
service_perfdata_file=/usr/local/nagios/var/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-graph

Теперь, открываем:

# vim  /usr/local/nagios/etc/objects/commands.cfg

И пропишем:

define command {
command_name process-service-graph
command_line /usr/local/nagios/libexec/insert.pl
}

Проверяем:

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Создаём файлы, каталоги, назначаем права:

# touch /usr/local/nagios/var/perfdata.log && touch /usr/local/nagios/var/nagiosgraph.log && touch /usr/local/nagios/var/nagiosgraph-cgi.log
# chmod 644 /usr/local/nagios/var/nagiosgraph.log
# chown nagios. /usr/local/nagios/var/nagiosgraph.log 
# chmod 644 /usr/local/nagios/var/nagiosgraph-cgi.log
# chown nginx /usr/local/nagios/var/nagiosgraph-cgi.log

Нужно  заменить путь к библиотекам:

sed -i -e "s/\/opt\/nagiosgraph\/etc/\/usr\/local\/nagios\/etc\/nagiosgraph/g" /usr/local/nagios/sbin/*.cgi
sed -i -e "s/\/opt\/nagiosgraph\/etc/\/usr\/local\/nagios\/etc\/nagiosgraph/g" /usr/local/nagios/libexec/insert.pl
sed -i -e "s/\/nagiosgraph\/nagiosgraph.js/\/js\/nagiosgraph.js/g" /usr/local/nagios/share/ssi/common-header.ssi

Открываем файл:

# vim /usr/local/nagios/etc/objects/templates.cfg

Нужно в этот файл( я вставил в самый конец файла) дописать проверку:

define service {
name graphed-service
action_url show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=week&rrdopts=-w+450+-j
register 0
}

Теперь, открываем ваш хост (для примера взят  /usr/local/nagios/etc/objects/localhost.cfg) и прописываем(добавляем значение graphed-service):

define service{
 use local-service,graphed-service ; Name of service template to use
 host_name localhost
 service_description Swap Usage
 check_command check_local_swap!20!10
 }

PS: Между local-service,graphed-service не должно быть никаких пробелов!

Последние штрихи — открываем файл:

# vim /usr/local/nagios/share/side.php

Добавим ссылки на графики (в любом удобном для вас месте):

<ul>
<li><a href="/nagios/cgi-bin/show.cgi" target="main">Graphs</a></li>
<li><a href="/nagios/cgi-bin/showhost.cgi" target="main">Graphs by Host</a></li>
<li><a href="/nagios/cgi-bin/showservice.cgi" target="main">Graphs by Service</a></li>
<li><a href="/nagios/cgi-bin/showgroup.cgi" target="main">Graphs by Group</a></li>
</ul>

Перезагружаем нагиос:

# service nagios restart

Открываем свой браузер:

 http://YOUR_server_or_IP/nagios/cgi-bin/showconfig.cgi

PS: у меня будет использоваться вот так:

http://YOUR_server_or_IP/nagios/showconfig.cgi

И видим следующее:

showconfig

Ругается что нет лог файлов, но я исправил это в своей статье и не стал переделывать рисунок. Для ленивых, вот готовая установка Nagiosgraph.

# cat Nagiosgraph.sh

Сам скрипт выглядит вот так:

#!/bin/bash

# CREATED:
# vitaliy.natarov@yahoo.com
#
# Unix/Linux blog:
# http://linux-notes.org
# Vitaliy Natarov
#

# Install nagiosgraph
 yum install perl-GD php-gd rrdtool-perl rrdtool-php rrdtool perl-CGI perl-Time-HiRes perl-Nagios-Plugin perl-CPAN -y
 PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install Nagios::Config'
 PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'Module::Build'
 cpan Nagios::Config -y

 cd /usr/local/src && wget http://jaist.dl.sourceforge.net/project/nagiosgraph/nagiosgraph/1.5.2/nagiosgraph-1.5.2.tar.gz && gunzip nagiosgraph-* && tar xvf nagiosgraph-*
 rm -f /usr/local/src/nagiosgraph-*.tar
 cd /usr/local/src/nagiosgraph-* && ./install.pl --check-prereq


 #
mkdir -p /usr/local/nagios/etc/nagiosgraph
cp -r /usr/local/src/nagiosgraph-*/etc/* /usr/local/nagios/etc/nagiosgraph
#
cp /usr/local/src/nagiosgraph-*/lib/insert.pl /usr/local/nagios/libexec
cp /usr/local/src/nagiosgraph-*/cgi/*.cgi /usr/local/nagios/sbin/
cp /usr/local/src/nagiosgraph-*/share/nagiosgraph.css /usr/local/nagios/share/stylesheets/
cp /usr/local/src/nagiosgraph-*/share/nagiosgraph.js /usr/local/nagios/share/js
cp /usr/local/src/nagiosgraph-*/share/nagiosgraph.ssi /usr/local/nagios/share/ssi/common-header.ssi
mv /usr/local/nagios/share/images/action.gif /usr/local/nagios/share/images/action.gif_origin
cp -i /usr/local/src/nagiosgraph-*/share/graph.gif /usr/local/nagios/share/images/action.gif
cp /usr/local/src/nagiosgraph-*/share/nagiosgraph.ssi /usr/local/nagios/share/ssi/common-header.ssi
#
# Download nagiosgraph config
mv /usr/local/nagios/etc/nagiosgraph/nagiosgraph.conf /usr/local/nagios/etc/nagiosgraph/nagiosgraph.conf_origin 
wget 2>/dev/null http://linux-notes.org/wp-content/uploads/scripts/nagios/nagiosgraph/nagiosgraph.conf -v -O /usr/local/nagios/etc/nagiosgraph/nagiosgraph.conf
#
touch /usr/local/nagios/var/perfdata.log && touch /usr/local/nagios/var/nagiosgraph.log && touch /usr/local/nagios/var/nagiosgraph-cgi.log
chmod 644 /usr/local/nagios/var/nagiosgraph.log
chown nagios. /usr/local/nagios/var/nagiosgraph.log 
chmod 644 /usr/local/nagios/var/nagiosgraph-cgi.log
chown nginx /usr/local/nagios/var/nagiosgraph-cgi.log

mkdir /usr/local/nagios/var/rrd
chown nagios:nginx /usr/local/nagios/var/rrd
chmod 755 /usr/local/nagios/var/rrd && chmod -R 755 /usr/local/nagios/
#
# Copy objects
wget 2>/dev/null http://linux-notes.org/wp-content/uploads/scripts/nagios/etc/objects/commands.cfg -v -O /usr/local/nagios/etc/objects/commands.cfg
wget 2>/dev/null http://linux-notes.org/wp-content/uploads/scripts/nagios/etc/objects/templates.cfg -v -O /usr/local/nagios/etc/objects/templates.cfg
wget 2>/dev/null http://linux-notes.org/wp-content/uploads/scripts/nagios/etc/objects/localhost.cfg -v -O /usr/local/nagios/etc/objects/localhost.cfg
# Copy side.php
mv /usr/local/nagios/share/side.php /usr/local/nagios/share/side.php_origin
wget 2>/dev/null http://linux-notes.org/wp-content/uploads/scripts/nagios/share/side.txt -v -O /usr/local/nagios/share/side.php
# 
#
sed -i -e "s/\/opt\/nagiosgraph\/etc/\/usr\/local\/nagios\/etc\/nagiosgraph/g" /usr/local/nagios/sbin/*.cgi
sed -i -e "s/\/opt\/nagiosgraph\/etc/\/usr\/local\/nagios\/etc\/nagiosgraph/g" /usr/local/nagios/libexec/insert.pl
sed -i -e "s/\/nagiosgraph\/nagiosgraph.js/\/js\/nagiosgraph.js/g" /usr/local/nagios/share/ssi/common-header.ssi
#
chown -R nagios. /usr/local/nagios
#
perl /usr/local/nagios/libexec/insert.pl

#Start/Restart all services 
service nginx restart
service nagios restart

echo "|---------------------------------------------------|";
echo "|--------------------FINISHED-----------------------|";
echo "|---------------------------------------------------|";

Все готово, но чтобы все корректно работало, необходимо прописать крон:

# crontab -u root -e

Содержание:

# minute  hour mday month day who   command
   *        *    *    *     *  root  /usr/bin/perl /usr/local/nagios/libexec/insert.pl

Вот и все, можете использовать. А на этом, я завершаю свою статью «Установка Nagiosgraph в Unix/Linux».

One thought on “Установка Nagiosgraph в Unix/Linux

  1. Здравствуйте!
    При попытке установки rrdtool-php получаю две ошибки при проверке зависимостей:
    «Ошибка: Пакет: rrdtool-php-1.4.8-9.el7.x86_64 (base)
    Необходимо: php(api) = 20100412-64
    Установлено: php-common-7.3.23-1.el7.remi.x86_64 (@remi-php73)
    php(api) = 20180731-64
    Доступно: php-common-5.4.16-48.el7.x86_64 (base)
    php(api) = 20100412-64
    Ошибка: Пакет: rrdtool-php-1.4.8-9.el7.x86_64 (base)
    Необходимо: php(zend-abi) = 20100525-64
    Установлено: php-common-7.3.23-1.el7.remi.x86_64 (@remi-php73)
    php(zend-abi) = 20180731-64
    Доступно: php-common-5.4.16-48.el7.x86_64 (base)
    php(zend-abi) = 20100525-64»

    Т.е. получается, что мне нужен более старый пакет php?..

Добавить комментарий

Ваш адрес email не будет опубликован.

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.