zabbix-api-simple 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/exe/zapishell.rb +15 -1
- data/lib/zabbix/api/client.rb +54 -1
- data/lib/zabbix/api/version.rb +1 -1
- data/lib/zabbix/api.rb +0 -6
- data/public/Zabbix/Api/Client.html +154 -79
- data/public/Zabbix/Api/FaradayMiddleware/ZabbixApiRequest.html +19 -11
- data/public/Zabbix/Api/FaradayMiddleware.html +1 -1
- data/public/Zabbix/Api/OpenStruct.html +384 -0
- data/public/Zabbix/Api/ZabbixStruct.html +384 -0
- data/public/Zabbix/Api.html +5 -5
- data/public/Zabbix.html +3 -3
- data/public/_index.html +7 -7
- data/public/class_list.html +1 -1
- data/public/file.CHANGELOG.html +15 -1
- data/public/file.LICENSE.html +1 -1
- data/public/file.README.html +1 -1
- data/public/index.html +1 -1
- data/public/method_list.html +32 -0
- data/public/top-level-namespace.html +1 -1
- data/zabbix-api.gemspec +2 -1
- metadata +19 -3
- data/public/Zabbix/Api/Error.html +0 -124
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29edc33eb38ffc5637044d089db8de87c61188c9b939610f35fa17371cd68e54
|
4
|
+
data.tar.gz: 8695fad3a891752d7baae725742f816614e11259cc30977c1278db86c4598299
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43e8c89766180de14705412c8c4983fe941d26782d05ccca9b215d7511e093f82ea0f16416e4025db9165cc40bd418d218f0e17882fbcdf0d03dd6e907a97b84
|
7
|
+
data.tar.gz: 78b1efab5a179280b9372758e70d9d0a040dbbb746c39b2e28b2c65d1069d16273ef47da075fbcf37d67cb4136c320058be621ec5e0f123c1ef3c5e989a4ce46
|
data/CHANGELOG.md
CHANGED
@@ -1,2 +1,9 @@
|
|
1
1
|
# 0.1.4
|
2
2
|
- Just doc changes
|
3
|
+
# 0.1.5
|
4
|
+
- deps fix for pry
|
5
|
+
- add known_objects method
|
6
|
+
- add exception trap for json parse issues w/ note about php memory
|
7
|
+
- change zapishell.rb to start in the api context
|
8
|
+
- add exception for apiinfo.version (refuses auth token for some reason)
|
9
|
+
- add pretty inspection mode to zapishell.rb
|
data/exe/zapishell.rb
CHANGED
@@ -12,12 +12,26 @@ opts = Optimist::options do
|
|
12
12
|
opt :pass, "Pass to auth user with", type: :string, required: true
|
13
13
|
end
|
14
14
|
|
15
|
+
|
16
|
+
|
17
|
+
Zabbix::Api::OpenStruct.prettymode = true
|
18
|
+
|
15
19
|
print "user.login: "
|
16
20
|
api = Zabbix::Api::Client.new(url: opts[:url])
|
17
21
|
|
18
22
|
ap api.login(user: opts[:user],pass:opts[:pass])
|
19
23
|
|
20
|
-
|
24
|
+
puts <<-END
|
25
|
+
|
26
|
+
Enter api commands e.g. host.get
|
27
|
+
|
28
|
+
execute known_objects for a list of known zabbix object types
|
29
|
+
|
30
|
+
quit to exit - your session will be logged out for you
|
31
|
+
|
32
|
+
END
|
33
|
+
|
34
|
+
api.pry
|
21
35
|
|
22
36
|
print "user.logout: "
|
23
37
|
ap api.logout
|
data/lib/zabbix/api/client.rb
CHANGED
@@ -4,6 +4,7 @@ module Zabbix
|
|
4
4
|
require 'faraday'
|
5
5
|
require 'json'
|
6
6
|
require 'set'
|
7
|
+
require 'amazing_print'
|
7
8
|
require 'pry'
|
8
9
|
|
9
10
|
module FaradayMiddleware
|
@@ -26,7 +27,11 @@ module Zabbix
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def on_complete(env)
|
29
|
-
|
30
|
+
begin
|
31
|
+
env[:response_body] = JSON.parse(env[:response_body])
|
32
|
+
rescue JSON::ParserError => e
|
33
|
+
env[:response_body] = {error: e,note: 'Check api web configuration (e.g. url, PHP memory, etc)'}
|
34
|
+
end
|
30
35
|
end
|
31
36
|
|
32
37
|
end
|
@@ -36,6 +41,41 @@ module Zabbix
|
|
36
41
|
end # module FaradayMiddleware
|
37
42
|
|
38
43
|
|
44
|
+
|
45
|
+
##
|
46
|
+
# Subclass of OpenStruct adds some niceties for REPL etc
|
47
|
+
#
|
48
|
+
class OpenStruct < OpenStruct
|
49
|
+
|
50
|
+
##
|
51
|
+
# If true, inspect returns awesome_inspect instead of default
|
52
|
+
@@prettymode = false
|
53
|
+
|
54
|
+
class << self
|
55
|
+
##
|
56
|
+
# returns current value of prettymode
|
57
|
+
#
|
58
|
+
def prettymode
|
59
|
+
@@prettymode
|
60
|
+
end
|
61
|
+
##
|
62
|
+
# sets prettymod to aBool
|
63
|
+
#
|
64
|
+
def prettymode=(aBool)
|
65
|
+
@@prettymode = aBool
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def inspect
|
70
|
+
if @@prettymode
|
71
|
+
awesome_inspect
|
72
|
+
else
|
73
|
+
super
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
39
79
|
##
|
40
80
|
# Each instance of this class acts as a connection Zabbix's API
|
41
81
|
class Client
|
@@ -120,7 +160,12 @@ module Zabbix
|
|
120
160
|
# results are returned as instances of OpenStruct. If you need this to be
|
121
161
|
# a hash just do to_h to the returned object.
|
122
162
|
def call(name, *args, &block)
|
163
|
+
res = nil
|
164
|
+
if name == 'apiinfo.version'
|
165
|
+
res = post(method: "#{name}", params: args.first, id: '1').body
|
166
|
+
else
|
123
167
|
res = post(method: "#{name}", params: args.first, id: '1', auth: @token).body
|
168
|
+
end
|
124
169
|
raise res['error'].awesome_inspect(plain: true) if res.has_key?('error')
|
125
170
|
if res.has_key?('result') and res['result'].class == Array
|
126
171
|
res = res['result'].collect{|each| OpenStruct.new(each)}
|
@@ -130,6 +175,14 @@ module Zabbix
|
|
130
175
|
return res
|
131
176
|
end
|
132
177
|
|
178
|
+
##
|
179
|
+
# just handy if you're doing a REPL (e.g. zapishell.rb) Returns
|
180
|
+
# list of zabbix objects the api currently is aware of
|
181
|
+
#
|
182
|
+
def known_objects
|
183
|
+
@@zabbix_objects
|
184
|
+
end
|
185
|
+
|
133
186
|
|
134
187
|
##
|
135
188
|
# this override of method_missing is the trick that lets zabbix-api-simple
|
data/lib/zabbix/api/version.rb
CHANGED
data/lib/zabbix/api.rb
CHANGED
@@ -335,6 +335,30 @@
|
|
335
335
|
<p>:url is required.</p>
|
336
336
|
</div></span>
|
337
337
|
|
338
|
+
</li>
|
339
|
+
|
340
|
+
|
341
|
+
<li class="public ">
|
342
|
+
<span class="summary_signature">
|
343
|
+
|
344
|
+
<a href="#known_objects-instance_method" title="#known_objects (instance method)">#<strong>known_objects</strong> ⇒ Object </a>
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
</span>
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
<span class="summary_desc"><div class='inline'>
|
359
|
+
<p>just handy if you're doing a REPL (e.g. zapishell.rb) Returns list of zabbix objects the api currently is aware of.</p>
|
360
|
+
</div></span>
|
361
|
+
|
338
362
|
</li>
|
339
363
|
|
340
364
|
|
@@ -490,19 +514,19 @@
|
|
490
514
|
<pre class="lines">
|
491
515
|
|
492
516
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
517
|
+
115
|
518
|
+
116
|
519
|
+
117
|
520
|
+
118
|
521
|
+
119
|
522
|
+
120
|
523
|
+
121
|
524
|
+
122
|
525
|
+
123
|
526
|
+
124</pre>
|
503
527
|
</td>
|
504
528
|
<td>
|
505
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
529
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 115</span>
|
506
530
|
|
507
531
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>url:</span> <span class='kw'>nil</span><span class='comma'>,</span><span class='label'>timeout:</span> <span class='int'>60</span><span class='rparen'>)</span>
|
508
532
|
<span class='ivar'>@conn</span> <span class='op'>=</span> <span class='const'>Faraday</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
@@ -555,23 +579,23 @@
|
|
555
579
|
<pre class="lines">
|
556
580
|
|
557
581
|
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
582
|
+
196
|
583
|
+
197
|
584
|
+
198
|
585
|
+
199
|
586
|
+
200
|
587
|
+
201
|
588
|
+
202
|
589
|
+
203
|
590
|
+
204
|
591
|
+
205
|
592
|
+
206
|
593
|
+
207
|
594
|
+
208
|
595
|
+
209</pre>
|
572
596
|
</td>
|
573
597
|
<td>
|
574
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
598
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 196</span>
|
575
599
|
|
576
600
|
<span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
577
601
|
<span class='kw'>if</span> <span class='cvar'>@@zabbix_objects</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
@@ -625,12 +649,12 @@
|
|
625
649
|
<pre class="lines">
|
626
650
|
|
627
651
|
|
628
|
-
|
629
|
-
|
630
|
-
|
652
|
+
84
|
653
|
+
85
|
654
|
+
86</pre>
|
631
655
|
</td>
|
632
656
|
<td>
|
633
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
657
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 84</span>
|
634
658
|
|
635
659
|
<span class='kw'>def</span> <span class='id identifier rubyid_last'>last</span>
|
636
660
|
<span class='ivar'>@last</span>
|
@@ -673,12 +697,12 @@
|
|
673
697
|
<pre class="lines">
|
674
698
|
|
675
699
|
|
676
|
-
|
677
|
-
|
678
|
-
|
700
|
+
107
|
701
|
+
108
|
702
|
+
109</pre>
|
679
703
|
</td>
|
680
704
|
<td>
|
681
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
705
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 107</span>
|
682
706
|
|
683
707
|
<span class='kw'>def</span> <span class='id identifier rubyid_conn'>conn</span>
|
684
708
|
<span class='ivar'>@conn</span>
|
@@ -716,12 +740,12 @@
|
|
716
740
|
<pre class="lines">
|
717
741
|
|
718
742
|
|
719
|
-
|
720
|
-
|
721
|
-
|
743
|
+
107
|
744
|
+
108
|
745
|
+
109</pre>
|
722
746
|
</td>
|
723
747
|
<td>
|
724
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
748
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 107</span>
|
725
749
|
|
726
750
|
<span class='kw'>def</span> <span class='id identifier rubyid_token'>token</span>
|
727
751
|
<span class='ivar'>@token</span>
|
@@ -759,12 +783,12 @@
|
|
759
783
|
<pre class="lines">
|
760
784
|
|
761
785
|
|
762
|
-
|
763
|
-
|
764
|
-
|
786
|
+
108
|
787
|
+
109
|
788
|
+
110</pre>
|
765
789
|
</td>
|
766
790
|
<td>
|
767
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
791
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 108</span>
|
768
792
|
|
769
793
|
<span class='kw'>def</span> <span class='id identifier rubyid_zabobject'>zabobject</span>
|
770
794
|
<span class='ivar'>@zabobject</span>
|
@@ -809,33 +833,84 @@
|
|
809
833
|
<pre class="lines">
|
810
834
|
|
811
835
|
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
836
|
+
162
|
837
|
+
163
|
838
|
+
164
|
839
|
+
165
|
840
|
+
166
|
841
|
+
167
|
842
|
+
168
|
843
|
+
169
|
844
|
+
170
|
845
|
+
171
|
846
|
+
172
|
847
|
+
173
|
848
|
+
174
|
849
|
+
175
|
850
|
+
176</pre>
|
822
851
|
</td>
|
823
852
|
<td>
|
824
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
853
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 162</span>
|
825
854
|
|
826
855
|
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
856
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
857
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>apiinfo.version</span><span class='tstring_end'>'</span></span>
|
858
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>params:</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='label'>id:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span>
|
859
|
+
<span class='kw'>else</span>
|
827
860
|
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>params:</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='label'>id:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>auth:</span> <span class='ivar'>@token</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span>
|
861
|
+
<span class='kw'>end</span>
|
828
862
|
<span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>error</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_awesome_inspect'>awesome_inspect</span><span class='lparen'>(</span><span class='label'>plain:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>error</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
829
863
|
<span class='kw'>if</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>result</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>and</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>result</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>==</span> <span class='const'>Array</span>
|
830
|
-
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>result</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_each'>each</span><span class='op'>|</span> <span class='const'>OpenStruct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_each'>each</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
864
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='id identifier rubyid_res'>res</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>result</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_each'>each</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="OpenStruct.html" title="Zabbix::Api::OpenStruct (class)">OpenStruct</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_each'>each</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
831
865
|
<span class='kw'>else</span>
|
832
|
-
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'>OpenStruct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='rparen'>)</span>
|
866
|
+
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="OpenStruct.html" title="Zabbix::Api::OpenStruct (class)">OpenStruct</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='rparen'>)</span>
|
833
867
|
<span class='kw'>end</span>
|
834
868
|
<span class='kw'>return</span> <span class='id identifier rubyid_res'>res</span>
|
835
869
|
<span class='kw'>end</span></pre>
|
836
870
|
</td>
|
837
871
|
</tr>
|
838
872
|
</table>
|
873
|
+
</div>
|
874
|
+
|
875
|
+
<div class="method_details ">
|
876
|
+
<h3 class="signature " id="known_objects-instance_method">
|
877
|
+
|
878
|
+
#<strong>known_objects</strong> ⇒ <tt>Object</tt>
|
879
|
+
|
880
|
+
|
881
|
+
|
882
|
+
|
883
|
+
|
884
|
+
</h3><div class="docstring">
|
885
|
+
<div class="discussion">
|
886
|
+
|
887
|
+
<p>just handy if you're doing a REPL (e.g. zapishell.rb) Returns list of zabbix objects the api currently is aware of</p>
|
888
|
+
|
889
|
+
|
890
|
+
</div>
|
891
|
+
</div>
|
892
|
+
<div class="tags">
|
893
|
+
|
894
|
+
|
895
|
+
</div><table class="source_code">
|
896
|
+
<tr>
|
897
|
+
<td>
|
898
|
+
<pre class="lines">
|
899
|
+
|
900
|
+
|
901
|
+
182
|
902
|
+
183
|
903
|
+
184</pre>
|
904
|
+
</td>
|
905
|
+
<td>
|
906
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 182</span>
|
907
|
+
|
908
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_known_objects'>known_objects</span>
|
909
|
+
<span class='cvar'>@@zabbix_objects</span>
|
910
|
+
<span class='kw'>end</span></pre>
|
911
|
+
</td>
|
912
|
+
</tr>
|
913
|
+
</table>
|
839
914
|
</div>
|
840
915
|
|
841
916
|
<div class="method_details ">
|
@@ -864,12 +939,12 @@
|
|
864
939
|
<pre class="lines">
|
865
940
|
|
866
941
|
|
867
|
-
|
868
|
-
|
869
|
-
|
942
|
+
213
|
943
|
+
214
|
944
|
+
215</pre>
|
870
945
|
</td>
|
871
946
|
<td>
|
872
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
947
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 213</span>
|
873
948
|
|
874
949
|
<span class='kw'>def</span> <span class='id identifier rubyid_last'>last</span>
|
875
950
|
<span class='const'><span class='object_link'><a href="" title="Zabbix::Api::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_last'><span class='object_link'><a href="#last-class_method" title="Zabbix::Api::Client.last (method)">last</a></span></span>
|
@@ -905,19 +980,19 @@
|
|
905
980
|
<pre class="lines">
|
906
981
|
|
907
982
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
983
|
+
139
|
984
|
+
140
|
985
|
+
141
|
986
|
+
142
|
987
|
+
143</pre>
|
913
988
|
</td>
|
914
989
|
<td>
|
915
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
990
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 139</span>
|
916
991
|
|
917
992
|
<span class='kw'>def</span> <span class='id identifier rubyid_login'>login</span><span class='lparen'>(</span><span class='label'>user:</span> <span class='kw'>nil</span><span class='comma'>,</span><span class='label'>pass:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
918
993
|
<span class='id identifier rubyid_res'>res</span> <span class='op'>=</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>user.login</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>params:</span> <span class='lbrace'>{</span><span class='label'>user:</span> <span class='id identifier rubyid_user'>user</span><span class='comma'>,</span> <span class='label'>password:</span><span class='id identifier rubyid_pass'>pass</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>auth:</span><span class='kw'>nil</span><span class='rparen'>)</span>
|
919
994
|
<span class='ivar'>@token</span> <span class='op'>=</span> <span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>result</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
920
|
-
<span class='const'>OpenStruct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
|
995
|
+
<span class='const'><span class='object_link'><a href="OpenStruct.html" title="Zabbix::Api::OpenStruct (class)">OpenStruct</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_res'>res</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
|
921
996
|
<span class='kw'>end</span></pre>
|
922
997
|
</td>
|
923
998
|
</tr>
|
@@ -950,15 +1025,15 @@
|
|
950
1025
|
<pre class="lines">
|
951
1026
|
|
952
1027
|
|
953
|
-
|
954
|
-
|
955
|
-
|
1028
|
+
150
|
1029
|
+
151
|
1030
|
+
152</pre>
|
956
1031
|
</td>
|
957
1032
|
<td>
|
958
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
1033
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 150</span>
|
959
1034
|
|
960
1035
|
<span class='kw'>def</span> <span class='id identifier rubyid_logout'>logout</span>
|
961
|
-
<span class='const'>OpenStruct</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>user.logout</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>params:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>auth:</span> <span class='ivar'>@token</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
|
1036
|
+
<span class='const'><span class='object_link'><a href="OpenStruct.html" title="Zabbix::Api::OpenStruct (class)">OpenStruct</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='label'>method:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>user.logout</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>params:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>auth:</span> <span class='ivar'>@token</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
|
962
1037
|
<span class='kw'>end</span></pre>
|
963
1038
|
</td>
|
964
1039
|
</tr>
|
@@ -991,15 +1066,15 @@
|
|
991
1066
|
<pre class="lines">
|
992
1067
|
|
993
1068
|
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1069
|
+
129
|
1070
|
+
130
|
1071
|
+
131
|
1072
|
+
132
|
1073
|
+
133
|
1074
|
+
134</pre>
|
1000
1075
|
</td>
|
1001
1076
|
<td>
|
1002
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
1077
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 129</span>
|
1003
1078
|
|
1004
1079
|
<span class='kw'>def</span> <span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
1005
1080
|
<span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='symbol'>:params</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='symbol'>:params</span><span class='rparen'>)</span> <span class='kw'>or</span> <span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='symbol'>:params</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
@@ -1017,7 +1092,7 @@
|
|
1017
1092
|
</div>
|
1018
1093
|
|
1019
1094
|
<div id="footer">
|
1020
|
-
Generated on Sat Sep
|
1095
|
+
Generated on Sat Sep 18 20:44:22 2021 by
|
1021
1096
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1022
1097
|
0.9.26 (ruby-2.7.4).
|
1023
1098
|
</div>
|
@@ -230,13 +230,13 @@
|
|
230
230
|
<pre class="lines">
|
231
231
|
|
232
232
|
|
233
|
-
17
|
234
233
|
18
|
235
234
|
19
|
236
|
-
20
|
235
|
+
20
|
236
|
+
21</pre>
|
237
237
|
</td>
|
238
238
|
<td>
|
239
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
239
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 18</span>
|
240
240
|
|
241
241
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_app'>app</span><span class='rparen'>)</span>
|
242
242
|
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_app'>app</span><span class='rparen'>)</span>
|
@@ -269,15 +269,23 @@
|
|
269
269
|
<pre class="lines">
|
270
270
|
|
271
271
|
|
272
|
-
28
|
273
272
|
29
|
274
|
-
30
|
273
|
+
30
|
274
|
+
31
|
275
|
+
32
|
276
|
+
33
|
277
|
+
34
|
278
|
+
35</pre>
|
275
279
|
</td>
|
276
280
|
<td>
|
277
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
281
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 29</span>
|
278
282
|
|
279
283
|
<span class='kw'>def</span> <span class='id identifier rubyid_on_complete'>on_complete</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
280
|
-
<span class='
|
284
|
+
<span class='kw'>begin</span>
|
285
|
+
<span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='symbol'>:response_body</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='symbol'>:response_body</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
286
|
+
<span class='kw'>rescue</span> <span class='const'>JSON</span><span class='op'>::</span><span class='const'>ParserError</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
287
|
+
<span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='symbol'>:response_body</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>error:</span> <span class='id identifier rubyid_e'>e</span><span class='comma'>,</span><span class='label'>note:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Check api web configuration (e.g. url, PHP memory, etc)</span><span class='tstring_end'>'</span></span><span class='rbrace'>}</span>
|
288
|
+
<span class='kw'>end</span>
|
281
289
|
<span class='kw'>end</span></pre>
|
282
290
|
</td>
|
283
291
|
</tr>
|
@@ -299,14 +307,14 @@
|
|
299
307
|
<pre class="lines">
|
300
308
|
|
301
309
|
|
302
|
-
22
|
303
310
|
23
|
304
311
|
24
|
305
312
|
25
|
306
|
-
26
|
313
|
+
26
|
314
|
+
27</pre>
|
307
315
|
</td>
|
308
316
|
<td>
|
309
|
-
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line
|
317
|
+
<pre class="code"><span class="info file"># File 'lib/zabbix/api/client.rb', line 23</span>
|
310
318
|
|
311
319
|
<span class='kw'>def</span> <span class='id identifier rubyid_on_request'>on_request</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
312
320
|
<span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='symbol'>:request_body</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:jsonrpc</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2.0</span><span class='tstring_end'>"</span></span>
|
@@ -323,7 +331,7 @@
|
|
323
331
|
</div>
|
324
332
|
|
325
333
|
<div id="footer">
|
326
|
-
Generated on Sat Sep
|
334
|
+
Generated on Sat Sep 18 20:44:22 2021 by
|
327
335
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
328
336
|
0.9.26 (ruby-2.7.4).
|
329
337
|
</div>
|
@@ -105,7 +105,7 @@
|
|
105
105
|
</div>
|
106
106
|
|
107
107
|
<div id="footer">
|
108
|
-
Generated on Sat Sep
|
108
|
+
Generated on Sat Sep 18 20:44:22 2021 by
|
109
109
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
110
110
|
0.9.26 (ruby-2.7.4).
|
111
111
|
</div>
|