qnotifier 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/qnotifier +15 -5
- data/config/qnotifier_config.yml +11 -10
- data/init.d/qnotifier +38 -0
- data/lib/web_service.rb +1 -1
- data/plugins/apache.rb +1 -28
- data/plugins/iostat.rb +1 -0
- data/plugins/network.rb +1 -0
- data/plugins/nginx.rb +26 -1
- data/plugins/passenger.rb +28 -0
- data/plugins/rails.rb +1 -2
- data/plugins/system.rb +8 -4
- data/plugins/urls.rb +48 -0
- data/qnotifier.gemspec +3 -3
- data.tar.gz.sig +0 -0
- metadata +3 -4
- metadata.gz.sig +0 -0
- data/plugins/processes.rb +0 -13
data/bin/qnotifier
CHANGED
@@ -40,6 +40,11 @@ module Qnotifier
|
|
40
40
|
setup_registration
|
41
41
|
|
42
42
|
elsif argv.first == 'debug'
|
43
|
+
runlock_file = "/var/lib/qnotifier/.runlock"
|
44
|
+
if File.exists?(runlock_file)
|
45
|
+
`rm #{runlock_file}`
|
46
|
+
end
|
47
|
+
|
43
48
|
puts "Running once in debug mode (use this mode to debug your plugins)\n\n"
|
44
49
|
require "qnotifier"
|
45
50
|
qnotifier = Qnotifier::MainProcess.new
|
@@ -117,7 +122,8 @@ module Qnotifier
|
|
117
122
|
copy_init
|
118
123
|
puts "Doing initial update..."
|
119
124
|
qnotifier.run
|
120
|
-
puts "\
|
125
|
+
puts "\nStarting Qnotifier daemon (qnotifier start)"
|
126
|
+
`qnotifier start`
|
121
127
|
else
|
122
128
|
puts "Exiting."
|
123
129
|
end
|
@@ -128,11 +134,15 @@ module Qnotifier
|
|
128
134
|
end
|
129
135
|
|
130
136
|
def self.copy_init
|
131
|
-
print "\nWould you like to install
|
137
|
+
print "\nWould you like to install a qnotifier init script in /etc/init.d? (y/n):"
|
132
138
|
response = STDIN.gets.chomp.downcase!
|
133
139
|
if response == "y" || response == "yes"
|
134
140
|
init_file = File.dirname(__FILE__) + "/../init/qnotifier"
|
135
|
-
`
|
141
|
+
qnotifier_location = `which qnotifier`
|
142
|
+
if qnotifier_location
|
143
|
+
`cat #{init_file} | sed 's/QNOTIFIER_DAEMON_LOCATION/#{qnotifier_location}/' > /etc/init.d/qnotifier;chmod a+x /etc/init.d/qnotifier`
|
144
|
+
puts "Qnotifier init.d installed at /etc/init.d/qnotifier - you'll need to set it to start at various run levels"
|
145
|
+
end
|
136
146
|
end
|
137
147
|
end
|
138
148
|
|
@@ -178,16 +188,16 @@ module Qnotifier
|
|
178
188
|
end
|
179
189
|
|
180
190
|
pid = fork do
|
181
|
-
`echo #{Process.pid} > /var/lib/qnotifier/qnotifer.pid`
|
182
191
|
$0 = 'qnotifierd'
|
183
192
|
Process.setsid
|
184
|
-
#Process.euid = 65534
|
185
193
|
exit if fork
|
186
194
|
File.umask 0000
|
187
195
|
STDIN.reopen "/dev/null"
|
188
196
|
STDOUT.reopen "/dev/null", "a"
|
189
197
|
STDERR.reopen STDOUT
|
190
198
|
trap("TERM") {daemon.stop; exit}
|
199
|
+
`echo #{Process.pid} > /var/lib/qnotifier/qnotifer.pid`
|
200
|
+
#Process.euid = 65534
|
191
201
|
loop do
|
192
202
|
cpid = fork do
|
193
203
|
require "qnotifier"
|
data/config/qnotifier_config.yml
CHANGED
@@ -43,6 +43,7 @@ System:
|
|
43
43
|
- "/"
|
44
44
|
|
45
45
|
# The Apache built-in plugin
|
46
|
+
# Not currently supported
|
46
47
|
Apache:
|
47
48
|
# Enabled, set to either true or false
|
48
49
|
enabled: false
|
@@ -51,6 +52,7 @@ Apache:
|
|
51
52
|
password: "password"
|
52
53
|
|
53
54
|
# The IOStat built-in plugin
|
55
|
+
# Not currently supported
|
54
56
|
Iostat:
|
55
57
|
# Enabled, set to either true or false
|
56
58
|
enabled: false
|
@@ -67,10 +69,14 @@ Mysql:
|
|
67
69
|
#hostname: "hostname"
|
68
70
|
# MySQL Port if not localhost, must be used with hostname above
|
69
71
|
#port: 3306
|
70
|
-
|
71
|
-
|
72
|
+
|
73
|
+
# The URL Monitor built-in plugin, will watch a URL for non-200 HTTP responses
|
74
|
+
Url:
|
75
|
+
enabled: false
|
76
|
+
url: "http://localhost"
|
72
77
|
|
73
78
|
# The Network Interface built-in plugin
|
79
|
+
# Not currently supported
|
74
80
|
Network:
|
75
81
|
# Enabled, set to either true or false
|
76
82
|
enabled: false
|
@@ -81,20 +87,15 @@ Network:
|
|
81
87
|
Nginx:
|
82
88
|
# Enabled, set to either true or false
|
83
89
|
enabled: false
|
84
|
-
|
85
|
-
password: "password"
|
90
|
+
url: "http://username:password@127.0.0.1/nginx_status"
|
86
91
|
|
87
92
|
# The Passenger Phusion built-in plugin
|
88
93
|
Passenger:
|
89
94
|
# Enabled, set to either true or false
|
90
95
|
enabled: false
|
91
|
-
|
92
|
-
# The Process List built-in plugin
|
93
|
-
Processes:
|
94
|
-
# Enabled, set to either true or false
|
95
|
-
enabled: false
|
96
|
-
|
96
|
+
|
97
97
|
# The Rails built-in plugin
|
98
|
+
# Not currently supported
|
98
99
|
Rails:
|
99
100
|
# Enabled, set to either true or false
|
100
101
|
enabled: false
|
data/init.d/qnotifier
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
### BEGIN INIT INFO
|
3
|
+
# Provides: qnotifier
|
4
|
+
# Required-Start: $remote_fs $syslog
|
5
|
+
# Required-Stop: $remote_fs $syslog
|
6
|
+
# Default-Start: 2 3 4 5
|
7
|
+
# Default-Stop: 0 1 6
|
8
|
+
# Short-Description: Qnotifier initscript
|
9
|
+
# Description: Qnotifier server monitoring daemon, see http://qnotifier.com
|
10
|
+
### END INIT INFO
|
11
|
+
|
12
|
+
# Author: Gersham Meharg <gersham@qnotifier.com>
|
13
|
+
|
14
|
+
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/opt/local/bin
|
15
|
+
DESC="Qnotifier Monitoring Daemon"
|
16
|
+
NAME=qnotifier
|
17
|
+
DAEMON=QNOTIFIER_DAEMON_LOCATION
|
18
|
+
|
19
|
+
# Exit if the package is not installed
|
20
|
+
[ -x "$DAEMON" ] || exit 0
|
21
|
+
|
22
|
+
case "$1" in
|
23
|
+
start)
|
24
|
+
$DAEMON start
|
25
|
+
;;
|
26
|
+
stop)
|
27
|
+
$DAEMON stop
|
28
|
+
;;
|
29
|
+
restart)
|
30
|
+
$DAEMON restart
|
31
|
+
;;
|
32
|
+
*)
|
33
|
+
echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
|
34
|
+
exit 3
|
35
|
+
;;
|
36
|
+
esac
|
37
|
+
|
38
|
+
:
|
data/lib/web_service.rb
CHANGED
@@ -79,7 +79,7 @@ module Qnotifier
|
|
79
79
|
return
|
80
80
|
end
|
81
81
|
if last_run and (Time.now - last_run) <= @@poll_interval
|
82
|
-
Qnotifier.log.info "Not
|
82
|
+
Qnotifier.log.info "Not reporting to the service yet, waiting until #{last_run + @@poll_interval}"
|
83
83
|
return
|
84
84
|
end
|
85
85
|
Qnotifier::Storage.put("last_run", Time.now)
|
data/plugins/apache.rb
CHANGED
@@ -8,34 +8,7 @@ module Qnotifier
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def main
|
11
|
-
|
12
|
-
# require "net/http", "uri"
|
13
|
-
#
|
14
|
-
# url = URI.parse(option("server_url"))
|
15
|
-
# req = Net::HTTP::Get.new(url.path + "?" + url.query.to_s)
|
16
|
-
# res = Net::HTTP.start(url.host, url.port) {|http|
|
17
|
-
# http.request(req)
|
18
|
-
# }
|
19
|
-
# values = {}
|
20
|
-
# res.body.split("\n").each do |item|
|
21
|
-
# k, v = item.split(": ")
|
22
|
-
# values[k] = v
|
23
|
-
# end
|
24
|
-
# total_accesses = values['Total Accesses'].to_i
|
25
|
-
# if (memory(:last_run_total_accesses) && memory(:last_run_time))
|
26
|
-
# accesses_since_last_run = total_accesses - memory(:last_run_total_accesses)
|
27
|
-
# seconds_since_last_run = Time.now - memory(:last_run_time)
|
28
|
-
# else
|
29
|
-
# accesses_since_last_run = total_accesses
|
30
|
-
# seconds_since_last_run = values['Uptime'].to_i
|
31
|
-
# end
|
32
|
-
#
|
33
|
-
# current_accesses_per_second = accesses_since_last_run / seconds_since_last_run
|
34
|
-
#
|
35
|
-
# report(:current_load => current_accesses_per_second)
|
36
|
-
# remember(:last_run_time => Time.now)
|
37
|
-
# remember(:last_run_total_accesses => total_accesses)
|
38
|
-
#
|
11
|
+
Qnotifier.log.error "Apache stats plugin not yet supported in this beta version"
|
39
12
|
end
|
40
13
|
end
|
41
14
|
end
|
data/plugins/iostat.rb
CHANGED
data/plugins/network.rb
CHANGED
data/plugins/nginx.rb
CHANGED
@@ -1,14 +1,39 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'open-uri'
|
3
|
+
|
2
4
|
module Qnotifier
|
3
5
|
class Nginx < Qnotifier::Plugin
|
4
6
|
|
5
7
|
def initialize
|
6
8
|
@defaults = {
|
7
|
-
"status_url" => "http://127.0.0.1/nginx_status"
|
8
9
|
}
|
9
10
|
end
|
10
11
|
|
11
12
|
def main
|
13
|
+
|
14
|
+
return if @options["url"].empty?
|
15
|
+
|
16
|
+
total, requests, reading, writing, waiting = nil
|
17
|
+
|
18
|
+
begin
|
19
|
+
open( @options["url"]) {|f|
|
20
|
+
f.each_line do |line|
|
21
|
+
total = $1 if line =~ /^Active connections:\s+(\d+)/
|
22
|
+
if line =~ /^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/
|
23
|
+
reading = $1
|
24
|
+
writing = $2
|
25
|
+
waiting = $3
|
26
|
+
end
|
27
|
+
requests = $3 if line =~ /^\s+(\d+)\s+(\d+)\s+(\d+)/
|
28
|
+
end
|
29
|
+
}
|
30
|
+
|
31
|
+
report("Connections", total)
|
32
|
+
stat("Activity", "total: #{total} reading: #{reading} writing: #{writing} waiting: #{waiting}")
|
33
|
+
|
34
|
+
rescue Exception => e
|
35
|
+
Qnotifier.log.error "Can not check Nginx Status #{e}"
|
36
|
+
end
|
12
37
|
end
|
13
38
|
end
|
14
39
|
end
|
data/plugins/passenger.rb
CHANGED
@@ -8,6 +8,34 @@ module Qnotifier
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def main
|
11
|
+
|
12
|
+
status = `passenger-status`
|
13
|
+
if status
|
14
|
+
max, count, active, inactive = 0
|
15
|
+
|
16
|
+
for line in status.split("\n")
|
17
|
+
|
18
|
+
s = line.split('=')
|
19
|
+
if s.length == 2
|
20
|
+
c = s[1].strip
|
21
|
+
|
22
|
+
if line =~ /max/
|
23
|
+
max = c
|
24
|
+
elsif line =~ /count/
|
25
|
+
count = c
|
26
|
+
elsif line =~ /active/
|
27
|
+
active = c
|
28
|
+
elsif line =~ /inactive/
|
29
|
+
inactive = c
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
report("Active", active)
|
34
|
+
stat("Handlers", "max: #{max} count: #{count} active: #{active} inactive: #{inactive}")
|
35
|
+
|
36
|
+
else
|
37
|
+
Qnotifier.log.error "Can't read passenger-status"
|
38
|
+
end
|
11
39
|
end
|
12
40
|
end
|
13
41
|
end
|
data/plugins/rails.rb
CHANGED
data/plugins/system.rb
CHANGED
@@ -84,7 +84,9 @@ module Qnotifier
|
|
84
84
|
|
85
85
|
# CPU
|
86
86
|
if RUBY_PLATFORM =~ /linux/
|
87
|
-
|
87
|
+
|
88
|
+
# Need to rewrite this, vmstat is only giving stats since system boot, not instant stats
|
89
|
+
vmstat = nil #`vmstat | tail -1`
|
88
90
|
if vmstat
|
89
91
|
vmstat = vmstat.split
|
90
92
|
if vmstat.size >= 16
|
@@ -150,10 +152,12 @@ module Qnotifier
|
|
150
152
|
unless meminfo.empty?
|
151
153
|
memory["Free"] = meminfo['MemFree'] / 1024
|
152
154
|
memory["Total"] = meminfo['MemTotal'] / 1024
|
153
|
-
|
154
|
-
memory["
|
155
|
+
memory["Buffers"] = meminfo['Buffers'] / 1024
|
156
|
+
memory["Cached"] = meminfo['Cached'] / 1024
|
157
|
+
memory_usable = memory["Free"] + memory["Buffers"] + memory["Cached"]
|
158
|
+
memory_percent = 100 - (memory_usable * 100 / memory["Total"])
|
155
159
|
|
156
|
-
stat("Memory", "Free: #{memory["Free"]}M,
|
160
|
+
stat("Memory", "Total: #{memory["Total"]}M, Free: #{memory["Free"]}M, Buffers: #{memory["Buffers"]}M, Cached: #{memory["Cached"]}M,")
|
157
161
|
report("Memory %", memory_percent)
|
158
162
|
|
159
163
|
if @options["alert_memory_threshold"] != 0 and memory_percent >= @options["alert_memory_threshold"]
|
data/plugins/urls.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
require 'uri'
|
5
|
+
|
2
6
|
module Qnotifier
|
3
7
|
class Urls < Qnotifier::Plugin
|
4
8
|
|
@@ -8,6 +12,50 @@ module Qnotifier
|
|
8
12
|
end
|
9
13
|
|
10
14
|
def main
|
15
|
+
|
16
|
+
url = @options["url"].strip
|
17
|
+
if url.empty?
|
18
|
+
Qnotifier.log.error "No URL specified for URL Monitor"
|
19
|
+
end
|
20
|
+
|
21
|
+
unless url =~ %r{\Ahttps?://}
|
22
|
+
url = "http://#{url}"
|
23
|
+
end
|
24
|
+
|
25
|
+
uri = URI.parse(url)
|
26
|
+
response = nil
|
27
|
+
stat("URL", url)
|
28
|
+
|
29
|
+
start_time = Time.now.usec
|
30
|
+
|
31
|
+
begin
|
32
|
+
http = Net::HTTP.new(uri.host,uri.port)
|
33
|
+
http.use_ssl = url =~ %r{\Ahttps://}
|
34
|
+
http.start(){|http|
|
35
|
+
http.open_timeout = 10
|
36
|
+
req = Net::HTTP::Get.new((uri.path != '' ? uri.path : '/' ) + (uri.query ? ('?' + uri.query) : ''))
|
37
|
+
if uri.user && uri.password
|
38
|
+
req.basic_auth uri.user, uri.password
|
39
|
+
end
|
40
|
+
response = http.request(req)
|
41
|
+
}
|
42
|
+
rescue Exception => e
|
43
|
+
puts "Exception #{e}"
|
44
|
+
stat("Code", 0)
|
45
|
+
alert("response", "HTTP connection error: #{e.message} #{url}")
|
46
|
+
return
|
47
|
+
end
|
48
|
+
|
49
|
+
response_time = (Time.now.usec - start_time) / 1000
|
50
|
+
report("Latency msec", response_time)
|
51
|
+
|
52
|
+
if response.code == 200
|
53
|
+
stat("Code", 200)
|
54
|
+
reset_alert("response", "HTTP OK #{url}")
|
55
|
+
else
|
56
|
+
stat("Code", response.code)
|
57
|
+
alert("response", "HTTP #{response.code} #{url}")
|
58
|
+
end
|
11
59
|
end
|
12
60
|
end
|
13
61
|
end
|
data/qnotifier.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{qnotifier}
|
5
|
-
s.version = "0.7.
|
5
|
+
s.version = "0.7.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Gersham Meharg"]
|
9
|
-
s.date = %q{2010-06-
|
9
|
+
s.date = %q{2010-06-28}
|
10
10
|
s.default_executable = %q{qnotifier}
|
11
11
|
s.description = %q{The server side agent for the QNotifier monitoring system. This software will monitor local Linux system parameters and upload them to the QNotifier servers where users can use iPhone/iPad applications to view those stats and recieve alerts.}
|
12
12
|
s.email = %q{gersham@qnotifier.com}
|
13
13
|
s.executables = ["qnotifier"]
|
14
14
|
s.extra_rdoc_files = ["bin/qnotifier", "lib/plugin.rb", "lib/qnotifier.rb", "lib/storage.rb", "lib/web_service.rb"]
|
15
|
-
s.files = ["Manifest", "Rakefile", "bin/qnotifier", "config/README", "config/qnotifier_config.yml", "gem-public_cert.pem", "lib/plugin.rb", "lib/qnotifier.rb", "lib/storage.rb", "lib/web_service.rb", "plugins/apache.rb", "plugins/iostat.rb", "plugins/mysql.rb", "plugins/network.rb", "plugins/nginx.rb", "plugins/passenger.rb", "plugins/
|
15
|
+
s.files = ["Manifest", "Rakefile", "bin/qnotifier", "config/README", "config/qnotifier_config.yml", "gem-public_cert.pem", "lib/plugin.rb", "lib/qnotifier.rb", "lib/storage.rb", "lib/web_service.rb", "plugins/apache.rb", "plugins/iostat.rb", "plugins/mysql.rb", "plugins/network.rb", "plugins/nginx.rb", "plugins/passenger.rb", "plugins/rails.rb", "plugins/ruby.rb", "plugins/system.rb", "plugins/urls.rb", "init.d/qnotifier", "qnotifier.gemspec"]
|
16
16
|
s.homepage = %q{http://qnotifier.com/qnotifier_gem}
|
17
17
|
s.post_install_message = %q{Qnotifier installed, please register by running 'qnotifier' in order to register this server.}
|
18
18
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Qnotifier"]
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 4
|
9
|
+
version: 0.7.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Gersham Meharg
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
wu7A8rLN6CU0SfWf
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date: 2010-06-
|
38
|
+
date: 2010-06-28 00:00:00 -07:00
|
39
39
|
default_executable: qnotifier
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -187,7 +187,6 @@ files:
|
|
187
187
|
- plugins/network.rb
|
188
188
|
- plugins/nginx.rb
|
189
189
|
- plugins/passenger.rb
|
190
|
-
- plugins/processes.rb
|
191
190
|
- plugins/rails.rb
|
192
191
|
- plugins/ruby.rb
|
193
192
|
- plugins/system.rb
|
metadata.gz.sig
CHANGED
Binary file
|