Created
May 30, 2013 16:47
-
-
Save andre/5679356 to your computer and use it in GitHub Desktop.
added connections per second
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PHPFpmStatus < Scout::Plugin | |
needs 'open-uri', 'json' | |
OPTIONS=<<-EOS | |
url: | |
name: FPM Status Url | |
default: "http://localhost/status?json" | |
EOS | |
def build_report | |
url = option(:url) || 'http://localhost/status?json' | |
begin | |
open(url) do |p| | |
content = p.read | |
stats = JSON.parse(content) | |
accepted_connections = stats["accepted conn"].to_i | |
report({ | |
:is_up => 1, | |
:start_since => stats["start since"].to_i, | |
:idle_processes => stats["idle processes"].to_i, | |
:active_processes => stats["active processes"].to_i, | |
:total_processes => stats["total processes"].to_i, | |
:accepted_connections => accepted_connections, | |
:accepted_connections_per_sec => counter(:accepted_connections, accepted_connections, :per=>:second), | |
:listen_queue => stats["listen queue"].to_i, | |
:listen_queue_length => stats["listen queue len"].to_i, | |
:max_active_processes => stats["max active processes"].to_i, | |
:max_children_reached => stats["max children reached"].to_i | |
}) | |
end | |
rescue StandardError => trouble | |
report({:is_up => 0}) | |
error("Unable to connect to status page", | |
"#{trouble}\n\n#{trouble.backtrace}") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment