Добро пожаловать! Это — архивная версия форумов на «Хакер.Ru». Она работает в режиме read-only.
 

Добавлением плагина для пинга нескольких хостов в приложение для мониторинга серверов munin

Пользователи, просматривающие топик: none

Зашли как: Guest
Все форумы >> [Веб-программинг] >> Добавлением плагина для пинга нескольких хостов в приложение для мониторинга серверов munin
Имя
Сообщение << Старые топики   Новые топики >>
Добавлением плагина для пинга нескольких хостов в приложение для мониторинга серверов munin - 2009-01-29 01:56:14.646666   
Rаlf

Сообщений: 408
Оценки: 0
Присоединился: 2008-01-31 23:20:28.036666
Проблема возникла с добавлением плагина multi_tcp_ping в munin.

линки:
информация о плагине - http://muninexchange.projects.linpro.no/?search=&cid=10&os&#…
исходный код плагина - http://muninexchange.projects.linpro.no/?view&phid=352

Поместил файл multi_tcp_ping в каталог /usr/share/munin/plugins
установил на него права chmod 755 как на других файлах плагинов в этом каталоге
добавил ссылку ln -s /usr/share/munin/plugins/multi_tcp_ping /etc/munin/plugins/multi_tcp_ping
в /etc/munin/plugin-conf.d/munin-node добавил:
quote:

[multi_tcp_ping]
user root

перезапустил munin-node выполнив /etc/init.d/munin-node restart

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


# This plugin is meant to be called from Munin. You should set the
# 'hosts' environment variable from Munin's configuration (i.e.
# /etc/munin/munin.conf) to specify which hosts and ports to query.

# Comma-separated list of hosts to query. You can specify the TCP port
# to connect to on each of the hosts by listing them as host:port - The
# port defaults to 80. The following is a valid hosts declaration:

# hosts='192.168.0.15, 192.168.0.18:22'

# It will query host 192.168.0.15 on the default port (80), as well as
# host 192.168.0.18 on port 22.

как бы вроде четко написано, что хосты задаются прописыванием строки:

hosts='10.235.155.1, 10.235.154.1, 10.235.153.1' в файле /etc/munin/munin.conf

так и зделал, затем снова перезапустил munin-node выполнив /etc/init.d/munin-node restart но графиков от multi_tcp_ping не появилось.

мой cat /etc/munin/munin.conf | grep -v "#"
dbdir /var/lib/munin htmldir /var/www/munin logdir /var/log/munin rundir /var/run/munin tmpldir /etc/munin/templates [localhost.ipcom] address 127.0.0.1 use_node_name yes hosts='10.235.155.1, 10.235.154.1, 10.235.153.1'
покопавшись в логах, в /var/log/munin/munin-node.log обнаружил:

quote:

2009/01/28-23:50:14 Plugin "multi_tcp_ping" exited with status 65280. —-
2009/01/28-23:51:35 Server closing!

Process Backgrounded
2009/01/28-23:51:35 MyPackage (type Net::Server::Fork) starting! pid(464)
Binding to TCP port 4949 on host 127.0.0.1
Hosts not set - cannot continue


Предполагаю, что проблема в том, что я не коректно задал хосты, которые необходимо пингать, и он говорит "Hosts not set - cannot continue" аля нет хостов которые нужно пингать…
Где ошибся?

ЗЫ: ув. модераторы, надюсь текушее название темы Вас устроит (:
Post #: 1
RE: Добавлением плагина для пинга нескольких хостов в приложение для мониторинга серверов munin - 2009-01-31 00:55:25.333333   
Rаlf

Сообщений: 408
Оценки: 0
Присоединился: 2008-01-31 23:20:28.036666
Проблему решил благодаря переменным окружения, так как хосты необходимо прописывать именно через них.
для этого в терминали достаточно прописать:
export hosts='192.168.1.2, 192.168.1.3'
Post #: 2
RE: Добавлением плагина для пинга нескольких хостов в приложение для мониторинга серверов munin - 2009-02-22 23:24:13.056666   
Rаlf

Сообщений: 408
Оценки: 0
Присоединился: 2008-01-31 23:20:28.036666
Встал вопрос в задании переменных окружения с помощью скрипта, так как хостов достаточно много а переменные окружения заданные непосредственно с терминала через 24 часа ищезают.

В каталог /etc/profile.d/ к примеру помеcтил файл host_10_235_155_x содержащий
#!/bin/sh export hosts_10_235_155_x='10.235.155.1, 10.235.155.2, 10.235.155.3, 10.235.155.4, 10.235.155.5, 10.235.155.6, 10.235.155.7, 10.235.155.8, 10.235.155.9, 10.235.155.10, 10.235.155.11, 10.235.155.12, 10.235.155.13, 10.235.155.14, 10.235.155.15, 10.235.155.16, 10.235.155.17, 10.235.155.18, 10.235.155.19, 10.235.155.20, 10.235.155.21, 10.235.155.22, 10.235.155.23, 10.235.155.24, 10.235.155.25, 10.235.155.26, 10.235.155.27, 10.235.155.28, 10.235.155.29, 10.235.155.30, 10.235.155.31, 10.235.155.32, 10.235.155.33, 10.235.155.34, 10.235.155.35, 10.235.155.36, 10.235.155.37, 10.235.155.38, 10.235.155.39, 10.235.155.40, 10.235.155.41, 10.235.155.42, 10.235.155.43, 10.235.155.44, 10.235.155.45, 10.235.155.46, 10.235.155.47, 10.235.155.48, 10.235.155.49, 10.235.155.50, 10.235.155.51, 10.235.155.52, 10.235.155.53, 10.235.155.54, 10.235.155.55, 10.235.155.56, 10.235.155.57, 10.235.155.58, 10.235.155.59, 10.235.155.60, 10.235.155.61, 10.235.155.62, 10.235.155.63, 10.235.155.64, 10.235.155.65, 10.235.155.66, 10.235.155.67, 10.235.155.68, 10.235.155.69, 10.235.155.155, 10.235.155.71, 10.235.155.72, 10.235.155.73, 10.235.155.74, 10.235.155.75, 10.235.155.76, 10.235.155.77, 10.235.155.78, 10.235.155.79, 10.235.155.80, 10.235.155.81, 10.235.155.82, 10.235.155.83, 10.235.155.84, 10.235.155.85, 10.235.155.86, 10.235.155.87, 10.235.155.88, 10.235.155.89, 10.235.155.90, 10.235.155.91, 10.235.155.92, 10.235.155.93, 10.235.155.94, 10.235.155.95, 10.235.155.96, 10.235.155.97, 10.235.155.98, 10.235.155.99, 10.235.155.100, 10.235.155.101, 10.235.155.102, 10.235.155.103, 10.235.155.104, 10.235.155.105, 10.235.155.106, 10.235.155.107, 10.235.155.108, 10.235.155.109, 10.235.155.110, 10.235.155.111, 10.235.155.112, 10.235.155.113, 10.235.155.114, 10.235.155.115, 10.235.155.116, 10.235.155.117, 10.235.155.118, 10.235.155.119, 10.235.155.120, 10.235.155.121, 10.235.155.122, 10.235.155.123, 10.235.155.124, 10.235.155.125, 10.235.155.126, 10.235.155.127, 10.235.155.128, 10.235.155.129, 10.235.155.130, 10.235.155.131, 10.235.155.132, 10.235.155.133, 10.235.155.134, 10.235.155.135, 10.235.155.136, 10.235.155.137, 10.235.155.138, 10.235.155.139, 10.235.155.140, 10.235.155.141, 10.235.155.142, 10.235.155.143, 10.235.155.144, 10.235.155.145, 10.235.155.146, 10.235.155.147, 10.235.155.148, 10.235.155.149, 10.235.155.150, 10.235.155.151, 10.235.155.152, 10.235.155.153, 10.235.155.154, 10.235.155.155, 10.235.155.156, 10.235.155.157, 10.235.155.158, 10.235.155.159, 10.235.155.160, 10.235.155.161, 10.235.155.162, 10.235.155.163, 10.235.155.164, 10.235.155.165, 10.235.155.166, 10.235.155.167, 10.235.155.168, 10.235.155.169, 10.235.155.1155, 10.235.155.171, 10.235.155.172, 10.235.155.173, 10.235.155.174, 10.235.155.175, 10.235.155.176, 10.235.155.177, 10.235.155.178, 10.235.155.179, 10.235.155.180, 10.235.155.181, 10.235.155.182, 10.235.155.183, 10.235.155.184, 10.235.155.185, 10.235.155.186, 10.235.155.187, 10.235.155.188, 10.235.155.189, 10.235.155.190, 10.235.155.191, 10.235.155.192, 10.235.155.193, 10.235.155.194, 10.235.155.195, 10.235.155.196, 10.235.155.197, 10.235.155.198, 10.235.155.199, 10.235.155.200, 10.235.155.201, 10.235.155.202, 10.235.155.203, 10.235.155.204, 10.235.155.205, 10.235.155.206, 10.235.155.207, 10.235.155.208, 10.235.155.209, 10.235.155.210, 10.235.155.211, 10.235.155.212, 10.235.155.213, 10.235.155.214, 10.235.155.215, 10.235.155.216, 10.235.155.217, 10.235.155.218, 10.235.155.219, 10.235.155.220, 10.235.155.221, 10.235.155.222, 10.235.155.223, 10.235.155.224, 10.235.155.225, 10.235.155.226, 10.235.155.227, 10.235.155.228, 10.235.155.229, 10.235.155.230, 10.235.155.231, 10.235.155.232, 10.235.155.233, 10.235.155.234, 10.235.155.235, 10.235.155.236, 10.235.155.237, 10.235.155.238, 10.235.155.239, 10.235.155.240, 10.235.155.241, 10.235.155.242, 10.235.155.243, 10.235.155.244, 10.235.155.245, 10.235.155.246, 10.235.155.247, 10.235.155.248, 10.235.155.249, 10.235.155.250, 10.235.155.251, 10.235.155.252, 10.235.155.253, 10.235.155.254, 10.235.155.255'; После рестарта переменная добавлялась, но с под рута ее не видно, соответственно и munin ее не видит.

Погуглил еще, выяслнил что еще можно прописывать в /etc/enviroment, добавил в этот файл строку hosts_10_235_155_x="10.235.155.1, 10.235.155.2, 10.235.155.3, 10.235.155.4, 10.235.155.5, 10.235.155.6, 10.235.155.7, 10.235.155.8, 10.235.155.9, 10.235.155.10, 10.235.155.11, 10.235.155.12, 10.235.155.13, 10.235.155.14, 10.235.155.15, 10.235.155.16, 10.235.155.17, 10.235.155.18, 10.235.155.19, 10.235.155.20, 10.235.155.21, 10.235.155.22, 10.235.155.23, 10.235.155.24, 10.235.155.25, 10.235.155.26, 10.235.155.27, 10.235.155.28, 10.235.155.29, 10.235.155.30, 10.235.155.31, 10.235.155.32, 10.235.155.33, 10.235.155.34, 10.235.155.35, 10.235.155.36, 10.235.155.37, 10.235.155.38, 10.235.155.39, 10.235.155.40, 10.235.155.41, 10.235.155.42, 10.235.155.43, 10.235.155.44, 10.235.155.45, 10.235.155.46, 10.235.155.47, 10.235.155.48, 10.235.155.49, 10.235.155.50, 10.235.155.51, 10.235.155.52, 10.235.155.53, 10.235.155.54, 10.235.155.55, 10.235.155.56, 10.235.155.57, 10.235.155.58, 10.235.155.59, 10.235.155.60, 10.235.155.61, 10.235.155.62, 10.235.155.63, 10.235.155.64, 10.235.155.65, 10.235.155.66, 10.235.155.67, 10.235.155.68, 10.235.155.69, 10.235.155.155, 10.235.155.71, 10.235.155.72, 10.235.155.73, 10.235.155.74, 10.235.155.75, 10.235.155.76, 10.235.155.77, 10.235.155.78, 10.235.155.79, 10.235.155.80, 10.235.155.81, 10.235.155.82, 10.235.155.83, 10.235.155.84, 10.235.155.85, 10.235.155.86, 10.235.155.87, 10.235.155.88, 10.235.155.89, 10.235.155.90, 10.235.155.91, 10.235.155.92, 10.235.155.93, 10.235.155.94, 10.235.155.95, 10.235.155.96, 10.235.155.97, 10.235.155.98, 10.235.155.99, 10.235.155.100, 10.235.155.101, 10.235.155.102, 10.235.155.103, 10.235.155.104, 10.235.155.105, 10.235.155.106, 10.235.155.107, 10.235.155.108, 10.235.155.109, 10.235.155.110, 10.235.155.111, 10.235.155.112, 10.235.155.113, 10.235.155.114, 10.235.155.115, 10.235.155.116, 10.235.155.117, 10.235.155.118, 10.235.155.119, 10.235.155.120, 10.235.155.121, 10.235.155.122, 10.235.155.123, 10.235.155.124, 10.235.155.125, 10.235.155.126, 10.235.155.127, 10.235.155.128, 10.235.155.129, 10.235.155.130, 10.235.155.131, 10.235.155.132, 10.235.155.133, 10.235.155.134, 10.235.155.135, 10.235.155.136, 10.235.155.137, 10.235.155.138, 10.235.155.139, 10.235.155.140, 10.235.155.141, 10.235.155.142, 10.235.155.143, 10.235.155.144, 10.235.155.145, 10.235.155.146, 10.235.155.147, 10.235.155.148, 10.235.155.149, 10.235.155.150, 10.235.155.151, 10.235.155.152, 10.235.155.153, 10.235.155.154, 10.235.155.155, 10.235.155.156, 10.235.155.157, 10.235.155.158, 10.235.155.159, 10.235.155.160, 10.235.155.161, 10.235.155.162, 10.235.155.163, 10.235.155.164, 10.235.155.165, 10.235.155.166, 10.235.155.167, 10.235.155.168, 10.235.155.169, 10.235.155.1155, 10.235.155.171, 10.235.155.172, 10.235.155.173, 10.235.155.174, 10.235.155.175, 10.235.155.176, 10.235.155.177, 10.235.155.178, 10.235.155.179, 10.235.155.180, 10.235.155.181, 10.235.155.182, 10.235.155.183, 10.235.155.184, 10.235.155.185, 10.235.155.186, 10.235.155.187, 10.235.155.188, 10.235.155.189, 10.235.155.190, 10.235.155.191, 10.235.155.192, 10.235.155.193, 10.235.155.194, 10.235.155.195, 10.235.155.196, 10.235.155.197, 10.235.155.198, 10.235.155.199, 10.235.155.200, 10.235.155.201, 10.235.155.202, 10.235.155.203, 10.235.155.204, 10.235.155.205, 10.235.155.206, 10.235.155.207, 10.235.155.208, 10.235.155.209, 10.235.155.210, 10.235.155.211, 10.235.155.212, 10.235.155.213, 10.235.155.214, 10.235.155.215, 10.235.155.216, 10.235.155.217, 10.235.155.218, 10.235.155.219, 10.235.155.220, 10.235.155.221, 10.235.155.222, 10.235.155.223, 10.235.155.224, 10.235.155.225, 10.235.155.226, 10.235.155.227, 10.235.155.228, 10.235.155.229, 10.235.155.230, 10.235.155.231, 10.235.155.232, 10.235.155.233, 10.235.155.234, 10.235.155.235, 10.235.155.236, 10.235.155.237, 10.235.155.238, 10.235.155.239, 10.235.155.240, 10.235.155.241, 10.235.155.242, 10.235.155.243, 10.235.155.244, 10.235.155.245, 10.235.155.246, 10.235.155.247, 10.235.155.248, 10.235.155.249, 10.235.155.250, 10.235.155.251, 10.235.155.252, 10.235.155.253, 10.235.155.254, 10.235.155.255" но с под рута переменная попрежнему не видна, с под моего моей учетки все зашибись.

Как задать переменную окружения при загрузке системы скриптом так, чтобы она была видна с под рута ?
Post #: 3
RE: Добавлением плагина для пинга нескольких хостов в приложение для мониторинга серверов munin - 2009-03-04 23:58:07.323333   
Rаlf

Сообщений: 408
Оценки: 0
Присоединился: 2008-01-31 23:20:28.036666
Проблему решил изменив источник списка хостов, который изначально брался с переменных окружения.
Теперь хосты берутся с файла hostslist.ip.
root@ralf-office:/# cat /usr/share/munin/plugins/multi_tcp_ping #!/usr/bin/perl =head1 NAME multi_tcp_ping - Graphs together the TCP ping results for several hosts =head1 SYNOPSIS This plugin is meant to be called from Munin. You should set the 'hosts' environment variable from Munin's configuration (i.e. /etc/munin/munin.conf) to specify which hosts and ports to query. =head1 DESCRIPTION This plugin expects to receive the following environment variables: =over 4 =item hosts (REQUIRED!) Comma-separated list of hosts to query. You can specify the TCP port to connect to on each of the hosts by listing them as host:port - The port defaults to 80. The following is a valid hosts declaration: hosts='192.168.0.15, 192.168.0.18:22' It will query host 192.168.0.15 on the default port (80), as well as host 192.168.0.18 on port 22. =back If the connection was opened successfully, it gives as the return value the time it took to establish the connection. If the requested host is not reachable, a hard-wired '-0.01' will be returned. Why -0.01? Because giving a negative value is the best way to easily get -visually- that something failed. Connection establishment times are usually in the 5-500ms range. 100ms will be not too little (and thus invisible), not too much (and thus killing the details in our graphs). =head1 DEPENDS ON L&lt;Net::Ping&gt; =head1 SEE ALSO L&lt;munin&gt;, L&lt;munin-node&gt; =head1 AUTHOR Gunnar Wolf &lt;gwolf@gwolf.org&gt; =head1 COPYRIGHT Copyright 2008 Gunnar Wolf, Instituto de Investigaciones Economicas, UNAM. This plugin is Free Software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 dated June, 1991, or any later version (at your choice). This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. =cut use strict; use warnings; use threads; use Net::Ping; my (%defaults, @hostslist, $cmd_arg,$config_file_name); %defaults = (port =&gt; 80, timeout =&gt; 2, unreachable =&gt; -0.01); $config_file_name = "/usr/share/munin/plugins/hostslist.ip"; open (IN_FILE,"&lt;$config_file_name") or die "Unable to open file hostslist.ip"; while (&lt;IN_FILE&gt;){ if (/\d+\.\d+\.\d+\.\d+/){ s/\s//g; push (@hostslist,[$_,$defaults{port}]); } } #@hostslist = get_hostslist($ENV{hostslist}); die "hostslist not set - cannot continue\n" unless @hostslist; $cmd_arg = $ARGV[0] || ''; config() if($cmd_arg eq "config"); autoconf() if ($cmd_arg eq 'autoconf'); for my $host (@hostslist) { threads-&gt;new(\&ping_host, $host) } map {$_-&gt;join} threads-&gt;list; exit 0; sub ping_host { my ($host, $addr, $p, $ret, $time, $ip); $host = shift; $addr = host_label_for($host); $p=Net::Ping-&gt;new("tcp", $defaults{timeout}); $p-&gt;hires(); $p-&gt;{port_num} = $host-&gt;[1] || $defaults{port}; ($ret, $time, $ip) = $p-&gt;ping($host-&gt;[0]); $time = $defaults{unreachable} if !$ret; print "${addr}.value $time\n"; } sub get_hostslist { # hostslist are defined in the 'hostslist' environment variable. It's a list of # hostslist (and optionally ports) - We parse the list and arrange it neatly # to be easily consumed. my ($hostslistdef, @hostslist); $hostslistdef = shift; return unless $hostslistdef; for my $host (split(/,/, $hostslistdef)) { $host =~ s/\s//g; $host =~ /^(?:([^:]+)) (?::(\d+))?$/x; push @hostslist, [$1, $2 || $defaults{port}]; } return @hostslist; } sub config { my @res = ("graph_title TCP connection times hostlist", "graph_args --base 1000 -l 0", "graph_vlabel seconds", "graph_category network", "graph_info Shows the time to establish a TCP connection"); for my $host (@hostslist) { my $addr = host_label_for($host); push @res, "$addr.label $addr"; push @res, "$addr.draw LINE2"; push @res, "$addr.info Time to establish TCP connection to " . "$host-&gt;[0]:$host-&gt;[1]"; } print map {"$_\n"} @res; exit 0; } sub autoconf { print "yes\n"; exit 0; } sub host_label_for { my ($ip, $port) = @{$_[0]}; # Periods and colonsare not allowed in variable names my $addr = "src_${ip}_${port}"; $addr =~ s/\./_/g; return $addr; }
Post #: 4
Страниц:  [1]
Все форумы >> [Веб-программинг] >> Добавлением плагина для пинга нескольких хостов в приложение для мониторинга серверов munin







Связаться:
Вопросы по сайту / xakep@glc.ru

Предупреждение: использование полученных знаний в противозаконных целях преследуется по закону.