qnotifier 0.7.5 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +3 -2
- data/Manifest +0 -1
- data/bin/qnotifier +5 -0
- data/config/README +54 -1
- data/config/qnotifier_config.yml +7 -15
- data/lib/plugin.rb +1 -0
- data/lib/qnotifier.rb +11 -1
- data/lib/web_service.rb +0 -1
- data/plugins/apache.rb +20 -1
- data/plugins/system.rb +40 -46
- data/plugins/urls.rb +15 -10
- data/qnotifier.gemspec +3 -3
- metadata +3 -4
- metadata.gz.sig +0 -0
- data/plugins/iostat.rb +0 -14
data.tar.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
��
|
1
|
+
�����
|
2
|
+
kk�߳%E�x:S�N��^/d|��8>0��_��ɛds�I�6��<' ��q�V.��/-T�j|��Y��Mq�)ӚԱ���o�v6�SD�Zs���B�
|
3
|
+
��L��8|�6y9�S��'�
|
data/Manifest
CHANGED
data/bin/qnotifier
CHANGED
@@ -33,6 +33,11 @@ module Qnotifier
|
|
33
33
|
`rm /var/lib/qnotifier/saved_variables.yml`
|
34
34
|
end
|
35
35
|
|
36
|
+
elsif argv.first == 'alert'
|
37
|
+
require "qnotifier"
|
38
|
+
qnotifier = Qnotifier::MainProcess.new
|
39
|
+
qnotifier.alert(argv[1], argv[2], 3)
|
40
|
+
|
36
41
|
elsif argv.first == 'register'
|
37
42
|
require "qnotifier"
|
38
43
|
qnotifier = Qnotifier::MainProcess.new
|
data/config/README
CHANGED
@@ -1 +1,54 @@
|
|
1
|
-
Plugin Development
|
1
|
+
Plugin Development
|
2
|
+
|
3
|
+
QNotifier supports user defined plugins to extend its capability. With this ability you can monitor and alert on pretty much anything on your system.
|
4
|
+
|
5
|
+
Location
|
6
|
+
- User generated plugins should be placed in /var/lib/qnotifier/plugins
|
7
|
+
|
8
|
+
Plugin Structure
|
9
|
+
- A plugin must subclass Qnotifier::Plugin and contain a main method and an initializer.
|
10
|
+
|
11
|
+
Here's a basic plugin that counts the number of processes on the system:
|
12
|
+
|
13
|
+
module Qnotifier
|
14
|
+
class Iostat < Qnotifier::Plugin
|
15
|
+
def main
|
16
|
+
processes = `ps -ef`
|
17
|
+
if processes
|
18
|
+
process_count = processes.split("/n").count
|
19
|
+
stat("Count", process_count)
|
20
|
+
report("Count", process_count)
|
21
|
+
if process_count > 100
|
22
|
+
alert("Count", "There are more than 100 processes running")
|
23
|
+
else
|
24
|
+
reset_alert("Count", "There are now under 100 processes running")
|
25
|
+
end
|
26
|
+
else
|
27
|
+
Qnotifier.log.error "Couldn't get output from the ps command"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Methods:
|
34
|
+
|
35
|
+
stat(key, value)
|
36
|
+
Will update the stat for key with value on the server. Value is a text field that will appear next to the property in the stats portion of the client.
|
37
|
+
|
38
|
+
report(key, value)
|
39
|
+
Will create a datapoint for graphs for the associated key. Value is a float or integer.
|
40
|
+
|
41
|
+
alert(key, message)
|
42
|
+
Sends a push notification for the specified key with the message string.
|
43
|
+
|
44
|
+
reset_alert(key, message)
|
45
|
+
Resets an alert, key must match the alert that it is associated with.
|
46
|
+
|
47
|
+
put(key, value)
|
48
|
+
Puts a value string in the saved variables to be retrieved on a subsequent run by get.
|
49
|
+
|
50
|
+
get(key)
|
51
|
+
Retrieves a stored value by key.
|
52
|
+
|
53
|
+
|
54
|
+
Submit your plugin to support@qnotifier.com if you feel like sharing it with others!
|
data/config/qnotifier_config.yml
CHANGED
@@ -30,12 +30,10 @@ System:
|
|
30
30
|
use_load: five_minute
|
31
31
|
# normalize_load: whether to divide the reported load by the number of CPUs in the system
|
32
32
|
normalize_load: false
|
33
|
-
# Alert if the CPU is above this percent usage, 0 disables
|
34
|
-
alert_cpu_threshold: 95
|
35
33
|
# Alert if the memory is above this percent usage, 0 disables
|
36
34
|
alert_memory_threshold: 90
|
37
35
|
# Alert if the load is above this percent usage, 0 disables
|
38
|
-
alert_load_threshold: 1.
|
36
|
+
alert_load_threshold: 1.5
|
39
37
|
# Alert if the disk is above this percent usage, 0 disables
|
40
38
|
alert_disk_threshold: 90
|
41
39
|
# Partitions which to monitor for free disk space
|
@@ -43,20 +41,12 @@ System:
|
|
43
41
|
- "/"
|
44
42
|
|
45
43
|
# The Apache built-in plugin
|
46
|
-
#
|
44
|
+
# You must enable mod_status at this URL
|
47
45
|
Apache:
|
48
46
|
# Enabled, set to either true or false
|
49
47
|
enabled: false
|
50
|
-
|
51
|
-
|
52
|
-
password: "password"
|
53
|
-
|
54
|
-
# The IOStat built-in plugin
|
55
|
-
# Not currently supported
|
56
|
-
Iostat:
|
57
|
-
# Enabled, set to either true or false
|
58
|
-
enabled: false
|
59
|
-
|
48
|
+
url: "http://username:password@127.0.0.1/nginx_status"
|
49
|
+
|
60
50
|
# The MySQL built-in plugin
|
61
51
|
Mysql:
|
62
52
|
# Enabled, set to either true or false
|
@@ -71,7 +61,8 @@ Mysql:
|
|
71
61
|
#port: 3306
|
72
62
|
|
73
63
|
# The URL Monitor built-in plugin, will watch a URL for non-200 HTTP responses
|
74
|
-
|
64
|
+
# Please be aware to make sure this isn't a redirect (301, 302)
|
65
|
+
Urls:
|
75
66
|
enabled: false
|
76
67
|
url: "http://localhost"
|
77
68
|
|
@@ -84,6 +75,7 @@ Network:
|
|
84
75
|
- eth0
|
85
76
|
|
86
77
|
# The Nginx built-in plugin
|
78
|
+
# You must compile nginx with --with-http_stub_status_module and point this url to the stub_status location
|
87
79
|
Nginx:
|
88
80
|
# Enabled, set to either true or false
|
89
81
|
enabled: false
|
data/lib/plugin.rb
CHANGED
data/lib/qnotifier.rb
CHANGED
@@ -45,7 +45,7 @@ module Qnotifier
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def run
|
48
|
-
Qnotifier.log.
|
48
|
+
Qnotifier.log.debug "QNotifier Running"
|
49
49
|
|
50
50
|
runlock_file = "/var/lib/qnotifier/.runlock"
|
51
51
|
if File.exists?(runlock_file)
|
@@ -160,6 +160,16 @@ module Qnotifier
|
|
160
160
|
Qnotifier::Storage.wipe
|
161
161
|
end
|
162
162
|
|
163
|
+
def alert(key, message, priority)
|
164
|
+
start_logging
|
165
|
+
load_config
|
166
|
+
|
167
|
+
alerts = {"User" => [[key, message, priority]]}
|
168
|
+
webservice = Qnotifier::WebService.new
|
169
|
+
webservice.config = @config
|
170
|
+
webservice.send_alerts(alerts)
|
171
|
+
end
|
172
|
+
|
163
173
|
def save_api_key(api_key)
|
164
174
|
return unless api_key
|
165
175
|
@config["api_key"] = api_key
|
data/lib/web_service.rb
CHANGED
data/plugins/apache.rb
CHANGED
@@ -8,7 +8,26 @@ module Qnotifier
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def main
|
11
|
-
|
11
|
+
|
12
|
+
return if @options["url"].empty?
|
13
|
+
|
14
|
+
connections, requests, cpu = nil
|
15
|
+
|
16
|
+
begin
|
17
|
+
open( @options["url"]) {|f|
|
18
|
+
f.each_line do |line|
|
19
|
+
connections = $1 if line.strip =~ /^(\d+)\srequests\scurrently\sbeing\sprocessed/
|
20
|
+
cpu = line if line.strip =~/CPU\sUsage/
|
21
|
+
requests = line if line =~/requests\/sec/
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
25
|
+
report("Connections", connections)
|
26
|
+
stat("Activity", "#{cpu} #{requests}")
|
27
|
+
|
28
|
+
rescue Exception => e
|
29
|
+
Qnotifier.log.error "Can not check Apache Status #{e}"
|
30
|
+
end
|
12
31
|
end
|
13
32
|
end
|
14
33
|
end
|
data/plugins/system.rb
CHANGED
@@ -67,7 +67,7 @@ module Qnotifier
|
|
67
67
|
items = line.split
|
68
68
|
|
69
69
|
disk = "Used: #{items[-2]} (#{items[-4]}), #{items[-3]} free"
|
70
|
-
stat("Disk #{partition}", disk)
|
70
|
+
stat("Disk #{partition}", disk)
|
71
71
|
report("Disk #{partition} %", items[-2].delete("%").to_i)
|
72
72
|
|
73
73
|
if @options["alert_disk_threshold"] != 0 and items[-2].delete("%").to_i >= @options["alert_disk_threshold"]
|
@@ -86,52 +86,48 @@ module Qnotifier
|
|
86
86
|
if RUBY_PLATFORM =~ /linux/
|
87
87
|
|
88
88
|
# Need to rewrite this, vmstat is only giving stats since system boot, not instant stats
|
89
|
-
|
90
|
-
if
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
reset_alert("cpu", "CPU is now #{cpu_percent}%")
|
89
|
+
proc_stat = `cat /proc/stat`
|
90
|
+
if proc_stat
|
91
|
+
for line in proc_stat.split("\n")
|
92
|
+
item = line.split
|
93
|
+
if item[0] == "cpu"
|
94
|
+
user = item[1].to_i + item[2].to_i
|
95
|
+
system = item[3].to_i
|
96
|
+
idle = item[4].to_i
|
97
|
+
iowait = item[5].to_i + item[6].to_i + item[7].to_i
|
98
|
+
|
99
|
+
last_user = get("cpu_user") ? get("cpu_user") : 0
|
100
|
+
last_system = get("cpu_system") ? get("cpu_system") : 0
|
101
|
+
last_idle = get("cpu_idle") ? get("cpu_idle") : 0
|
102
|
+
last_iowait = get("cpu_iowait") ? get("cpu_iowait") : 0
|
103
|
+
|
104
|
+
user_diff = user - last_user
|
105
|
+
system_diff = system - last_system
|
106
|
+
idle_diff = idle - last_idle
|
107
|
+
iowait_diff = iowait - last_iowait
|
108
|
+
|
109
|
+
div = user_diff + system_diff + idle_diff + iowait_diff
|
110
|
+
half_div = div / 2
|
111
|
+
|
112
|
+
user_pc = (100 * user_diff + half_div) / div
|
113
|
+
system_pc = (100 * system_diff + half_div) / div
|
114
|
+
idle_pc = (100 * idle_diff + half_div) / div
|
115
|
+
iowait_pc = (100 * iowait_diff + half_div) / div
|
116
|
+
cpu_pc = 100 - idle_pc
|
117
|
+
|
118
|
+
put("cpu_user", user)
|
119
|
+
put("cpu_system", system)
|
120
|
+
put("cpu_idle", idle)
|
121
|
+
put("cpu_iowait", iowait)
|
122
|
+
|
123
|
+
stat("CPU", "#{user_pc}% user, #{system_pc}% system, #{iowait_pc}% iowait, #{idle_pc}% idle")
|
124
|
+
report("CPU %", cpu_pc)
|
125
|
+
|
126
|
+
break
|
128
127
|
end
|
129
|
-
|
130
|
-
else
|
131
|
-
Qnotifier.log.error "Can't parse iostat"
|
132
128
|
end
|
133
129
|
else
|
134
|
-
Qnotifier.log.error "Can't parse
|
130
|
+
Qnotifier.log.error "Can't parse /proc/stat"
|
135
131
|
end
|
136
132
|
else
|
137
133
|
Qnotifier.log.error "Can't parse CPU for this platform - #{RUBY_PLATFORM}"
|
@@ -169,8 +165,6 @@ module Qnotifier
|
|
169
165
|
Qnotifier.log.error "Can't get memory information from /proc/meminfo (is it supported by this OS?)"
|
170
166
|
end
|
171
167
|
|
172
|
-
elsif RUBY_PLATFORM =~ /darwin/
|
173
|
-
# Not supported on OSX currently
|
174
168
|
else
|
175
169
|
Qnotifier.log.error "Can't parse Memory for this platform - #{RUBY_PLATFORM}"
|
176
170
|
end
|
data/plugins/urls.rb
CHANGED
@@ -28,6 +28,9 @@ module Qnotifier
|
|
28
28
|
|
29
29
|
start_time = Time.now.usec
|
30
30
|
|
31
|
+
code = 0
|
32
|
+
failure_message = ""
|
33
|
+
|
31
34
|
begin
|
32
35
|
http = Net::HTTP.new(uri.host,uri.port)
|
33
36
|
http.use_ssl = url =~ %r{\Ahttps://}
|
@@ -38,23 +41,25 @@ module Qnotifier
|
|
38
41
|
req.basic_auth uri.user, uri.password
|
39
42
|
end
|
40
43
|
response = http.request(req)
|
44
|
+
code = response.code.to_i
|
41
45
|
}
|
42
46
|
rescue Exception => e
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
return
|
47
|
+
Qnotifier.log.error "Exception #{e}"
|
48
|
+
failure_message = e
|
49
|
+
code = 0
|
47
50
|
end
|
48
51
|
|
49
|
-
|
50
|
-
report("Latency msec", response_time)
|
51
|
-
|
52
|
-
if response.code == 200
|
52
|
+
if code == 200
|
53
53
|
stat("Code", 200)
|
54
54
|
reset_alert("response", "HTTP OK #{url}")
|
55
|
+
response_time = (Time.now.usec - start_time) / 1000
|
56
|
+
report("Latency msec", response_time)
|
57
|
+
elsif code == 0
|
58
|
+
stat("Code", code)
|
59
|
+
alert("response", "HTTP Connection Failed #{url} #{failure_message}")
|
55
60
|
else
|
56
|
-
stat("Code",
|
57
|
-
alert("response", "HTTP #{
|
61
|
+
stat("Code", code)
|
62
|
+
alert("response", "HTTP #{code} #{url}")
|
58
63
|
end
|
59
64
|
end
|
60
65
|
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.6"
|
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-07-06}
|
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/
|
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/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"]
|
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
|
+
- 6
|
9
|
+
version: 0.7.6
|
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-07-06 00:00:00 -07:00
|
39
39
|
default_executable: qnotifier
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -182,7 +182,6 @@ files:
|
|
182
182
|
- lib/storage.rb
|
183
183
|
- lib/web_service.rb
|
184
184
|
- plugins/apache.rb
|
185
|
-
- plugins/iostat.rb
|
186
185
|
- plugins/mysql.rb
|
187
186
|
- plugins/network.rb
|
188
187
|
- plugins/nginx.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/plugins/iostat.rb
DELETED