root / plugins / php / php_eaccelerator @ 17f78427
Historique | Voir | Annoter | Télécharger (2,72 ko)
| 1 | 7a37bfb1 | Lars Kruse | #!/usr/bin/env ruby |
|---|---|---|---|
| 2 | e94cf4d4 | Dirk Gomez | |
| 3 | 17f78427 | Lars Kruse | # Monitor your EAccelerator usage. |
| 4 | e94cf4d4 | Dirk Gomez | # 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 | b19b3a81 | dipohl | print "graph_category webserver\n" |
| 38 | 17f78427 | Lars Kruse | 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 | e94cf4d4 | Dirk Gomez | 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=three_liners+1 |
||
| 58 | |||
| 59 | if three_liners==2 |
||
| 60 | print "Memoryusagepercentage.value " |
||
| 61 | end |
||
| 62 | |||
| 63 | if three_liners==3 |
||
| 64 | print "Memoryusage.value " |
||
| 65 | end |
||
| 66 | |||
| 67 | if three_liners==4 |
||
| 68 | print "Memorymax.value " |
||
| 69 | end |
||
| 70 | |||
| 71 | print line.gsub!(/[^0-9.]/s,"") |
||
| 72 | print "\n" |
||
| 73 | end |
||
| 74 | |||
| 75 | if one_liners>0 |
||
| 76 | one_liners=one_liners+1 |
||
| 77 | print "#{key}.value "
|
||
| 78 | print line.gsub!(/[^0-9.]/s,"") |
||
| 79 | print "\n" |
||
| 80 | end |
||
| 81 | |||
| 82 | if one_liners>1 |
||
| 83 | line="" |
||
| 84 | one_liners=0 |
||
| 85 | end |
||
| 86 | |||
| 87 | if three_liners>3 |
||
| 88 | line="" |
||
| 89 | three_liners=0 |
||
| 90 | end |
||
| 91 | |||
| 92 | if line =~ /Memory usage/ |
||
| 93 | key=line.gsub!(/(<[^>]*>)|\n|\t| /s,"") |
||
| 94 | three_liners=three_liners+1 |
||
| 95 | end |
||
| 96 | |||
| 97 | 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/ |
||
| 98 | key=line.gsub!(/(<[^>]*>)|\n|\t| /s,"") |
||
| 99 | one_liners=one_liners+1 |
||
| 100 | end |
||
| 101 | |||
| 102 | end |
||
| 103 | end |
