2
2

More than 5 years have passed since last update.

ZabbixでApacheのモニタリング

Last updated at Posted at 2013-02-24

UserParameterだとパラメータ毎に取得タイミングがずれるので、zabbix_sender方式に変更しました。

以下のスクリプトはZabbixに登録しているホスト名とhostnameで取得できるホスト名は一致しているのが前提です。違う場合はhostname の部分を適宜変更してください。

/usr/local/sbin/send_apache_stat_to_zabbix.sh
#!/bin/sh
zabbix_server=${Your_zabbix_server_or_proxy_address_here}
my_zabbix_hostname=`hostname`
interval_seconds=60

while :
do
  curl -s 'http://127.0.0.1/server-status?auto' | awk '
BEGIN {FS=": "}
$1=="Total Accesses" {
  print "'$my_zabbix_hostname'", "apache.total_accesses", $2
}
$1=="Total kBytes" {
  print "'$my_zabbix_hostname'", "apache.total_kilobytes", $2
}
$1=="BusyWorkers" {
  print "'$my_zabbix_hostname'", "apache.busy_workers", $2
}
$1=="IdleWorkers" {
  print "'$my_zabbix_hostname'", "apache.idle_workers", $2
}
' | zabbix_sender -z $zabbix_server -s $my_zabbix_hostname -i -
  sleep $interval_seconds
done
/etc/init/send_apache_stat_to_zabbix.conf
start on runlevel [12345]
stop on runlevel [^12345]
respawn
exec /usr/local/sbin/send_apache_stat_to_zabbix.sh
/etc/httpd/conf.d/server-status.conf
ExtendedStatus On

<VirtualHost *:80>
    ServerName localhost
    <Location /server-status>
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    </Location>
</VirtualHost>
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2