zabbix-api-simple 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,186 @@
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><img src="images/zabbix-api-simple-simplicity.png"></p>
104
+
105
+ <p>If “object” is unknown, “Unknown zabbix object given” will be raised.</p>
106
+
107
+ <p>If this call results in an error from the API, a RuntimeError will be raised indicating the specifics.</p>
108
+
109
+ <p>Complete detail about the last transaction you attempted is available via <code>clientinstance.last</code></p>
110
+
111
+ <p>e.g.:</p>
112
+
113
+ <pre class="code ruby"><code class="ruby"><span class='comment'>#!/usr/bin/env ruby
114
+ </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>
115
+ <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>
116
+ <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>
117
+
118
+
119
+
120
+ <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>
121
+ <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>
122
+ <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>
123
+ <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>
124
+ <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>
125
+ <span class='kw'>end</span>
126
+
127
+ <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>
128
+
129
+ <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>
130
+
131
+ <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
132
+ </span>
133
+ <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>
134
+ <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>
135
+ <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>
136
+
137
+ <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>
138
+ <span class='rbrace'>}</span>
139
+
140
+
141
+ <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>
142
+ <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>
143
+ <span class='label'>interfaces:</span> <span class='lbrace'>{</span>
144
+ <span class='label'>type:</span> <span class='int'>1</span><span class='comma'>,</span>
145
+ <span class='label'>main:</span> <span class='int'>1</span><span class='comma'>,</span>
146
+ <span class='label'>useip:</span> <span class='int'>1</span><span class='comma'>,</span>
147
+ <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>
148
+ <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>
149
+ <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>
150
+ <span class='rbrace'>}</span><span class='comma'>,</span>
151
+ <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>
152
+ <span class='rparen'>)</span>
153
+
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_last'>last</span> <span class='comment'># shows detail of the last transaction
155
+ </span>
156
+ <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>
157
+ </code></pre>
158
+
159
+ <p>There&#39;s a little cli program that gets installed with the gem called zapishell.rb:</p>
160
+
161
+ <pre class="code ruby"><code class="ruby"># zapishell.rb --help
162
+ Options:
163
+ -u, --url=&lt;s&gt; URL up to but no including api_jsonrpc.php (default: http://localhost)
164
+ -s, --user=&lt;s&gt; User name to authenticate
165
+ -p, --pass=&lt;s&gt; Pass to auth user with
166
+ -h, --help Show this message
167
+ </code></pre>
168
+
169
+ <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>
170
+
171
+ <p>Refer to the API documentation for your version of Zabbix for the particulars.</p>
172
+
173
+ <h2 id="label-Contributing">Contributing</h2>
174
+
175
+ <p>Bug reports and pull requests are welcome on GitLab at <a href="https://gitlab.com/svdasein/zabbix-api">gitlab.com/svdasein/zabbix-api</a></p>
176
+ </div></div>
177
+
178
+ <div id="footer">
179
+ Generated on Sun Sep 19 10:15:06 2021 by
180
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
181
+ 0.9.26 (ruby-2.7.4).
182
+ </div>
183
+
184
+ </div>
185
+ </body>
186
+ </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,186 @@
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><img src="images/zabbix-api-simple-simplicity.png"></p>
104
+
105
+ <p>If “object” is unknown, “Unknown zabbix object given” will be raised.</p>
106
+
107
+ <p>If this call results in an error from the API, a RuntimeError will be raised indicating the specifics.</p>
108
+
109
+ <p>Complete detail about the last transaction you attempted is available via <code>clientinstance.last</code></p>
110
+
111
+ <p>e.g.:</p>
112
+
113
+ <pre class="code ruby"><code class="ruby"><span class='comment'>#!/usr/bin/env ruby
114
+ </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>
115
+ <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>
116
+ <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>
117
+
118
+
119
+
120
+ <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>
121
+ <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>
122
+ <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>
123
+ <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>
124
+ <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>
125
+ <span class='kw'>end</span>
126
+
127
+ <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>
128
+
129
+ <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>
130
+
131
+ <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
132
+ </span>
133
+ <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>
134
+ <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>
135
+ <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>
136
+
137
+ <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>
138
+ <span class='rbrace'>}</span>
139
+
140
+
141
+ <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>
142
+ <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>
143
+ <span class='label'>interfaces:</span> <span class='lbrace'>{</span>
144
+ <span class='label'>type:</span> <span class='int'>1</span><span class='comma'>,</span>
145
+ <span class='label'>main:</span> <span class='int'>1</span><span class='comma'>,</span>
146
+ <span class='label'>useip:</span> <span class='int'>1</span><span class='comma'>,</span>
147
+ <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>
148
+ <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>
149
+ <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>
150
+ <span class='rbrace'>}</span><span class='comma'>,</span>
151
+ <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>
152
+ <span class='rparen'>)</span>
153
+
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_last'>last</span> <span class='comment'># shows detail of the last transaction
155
+ </span>
156
+ <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>
157
+ </code></pre>
158
+
159
+ <p>There&#39;s a little cli program that gets installed with the gem called zapishell.rb:</p>
160
+
161
+ <pre class="code ruby"><code class="ruby"># zapishell.rb --help
162
+ Options:
163
+ -u, --url=&lt;s&gt; URL up to but no including api_jsonrpc.php (default: http://localhost)
164
+ -s, --user=&lt;s&gt; User name to authenticate
165
+ -p, --pass=&lt;s&gt; Pass to auth user with
166
+ -h, --help Show this message
167
+ </code></pre>
168
+
169
+ <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>
170
+
171
+ <p>Refer to the API documentation for your version of Zabbix for the particulars.</p>
172
+
173
+ <h2 id="label-Contributing">Contributing</h2>
174
+
175
+ <p>Bug reports and pull requests are welcome on GitLab at <a href="https://gitlab.com/svdasein/zabbix-api">gitlab.com/svdasein/zabbix-api</a></p>
176
+ </div></div>
177
+
178
+ <div id="footer">
179
+ Generated on Sun Sep 19 10:15:06 2021 by
180
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
181
+ 0.9.26 (ruby-2.7.4).
182
+ </div>
183
+
184
+ </div>
185
+ </body>
186
+ </html>