-
Notifications
You must be signed in to change notification settings - Fork 9
/
zapish.inc.3.xml
274 lines (273 loc) · 8.32 KB
/
zapish.inc.3.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2017-2018 Tomasz Kłoczko <[email protected]>
This program is free software, distributed under the terms of
the GNU General Public License Version 2.
-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
<refentry>
<refentryinfo>
<title>zapish.inc Manual</title>
<productname>zapish</productname>
<copyright>
<year>2017-2018</year>
</copyright>
<authorgroup>
<author>
<personname>
<firstname>Tomasz</firstname>
<surname>Kłoczko</surname>
<affiliation>
<address>
<email>[email protected]</email>
</address>
</affiliation>
</personname>
<personblurb>
kloczek
</personblurb>
<contrib>
Author
</contrib>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>zapish.inc</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo class="sectdesc">Library functions</refmiscinfo>
<refmiscinfo class="source">zapish.inc</refmiscinfo>
</refmeta>
<refnamediv id="name">
<refname>zapish.inc</refname>
<refpurpose>Zabbix API SHell binding</refpurpose>
</refnamediv>
<refsynopsisdiv id="synopsis">
<cmdsynopsis>
<command>. /usr/libexec/zapish.inc</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1 id="description">
<title>DESCRIPTION</title>
<para>
The <command>zapish.inc</command> is the file to include in own
SH/bash scripts with few functions which make calling Zabbix API easy.
</para>
<para>
It consists of few functions for:
</para>
<itemizedlist>
<listitem>
<para>
construct JSON string fields like string, numeric and arrays
</para>
</listitem>
<listitem>
<para>
the main <command>zabbix_api</command> function which is used
to call Zabbix API
</para>
</listitem>
<listitem>
<para>
JSON return values parser/extractor
</para>
</listitem>
<listitem>
<para>
the <command>zapish_init</command> function which reads
<command>~/.zapish.rc</command> configuration file or initialize
if it does not exist
</para>
</listitem>
</itemizedlist>
<para>
At the moment zapish.inc is not fully POSIX SH compliant because it
uses in few places "local" keyword to define functions local
variables. However, the intention is to rewrite it to make it fully
POSIX SH compliant code.
</para>
</refsect1>
<refsect1 id="options">
<title>FUNCTIONS</title>
<para><command>NOTE:</command>Below all json_* functions as last argument must have empty string ("").</para>
<variablelist remap="IP">
<varlistentry>
<term>
<option>json_array_num</option>
</term>
<listitem>
<para>
This function prints string in the format of the JSON table of numbers.
</para>
<para>
Syntax: <command>json_array_num</command> "array_name" num1 [[num2] ...] ""
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>json_array_str</option>
</term>
<listitem>
<para>
This function prints string in the format of the JSON table of strings.
</para>
<para>
Syntax: <command>json_array_str</command> "array_name" "str1" [["str2"] ...] ""
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>json_list</option>
</term>
<listitem>
<para>
This function prints string in the format of the JSON list of unspecified elements.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>json_num</option>
</term>
<listitem>
<para>
This function prints list of parameters in the format of the JSON field with list of numbers.
</para>
<para>
Syntax: <command>json_num</command> "list_num_name" num1 [[num2] ...] ""
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>json_str</option>
</term>
<listitem>
<para>
This function prints list of parameters in the format of the JSON field with list of strings.
</para>
<para>
Syntax: <command>json_num</command> "list_str_name" "str1" [["str2"] ...] ""
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>zabbix_api</option>
</term>
<listitem>
<para>
The main zapish function used to call any Zabbix API. This function
expects only one parameter in which should be
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="configuration">
<title>CONFIGURATION</title>
<para>
The <command>zapish.inc</command> functions uses following
configuration variables in <command>~/.zapish.rc</command>:
</para>
<variablelist>
<varlistentry>
<term>
<option>zapish_url</option>
</term>
<listitem>
<para>URL of the Zabbix API gateway used by
<command>zapish.inc</command>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>zapish_auth</option>
</term>
<listitem>
<para>Zabbix API authentication token generated by
<command>user.login</command> API function.</para>
</listitem>
</varlistentry>
</variablelist>
<para>
The <command>~/.zapish.rc</command> file is generated automatically if
it does not exist by any script which includes
<command>zapish.inc</command>. It will prompt to enter the username,
password and the Zabbix API gateway URL. If authentication will be
correct generated authentication token hash and API gateway URL will
be stored in <command>~/.zapish.rc</command>.
</para>
</refsect1>
<refsect1 id="files">
<title>FILES</title>
<variablelist>
<varlistentry>
<term>
<command>/usr/libexec/zapish/zapish.inc</command>
</term>
<listitem>
<para>The default location of the <command>zapish.inc</command> include file.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="exit_codes">
<title>EXIT CODES</title>
<table>
<title>
Functions defined in <command>zapish.inc</command> may exit with the following exit codes:
</title>
<tgroup cols="2" align="left" colsep="1" rowsep="1">
<colspec align="center"/>
<colspec align="left"/>
<thead>
<row>
<entry>Exit code</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>0</entry>
<entry>Success</entry>
</row>
<row>
<entry>1</entry>
<entry>Zabbix API authentication error</entry>
</row>
<row>
<entry>2</entry>
<entry>
First use of zapish. Initialization has been done and <command>~/.zapish.rc</command> file has been created sucessfully
</entry>
</row>
<row>
<entry>3</entry>
<entry>The zabbix_api() called without arguments</entry>
</row>
<row>
<entry>4</entry>
<entry>The zabbix_api() call error</entry>
</row>
</tbody>
</tgroup>
</table>
</refsect1>
<refsect1 id="see_also">
<title>SEE ALSO</title>
<para><citerefentry><refentrytitle>sh</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>bash</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
</para>
<para>
<ulink url="https://github.com/kloczek/zapish/"/>
</para>
<para>
<ulink url="https://www.zabbix.com/documentation/3.4/manual/api/"/>
</para>
</refsect1>
</refentry>