<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Мониторинг сервисов (Apache, MySQL, Nginx, Postfix, Sendmail, ...)]]></title><description><![CDATA[<p dir="auto"><strong>Мониторинг Apache</strong> (требуется модуль mod_status)<br />
в файл httpd.conf добавьте:</p>
<pre><code>ExtendedStatus        On

&lt;Location /server-status&gt;
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from localhost
&lt;/Location&gt;
</code></pre>
<p dir="auto">в файл nxagentd.conf добавьте (вариант для FreeBSD, Apache 1.3):</p>
<pre><code># parameters for monitoring WebServer Apache
ExternalParameter = ApacheAccesses(*):fetch -qo - http://$1/server-status?auto | head -n 9 | grep Accesses | cut -d " " -f 3
ExternalParameter = ApacheTotalKb(*):fetch -qo - http://$1/server-status?auto | head -n 9 | grep kBytes | cut -d " " -f 3
ExternalParameter = ApacheCPULoad(*):fetch -qo - http://$1/server-status?auto | head -n 9 | grep CPULoad | cut -d " " -f 2
ExternalParameter = ApacheUptime(*):fetch -qo - http://$1/server-status?auto | head -n 9 | grep Uptime | cut -d " " -f 2
ExternalParameter = ApacheReqPerSec(*):fetch -qo - http://$1/server-status?auto | head -n 9 | grep ReqPerSec | cut -d " " -f 2
ExternalParameter = ApacheBytesPerSec(*):fetch -qo - http://$1/server-status?auto | head -n 9 | grep BytesPerSec | cut -d " " -f 2
ExternalParameter = ApacheBytesPerReq(*):fetch -qo - http://$1/server-status?auto | head -n 9 | grep BytesPerReq | cut -d " " -f 2
ExternalParameter = ApacheBusyServers(*):fetch -qo - http://$1/server-status?auto | head -n 9 | grep BusyServers | cut -d " " -f 2
ExternalParameter = ApacheIdleServers(*):fetch -qo - http://$1/server-status?auto | head -n 9 | grep IdleServers | cut -d " " -f 2
</code></pre>
<p dir="auto">пример вывода:</p>
<pre><code># fetch -qo - http://localhost/server-status?auto
Total Accesses: 5
Total kBytes: 3
Uptime: 6
ReqPerSec: .833333
BytesPerSec: 512
BytesPerReq: 614.4
BusyServers: 1
IdleServers: 4
Scoreboard: W____...
</code></pre>
<p dir="auto"><em>заметка:<br />
 - в качестве аргумента использется - ip-адрес или hostname, в качестве дополнительного параметра добавьте port<br />
 - для Linux вместо fetch используйте wget, GET (perl-libwww), lynx</em></p>
<p dir="auto">список параметров: ApacheAccesses(*), ApacheTotalKb(*), ApacheCPULoad(*), ApacheUptime(*), ApacheReqPerSec(*), ApacheBytesPerSec(*), ApacheBytesPerReq(*), ApacheBusyServers(*), ApacheIdleServers(*)</p>
<p dir="auto"><strong>Мониторинг Nginx</strong><br />
откройте файл nginx.conf, найдите строчку 'server {' и добавьте ниже код:</p>
<pre><code>                location /nginx_status {
                    stub_status on;
                    access_log   off;
                    allow 127.0.0.254;
                    deny all;
                }
</code></pre>
<p dir="auto">в файл nxagentd.conf добавьте:</p>
<pre><code># parameters for monitoring WebServer Nginx
ExternalParameter = NginxActiveConnections(*):fetch -qo - http://$1:$2/nginx_status | grep "Active connections" | cut -f3 -d" "
ExternalParameter = NginxServerAccepts(*):fetch -qo - http://$1:$2/nginx_status | head -n3 | tail -n1 | cut -f2 -d" "
ExternalParameter = NginxServerHandled(*):fetch -qo - http://$1:$2/nginx_status | head -n3 | tail -n1 | cut -f3 -d" "
ExternalParameter = NginxServerRequests(*):fetch -qo - http://$1:$2/nginx_status | head -n3 | tail -n1 | cut -f4 -d" "
ExternalParameter = NginxServerReading(*):fetch -qo - http://$1:$2/nginx_status | head -n4 | tail -n1 | cut -f2 -d" "
ExternalParameter = NginxServerWriting(*):fetch -qo - http://$1:$2/nginx_status | head -n4 | tail -n1 | cut -f4 -d" "
ExternalParameter = NginxServerWaiting(*):fetch -qo - http://$1:$2/nginx_status | head -n4 | tail -n1 | cut -f6 -d" "
</code></pre>
<p dir="auto">пример вывода:</p>
<pre><code># fetch -qo - http://localhost:85/nginx_status
Active connections: 13
server accepts handled requests
 234 327 236
Reading: 0 Writing: 412 Waiting: 0
</code></pre>
<p dir="auto">список параметров: NginxActiveConnections(*), NginxServerAccepts(*), NginxServerHandled(*), NginxServerRequests(*), NginxServerReading(*), NginxServerWriting(*), NginxServerWaiting(*)</p>
<p dir="auto"><strong>Мониторинг MySQL</strong><br />
в файл nxagentd.conf добавьте:</p>
<pre><code># parameters for monitoring MySQL server
ExternalParameter = MySQL_Ping,mysqladmin -uroot ping|grep alive|wc -l
ExternalParameter = MySQL_Uptime,mysqladmin -uroot status|cut -f2 -d":"|cut -f1 -d"T"
ExternalParameter = MySQL_Threads,mysqladmin -uroot status|cut -f3 -d":"|cut -f1 -d"Q"
ExternalParameter = MySQL_Questions,mysqladmin -uroot status|cut -f4 -d":"|cut -f1 -d"S"
ExternalParameter = MySQL_SlowQueries,mysqladmin -uroot status|cut -f5 -d":"|cut -f1 -d"O"
ExternalParameter = MySQL_qps,mysqladmin -uroot status|cut -f9 -d":"
ExternalParameter = MySQL_Version,mysql -V
</code></pre>
<p dir="auto"><em>заметка: определите -u&lt;username&gt; и добавьте -p&lt;password&gt; если потребуется</em></p>
]]></description><link>https://forum.netxms.org/topic/145/мониторинг-сервисов-apache-mysql-nginx-postfix-sendmail-...</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 20:48:08 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/145.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 21 Nov 2007 16:09:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Мониторинг сервисов (Apache, MySQL, Nginx, Postfix, Sendmail, ...) on Tue, 18 Dec 2007 14:35:35 GMT]]></title><description><![CDATA[<p dir="auto">пример shell-строки для мониторинга tcp-сервисов</p>
<pre><code>if echo $1 | nc -w $2  $3 $4 2&gt;&amp;- | grep -q $5; then echo 1; else echo 0; fi
</code></pre>
<p dir="auto">список аргументов:<br />
$1 - запрос;<br />
$2 - время ожидания в секундах (timeout);<br />
$3 - адрес хоста;<br />
$4 - порт;<br />
$5 - ожидаемый ответ (элемент ответа);</p>
<p dir="auto">загоняем строчку в 'ExternalParameter' nx-агента (параметры указываются через запятую)<br />
на выходе получаем 0(ложь) либо 1(истина)</p>
<p dir="auto"><em>заметка: программа nc(NetCat) имеется далеко не во всех Unix-системах и если её нет на Вашей системе, то просто установите её<br />
nc также имеет возможность работать с udp-сервисами и сканировать порты</em></p>
<p dir="auto">пример perl-скрипта для реализации мониторинга tcp-сервисов</p>
<pre><code>#!/usr/local/bin/perl

# Service Poller
use strict;
use IO::Socket::INET;

die "usage: ./service_poller.pl &lt;request&gt; &lt;timeout&gt; &lt;host&gt; &lt;port&gt; &lt;response&gt;" unless $ARGV[0];
die "usage: ./service_poller.pl &lt;request&gt; &lt;timeout&gt; &lt;host&gt; &lt;port&gt; &lt;response&gt;" unless $ARGV[1];
die "usage: ./service_poller.pl &lt;request&gt; &lt;timeout&gt; &lt;host&gt; &lt;port&gt; &lt;response&gt;" unless $ARGV[2];
die "usage: ./service_poller.pl &lt;request&gt; &lt;timeout&gt; &lt;host&gt; &lt;port&gt; &lt;response&gt;" unless $ARGV[3];
die "usage: ./service_poller.pl &lt;request&gt; &lt;timeout&gt; &lt;host&gt; &lt;port&gt; &lt;response&gt;" unless $ARGV[4];

my $recive_response = "";
my $request=$ARGV[0];
my $timeout=$ARGV[1];
my $host=$ARGV[2];
my $port=$ARGV[3];
my $response=$ARGV[4];

my $sock = new
IO::Socket::INET(
PeerAddr=&gt;$host,
PeerPort=&gt;$port,
Proto=&gt;'tcp',
#LocalAddr =&gt; 'localhost',
#LocalPort =&gt; 27005,
#Broadcast =&gt; 1
Timeout=&gt;$timeout);
#die "Could not create socket: $!\n" unless $sock;
die "0\n" unless $sock;
$sock-&gt;autoflush(1);
syswrite $sock, $request."\n";
sysread $sock,$recive_response,65535;
#chomp($recive_response);
#chop($recive_response);
#print $recive_response;
if($recive_response =~ /$response/) {
print "1"."\n";
} else {
print "0"."\n";
}

close $sock;
</code></pre>
]]></description><link>https://forum.netxms.org/post/784</link><guid isPermaLink="true">https://forum.netxms.org/post/784</guid><dc:creator><![CDATA[weec]]></dc:creator><pubDate>Tue, 18 Dec 2007 14:35:35 GMT</pubDate></item><item><title><![CDATA[Reply to Мониторинг сервисов (Apache, MySQL, Nginx, Postfix, Sendmail, ...) on Thu, 22 Nov 2007 08:59:46 GMT]]></title><description><![CDATA[<p dir="auto">Прошу прощения, не внимательно видимо прочел первый пост..</p>
]]></description><link>https://forum.netxms.org/post/699</link><guid isPermaLink="true">https://forum.netxms.org/post/699</guid><dc:creator><![CDATA[axel]]></dc:creator><pubDate>Thu, 22 Nov 2007 08:59:46 GMT</pubDate></item><item><title><![CDATA[Reply to Мониторинг сервисов (Apache, MySQL, Nginx, Postfix, Sendmail, ...) on Thu, 22 Nov 2007 10:46:59 GMT]]></title><description><![CDATA[<p dir="auto">для мониторинга у Apache есть модуль mod_status, более подробная информация<br />
<a href="http://httpd.apache.org/docs/1.3/mod/mod_status.html" rel="nofollow ugc">http://httpd.apache.org/docs/1.3/mod/mod_status.html</a><br />
там же содержится описание URL /server-status?auto</p>
]]></description><link>https://forum.netxms.org/post/698</link><guid isPermaLink="true">https://forum.netxms.org/post/698</guid><dc:creator><![CDATA[weec]]></dc:creator><pubDate>Thu, 22 Nov 2007 10:46:59 GMT</pubDate></item><item><title><![CDATA[Reply to Мониторинг сервисов (Apache, MySQL, Nginx, Postfix, Sendmail, ...) on Thu, 22 Nov 2007 08:34:35 GMT]]></title><description><![CDATA[<p dir="auto">Я не спорю что она актуальна... Я вопрос задал, что за урл такой, по которому проводится тестирование. Согласись что этот УРЛ должен выдавать инфу, по которой ты начинаешь грепать что-либо. Вот я и спросил, что это за урл?</p>
]]></description><link>https://forum.netxms.org/post/697</link><guid isPermaLink="true">https://forum.netxms.org/post/697</guid><dc:creator><![CDATA[axel]]></dc:creator><pubDate>Thu, 22 Nov 2007 08:34:35 GMT</pubDate></item><item><title><![CDATA[Reply to Мониторинг сервисов (Apache, MySQL, Nginx, Postfix, Sendmail, ...) on Thu, 22 Nov 2007 10:46:14 GMT]]></title><description><![CDATA[<p dir="auto">тема актуальная, постепенно я буду добавлять в этот топик больше информации по мониторингу сервисов</p>
]]></description><link>https://forum.netxms.org/post/696</link><guid isPermaLink="true">https://forum.netxms.org/post/696</guid><dc:creator><![CDATA[weec]]></dc:creator><pubDate>Thu, 22 Nov 2007 10:46:14 GMT</pubDate></item><item><title><![CDATA[Reply to Мониторинг сервисов (Apache, MySQL, Nginx, Postfix, Sendmail, ...) on Thu, 22 Nov 2007 09:02:59 GMT]]></title><description><![CDATA[<p dir="auto">weeс,  не затруднит объяснить что за урл такой "server-status?auto" ???</p>
]]></description><link>https://forum.netxms.org/post/692</link><guid isPermaLink="true">https://forum.netxms.org/post/692</guid><dc:creator><![CDATA[axel]]></dc:creator><pubDate>Thu, 22 Nov 2007 09:02:59 GMT</pubDate></item></channel></rss>