root / plugins / php / php_eaccelerator @ 09b88141
Historique | Voir | Annoter | Télécharger (2,67 ko)
| 1 |
#!/usr/bin/env ruby |
|---|---|
| 2 |
|
| 3 |
# Monitor your EAccelerator usage. |
| 4 |
# Requires: ruby |
| 5 |
|
| 6 |
# Mandatory Parameters |
| 7 |
|
| 8 |
# user / pwd - for basic authentication against control.php |
| 9 |
# url - fullpath to control.php |
| 10 |
|
| 11 |
# Author: Dirk Gomez <munin@dirkgomez.de> |
| 12 |
# Copyright (C) 2007 Dirk Gomez |
| 13 |
# |
| 14 |
# This program is free software; you can redistribute it and/or |
| 15 |
# modify it under the terms of the GNU General Public License |
| 16 |
# as published by the Free Software Foundation; either version 2 |
| 17 |
# of the License, or (at your option) any later version. |
| 18 |
# |
| 19 |
# This program is distributed in the hope that it will be useful, |
| 20 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
# GNU General Public License for more details. |
| 23 |
# |
| 24 |
# You should have received a copy of the GNU General Public License |
| 25 |
# along with this program; if not, write to the Free Software |
| 26 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 27 |
|
| 28 |
require 'open-uri' |
| 29 |
|
| 30 |
user = ENV['user'] || 'user' |
| 31 |
pwd = ENV['password'] || 'password' |
| 32 |
url = ENV['url'] || 'http://127.0.0.1/control.php' |
| 33 |
|
| 34 |
if ARGV[0] == 'config' |
| 35 |
print "EAccelerator Monitoring\n" |
| 36 |
print "graph_title PHP Eaccelerator\n" |
| 37 |
print "graph_category webserver\n" |
| 38 |
print "Memoryusagepercentage.label Memory Usage %\n" |
| 39 |
print "Memoryusagepercentage.warning 95\n" |
| 40 |
print "Memoryusagepercentage.critical 95\n" |
| 41 |
print "Memoryusage.label Memory Usage MB\n" |
| 42 |
print "Memorymax.label Cache Size MB\n" |
| 43 |
print "Freememory.label Free Memory MB\n" |
| 44 |
print "Cachedscripts.label Cached Scripts\n" |
| 45 |
print "Removedscripts.label Removed Scripts\n" |
| 46 |
print "Cachedkeys.label Cached Keys\n" |
| 47 |
exit |
| 48 |
end |
| 49 |
|
| 50 |
one_liners = 0 |
| 51 |
three_liners = 0 |
| 52 |
key = '' |
| 53 |
|
| 54 |
open(url, http_basic_authentication: [user, pwd]) do |f| |
| 55 |
f.each do |line| |
| 56 |
if three_liners > 0 |
| 57 |
three_liners += 1 |
| 58 |
|
| 59 |
print 'Memoryusagepercentage.value ' if three_liners == 2 |
| 60 |
|
| 61 |
print 'Memoryusage.value ' if three_liners == 3 |
| 62 |
|
| 63 |
print 'Memorymax.value ' if three_liners == 4 |
| 64 |
|
| 65 |
print line.gsub!(/[^0-9.]/s, '') |
| 66 |
print "\n" |
| 67 |
end |
| 68 |
|
| 69 |
if one_liners > 0 |
| 70 |
one_liners += 1 |
| 71 |
print "#{key}.value "
|
| 72 |
print line.gsub!(/[^0-9.]/s, '') |
| 73 |
print "\n" |
| 74 |
end |
| 75 |
|
| 76 |
if one_liners > 1 |
| 77 |
line = '' |
| 78 |
one_liners = 0 |
| 79 |
end |
| 80 |
|
| 81 |
if three_liners > 3 |
| 82 |
line = '' |
| 83 |
three_liners = 0 |
| 84 |
end |
| 85 |
|
| 86 |
if line =~ /Memory usage/ |
| 87 |
key = line.gsub!(/(<[^>]*>)|\n|\t| /s, '') |
| 88 |
three_liners += 1 |
| 89 |
end |
| 90 |
|
| 91 |
if line =~ /<td class="e">Free memory/ || line =~ /<td class="e">Cached scripts/ || line =~ /<td class="e">Removed scripts/ || line =~ /<td class="e">Cached keys/ |
| 92 |
key = line.gsub!(/(<[^>]*>)|\n|\t| /s, '') |
| 93 |
one_liners += 1 |
| 94 |
end |
| 95 |
end |
| 96 |
end |
