sensu-plugins-erlang 0.0.1.alpha.1
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.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -0
- data/CHANGELOG.md +4 -0
- data/LICENSE +22 -0
- data/README.md +54 -0
- data/bin/check-erlang-mailboxes.escript +174 -0
- data/bin/metrics-erlang.escript +177 -0
- data/lib/sensu-plugins-erlang.rb +7 -0
- metadata +201 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2af2cd662abb99430f64e047996c48c5b6b8bd54
|
4
|
+
data.tar.gz: 42abd0ca833d80df86a4d841e6f26d2dcf2cd2d6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 73cc1c4be1f2a9c097cedd118af20e7e6eae9c94707054a11f72e13993b1133f64ffb0dc067106b418f8cb6349209cfca8cecc2b9e9f20d068735bf9deb54d68
|
7
|
+
data.tar.gz: 08e7014d2440a968d5482c33b3dedb2103ec57f90ad1067993a0b7b503f782baf1c4f304126c753a94b780c33cab9d1d95f17553fa5320bb4f30f36349c78f98
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
?f��y�}z����+���9���}4q�ڀ��e�7��e<Z���_L��D��MI��j �n������^�b}��5lf��D^����3�'JwE�����3�_���Y�? ��B��+��ŧ�L��_�j�R�0u�60����h��N��;��en��?��i\TS�+��(L�Rv��j��8sr*��H\F�Y+���5�M}$^�!�9���6M��=d�O����+%qD�N��)���R�w_��
|
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 devops@yieldbot.com
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
## Sensu-Plugins-erlang
|
2
|
+
|
3
|
+
[](https://travis-ci.org/sensu-plugins/sensu-plugins-erlang)
|
4
|
+
[](http://badge.fury.io/rb/sensu-plugins-erlang)
|
5
|
+
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-erlang)
|
6
|
+
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-erlang)
|
7
|
+
[](https://gemnasium.com/sensu-plugins/sensu-plugins-erlang)
|
8
|
+
|
9
|
+
## Functionality
|
10
|
+
|
11
|
+
## Files
|
12
|
+
* bin/check-erlang-mailboxes
|
13
|
+
* bin/metrics-erlang
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add the public key (if you haven’t already) as a trusted certificate
|
20
|
+
|
21
|
+
```
|
22
|
+
gem cert --add <(curl -Ls https://raw.githubusercontent.com/sensu-plugins/sensu-plugins.github.io/master/certs/sensu-plugins.pem)
|
23
|
+
gem install sensu-plugins-erlang -P MediumSecurity
|
24
|
+
```
|
25
|
+
|
26
|
+
You can also download the key from /certs/ within each repository.
|
27
|
+
|
28
|
+
#### Rubygems
|
29
|
+
|
30
|
+
`gem install sensu-plugins-erlang`
|
31
|
+
|
32
|
+
#### Bundler
|
33
|
+
|
34
|
+
Add *sensu-plugins-erlang* to your Gemfile and run `bundle install` or `bundle update`
|
35
|
+
|
36
|
+
#### Chef
|
37
|
+
|
38
|
+
Using the Sensu **sensu_gem** LWRP
|
39
|
+
```
|
40
|
+
sensu_gem 'sensu-plugins-erlang' do
|
41
|
+
options('--prerelease')
|
42
|
+
version '0.0.1'
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
Using the Chef **gem_package** resource
|
47
|
+
```
|
48
|
+
gem_package 'sensu-plugins-erlang' do
|
49
|
+
options('--prerelease')
|
50
|
+
version '0.0.1'
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
## Notes
|
@@ -0,0 +1,174 @@
|
|
1
|
+
#!/usr/bin/env escript
|
2
|
+
%% -*- erlang -*-
|
3
|
+
%%
|
4
|
+
%% Simple (and mostly naive) script that connects to a remote Erlang node,
|
5
|
+
%% and checks process mailboxes, printing them in a Sensu compatible way
|
6
|
+
%% for checks
|
7
|
+
%%
|
8
|
+
%% Usage:
|
9
|
+
%% ./check-erlang-mailboxes.escript -c epic_erlang_cookie -n metrics@127.0.0.1 -r epic_erlang_app@127.0.0.1 -W 1000 -C 5000 -d true
|
10
|
+
%%
|
11
|
+
%% Copyright 2014 Panagiotis Papadomitsos <pj@ezgr.net>.
|
12
|
+
%%
|
13
|
+
%% Released under the same terms as Sensu (the MIT license); see LICENSE
|
14
|
+
%% for details.
|
15
|
+
|
16
|
+
%% #RED
|
17
|
+
main(Options) ->
|
18
|
+
ParsedOptions = parse_options(Options),
|
19
|
+
ok = set_local_node_name(ParsedOptions),
|
20
|
+
ok = set_connection_cookie(ParsedOptions),
|
21
|
+
ok = connect_to_remote_node(ParsedOptions),
|
22
|
+
ok = crawl_mailboxes(ParsedOptions),
|
23
|
+
halt(0).
|
24
|
+
|
25
|
+
usage() ->
|
26
|
+
io:format(standard_error, "Usage: ~s [-C CRITICAL] [-W WARNING] [-p PROCESSES] [-c COOKIE] [-n NODE_NAME] [-r REMOTE_NODE]~n~n", [escript:script_name()]),
|
27
|
+
io:format(standard_error, " -C CRITICAL The number of messages in a mailbox considered critical~n", []),
|
28
|
+
io:format(standard_error, " -W WARNING The number of messages in a mailbox considered warning level~n", []),
|
29
|
+
io:format(standard_error, " -c COOKIE Set the Erlang cookie~n", []),
|
30
|
+
io:format(standard_error, " -n NODE_NAME Set the Erlang node name (automatic short/long name detection)~n", []),
|
31
|
+
io:format(standard_error, " -r REMOTE_NODE Set the Erlang node to connect to~n", []),
|
32
|
+
io:format(standard_error, " -d true Enable debug mode to catch RPC call failures~n~n", []).
|
33
|
+
|
34
|
+
parse_options(Options) ->
|
35
|
+
parse_options(Options, []).
|
36
|
+
|
37
|
+
%% We consider you a sane person that will provide the appropriate parameters
|
38
|
+
%% along with the switches, so no sanity check here
|
39
|
+
parse_options([Option|Options], ParsedOptions) ->
|
40
|
+
case Option of
|
41
|
+
"-d" ->
|
42
|
+
[_Debug|NewOptions] = Options,
|
43
|
+
parse_options(NewOptions, [{debug, true}|ParsedOptions]);
|
44
|
+
"-C" ->
|
45
|
+
[Critical|NewOptions] = Options,
|
46
|
+
parse_options(NewOptions, [{critical, Critical}|ParsedOptions]);
|
47
|
+
"-W" ->
|
48
|
+
[Warning|NewOptions] = Options,
|
49
|
+
parse_options(NewOptions, [{warning, Warning}|ParsedOptions]);
|
50
|
+
"-c" ->
|
51
|
+
[Cookie|NewOptions] = Options,
|
52
|
+
parse_options(NewOptions, [{cookie, Cookie}|ParsedOptions]);
|
53
|
+
"-n" ->
|
54
|
+
[Node|NewOptions] = Options,
|
55
|
+
parse_options(NewOptions, [{node, Node}|ParsedOptions]);
|
56
|
+
"-r" ->
|
57
|
+
[Remote|NewOptions] = Options,
|
58
|
+
parse_options(NewOptions, [{remote, Remote}|ParsedOptions]);
|
59
|
+
"-h" ->
|
60
|
+
usage(),
|
61
|
+
halt(0);
|
62
|
+
_ ->
|
63
|
+
usage(),
|
64
|
+
io:format(standard_error, "Invalid option specified!~n", []),
|
65
|
+
halt(3)
|
66
|
+
end;
|
67
|
+
parse_options([], ParsedOptions) ->
|
68
|
+
if
|
69
|
+
length(ParsedOptions) < 1 ->
|
70
|
+
usage(),
|
71
|
+
halt(3);
|
72
|
+
true ->
|
73
|
+
ParsedOptions
|
74
|
+
end.
|
75
|
+
|
76
|
+
set_local_node_name(ParsedOptions) ->
|
77
|
+
Node = proplists:get_value(node, ParsedOptions, "sensucheck@localhost.localdomain"),
|
78
|
+
case lists:member($@, Node) of
|
79
|
+
true ->
|
80
|
+
net_kernel:start([list_to_atom(Node), longnames]);
|
81
|
+
false ->
|
82
|
+
net_kernel:start([list_to_atom(Node), shortnames])
|
83
|
+
end,
|
84
|
+
ok.
|
85
|
+
|
86
|
+
set_connection_cookie(ParsedOptions) ->
|
87
|
+
Cookie = proplists:get_value(cookie, ParsedOptions, "secret"),
|
88
|
+
erlang:set_cookie(node(), list_to_atom(Cookie)),
|
89
|
+
ok.
|
90
|
+
|
91
|
+
connect_to_remote_node(ParsedOptions) ->
|
92
|
+
RemoteNode = proplists:get_value(remote, ParsedOptions, "erlang@localhost.localdomain"),
|
93
|
+
case net_adm:ping(list_to_atom(RemoteNode)) of
|
94
|
+
pong ->
|
95
|
+
ok;
|
96
|
+
pang ->
|
97
|
+
io:format(standard_error, "Invalid remote node specified or a connection could not be made!~n", []),
|
98
|
+
halt(3)
|
99
|
+
end.
|
100
|
+
|
101
|
+
crawl_mailboxes(ParsedOptions) ->
|
102
|
+
RemoteNode = proplists:get_value(remote, ParsedOptions, "erlang@localhost.localdomain"),
|
103
|
+
Warning = case proplists:get_value(warning, ParsedOptions, 1000) of
|
104
|
+
W when is_list(W) -> list_to_integer(W);
|
105
|
+
W -> W
|
106
|
+
end,
|
107
|
+
Critical = case proplists:get_value(critical, ParsedOptions, 5000) of
|
108
|
+
C when is_list(C) -> list_to_integer(C);
|
109
|
+
C -> C
|
110
|
+
end,
|
111
|
+
RemoteNode = proplists:get_value(remote, ParsedOptions, "erlang@localhost.localdomain"),
|
112
|
+
Debug = proplists:get_value(debug, ParsedOptions, false),
|
113
|
+
try
|
114
|
+
ok = crawl_mailboxes(Warning, Critical, RemoteNode, Debug)
|
115
|
+
catch
|
116
|
+
throw:process_over_limits ->
|
117
|
+
ok;
|
118
|
+
throw:process_does_not_exist ->
|
119
|
+
ok
|
120
|
+
end,
|
121
|
+
ok.
|
122
|
+
|
123
|
+
crawl_mailboxes(Warning, Critical, RemoteNode, Debug) ->
|
124
|
+
case fetch_rpc_metric(RemoteNode, erlang, processes, [], Debug) of
|
125
|
+
error ->
|
126
|
+
warning("Could not connect to node ~s", [RemoteNode]),
|
127
|
+
throw(could_not_connect_to_node);
|
128
|
+
Processes when is_list(Processes) ->
|
129
|
+
lists:map(fun(Proc) ->
|
130
|
+
case fetch_rpc_metric(RemoteNode, erlang, process_info, [Proc, [registered_name, message_queue_len]], Debug) of
|
131
|
+
[{registered_name, []}, {message_queue_len, Mbox}] when Mbox >= Critical ->
|
132
|
+
critical("Message queue length for process ~p is ~B", [Proc, Mbox]),
|
133
|
+
throw(process_over_limits);
|
134
|
+
[{registered_name, Name}, {message_queue_len, Mbox}] when Mbox >= Critical ->
|
135
|
+
critical("Message queue length for process ~s (~p) is ~B", [Name, Proc, Mbox]),
|
136
|
+
throw(process_over_limits);
|
137
|
+
[{registered_name, []}, {message_queue_len, Mbox}] when Mbox >= Warning ->
|
138
|
+
warning("Message queue length for process ~p is ~B", [Proc, Mbox]),
|
139
|
+
throw(process_over_limits);
|
140
|
+
[{registered_name, Name}, {message_queue_len, Mbox}] when Mbox >= Warning ->
|
141
|
+
warning("Message queue length for process ~s (~p) is ~B", [Name, Proc, Mbox]),
|
142
|
+
throw(process_over_limits);
|
143
|
+
[{registered_name, _}, {message_queue_len, Mbox}] when Mbox < Warning ->
|
144
|
+
ok;
|
145
|
+
undefined ->
|
146
|
+
ok;
|
147
|
+
error ->
|
148
|
+
warning("Could not connect to node ~s", [RemoteNode]),
|
149
|
+
throw(could_not_connect_to_node)
|
150
|
+
end
|
151
|
+
end, Processes),
|
152
|
+
io:format("ErlCheck OK: All processes have mailboxes below limits~n")
|
153
|
+
end.
|
154
|
+
|
155
|
+
fetch_rpc_metric(Node, M, F, A, Debug) when is_list(Node) ->
|
156
|
+
fetch_rpc_metric(list_to_atom(Node), M, F, A, Debug);
|
157
|
+
fetch_rpc_metric(Node, M, F, A, Debug) when is_atom(Node), is_atom(M), is_atom(F), is_list(A), is_atom(Debug) ->
|
158
|
+
case rpc:call(Node, M, F, A) of
|
159
|
+
{badrpc, Reason} when Debug =:= true ->
|
160
|
+
io:format(standard_error, "RPC call failed with reason: ~p~n", [Reason]),
|
161
|
+
error;
|
162
|
+
{badrpc, _Reason} when Debug =:= false ->
|
163
|
+
error;
|
164
|
+
Result ->
|
165
|
+
Result
|
166
|
+
end.
|
167
|
+
|
168
|
+
warning(Message, Args) ->
|
169
|
+
io:format("ErlCheck WARNING: " ++ Message ++ "~n", Args),
|
170
|
+
ok.
|
171
|
+
|
172
|
+
critical(Message, Args) ->
|
173
|
+
io:format("ErlCheck CRITICAL: " ++ Message ++ "~n", Args),
|
174
|
+
ok.
|
@@ -0,0 +1,177 @@
|
|
1
|
+
#!/usr/bin/env escript
|
2
|
+
%% -*- erlang -*-
|
3
|
+
%%
|
4
|
+
%% Simple (and mostly naive) script that connects to a remote Erlang node,
|
5
|
+
%% fetches memory and process statistics and prints them in a Sensu compatible way
|
6
|
+
%% for metrics gathering (great for Graphite)
|
7
|
+
%%
|
8
|
+
%% Usage:
|
9
|
+
%% ./erlang_stats.erl -c epic_erlang_cookie -n metrics@127.0.0.1 -r epic_erlang_app@127.0.0.1 -s prod.epic_erlang_app -p named_process1 -d true
|
10
|
+
%%
|
11
|
+
%% Copyright 2013 Panagiotis Papadomitsos <pj@ezgr.net>.
|
12
|
+
%%
|
13
|
+
%% Released under the same terms as Sensu (the MIT license); see LICENSE
|
14
|
+
%% for details.
|
15
|
+
|
16
|
+
%% #RED
|
17
|
+
main(Options) ->
|
18
|
+
ParsedOptions = parse_options(Options),
|
19
|
+
ok = set_local_node_name(ParsedOptions),
|
20
|
+
ok = set_connection_cookie(ParsedOptions),
|
21
|
+
ok = connect_to_remote_node(ParsedOptions),
|
22
|
+
ok = collect_metrics(ParsedOptions),
|
23
|
+
halt(0).
|
24
|
+
|
25
|
+
usage() ->
|
26
|
+
io:format(standard_error, "Usage: ~s [-s SCHEME] [-c COOKIE] [-n NODE_NAME] [-r REMOTE_NODE]~n~n", [escript:script_name()]),
|
27
|
+
io:format(standard_error, " -s SCHEME Set the metric scheme (default: host FQDN)~n", []),
|
28
|
+
io:format(standard_error, " -p PROCESSES Set a comma-separated list of named processes to gather process info from~n", []),
|
29
|
+
io:format(standard_error, " -c COOKIE Set the Erlang cookie~n", []),
|
30
|
+
io:format(standard_error, " -n NODE_NAME Set the Erlang node name (automatic short/long name detection)~n", []),
|
31
|
+
io:format(standard_error, " -r REMOTE_NODE Set the Erlang node to connect to~n", []),
|
32
|
+
io:format(standard_error, " -d true Enable debug mode to catch RPC call failures~n~n", []).
|
33
|
+
|
34
|
+
parse_options(Options) ->
|
35
|
+
parse_options(Options, []).
|
36
|
+
|
37
|
+
%% We consider you a sane person that will provide the appropriate parameters
|
38
|
+
%% along with the switches, so no sanity check here
|
39
|
+
parse_options([Option|Options], ParsedOptions) ->
|
40
|
+
case Option of
|
41
|
+
"-s" ->
|
42
|
+
[Scheme|NewOptions] = Options,
|
43
|
+
parse_options(NewOptions, [{scheme, Scheme}|ParsedOptions]);
|
44
|
+
"-d" ->
|
45
|
+
[_Debug|NewOptions] = Options,
|
46
|
+
parse_options(NewOptions, [{debug, true}|ParsedOptions]);
|
47
|
+
"-p" ->
|
48
|
+
[ReadProcesses|NewOptions] = Options,
|
49
|
+
Processes = string:tokens(ReadProcesses, ","),
|
50
|
+
parse_options(NewOptions, [{processes, Processes}|ParsedOptions]);
|
51
|
+
"-c" ->
|
52
|
+
[Cookie|NewOptions] = Options,
|
53
|
+
parse_options(NewOptions, [{cookie, Cookie}|ParsedOptions]);
|
54
|
+
"-n" ->
|
55
|
+
[Node|NewOptions] = Options,
|
56
|
+
parse_options(NewOptions, [{node, Node}|ParsedOptions]);
|
57
|
+
"-r" ->
|
58
|
+
[Remote|NewOptions] = Options,
|
59
|
+
parse_options(NewOptions, [{remote, Remote}|ParsedOptions]);
|
60
|
+
"-h" ->
|
61
|
+
usage(),
|
62
|
+
halt(0);
|
63
|
+
_ ->
|
64
|
+
usage(),
|
65
|
+
io:format(standard_error, "Invalid option specified!~n", []),
|
66
|
+
halt(3)
|
67
|
+
end;
|
68
|
+
parse_options([], ParsedOptions) ->
|
69
|
+
if
|
70
|
+
length(ParsedOptions) < 1 ->
|
71
|
+
usage(),
|
72
|
+
halt(3);
|
73
|
+
true ->
|
74
|
+
ParsedOptions
|
75
|
+
end.
|
76
|
+
|
77
|
+
set_local_node_name(ParsedOptions) ->
|
78
|
+
Node = proplists:get_value(node, ParsedOptions, "metrics@localhost.localdomain"),
|
79
|
+
case lists:member($@, Node) of
|
80
|
+
true ->
|
81
|
+
net_kernel:start([list_to_atom(Node), longnames]);
|
82
|
+
false ->
|
83
|
+
net_kernel:start([list_to_atom(Node), shortnames])
|
84
|
+
end,
|
85
|
+
ok.
|
86
|
+
|
87
|
+
set_connection_cookie(ParsedOptions) ->
|
88
|
+
Cookie = proplists:get_value(cookie, ParsedOptions, "secret"),
|
89
|
+
erlang:set_cookie(node(), list_to_atom(Cookie)),
|
90
|
+
ok.
|
91
|
+
|
92
|
+
connect_to_remote_node(ParsedOptions) ->
|
93
|
+
RemoteNode = proplists:get_value(remote, ParsedOptions, "erlang@localhost.localdomain"),
|
94
|
+
case net_adm:ping(list_to_atom(RemoteNode)) of
|
95
|
+
pong ->
|
96
|
+
ok;
|
97
|
+
_OtherAnswer ->
|
98
|
+
io:format(standard_error, "Invalid remote node specified or a connection could not be made!~n", []),
|
99
|
+
halt(3)
|
100
|
+
end.
|
101
|
+
|
102
|
+
print_metric(Scheme, Category, Key, Value, Timestamp) when is_atom(Key) ->
|
103
|
+
print_metric(Scheme, Category, atom_to_list(Key), Value, Timestamp);
|
104
|
+
print_metric(Scheme, Category, Key, Value, Timestamp) when is_list(Key) ->
|
105
|
+
io:format("~s.~s.~s ~B ~B~n", [Scheme, Category, Key, Value, Timestamp]).
|
106
|
+
|
107
|
+
print_metric(Scheme, Key, Value, Timestamp) when is_atom(Key) ->
|
108
|
+
print_metric(Scheme, atom_to_list(Key), Value, Timestamp);
|
109
|
+
print_metric(Scheme, Key, Value, Timestamp) when is_list(Key) ->
|
110
|
+
io:format("~s.~s ~B ~B~n", [Scheme, Key, Value, Timestamp]).
|
111
|
+
|
112
|
+
fetch_rpc_metric(Node, M, F, A, Callback, Debug) when is_list(Node) ->
|
113
|
+
fetch_rpc_metric(list_to_atom(Node), M, F, A, Callback, Debug);
|
114
|
+
fetch_rpc_metric(Node, M, F, A, Callback, Debug) when is_atom(Node), is_atom(M), is_atom(F), is_list(A), is_function(Callback), is_atom(Debug) ->
|
115
|
+
case rpc:call(Node, M, F, A) of
|
116
|
+
{badrpc, Reason} when Debug =:= true ->
|
117
|
+
io:format(standard_error, "RPC call failed with reason: ~p~n", [Reason]),
|
118
|
+
error;
|
119
|
+
{badrpc, _Reason} when Debug =:= false ->
|
120
|
+
error;
|
121
|
+
Result ->
|
122
|
+
Callback(Result)
|
123
|
+
end.
|
124
|
+
|
125
|
+
collect_metrics(ParsedOptions) ->
|
126
|
+
Scheme = lists:flatten(proplists:get_value(scheme, ParsedOptions, element(2, inet:gethostname())), ".erlang"),
|
127
|
+
RemoteNode = proplists:get_value(remote, ParsedOptions, "erlang@localhost.localdomain"),
|
128
|
+
Debug = proplists:get_value(debug, ParsedOptions, false),
|
129
|
+
Processes = proplists:get_value(processes, ParsedOptions, []),
|
130
|
+
{Mega, Secs, _Micro} = erlang:now(),
|
131
|
+
Timestamp = Mega * 1000000 + Secs,
|
132
|
+
% Memory statistics
|
133
|
+
fetch_rpc_metric(RemoteNode, erlang, memory, [], fun(MemoryMetrics) ->
|
134
|
+
lists:foreach(fun({Key, Value}) ->
|
135
|
+
print_metric(Scheme, "memory", Key, Value, Timestamp)
|
136
|
+
end, MemoryMetrics)
|
137
|
+
end, Debug),
|
138
|
+
% Total number of processes
|
139
|
+
fetch_rpc_metric(RemoteNode, erlang, system_info, [process_count], fun(LiveProcesses) ->
|
140
|
+
print_metric(Scheme, "processes", LiveProcesses, Timestamp)
|
141
|
+
end, Debug),
|
142
|
+
% Context switches
|
143
|
+
fetch_rpc_metric(RemoteNode, erlang, statistics, [context_switches], fun({Switches, 0}) ->
|
144
|
+
print_metric(Scheme, "context_switches", Switches, Timestamp)
|
145
|
+
end, Debug),
|
146
|
+
% GC Metrics
|
147
|
+
fetch_rpc_metric(RemoteNode, erlang, statistics, [garbage_collection], fun({NumberofGCs, WordsReclaimed, 0}) ->
|
148
|
+
print_metric(Scheme, "number_of_gcs", NumberofGCs, Timestamp),
|
149
|
+
print_metric(Scheme, "words_reclaimed", WordsReclaimed, Timestamp)
|
150
|
+
end, Debug),
|
151
|
+
% I/O Metrics
|
152
|
+
fetch_rpc_metric(RemoteNode, erlang, statistics, [io], fun({{input, Input}, {output, Output}}) ->
|
153
|
+
print_metric(Scheme, "input_io_bytes", Input, Timestamp),
|
154
|
+
print_metric(Scheme, "output_io_bytes", Output, Timestamp)
|
155
|
+
end, Debug),
|
156
|
+
% Total number of scheduler reductions
|
157
|
+
fetch_rpc_metric(RemoteNode, erlang, statistics, [reductions], fun({TotalReductions, _ReductionsSinceLastCall}) ->
|
158
|
+
print_metric(Scheme, "reductions", TotalReductions, Timestamp)
|
159
|
+
end, Debug),
|
160
|
+
% Total nubmer of processes in the run_queue of each scheduler
|
161
|
+
fetch_rpc_metric(RemoteNode, erlang, statistics, [run_queue], fun(RunQueue) ->
|
162
|
+
print_metric(Scheme, "run_queue", RunQueue, Timestamp)
|
163
|
+
end, Debug),
|
164
|
+
% Process-specific info
|
165
|
+
lists:foreach(fun(Process) ->
|
166
|
+
fetch_rpc_metric(RemoteNode, erlang, whereis, [list_to_atom(Process)], fun(Pid) ->
|
167
|
+
fetch_rpc_metric(RemoteNode, erlang, process_info, [Pid], fun(ProcessInfo) ->
|
168
|
+
print_metric(Scheme, "process_info", Process ++ ".message_queue_len", proplists:get_value(message_queue_len, ProcessInfo, 0), Timestamp),
|
169
|
+
print_metric(Scheme, "process_info", Process ++ ".total_heap_size", proplists:get_value(total_heap_size, ProcessInfo, 0), Timestamp),
|
170
|
+
print_metric(Scheme, "process_info", Process ++ ".heap_size", proplists:get_value(heap_size, ProcessInfo, 0), Timestamp),
|
171
|
+
print_metric(Scheme, "process_info", Process ++ ".reductions", proplists:get_value(reductions, ProcessInfo, 0), Timestamp),
|
172
|
+
GCInfo = proplists:get_value(garbage_collection, ProcessInfo, []),
|
173
|
+
print_metric(Scheme, "process_info", Process ++ ".minor_gcs", proplists:get_value(minor_gcs, GCInfo, 0), Timestamp)
|
174
|
+
end, Debug)
|
175
|
+
end, Debug)
|
176
|
+
end, Processes),
|
177
|
+
ok.
|
metadata
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-erlang
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yieldbot, Inc. and contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
|
14
|
+
am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
|
15
|
+
A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
|
16
|
+
CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
|
17
|
+
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
|
18
|
+
CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
|
19
|
+
zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
|
20
|
+
qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
|
21
|
+
k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
|
22
|
+
oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
|
23
|
+
0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
24
|
+
HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
|
25
|
+
QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
|
26
|
+
MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
|
27
|
+
rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
|
28
|
+
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
|
29
|
+
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
|
30
|
+
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
|
+
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2015-04-11 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: codeclimate-test-reporter
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.4'
|
42
|
+
type: :development
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.4'
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rubocop
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.17.0
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.17.0
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rspec
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.1'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.1'
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: bundler
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.7'
|
84
|
+
type: :development
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '1.7'
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: rake
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '10.0'
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '10.0'
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: github-markup
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.3'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1.3'
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: redcarpet
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '3.2'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '3.2'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: yard
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0.8'
|
140
|
+
type: :development
|
141
|
+
prerelease: false
|
142
|
+
version_requirements: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0.8'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: pry
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0.10'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0.10'
|
161
|
+
description: Sensu plugins for erlang
|
162
|
+
email: "<sensu-users@googlegroups.com>"
|
163
|
+
executables: []
|
164
|
+
extensions: []
|
165
|
+
extra_rdoc_files: []
|
166
|
+
files:
|
167
|
+
- CHANGELOG.md
|
168
|
+
- LICENSE
|
169
|
+
- README.md
|
170
|
+
- bin/check-erlang-mailboxes.escript
|
171
|
+
- bin/metrics-erlang.escript
|
172
|
+
- lib/sensu-plugins-erlang.rb
|
173
|
+
homepage: https://github.com/sensu-plugins/sensu-plugins-erlang
|
174
|
+
licenses:
|
175
|
+
- MIT
|
176
|
+
metadata:
|
177
|
+
maintainer: ''
|
178
|
+
development_status: unmaintained
|
179
|
+
production_status: unstable - testing recommended
|
180
|
+
post_install_message:
|
181
|
+
rdoc_options: []
|
182
|
+
require_paths:
|
183
|
+
- lib
|
184
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: 1.9.3
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - ">"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: 1.3.1
|
194
|
+
requirements: []
|
195
|
+
rubyforge_project:
|
196
|
+
rubygems_version: 2.2.2
|
197
|
+
signing_key:
|
198
|
+
specification_version: 4
|
199
|
+
summary: Sensu plugins for erlang
|
200
|
+
test_files: []
|
201
|
+
has_rdoc:
|
metadata.gz.sig
ADDED
Binary file
|