zabbix-api-simple 0.1.0 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,75 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: CHANGELOG
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "CHANGELOG";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: CHANGELOG</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>
61
+ <h1 id="label-0.1.4">0.1.4</h1>
62
+ <ul><li>
63
+ <p>Just doc changes</p>
64
+ </li></ul>
65
+ </div></div>
66
+
67
+ <div id="footer">
68
+ Generated on Sat Sep 11 20:08:37 2021 by
69
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
70
+ 0.9.26 (ruby-2.7.4).
71
+ </div>
72
+
73
+ </div>
74
+ </body>
75
+ </html>
@@ -0,0 +1,70 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: LICENSE
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "LICENSE";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: LICENSE</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>MIT License<br/><br/>Copyright (c) 2021 David Parker<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the &quot;Software&quot;), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in all<br/>copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br/>SOFTWARE.</div></div>
61
+
62
+ <div id="footer">
63
+ Generated on Sat Sep 11 20:08:37 2021 by
64
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
65
+ 0.9.26 (ruby-2.7.4).
66
+ </div>
67
+
68
+ </div>
69
+ </body>
70
+ </html>
@@ -0,0 +1,190 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>
61
+ <h1 id="label-Zabbix-3A-3AApi+rdoc-image-3Ahttps-3A-2F-2Fbadge.fury.io-2Frb-2Fzabbix-api-simple.svg">Zabbix::Api <a href="https://badge.fury.io/rb/zabbix-api-simple"><img src="https://badge.fury.io/rb/zabbix-api-simple.svg"></a></h1>
62
+
63
+ <p>This zabbix api implementation for Ruby strives for three things:</p>
64
+ <ul><li>
65
+ <p>To the greatest extent possible, be syntactically &amp; structurally identical to the API as it is described in the Zabbix documentation</p>
66
+ </li><li>
67
+ <p>Be API version agnostic</p>
68
+ </li><li>
69
+ <p>Be internally simple, unobtrusive, and low-maintenance</p>
70
+ </li></ul>
71
+
72
+ <p>It accomplishes these goals primarily by deferring (via Faraday) to the Zabbix API itself for just about everything - it does not attempt to re-create or otherwise “fancy-up” the API. The reasoning behind this is that the zabbix api itself is complex enough, and the Zabbix project can alter the specifics of the api at any time. This library just provides Ruby semantics that closely follow the API specification. The advantage to you is that you do not need to wrap your head around two APIs (the Zabbix API proper, and the API library&#39;s API)</p>
73
+
74
+ <p><strong>Detailed documentation for this library is <a href="https://svdasein.gitlab.io/zabbix-api">>>HERE<<</a></strong></p>
75
+
76
+ <p><strong>Source repository is <a href="https://gitlab.com/svdasein/zabbix-api">>>HERE<<</a></strong></p>
77
+
78
+ <p>If you need to send data into Zabbix via the “Zabbix trapper” protocol, you might also be interested in <a href="https://svdasein.gitlab.io/zabbix_sender_api">zabbix_sender_api</a></p>
79
+
80
+ <h2 id="label-Installation">Installation</h2>
81
+
82
+ <p>Add this line to your application&#39;s Gemfile:</p>
83
+
84
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>zabbix-api-simple</span><span class='tstring_end'>&#39;</span></span>
85
+ </code></pre>
86
+
87
+ <p>And then execute:</p>
88
+
89
+ <pre class="code ruby"><code class="ruby">$ bundle install
90
+ </code></pre>
91
+
92
+ <p>Or install it yourself as:</p>
93
+
94
+ <pre class="code ruby"><code class="ruby">$ gem install zabbix-api-simple
95
+ </code></pre>
96
+
97
+ <h2 id="label-Usage">Usage</h2>
98
+
99
+ <p>Once you have an authenticated instance of the client, syntax is basically always this:</p>
100
+
101
+ <p><code>clientinstance.object.verb(&lt;param kv pairs&gt;)</code></p>
102
+
103
+ <p>If “object” is unknown, “Unknown zabbix object given” will be raised.</p>
104
+
105
+ <p>If this call results in an error from the API, a RuntimeError will be raised indicating the specifics.</p>
106
+
107
+ <p>Complete detail about the last transaction you attempted is available via <code>clientinstance.last</code></p>
108
+
109
+ <p>e.g.:</p>
110
+
111
+ <pre class="code ruby"><code class="ruby"><span class='comment'>#!/usr/bin/env ruby
112
+ </span><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>zabbix/api</span><span class='tstring_end'>&#39;</span></span>
113
+ <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>optimist</span><span class='tstring_end'>&#39;</span></span>
114
+ <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>amazing_print</span><span class='tstring_end'>&#39;</span></span>
115
+
116
+
117
+
118
+ <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='const'>Optimist</span><span class='op'>::</span><span class='id identifier rubyid_options'>options</span> <span class='kw'>do</span>
119
+ <span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:url</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>URL up to but no including api_jsonrpc.php</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span><span class='label'>type:</span> <span class='symbol'>:string</span><span class='comma'>,</span><span class='label'>default:</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://localhost</span><span class='tstring_end'>&#39;</span></span>
120
+ <span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:user</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>User name to authenticate</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='symbol'>:string</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>true</span>
121
+ <span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:pass</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Pass to auth user with</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='symbol'>:string</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>true</span>
122
+ <span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:hostname</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Host name to search for</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='symbol'>:string</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>true</span>
123
+ <span class='kw'>end</span>
124
+
125
+ <span class='id identifier rubyid_api'>api</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Zabbix.html" title="Zabbix (module)">Zabbix</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Zabbix/Api.html" title="Zabbix::Api (module)">Api</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Zabbix/Api/Client.html" title="Zabbix::Api::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Zabbix/Api/Client.html#initialize-instance_method" title="Zabbix::Api::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>url:</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:url</span><span class='rbracket'>]</span><span class='rparen'>)</span>
126
+
127
+ <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_login'>login</span><span class='lparen'>(</span><span class='label'>user:</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:user</span><span class='rbracket'>]</span><span class='comma'>,</span><span class='label'>pass:</span><span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:pass</span><span class='rbracket'>]</span><span class='rparen'>)</span>
128
+
129
+ <span class='id identifier rubyid_hosts'>hosts</span> <span class='op'>=</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='label'>search:</span> <span class='lbrace'>{</span><span class='label'>host:</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:hostname</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'># return value is an OpenStruct
130
+ </span>
131
+ <span class='id identifier rubyid_hosts'>hosts</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_host'>host</span><span class='op'>|</span>
132
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span>
133
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_hostid'>hostid</span>
134
+
135
+ <span class='id identifier rubyid_ap'>ap</span> <span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span>
136
+ <span class='rbrace'>}</span>
137
+
138
+
139
+ <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span>
140
+ <span class='label'>host:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>mynewhost</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
141
+ <span class='label'>interfaces:</span> <span class='lbrace'>{</span>
142
+ <span class='label'>type:</span> <span class='int'>1</span><span class='comma'>,</span>
143
+ <span class='label'>main:</span> <span class='int'>1</span><span class='comma'>,</span>
144
+ <span class='label'>useip:</span> <span class='int'>1</span><span class='comma'>,</span>
145
+ <span class='label'>ip:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>1.2.3.4</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
146
+ <span class='label'>dns:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
147
+ <span class='label'>port:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>10050</span><span class='tstring_end'>&quot;</span></span>
148
+ <span class='rbrace'>}</span><span class='comma'>,</span>
149
+ <span class='label'>groups:</span> <span class='lbrace'>{</span><span class='label'>groupid:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>42</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
150
+ <span class='rparen'>)</span>
151
+
152
+ <span class='id identifier rubyid_ap'>ap</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span> <span class='comment'># shows detail of the last transaction
153
+ </span>
154
+ <span class='id identifier rubyid_ap'>ap</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_logout'>logout</span>
155
+ </code></pre>
156
+
157
+ <p>There&#39;s a little cli program that gets installed with the gem called zapishell.rb:</p>
158
+
159
+ <pre class="code ruby"><code class="ruby"># zapishell.rb --help
160
+ Options:
161
+ -u, --url=&lt;s&gt; URL up to but no including api_jsonrpc.php (default: http://localhost)
162
+ -s, --user=&lt;s&gt; User name to authenticate
163
+ -p, --pass=&lt;s&gt; Pass to auth user with
164
+ -h, --help Show this message
165
+ </code></pre>
166
+
167
+ <p>It attempts to authenticate you to the given server, and then drops you to a pry prompt. You can play around with the api in that by doing <code>api.object.verb(key: &#39;value pairs&#39;)</code></p>
168
+
169
+ <p>Refer to the API documentation for your version of Zabbix for the particulars.</p>
170
+
171
+ <h2 id="label-Development">Development</h2>
172
+
173
+ <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
174
+
175
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and the created tag, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
176
+
177
+ <h2 id="label-Contributing">Contributing</h2>
178
+
179
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/[USERNAME]/zabbix-api">github.com/[USERNAME]/zabbix-api</a>.</p>
180
+ </div></div>
181
+
182
+ <div id="footer">
183
+ Generated on Sat Sep 11 20:08:37 2021 by
184
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
185
+ 0.9.26 (ruby-2.7.4).
186
+ </div>
187
+
188
+ </div>
189
+ </body>
190
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8" />
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
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
+ <title>File List</title>
19
+ <base id="base_target" target="_parent" />
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">File List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">Search: <input type="text" /></div>
42
+ </div>
43
+
44
+ <ul id="full_list" class="file">
45
+
46
+
47
+ <li id="object_README" class="odd">
48
+ <div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
49
+ </li>
50
+
51
+
52
+ <li id="object_CHANGELOG" class="even">
53
+ <div class="item"><span class="object_link"><a href="file.CHANGELOG.html" title="CHANGELOG">CHANGELOG</a></span></div>
54
+ </li>
55
+
56
+
57
+ <li id="object_LICENSE" class="odd">
58
+ <div class="item"><span class="object_link"><a href="file.LICENSE.html" title="LICENSE">LICENSE</a></span></div>
59
+ </li>
60
+
61
+
62
+
63
+ </ul>
64
+ </div>
65
+ </body>
66
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Documentation by YARD 0.9.26</title>
6
+ </head>
7
+ <script type="text/javascript">
8
+ var match = unescape(window.location.hash).match(/^#!(.+)/);
9
+ var name = match ? match[1] : 'index.html';
10
+ name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
+ window.top.location = name;
12
+ </script>
13
+ <noscript>
14
+ <h1>Oops!</h1>
15
+ <h2>YARD requires JavaScript!</h2>
16
+ </noscript>
17
+ </html>
data/public/index.html ADDED
@@ -0,0 +1,190 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'>
61
+ <h1 id="label-Zabbix-3A-3AApi+rdoc-image-3Ahttps-3A-2F-2Fbadge.fury.io-2Frb-2Fzabbix-api-simple.svg">Zabbix::Api <a href="https://badge.fury.io/rb/zabbix-api-simple"><img src="https://badge.fury.io/rb/zabbix-api-simple.svg"></a></h1>
62
+
63
+ <p>This zabbix api implementation for Ruby strives for three things:</p>
64
+ <ul><li>
65
+ <p>To the greatest extent possible, be syntactically &amp; structurally identical to the API as it is described in the Zabbix documentation</p>
66
+ </li><li>
67
+ <p>Be API version agnostic</p>
68
+ </li><li>
69
+ <p>Be internally simple, unobtrusive, and low-maintenance</p>
70
+ </li></ul>
71
+
72
+ <p>It accomplishes these goals primarily by deferring (via Faraday) to the Zabbix API itself for just about everything - it does not attempt to re-create or otherwise “fancy-up” the API. The reasoning behind this is that the zabbix api itself is complex enough, and the Zabbix project can alter the specifics of the api at any time. This library just provides Ruby semantics that closely follow the API specification. The advantage to you is that you do not need to wrap your head around two APIs (the Zabbix API proper, and the API library&#39;s API)</p>
73
+
74
+ <p><strong>Detailed documentation for this library is <a href="https://svdasein.gitlab.io/zabbix-api">>>HERE<<</a></strong></p>
75
+
76
+ <p><strong>Source repository is <a href="https://gitlab.com/svdasein/zabbix-api">>>HERE<<</a></strong></p>
77
+
78
+ <p>If you need to send data into Zabbix via the “Zabbix trapper” protocol, you might also be interested in <a href="https://svdasein.gitlab.io/zabbix_sender_api">zabbix_sender_api</a></p>
79
+
80
+ <h2 id="label-Installation">Installation</h2>
81
+
82
+ <p>Add this line to your application&#39;s Gemfile:</p>
83
+
84
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>zabbix-api-simple</span><span class='tstring_end'>&#39;</span></span>
85
+ </code></pre>
86
+
87
+ <p>And then execute:</p>
88
+
89
+ <pre class="code ruby"><code class="ruby">$ bundle install
90
+ </code></pre>
91
+
92
+ <p>Or install it yourself as:</p>
93
+
94
+ <pre class="code ruby"><code class="ruby">$ gem install zabbix-api-simple
95
+ </code></pre>
96
+
97
+ <h2 id="label-Usage">Usage</h2>
98
+
99
+ <p>Once you have an authenticated instance of the client, syntax is basically always this:</p>
100
+
101
+ <p><code>clientinstance.object.verb(&lt;param kv pairs&gt;)</code></p>
102
+
103
+ <p>If “object” is unknown, “Unknown zabbix object given” will be raised.</p>
104
+
105
+ <p>If this call results in an error from the API, a RuntimeError will be raised indicating the specifics.</p>
106
+
107
+ <p>Complete detail about the last transaction you attempted is available via <code>clientinstance.last</code></p>
108
+
109
+ <p>e.g.:</p>
110
+
111
+ <pre class="code ruby"><code class="ruby"><span class='comment'>#!/usr/bin/env ruby
112
+ </span><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>zabbix/api</span><span class='tstring_end'>&#39;</span></span>
113
+ <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>optimist</span><span class='tstring_end'>&#39;</span></span>
114
+ <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>amazing_print</span><span class='tstring_end'>&#39;</span></span>
115
+
116
+
117
+
118
+ <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='const'>Optimist</span><span class='op'>::</span><span class='id identifier rubyid_options'>options</span> <span class='kw'>do</span>
119
+ <span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:url</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>URL up to but no including api_jsonrpc.php</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span><span class='label'>type:</span> <span class='symbol'>:string</span><span class='comma'>,</span><span class='label'>default:</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://localhost</span><span class='tstring_end'>&#39;</span></span>
120
+ <span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:user</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>User name to authenticate</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='symbol'>:string</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>true</span>
121
+ <span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:pass</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Pass to auth user with</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='symbol'>:string</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>true</span>
122
+ <span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:hostname</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Host name to search for</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='symbol'>:string</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>true</span>
123
+ <span class='kw'>end</span>
124
+
125
+ <span class='id identifier rubyid_api'>api</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Zabbix.html" title="Zabbix (module)">Zabbix</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Zabbix/Api.html" title="Zabbix::Api (module)">Api</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Zabbix/Api/Client.html" title="Zabbix::Api::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Zabbix/Api/Client.html#initialize-instance_method" title="Zabbix::Api::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>url:</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:url</span><span class='rbracket'>]</span><span class='rparen'>)</span>
126
+
127
+ <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_login'>login</span><span class='lparen'>(</span><span class='label'>user:</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:user</span><span class='rbracket'>]</span><span class='comma'>,</span><span class='label'>pass:</span><span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:pass</span><span class='rbracket'>]</span><span class='rparen'>)</span>
128
+
129
+ <span class='id identifier rubyid_hosts'>hosts</span> <span class='op'>=</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='label'>search:</span> <span class='lbrace'>{</span><span class='label'>host:</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:hostname</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'># return value is an OpenStruct
130
+ </span>
131
+ <span class='id identifier rubyid_hosts'>hosts</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_host'>host</span><span class='op'>|</span>
132
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span>
133
+ <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_hostid'>hostid</span>
134
+
135
+ <span class='id identifier rubyid_ap'>ap</span> <span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span>
136
+ <span class='rbrace'>}</span>
137
+
138
+
139
+ <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_host'>host</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span>
140
+ <span class='label'>host:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>mynewhost</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
141
+ <span class='label'>interfaces:</span> <span class='lbrace'>{</span>
142
+ <span class='label'>type:</span> <span class='int'>1</span><span class='comma'>,</span>
143
+ <span class='label'>main:</span> <span class='int'>1</span><span class='comma'>,</span>
144
+ <span class='label'>useip:</span> <span class='int'>1</span><span class='comma'>,</span>
145
+ <span class='label'>ip:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>1.2.3.4</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
146
+ <span class='label'>dns:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
147
+ <span class='label'>port:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>10050</span><span class='tstring_end'>&quot;</span></span>
148
+ <span class='rbrace'>}</span><span class='comma'>,</span>
149
+ <span class='label'>groups:</span> <span class='lbrace'>{</span><span class='label'>groupid:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>42</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
150
+ <span class='rparen'>)</span>
151
+
152
+ <span class='id identifier rubyid_ap'>ap</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span> <span class='comment'># shows detail of the last transaction
153
+ </span>
154
+ <span class='id identifier rubyid_ap'>ap</span> <span class='id identifier rubyid_api'>api</span><span class='period'>.</span><span class='id identifier rubyid_logout'>logout</span>
155
+ </code></pre>
156
+
157
+ <p>There&#39;s a little cli program that gets installed with the gem called zapishell.rb:</p>
158
+
159
+ <pre class="code ruby"><code class="ruby"># zapishell.rb --help
160
+ Options:
161
+ -u, --url=&lt;s&gt; URL up to but no including api_jsonrpc.php (default: http://localhost)
162
+ -s, --user=&lt;s&gt; User name to authenticate
163
+ -p, --pass=&lt;s&gt; Pass to auth user with
164
+ -h, --help Show this message
165
+ </code></pre>
166
+
167
+ <p>It attempts to authenticate you to the given server, and then drops you to a pry prompt. You can play around with the api in that by doing <code>api.object.verb(key: &#39;value pairs&#39;)</code></p>
168
+
169
+ <p>Refer to the API documentation for your version of Zabbix for the particulars.</p>
170
+
171
+ <h2 id="label-Development">Development</h2>
172
+
173
+ <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
174
+
175
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and the created tag, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
176
+
177
+ <h2 id="label-Contributing">Contributing</h2>
178
+
179
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/[USERNAME]/zabbix-api">github.com/[USERNAME]/zabbix-api</a>.</p>
180
+ </div></div>
181
+
182
+ <div id="footer">
183
+ Generated on Sat Sep 11 20:08:36 2021 by
184
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
185
+ 0.9.26 (ruby-2.7.4).
186
+ </div>
187
+
188
+ </div>
189
+ </body>
190
+ </html>