zabbix_sender_api 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,528 @@
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
+ Class: Zabbix::Sender::Socket
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 = "Zabbix::Sender::Socket";
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 (S)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../Zabbix.html" title="Zabbix (module)">Zabbix</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Sender.html" title="Zabbix::Sender (module)">Sender</a></span></span>
41
+ &raquo;
42
+ <span class="title">Socket</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Zabbix::Sender::Socket
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName"><span class='object_link'><a href="Connection.html" title="Zabbix::Sender::Connection (class)">Connection</a></span></span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next"><span class='object_link'><a href="Connection.html" title="Zabbix::Sender::Connection (class)">Connection</a></span></li>
78
+
79
+ <li class="next">Zabbix::Sender::Socket</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <dl>
98
+ <dt>Defined in:</dt>
99
+ <dd>lib/zabbix_sender_api/api.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>Socket instances enable TCPSocket based communication with a zabbix trapper server instance</p>
108
+
109
+
110
+ </div>
111
+ </div>
112
+ <div class="tags">
113
+
114
+
115
+ </div>
116
+
117
+
118
+
119
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
120
+ <ul class="summary">
121
+
122
+ <li class="public ">
123
+ <span class="summary_signature">
124
+
125
+ <a href="#port-instance_method" title="#port (instance method)">#<strong>port</strong> &#x21d2; Object </a>
126
+
127
+
128
+
129
+ </span>
130
+
131
+
132
+
133
+
134
+ <span class="note title readonly">readonly</span>
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+ <span class="summary_desc"><div class='inline'>
145
+ <p>Returns the value of attribute port.</p>
146
+ </div></span>
147
+
148
+ </li>
149
+
150
+
151
+ </ul>
152
+
153
+
154
+
155
+
156
+
157
+ <h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Connection.html" title="Zabbix::Sender::Connection (class)">Connection</a></span></h3>
158
+ <p class="inherited"><span class='object_link'><a href="Connection.html#pipe-instance_method" title="Zabbix::Sender::Connection#pipe (method)">#pipe</a></span>, <span class='object_link'><a href="Connection.html#targetHost-instance_method" title="Zabbix::Sender::Connection#targetHost (method)">#targetHost</a></span></p>
159
+
160
+
161
+
162
+ <h2>
163
+ Instance Method Summary
164
+ <small><a href="#" class="summary_toggle">collapse</a></small>
165
+ </h2>
166
+
167
+ <ul class="summary">
168
+
169
+ <li class="public ">
170
+ <span class="summary_signature">
171
+
172
+ <a href="#flush-instance_method" title="#flush (instance method)">#<strong>flush</strong> &#x21d2; Object </a>
173
+
174
+
175
+
176
+ </span>
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+ <span class="summary_desc"><div class='inline'></div></span>
187
+
188
+ </li>
189
+
190
+
191
+ <li class="public ">
192
+ <span class="summary_signature">
193
+
194
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(proxy: Zabbix::AgentConfiguration.zabbixProxy, port: 10051) &#x21d2; Socket </a>
195
+
196
+
197
+
198
+ </span>
199
+
200
+
201
+ <span class="note title constructor">constructor</span>
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+ <span class="summary_desc"><div class='inline'>
211
+ <p>Create a new socket connection object.</p>
212
+ </div></span>
213
+
214
+ </li>
215
+
216
+
217
+ <li class="public ">
218
+ <span class="summary_signature">
219
+
220
+ <a href="#open-instance_method" title="#open (instance method)">#<strong>open</strong> &#x21d2; Object </a>
221
+
222
+
223
+
224
+ </span>
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+ <span class="summary_desc"><div class='inline'>
235
+ <p>Open tcp socket to target proxy/server.</p>
236
+ </div></span>
237
+
238
+ </li>
239
+
240
+
241
+ <li class="public ">
242
+ <span class="summary_signature">
243
+
244
+ <a href="#sendBatch-instance_method" title="#sendBatch (instance method)">#<strong>sendBatch</strong>(aBatch) &#x21d2; Object </a>
245
+
246
+
247
+
248
+ </span>
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+ <span class="summary_desc"><div class='inline'>
259
+ <p>Send aBatch to zabbix via the socket.</p>
260
+ </div></span>
261
+
262
+ </li>
263
+
264
+
265
+ </ul>
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Connection.html" title="Zabbix::Sender::Connection (class)">Connection</a></span></h3>
278
+ <p class="inherited"><span class='object_link'><a href="Connection.html#sendBatchAtomic-instance_method" title="Zabbix::Sender::Connection#sendBatchAtomic (method)">#sendBatchAtomic</a></span></p>
279
+ <div id="constructor_details" class="method_details_list">
280
+ <h2>Constructor Details</h2>
281
+
282
+ <div class="method_details first">
283
+ <h3 class="signature first" id="initialize-instance_method">
284
+
285
+ #<strong>initialize</strong>(proxy: Zabbix::AgentConfiguration.zabbixProxy, port: 10051) &#x21d2; <tt><span class='object_link'><a href="" title="Zabbix::Sender::Socket (class)">Socket</a></span></tt>
286
+
287
+
288
+
289
+
290
+
291
+ </h3><div class="docstring">
292
+ <div class="discussion">
293
+
294
+ <p>Create a new socket connection object. Both proxy and port are optional.</p>
295
+
296
+ <p>An attempt is made to provide sane default values. If you have a zabbix_agentd.conf file in one of the usual places and zabbix_sender is on your path, it&#39;ll probably just work</p>
297
+
298
+
299
+ </div>
300
+ </div>
301
+ <div class="tags">
302
+
303
+
304
+ </div><table class="source_code">
305
+ <tr>
306
+ <td>
307
+ <pre class="lines">
308
+
309
+
310
+ 135
311
+ 136
312
+ 137
313
+ 138
314
+ 139</pre>
315
+ </td>
316
+ <td>
317
+ <pre class="code"><span class="info file"># File 'lib/zabbix_sender_api/api.rb', line 135</span>
318
+
319
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>proxy:</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="../AgentConfiguration.html" title="Zabbix::AgentConfiguration (class)">AgentConfiguration</a></span></span><span class='period'>.</span><span class='id identifier rubyid_zabbixProxy'><span class='object_link'><a href="../AgentConfiguration.html#zabbixProxy-class_method" title="Zabbix::AgentConfiguration.zabbixProxy (method)">zabbixProxy</a></span></span><span class='comma'>,</span> <span class='label'>port:</span> <span class='int'>10051</span><span class='rparen'>)</span>
320
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='label'>proxy:</span> <span class='id identifier rubyid_proxy'>proxy</span><span class='rparen'>)</span>
321
+ <span class='ivar'>@port</span> <span class='op'>=</span> <span class='id identifier rubyid_port'>port</span>
322
+ <span class='ivar'>@lastres</span> <span class='op'>=</span> <span class='kw'>nil</span>
323
+ <span class='kw'>end</span></pre>
324
+ </td>
325
+ </tr>
326
+ </table>
327
+ </div>
328
+
329
+ </div>
330
+
331
+ <div id="instance_attr_details" class="attr_details">
332
+ <h2>Instance Attribute Details</h2>
333
+
334
+
335
+ <span id=""></span>
336
+ <div class="method_details first">
337
+ <h3 class="signature first" id="port-instance_method">
338
+
339
+ #<strong>port</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
340
+
341
+
342
+
343
+
344
+
345
+ </h3><div class="docstring">
346
+ <div class="discussion">
347
+
348
+ <p>Returns the value of attribute port.</p>
349
+
350
+
351
+ </div>
352
+ </div>
353
+ <div class="tags">
354
+
355
+
356
+ </div><table class="source_code">
357
+ <tr>
358
+ <td>
359
+ <pre class="lines">
360
+
361
+
362
+ 127
363
+ 128
364
+ 129</pre>
365
+ </td>
366
+ <td>
367
+ <pre class="code"><span class="info file"># File 'lib/zabbix_sender_api/api.rb', line 127</span>
368
+
369
+ <span class='kw'>def</span> <span class='id identifier rubyid_port'>port</span>
370
+ <span class='ivar'>@port</span>
371
+ <span class='kw'>end</span></pre>
372
+ </td>
373
+ </tr>
374
+ </table>
375
+ </div>
376
+
377
+ </div>
378
+
379
+
380
+ <div id="instance_method_details" class="method_details_list">
381
+ <h2>Instance Method Details</h2>
382
+
383
+
384
+ <div class="method_details first">
385
+ <h3 class="signature first" id="flush-instance_method">
386
+
387
+ #<strong>flush</strong> &#x21d2; <tt>Object</tt>
388
+
389
+
390
+
391
+
392
+
393
+ </h3><table class="source_code">
394
+ <tr>
395
+ <td>
396
+ <pre class="lines">
397
+
398
+
399
+ 171
400
+ 172
401
+ 173
402
+ 174</pre>
403
+ </td>
404
+ <td>
405
+ <pre class="code"><span class="info file"># File 'lib/zabbix_sender_api/api.rb', line 171</span>
406
+
407
+ <span class='kw'>def</span> <span class='id identifier rubyid_flush'>flush</span>
408
+ <span class='kw'>super</span>
409
+ <span class='kw'>return</span> <span class='ivar'>@lastres</span>
410
+ <span class='kw'>end</span></pre>
411
+ </td>
412
+ </tr>
413
+ </table>
414
+ </div>
415
+
416
+ <div class="method_details ">
417
+ <h3 class="signature " id="open-instance_method">
418
+
419
+ #<strong>open</strong> &#x21d2; <tt>Object</tt>
420
+
421
+
422
+
423
+
424
+
425
+ </h3><div class="docstring">
426
+ <div class="discussion">
427
+
428
+ <p>Open tcp socket to target proxy/server</p>
429
+
430
+
431
+ </div>
432
+ </div>
433
+ <div class="tags">
434
+
435
+
436
+ </div><table class="source_code">
437
+ <tr>
438
+ <td>
439
+ <pre class="lines">
440
+
441
+
442
+ 143
443
+ 144
444
+ 145</pre>
445
+ </td>
446
+ <td>
447
+ <pre class="code"><span class="info file"># File 'lib/zabbix_sender_api/api.rb', line 143</span>
448
+
449
+ <span class='kw'>def</span> <span class='id identifier rubyid_open'>open</span>
450
+ <span class='ivar'>@pipe</span> <span class='op'>=</span> <span class='const'>TCPSocket</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@targetHost</span><span class='comma'>,</span> <span class='ivar'>@port</span><span class='rparen'>)</span>
451
+ <span class='kw'>end</span></pre>
452
+ </td>
453
+ </tr>
454
+ </table>
455
+ </div>
456
+
457
+ <div class="method_details ">
458
+ <h3 class="signature " id="sendBatch-instance_method">
459
+
460
+ #<strong>sendBatch</strong>(aBatch) &#x21d2; <tt>Object</tt>
461
+
462
+
463
+
464
+
465
+
466
+ </h3><div class="docstring">
467
+ <div class="discussion">
468
+
469
+ <p>Send aBatch to zabbix via the socket. Note that zabbix will close the connection after you send a complete message, so you *can&#39;t* do this:</p>
470
+
471
+ <p>socket.open socket.sendBatch(a) socket.sendBatch(b) &lt;– this will blow up socket.flush</p>
472
+
473
+ <p>…as you can with Zabbix::Sender::Pipe. You&#39;re really best off just using sendBatchAtomic for sockets.</p>
474
+
475
+ <p>This assumes that the socket is already open.</p>
476
+
477
+
478
+ </div>
479
+ </div>
480
+ <div class="tags">
481
+
482
+
483
+ </div><table class="source_code">
484
+ <tr>
485
+ <td>
486
+ <pre class="lines">
487
+
488
+
489
+ 161
490
+ 162
491
+ 163
492
+ 164
493
+ 165
494
+ 166
495
+ 167
496
+ 168
497
+ 169</pre>
498
+ </td>
499
+ <td>
500
+ <pre class="code"><span class="info file"># File 'lib/zabbix_sender_api/api.rb', line 161</span>
501
+
502
+ <span class='kw'>def</span> <span class='id identifier rubyid_sendBatch'>sendBatch</span><span class='lparen'>(</span><span class='id identifier rubyid_aBatch'>aBatch</span><span class='rparen'>)</span>
503
+ <span class='id identifier rubyid_header'>header</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>%Q(</span><span class='tstring_content'>ZBXD\x01</span><span class='tstring_end'>)</span></span>
504
+ <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid_aBatch'>aBatch</span><span class='period'>.</span><span class='id identifier rubyid_to_senderstruct'>to_senderstruct</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
505
+ <span class='id identifier rubyid_blob'>blob</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>%Q(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_header'>header</span><span class='embexpr_end'>}</span><span class='embexpr_beg'>#{</span><span class='lbracket'>[</span><span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_bytesize'>bytesize</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_pack'>pack</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Q</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_force_encoding'>force_encoding</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>UTF-8</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_data'>data</span><span class='embexpr_end'>}</span><span class='tstring_end'>)</span></span>
506
+ <span class='ivar'>@pipe</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_blob'>blob</span><span class='rparen'>)</span>
507
+ <span class='id identifier rubyid_respHeader'>respHeader</span> <span class='op'>=</span> <span class='ivar'>@pipe</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_header'>header</span><span class='period'>.</span><span class='id identifier rubyid_bytesize'>bytesize</span> <span class='op'>+</span> <span class='int'>8</span><span class='rparen'>)</span>
508
+ <span class='id identifier rubyid_datalen'>datalen</span> <span class='op'>=</span> <span class='id identifier rubyid_respHeader'>respHeader</span><span class='lbracket'>[</span><span class='id identifier rubyid_header'>header</span><span class='period'>.</span><span class='id identifier rubyid_bytesize'>bytesize</span><span class='comma'>,</span> <span class='int'>8</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_unpack'>unpack</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Q</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
509
+ <span class='ivar'>@lastres</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='ivar'>@pipe</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_datalen'>datalen</span><span class='rparen'>)</span><span class='rparen'>)</span>
510
+ <span class='kw'>end</span></pre>
511
+ </td>
512
+ </tr>
513
+ </table>
514
+ </div>
515
+
516
+ </div>
517
+
518
+ </div>
519
+
520
+ <div id="footer">
521
+ Generated on Sat Sep 11 00:00:06 2021 by
522
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
523
+ 0.9.26 (ruby-2.7.4).
524
+ </div>
525
+
526
+ </div>
527
+ </body>
528
+ </html>