zabby 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/LICENSE +49 -0
- data/README.rdoc +137 -0
- data/Rakefile +8 -0
- data/bin/zabbyrb +86 -0
- data/bin/zabbysh +68 -0
- data/doc/Zabby.html +208 -0
- data/doc/Zabby/AuthenticationError.html +116 -0
- data/doc/Zabby/Config.html +414 -0
- data/doc/Zabby/ConfigurationError.html +116 -0
- data/doc/Zabby/Connection.html +1617 -0
- data/doc/Zabby/ResponseCodeError.html +116 -0
- data/doc/Zabby/Runner.html +1116 -0
- data/doc/_index.html +175 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file.LICENSE.html +132 -0
- data/doc/file.README.html +234 -0
- data/doc/file_list.html +52 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +234 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +167 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +358 -0
- data/doc/top-level-namespace.html +103 -0
- data/lib/zabby.rb +25 -0
- data/lib/zabby/config.rb +38 -0
- data/lib/zabby/connection.rb +131 -0
- data/lib/zabby/exceptions.rb +10 -0
- data/lib/zabby/runner.rb +152 -0
- data/lib/zabby/version.rb +8 -0
- data/lib/zabby/zobject.rb +27 -0
- data/spec/spec_helper.rb +5 -0
- data/zabby.gemspec +31 -0
- metadata +170 -0
@@ -0,0 +1,132 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=fr_fr" />
|
6
|
+
<title>
|
7
|
+
File: LICENSE
|
8
|
+
|
9
|
+
— Documentation by YARD 0.7.4
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
relpath = '';
|
19
|
+
if (relpath != '') relpath += '/';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
25
|
+
|
26
|
+
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<script type="text/javascript" charset="utf-8">
|
30
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
+
</script>
|
32
|
+
|
33
|
+
<div id="header">
|
34
|
+
<div id="menu">
|
35
|
+
|
36
|
+
<a href="_index.html" title="Index">Index</a> »
|
37
|
+
<span class="title">File: LICENSE</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a id="class_list_link" href="#">Class List</a>
|
46
|
+
|
47
|
+
<a id="method_list_link" href="#">Method List</a>
|
48
|
+
|
49
|
+
<a id="file_list_link" href="#">File List</a>
|
50
|
+
|
51
|
+
</div>
|
52
|
+
<div class="clear"></div>
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<iframe id="search_frame"></iframe>
|
56
|
+
|
57
|
+
<div id="content"><div id='filecontents'><p>
|
58
|
+
Copyright 2011 Farzad FARID / Pragmatic Source. All rights reserved.
|
59
|
+
</p>
|
60
|
+
<p>
|
61
|
+
Redistribution and use in source and binary forms, with or without
|
62
|
+
modification, are permitted provided that the following conditions are met:
|
63
|
+
</p>
|
64
|
+
<pre class="code">
|
65
|
+
<span class='float val'>1</span><span class='dot token'>.</span> <span class='rubyid_Redistributions constant id'>Redistributions</span> <span class='rubyid_of identifier id'>of</span> <span class='rubyid_source identifier id'>source</span> <span class='rubyid_code identifier id'>code</span> <span class='rubyid_must identifier id'>must</span> <span class='rubyid_retain identifier id'>retain</span> <span class='rubyid_the identifier id'>the</span> <span class='rubyid_above identifier id'>above</span> <span class='rubyid_copyright identifier id'>copyright</span> <span class='rubyid_notice identifier id'>notice</span><span class='comma token'>,</span> <span class='rubyid_this identifier id'>this</span> <span class='rubyid_list identifier id'>list</span> <span class='rubyid_of identifier id'>of</span>
|
66
|
+
<span class='rubyid_conditions identifier id'>conditions</span> <span class='rubyid_and and kw'>and</span> <span class='rubyid_the identifier id'>the</span> <span class='rubyid_following identifier id'>following</span> <span class='rubyid_disclaimer identifier id'>disclaimer</span><span class='dot token'>.</span>
|
67
|
+
|
68
|
+
<span class='float val'>2</span><span class='dot token'>.</span> <span class='rubyid_Redistributions constant id'>Redistributions</span> <span class='rubyid_in in kw'>in</span> <span class='rubyid_binary identifier id'>binary</span> <span class='rubyid_form identifier id'>form</span> <span class='rubyid_must identifier id'>must</span> <span class='rubyid_reproduce identifier id'>reproduce</span> <span class='rubyid_the identifier id'>the</span> <span class='rubyid_above identifier id'>above</span> <span class='rubyid_copyright identifier id'>copyright</span> <span class='rubyid_notice identifier id'>notice</span><span class='comma token'>,</span> <span class='rubyid_this identifier id'>this</span> <span class='rubyid_list identifier id'>list</span>
|
69
|
+
<span class='rubyid_of identifier id'>of</span> <span class='rubyid_conditions identifier id'>conditions</span> <span class='rubyid_and and kw'>and</span> <span class='rubyid_the identifier id'>the</span> <span class='rubyid_following identifier id'>following</span> <span class='rubyid_disclaimer identifier id'>disclaimer</span> <span class='rubyid_in in kw'>in</span> <span class='rubyid_the identifier id'>the</span> <span class='rubyid_documentation identifier id'>documentation</span> <span class='rubyid_and and kw'>and</span><span class='regexp val'>/or other materials
|
70
|
+
provided with the distribution.
|
71
|
+
</span></pre>
|
72
|
+
<p>
|
73
|
+
THIS SOFTWARE IS PROVIDED BY PRAGMATIC SOURCE ’’AS
|
74
|
+
IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
75
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
76
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PRAGMATIC SOURCE OR
|
77
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
78
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
79
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
80
|
+
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
81
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
82
|
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
83
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
84
|
+
</p>
|
85
|
+
<p>
|
86
|
+
The views and conclusions contained in the software and documentation are
|
87
|
+
those of the authors and should not be interpreted as representing official
|
88
|
+
policies, either expressed or implied, of Pragmatic Source.
|
89
|
+
</p>
|
90
|
+
<p>
|
91
|
+
OTHER LICENSES COVERING PORTIONS OF CODE
|
92
|
+
</p>
|
93
|
+
<h6>==================================</h6>
|
94
|
+
<p>
|
95
|
+
Portions of code in "Zabbix::Running" were inspired by Rush
|
96
|
+
(https://github.com/adamwiggins/rush):
|
97
|
+
</p>
|
98
|
+
<p>
|
99
|
+
Copyright © 2010 Adam Wiggins
|
100
|
+
</p>
|
101
|
+
<p>
|
102
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
103
|
+
copy of this software and associated documentation files (the
|
104
|
+
"Software"), to deal in the Software without restriction,
|
105
|
+
including without limitation the rights to use, copy, modify, merge,
|
106
|
+
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
107
|
+
permit persons to whom the Software is furnished to do so, subject to the
|
108
|
+
following conditions:
|
109
|
+
</p>
|
110
|
+
<p>
|
111
|
+
The above copyright notice and this permission notice shall be included in
|
112
|
+
all copies or substantial portions of the Software.
|
113
|
+
</p>
|
114
|
+
<p>
|
115
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
116
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
117
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
118
|
+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
119
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
120
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
121
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
122
|
+
</p>
|
123
|
+
</div></div>
|
124
|
+
|
125
|
+
<div id="footer">
|
126
|
+
Generated on Mon Dec 19 13:31:45 2011 by
|
127
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
128
|
+
0.7.4 (ruby-1.8.7).
|
129
|
+
</div>
|
130
|
+
|
131
|
+
</body>
|
132
|
+
</html>
|
@@ -0,0 +1,234 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=fr_fr" />
|
6
|
+
<title>
|
7
|
+
File: README
|
8
|
+
|
9
|
+
— Documentation by YARD 0.7.4
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
relpath = '';
|
19
|
+
if (relpath != '') relpath += '/';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
25
|
+
|
26
|
+
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<script type="text/javascript" charset="utf-8">
|
30
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
+
</script>
|
32
|
+
|
33
|
+
<div id="header">
|
34
|
+
<div id="menu">
|
35
|
+
|
36
|
+
<a href="_index.html" title="Index">Index</a> »
|
37
|
+
<span class="title">File: README</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a id="class_list_link" href="#">Class List</a>
|
46
|
+
|
47
|
+
<a id="method_list_link" href="#">Method List</a>
|
48
|
+
|
49
|
+
<a id="file_list_link" href="#">File List</a>
|
50
|
+
|
51
|
+
</div>
|
52
|
+
<div class="clear"></div>
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<iframe id="search_frame"></iframe>
|
56
|
+
|
57
|
+
<div id="content"><div id='filecontents'><h1>Zabby</h1>
|
58
|
+
<p>
|
59
|
+
Zabby[http://zabby.org] is a Ruby library and client for
|
60
|
+
Zabbix[http://www.zabbix.com/]. It provides a simple and clean interface to
|
61
|
+
the Web Services[http://www.zabbix.com/documentation/1.8/api].
|
62
|
+
</p>
|
63
|
+
<h2>Goals</h2>
|
64
|
+
<p>
|
65
|
+
There already are Ruby Zabbix libraries but some of them are unfinished
|
66
|
+
(and apparently abandonned) and some other’s code is too complicated
|
67
|
+
or poorly designed. This is why I decided to write another tool for which
|
68
|
+
my primary goal is to keep the code design, the user interaction and
|
69
|
+
application interface clean and simple.
|
70
|
+
</p>
|
71
|
+
<p>
|
72
|
+
Zabby has the following caracteristics:
|
73
|
+
</p>
|
74
|
+
<ul>
|
75
|
+
<li>Works both as a Ruby API and a command line tool.
|
76
|
+
|
77
|
+
</li>
|
78
|
+
<li>Uses an internal Ruby DSL (Domain Specific Langage) that give access to the
|
79
|
+
full power of Ruby scripting in your configurarion files. No need for a
|
80
|
+
specific configuration language.
|
81
|
+
|
82
|
+
</li>
|
83
|
+
<li>Simple design: avoids spaghetti code, WTF and facepalm, unlike some other
|
84
|
+
Ruby Zabbix libraries.
|
85
|
+
|
86
|
+
</li>
|
87
|
+
</ul>
|
88
|
+
<h2>Examples</h2>
|
89
|
+
<h3>API use</h3>
|
90
|
+
<p>
|
91
|
+
The barebone API can be used in Ruby like this:
|
92
|
+
</p>
|
93
|
+
<pre class="code">
|
94
|
+
<span class='rubyid_require identifier id'>require</span> <span class='string val'>"rubygems"</span>
|
95
|
+
<span class='rubyid_require identifier id'>require</span> <span class='string val'>"zabby"</span>
|
96
|
+
<span class='rubyid_require identifier id'>require</span> <span class='string val'>"pp"</span>
|
97
|
+
|
98
|
+
<span class='rubyid_z identifier id'>z</span> <span class='assign token'>=</span> <span class='rubyid_Zabby constant id'>Zabby</span><span class='dot token'>.</span><span class='rubyid_init identifier id'>init</span> <span class='rubyid_do do kw'>do</span>
|
99
|
+
<span class='rubyid_host identifier id'>host</span> <span class='string val'>"https://monitoring.example.com"</span>
|
100
|
+
<span class='rubyid_user identifier id'>user</span> <span class='string val'>"api_user"</span>
|
101
|
+
<span class='rubyid_password identifier id'>password</span> <span class='string val'>"s3cr3t"</span>
|
102
|
+
<span class='rubyid_proxy_host identifier id'>proxy_host</span> <span class='string val'>"http://10.10.10.10"</span>
|
103
|
+
<span class='rubyid_proxy_user identifier id'>proxy_user</span> <span class='string val'>"john"</span>
|
104
|
+
<span class='rubyid_proxy_password identifier id'>proxy_password</span> <span class='string val'>"D0e"</span>
|
105
|
+
<span class='rubyid_end end kw'>end</span>
|
106
|
+
<span class='rubyid_z identifier id'>z</span><span class='dot token'>.</span><span class='rubyid_login identifier id'>login</span>
|
107
|
+
|
108
|
+
<span class='rubyid_pp identifier id'>pp</span> <span class='rubyid_z identifier id'>z</span><span class='dot token'>.</span><span class='rubyid_connection identifier id'>connection</span><span class='dot token'>.</span><span class='rubyid_perform_request identifier id'>perform_request</span><span class='lparen token'>(</span><span class='string val'>"host"</span><span class='comma token'>,</span> <span class='string val'>"get"</span><span class='comma token'>,</span> <span class='lbrace token'>{</span> <span class='string val'>"filter"</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='lbrace token'>{</span> <span class='string val'>"host"</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>"master.example.com"</span> <span class='rbrace token'>}</span> <span class='rbrace token'>}</span><span class='rparen token'>)</span>
|
109
|
+
<span class='rubyid_pp identifier id'>pp</span> <span class='rubyid_z identifier id'>z</span><span class='dot token'>.</span><span class='rubyid_connection identifier id'>connection</span><span class='dot token'>.</span><span class='rubyid_perform_request identifier id'>perform_request</span><span class='lparen token'>(</span><span class='string val'>"item"</span><span class='comma token'>,</span> <span class='string val'>"get"</span><span class='comma token'>,</span> <span class='lbrace token'>{</span> <span class='string val'>"host"</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>"master.example.com"</span><span class='comma token'>,</span> <span class='string val'>"output"</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>"shorten"</span> <span class='rbrace token'>}</span><span class='rparen token'>)</span>
|
110
|
+
</pre>
|
111
|
+
<ul>
|
112
|
+
<li>The <em>host</em>, <em>user</em> and <em>passord</em> are necessary.
|
113
|
+
|
114
|
+
</li>
|
115
|
+
<li>If you don’t provide the path to the JSON-RPC script
|
116
|
+
"/api_jsonrpc.php" is appended to the URI automatically.
|
117
|
+
|
118
|
+
</li>
|
119
|
+
<li>The <em>proxy_*</em> settings are optionnal.
|
120
|
+
|
121
|
+
</li>
|
122
|
+
</ul>
|
123
|
+
<h3>Shell (experimental)</h3>
|
124
|
+
<p>
|
125
|
+
<b>zabbysh</b> is an experimental Zabbix Shell. It runs either
|
126
|
+
interactively or can be used to execute a command file with the "-f
|
127
|
+
CMD_FILE" option.
|
128
|
+
</p>
|
129
|
+
<p>
|
130
|
+
If the command file does not end with "exit" then the program
|
131
|
+
drops into the shell after executing the file.
|
132
|
+
</p>
|
133
|
+
<h4>Interactive shell</h4>
|
134
|
+
<pre class="code">
|
135
|
+
<span class='comment val'># zabbysh</span>
|
136
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_host identifier id'>host</span> <span class='string val'>"https://monitoring.example.com"</span>
|
137
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_user identifier id'>user</span> <span class='string val'>"api_user"</span>
|
138
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_password identifier id'>password</span> <span class='string val'>"s3cr3t"</span>
|
139
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_proxy_host identifier id'>proxy_host</span> <span class='string val'>"http://10.10.10.10"</span>
|
140
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_proxy_user identifier id'>proxy_user</span> <span class='string val'>"john"</span>
|
141
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_proxy_password identifier id'>proxy_password</span> <span class='string val'>"prD0e"</span>
|
142
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_login identifier id'>login</span>
|
143
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_logged_in? fid id'>logged_in?</span>
|
144
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='lbrack token'>[</span><span class='dot3 op'>...</span><span class='rbrack token'>]</span>
|
145
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_logout identifier id'>logout</span>
|
146
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_exit identifier id'>exit</span>
|
147
|
+
</pre>
|
148
|
+
<h4>Execute a command script</h4>
|
149
|
+
<p>
|
150
|
+
Create a file and put the same instructions as above in it, then execute
|
151
|
+
<b>zabbysh</b>:
|
152
|
+
</p>
|
153
|
+
<pre class="code">
|
154
|
+
<span class='comment val'># zabbysh --file my_zabbix_commands.txt</span>
|
155
|
+
</pre>
|
156
|
+
<h2>Requirements</h2>
|
157
|
+
<ul>
|
158
|
+
<li>Ruby 1.8.7. May run on Ruby 1.8.5
|
159
|
+
|
160
|
+
</li>
|
161
|
+
<li>JSON library: json_pure
|
162
|
+
|
163
|
+
</li>
|
164
|
+
<li>OptionParser
|
165
|
+
|
166
|
+
</li>
|
167
|
+
<li>Readline (optionnal, used by the interactive shell)
|
168
|
+
|
169
|
+
</li>
|
170
|
+
</ul>
|
171
|
+
<h2>References</h2>
|
172
|
+
<ul>
|
173
|
+
<li>Main web site: http://zabby.org
|
174
|
+
|
175
|
+
</li>
|
176
|
+
<li>GitHub projet: https://github.com/Pragmatic-Source/zabby
|
177
|
+
|
178
|
+
</li>
|
179
|
+
</ul>
|
180
|
+
<h2>Author</h2>
|
181
|
+
<p>
|
182
|
+
Farzad FARID mailto:ffarid@pragmatic-source.com
|
183
|
+
</p>
|
184
|
+
<p>
|
185
|
+
Thanks to:
|
186
|
+
</p>
|
187
|
+
<ul>
|
188
|
+
<li>Jean-Hadrien Chabran (jhchabran): Advices on code design.
|
189
|
+
|
190
|
+
</li>
|
191
|
+
<li>Nicolas Blanco (slainer68): Advices on code design and Triple Facepalming
|
192
|
+
after reading other Ruby/Zabbix code.
|
193
|
+
|
194
|
+
</li>
|
195
|
+
<li>Renaud Chaput (renchap): For suggesting the "zabby" name.
|
196
|
+
|
197
|
+
</li>
|
198
|
+
</ul>
|
199
|
+
<h3>Sources of inspiration</h3>
|
200
|
+
<ul>
|
201
|
+
<li>Adam Wiggins’s Rush[https://github.com/adamwiggins/rush] for the
|
202
|
+
interactive shell.
|
203
|
+
|
204
|
+
</li>
|
205
|
+
<li>Other Zabbix Ruby libraries (only the good parts ;) ):
|
206
|
+
|
207
|
+
</li>
|
208
|
+
</ul>
|
209
|
+
<table>
|
210
|
+
<tr><td valign="top">zabcon[http://trac.red-tux.net/]:</td><td>Zabcon is a command line interface for Zabbix written in Ruby
|
211
|
+
|
212
|
+
</td></tr>
|
213
|
+
<tr><td valign="top">rzabbix[http://github.com/neerfri/rzabbix]:</td><td>Zabbix API client for Ruby
|
214
|
+
|
215
|
+
</td></tr>
|
216
|
+
<tr><td valign="top">rubix[https://github.com/dhruvbansal/rubix]:</td><td>Rubix is a Ruby client for Zabbix
|
217
|
+
|
218
|
+
</td></tr>
|
219
|
+
</table>
|
220
|
+
<h2>License</h2>
|
221
|
+
<p>
|
222
|
+
This software is release under the <b>Simplified BSD license</b>. See the
|
223
|
+
LICENSE file.
|
224
|
+
</p>
|
225
|
+
</div></div>
|
226
|
+
|
227
|
+
<div id="footer">
|
228
|
+
Generated on Mon Dec 19 13:31:45 2011 by
|
229
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
230
|
+
0.7.4 (ruby-1.8.7).
|
231
|
+
</div>
|
232
|
+
|
233
|
+
</body>
|
234
|
+
</html>
|
data/doc/file_list.html
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=fr_fr" />
|
6
|
+
|
7
|
+
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
|
+
|
17
|
+
|
18
|
+
<base id="base_target" target="_parent" />
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
<script type="text/javascript" charset="utf-8">
|
22
|
+
if (window.top.frames.main) {
|
23
|
+
document.getElementById('base_target').target = 'main';
|
24
|
+
document.body.className = 'frames';
|
25
|
+
}
|
26
|
+
</script>
|
27
|
+
<div id="content">
|
28
|
+
<h1 id="full_list_header">File List</h1>
|
29
|
+
<div id="nav">
|
30
|
+
|
31
|
+
<a target="_self" href="class_list.html">Classes</a>
|
32
|
+
|
33
|
+
<a target="_self" href="method_list.html">Methods</a>
|
34
|
+
|
35
|
+
<a target="_self" href="file_list.html">Files</a>
|
36
|
+
|
37
|
+
</div>
|
38
|
+
<div id="search">Search: <input type="text" /></div>
|
39
|
+
|
40
|
+
<ul id="full_list" class="files">
|
41
|
+
|
42
|
+
|
43
|
+
<li class="r1"><a href="index.html" title="README">README</a></li>
|
44
|
+
|
45
|
+
|
46
|
+
<li class="r2"><a href="file.LICENSE.html" title="LICENSE">LICENSE</a></li>
|
47
|
+
|
48
|
+
|
49
|
+
</ul>
|
50
|
+
</div>
|
51
|
+
</body>
|
52
|
+
</html>
|
data/doc/frames.html
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=fr_fr"/>
|
7
|
+
<title>Documentation by YARD 0.7.4</title>
|
8
|
+
</head>
|
9
|
+
<frameset cols="20%,*">
|
10
|
+
<frame name="list" src="class_list.html" />
|
11
|
+
<frame name="main" src="index.html" />
|
12
|
+
</frameset>
|
13
|
+
</html>
|
data/doc/index.html
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=fr_fr" />
|
6
|
+
<title>
|
7
|
+
File: README
|
8
|
+
|
9
|
+
— Documentation by YARD 0.7.4
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
relpath = '';
|
19
|
+
if (relpath != '') relpath += '/';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
25
|
+
|
26
|
+
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<script type="text/javascript" charset="utf-8">
|
30
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
+
</script>
|
32
|
+
|
33
|
+
<div id="header">
|
34
|
+
<div id="menu">
|
35
|
+
|
36
|
+
<a href="_index.html" title="Index">Index</a> »
|
37
|
+
<span class="title">File: README</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a id="class_list_link" href="#">Class List</a>
|
46
|
+
|
47
|
+
<a id="method_list_link" href="#">Method List</a>
|
48
|
+
|
49
|
+
<a id="file_list_link" href="#">File List</a>
|
50
|
+
|
51
|
+
</div>
|
52
|
+
<div class="clear"></div>
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<iframe id="search_frame"></iframe>
|
56
|
+
|
57
|
+
<div id="content"><div id='filecontents'><h1>Zabby</h1>
|
58
|
+
<p>
|
59
|
+
Zabby[http://zabby.org] is a Ruby library and client for
|
60
|
+
Zabbix[http://www.zabbix.com/]. It provides a simple and clean interface to
|
61
|
+
the Web Services[http://www.zabbix.com/documentation/1.8/api].
|
62
|
+
</p>
|
63
|
+
<h2>Goals</h2>
|
64
|
+
<p>
|
65
|
+
There already are Ruby Zabbix libraries but some of them are unfinished
|
66
|
+
(and apparently abandonned) and some other’s code is too complicated
|
67
|
+
or poorly designed. This is why I decided to write another tool for which
|
68
|
+
my primary goal is to keep the code design, the user interaction and
|
69
|
+
application interface clean and simple.
|
70
|
+
</p>
|
71
|
+
<p>
|
72
|
+
Zabby has the following caracteristics:
|
73
|
+
</p>
|
74
|
+
<ul>
|
75
|
+
<li>Works both as a Ruby API and a command line tool.
|
76
|
+
|
77
|
+
</li>
|
78
|
+
<li>Uses an internal Ruby DSL (Domain Specific Langage) that give access to the
|
79
|
+
full power of Ruby scripting in your configurarion files. No need for a
|
80
|
+
specific configuration language.
|
81
|
+
|
82
|
+
</li>
|
83
|
+
<li>Simple design: avoids spaghetti code, WTF and facepalm, unlike some other
|
84
|
+
Ruby Zabbix libraries.
|
85
|
+
|
86
|
+
</li>
|
87
|
+
</ul>
|
88
|
+
<h2>Examples</h2>
|
89
|
+
<h3>API use</h3>
|
90
|
+
<p>
|
91
|
+
The barebone API can be used in Ruby like this:
|
92
|
+
</p>
|
93
|
+
<pre class="code">
|
94
|
+
<span class='rubyid_require identifier id'>require</span> <span class='string val'>"rubygems"</span>
|
95
|
+
<span class='rubyid_require identifier id'>require</span> <span class='string val'>"zabby"</span>
|
96
|
+
<span class='rubyid_require identifier id'>require</span> <span class='string val'>"pp"</span>
|
97
|
+
|
98
|
+
<span class='rubyid_z identifier id'>z</span> <span class='assign token'>=</span> <span class='rubyid_Zabby constant id'>Zabby</span><span class='dot token'>.</span><span class='rubyid_init identifier id'>init</span> <span class='rubyid_do do kw'>do</span>
|
99
|
+
<span class='rubyid_host identifier id'>host</span> <span class='string val'>"https://monitoring.example.com"</span>
|
100
|
+
<span class='rubyid_user identifier id'>user</span> <span class='string val'>"api_user"</span>
|
101
|
+
<span class='rubyid_password identifier id'>password</span> <span class='string val'>"s3cr3t"</span>
|
102
|
+
<span class='rubyid_proxy_host identifier id'>proxy_host</span> <span class='string val'>"http://10.10.10.10"</span>
|
103
|
+
<span class='rubyid_proxy_user identifier id'>proxy_user</span> <span class='string val'>"john"</span>
|
104
|
+
<span class='rubyid_proxy_password identifier id'>proxy_password</span> <span class='string val'>"D0e"</span>
|
105
|
+
<span class='rubyid_end end kw'>end</span>
|
106
|
+
<span class='rubyid_z identifier id'>z</span><span class='dot token'>.</span><span class='rubyid_login identifier id'>login</span>
|
107
|
+
|
108
|
+
<span class='rubyid_pp identifier id'>pp</span> <span class='rubyid_z identifier id'>z</span><span class='dot token'>.</span><span class='rubyid_connection identifier id'>connection</span><span class='dot token'>.</span><span class='rubyid_perform_request identifier id'>perform_request</span><span class='lparen token'>(</span><span class='string val'>"host"</span><span class='comma token'>,</span> <span class='string val'>"get"</span><span class='comma token'>,</span> <span class='lbrace token'>{</span> <span class='string val'>"filter"</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='lbrace token'>{</span> <span class='string val'>"host"</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>"master.example.com"</span> <span class='rbrace token'>}</span> <span class='rbrace token'>}</span><span class='rparen token'>)</span>
|
109
|
+
<span class='rubyid_pp identifier id'>pp</span> <span class='rubyid_z identifier id'>z</span><span class='dot token'>.</span><span class='rubyid_connection identifier id'>connection</span><span class='dot token'>.</span><span class='rubyid_perform_request identifier id'>perform_request</span><span class='lparen token'>(</span><span class='string val'>"item"</span><span class='comma token'>,</span> <span class='string val'>"get"</span><span class='comma token'>,</span> <span class='lbrace token'>{</span> <span class='string val'>"host"</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>"master.example.com"</span><span class='comma token'>,</span> <span class='string val'>"output"</span> <span class='assign token'>=</span><span class='gt op'>></span> <span class='string val'>"shorten"</span> <span class='rbrace token'>}</span><span class='rparen token'>)</span>
|
110
|
+
</pre>
|
111
|
+
<ul>
|
112
|
+
<li>The <em>host</em>, <em>user</em> and <em>passord</em> are necessary.
|
113
|
+
|
114
|
+
</li>
|
115
|
+
<li>If you don’t provide the path to the JSON-RPC script
|
116
|
+
"/api_jsonrpc.php" is appended to the URI automatically.
|
117
|
+
|
118
|
+
</li>
|
119
|
+
<li>The <em>proxy_*</em> settings are optionnal.
|
120
|
+
|
121
|
+
</li>
|
122
|
+
</ul>
|
123
|
+
<h3>Shell (experimental)</h3>
|
124
|
+
<p>
|
125
|
+
<b>zabbysh</b> is an experimental Zabbix Shell. It runs either
|
126
|
+
interactively or can be used to execute a command file with the "-f
|
127
|
+
CMD_FILE" option.
|
128
|
+
</p>
|
129
|
+
<p>
|
130
|
+
If the command file does not end with "exit" then the program
|
131
|
+
drops into the shell after executing the file.
|
132
|
+
</p>
|
133
|
+
<h4>Interactive shell</h4>
|
134
|
+
<pre class="code">
|
135
|
+
<span class='comment val'># zabbysh</span>
|
136
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_host identifier id'>host</span> <span class='string val'>"https://monitoring.example.com"</span>
|
137
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_user identifier id'>user</span> <span class='string val'>"api_user"</span>
|
138
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_password identifier id'>password</span> <span class='string val'>"s3cr3t"</span>
|
139
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_proxy_host identifier id'>proxy_host</span> <span class='string val'>"http://10.10.10.10"</span>
|
140
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_proxy_user identifier id'>proxy_user</span> <span class='string val'>"john"</span>
|
141
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_set identifier id'>set</span> <span class='rubyid_proxy_password identifier id'>proxy_password</span> <span class='string val'>"prD0e"</span>
|
142
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_login identifier id'>login</span>
|
143
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_logged_in? fid id'>logged_in?</span>
|
144
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='lbrack token'>[</span><span class='dot3 op'>...</span><span class='rbrack token'>]</span>
|
145
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_logout identifier id'>logout</span>
|
146
|
+
<span class='rubyid_zabby identifier id'>zabby</span><span class='gt op'>></span> <span class='rubyid_exit identifier id'>exit</span>
|
147
|
+
</pre>
|
148
|
+
<h4>Execute a command script</h4>
|
149
|
+
<p>
|
150
|
+
Create a file and put the same instructions as above in it, then execute
|
151
|
+
<b>zabbysh</b>:
|
152
|
+
</p>
|
153
|
+
<pre class="code">
|
154
|
+
<span class='comment val'># zabbysh --file my_zabbix_commands.txt</span>
|
155
|
+
</pre>
|
156
|
+
<h2>Requirements</h2>
|
157
|
+
<ul>
|
158
|
+
<li>Ruby 1.8.7. May run on Ruby 1.8.5
|
159
|
+
|
160
|
+
</li>
|
161
|
+
<li>JSON library: json_pure
|
162
|
+
|
163
|
+
</li>
|
164
|
+
<li>OptionParser
|
165
|
+
|
166
|
+
</li>
|
167
|
+
<li>Readline (optionnal, used by the interactive shell)
|
168
|
+
|
169
|
+
</li>
|
170
|
+
</ul>
|
171
|
+
<h2>References</h2>
|
172
|
+
<ul>
|
173
|
+
<li>Main web site: http://zabby.org
|
174
|
+
|
175
|
+
</li>
|
176
|
+
<li>GitHub projet: https://github.com/Pragmatic-Source/zabby
|
177
|
+
|
178
|
+
</li>
|
179
|
+
</ul>
|
180
|
+
<h2>Author</h2>
|
181
|
+
<p>
|
182
|
+
Farzad FARID mailto:ffarid@pragmatic-source.com
|
183
|
+
</p>
|
184
|
+
<p>
|
185
|
+
Thanks to:
|
186
|
+
</p>
|
187
|
+
<ul>
|
188
|
+
<li>Jean-Hadrien Chabran (jhchabran): Advices on code design.
|
189
|
+
|
190
|
+
</li>
|
191
|
+
<li>Nicolas Blanco (slainer68): Advices on code design and Triple Facepalming
|
192
|
+
after reading other Ruby/Zabbix code.
|
193
|
+
|
194
|
+
</li>
|
195
|
+
<li>Renaud Chaput (renchap): For suggesting the "zabby" name.
|
196
|
+
|
197
|
+
</li>
|
198
|
+
</ul>
|
199
|
+
<h3>Sources of inspiration</h3>
|
200
|
+
<ul>
|
201
|
+
<li>Adam Wiggins’s Rush[https://github.com/adamwiggins/rush] for the
|
202
|
+
interactive shell.
|
203
|
+
|
204
|
+
</li>
|
205
|
+
<li>Other Zabbix Ruby libraries (only the good parts ;) ):
|
206
|
+
|
207
|
+
</li>
|
208
|
+
</ul>
|
209
|
+
<table>
|
210
|
+
<tr><td valign="top">zabcon[http://trac.red-tux.net/]:</td><td>Zabcon is a command line interface for Zabbix written in Ruby
|
211
|
+
|
212
|
+
</td></tr>
|
213
|
+
<tr><td valign="top">rzabbix[http://github.com/neerfri/rzabbix]:</td><td>Zabbix API client for Ruby
|
214
|
+
|
215
|
+
</td></tr>
|
216
|
+
<tr><td valign="top">rubix[https://github.com/dhruvbansal/rubix]:</td><td>Rubix is a Ruby client for Zabbix
|
217
|
+
|
218
|
+
</td></tr>
|
219
|
+
</table>
|
220
|
+
<h2>License</h2>
|
221
|
+
<p>
|
222
|
+
This software is release under the <b>Simplified BSD license</b>. See the
|
223
|
+
LICENSE file.
|
224
|
+
</p>
|
225
|
+
</div></div>
|
226
|
+
|
227
|
+
<div id="footer">
|
228
|
+
Generated on Mon Dec 19 13:31:45 2011 by
|
229
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
230
|
+
0.7.4 (ruby-1.8.7).
|
231
|
+
</div>
|
232
|
+
|
233
|
+
</body>
|
234
|
+
</html>
|