Code

a6d7314b41844108c4368b10a1e8c584b1a4ae7e
[sysdb.git] / doc / sysdbql.7.txt
1 sysdbql(7)
2 ==========
3 Sebastian "tokkee" Harl <sh@tokkee.org>
4 version {package_version}, {build_date}
5 :doctype: manpage
7 NAME
8 ----
9 sysdbql - the SysDB query language
11 SYNOPSIS
12 --------
14   LIST;
16   QUERY hosts WHERE attribute.architecture = 'amd64';
18 DESCRIPTION
19 -----------
20 include::sysdb-description.txt[]
22 The SysDB query language is a human-readable format for describing a request
23 to retrieve data from a SysDB daemon. It is very remotely similar to the
24 Standard Query Language (SQL) supported by relational database management
25 systems (RDBMS) but specialized for SysDB's use-case.
27 QUERY COMMANDS
28 --------------
29 Each command is terminated by a semicolon. The following commands are
30 available to retrieve information from SysDB:
32 *LIST*::
33 Retrieve a sorted (by name) list of all hosts currently stored in SysDB. The
34 return value is a list of hosts where each host description includes its name,
35 the timestamp of the last update of the object in SysDB and an approximation
36 of the interval with which the host was updated.
38 *FETCH* '<hostname>'::
39 Retrieve detailed information about the specified host object. The return
40 value includes the hostname, a list of services referenced by the host, and a
41 list of attributes for the host and each service. If the host does not exist,
42 an error is returned.
44 *LOOKUP* hosts *WHERE* '<search_condition>'::
45 Retrieve detailed information about all host objects matching the specified
46 search condition. The return value is a list of detailed information for each
47 matching host providing the same details as returned by the *FETCH* command.
48 See the section "WHERE clause" for more details about how to specify the
49 search condition.
51 WHERE clause
52 ~~~~~~~~~~~~
53 The *WHERE* clause in a query specifies a boolean expression which is used to
54 match host objects based on their names, their attributes, or services
55 referenced by the host. Each *WHERE* clause may be made up of one or multiple
56 subexpressions each matching on one criteria. The following subexpressions
57 are supported by SysDB:
59 '<field>' '<operator>' '<value>'::
60         Match a named field against the specified value. See below for what fields
61         and operators are supported.
63 *NOT* '<subexpression>'::
64         Invert the boolean result of the specified subexpression.
66 '<subexpression>' *AND* '<subexpression>'::
67 '<subexpression>' *OR* '<subexpression>'::
68         Combine multiple subexpressions using logical AND or logical OR.
70 The following fields may be queried:
72 *host.name*::
73         The full name of the host.
75 *service.name*::
76         The full service name as referenced by the host.
78 *attribute.name*::
79         The full name of a host attribute.
81 *attribute.*'<name>'::
82         The value of the named host attribute. If an attribute of the specified
83         does not exist, each comparison is treated as if the value does not match.
85 The following operators may be used to match field values:
87 *=*::
88         Evaluates to true if the field value exactly matches the specified value.
90 *!=*::
91         Evaluates to true if the field value does not match the exact specified
92         value.
94 *=~*::
95         Evaluates to true if the field value matches the specified regular
96         expression. SysDB uses POSIX extended regular expressions.
98 *!~*::
99         Evalues to true if the field value does not match the specified regular
100         expression.
102 RESPONSE FORMAT
103 ---------------
104 The JavaScript Object Notation (JSON) format, as specified in RFC 4627, is
105 used in all replies from the server. http://www.ietf.org/rfc/rfc4627.txt
107 EXAMPLES
108 --------
109 The following examples illustrate the use of the commands and what their
110 replies look like. The replies are pretty-printed to more easily follow them.
112   LIST;
113   {"hosts":[{
114       "name": "host1.example.com",
115       "last_update": "2001-02-03 04:05:06 +0700",
116       "update_interval": "5m4s"
117     },{
118       "name": "host2.example.com",
119       "last_update": "2001-02-03 04:05:06 +0700",
120       "update_interval": "5m4s"
121     }]}
123   FETCH 'host1.example.com';
124   {
125       "name": "host1.example.com",
126       "last_update": "2001-02-03 04:05:06 +0700",
127       "update_interval": "5m4s",
128       "attributes": [{
129           "name": "architecture",
130           "value": "amd64",
131           "last_update": "2001-02-03 04:05:06 +0700",
132           "update_interval": "5m4s"
133         },{
134           ...
135         }],
136       "services": [{
137           "name": "some service",
138           "last_update": "2001-02-03 04:05:06 +0700",
139           "update_interval": "5m4s"
140         },{
141           ...
142         }]}
144   LOOKUP hosts WHERE attribute.architecture = 'amd64';
145   [{
146       "name": "host1.example.com",
147       "last_update": "2001-02-03 04:05:06 +0700",
148       "update_interval": "5m4s",
149       "attributes": [{
150           "name": "architecture",
151           "value": "amd64",
152           "last_update": "2001-02-03 04:05:06 +0700",
153           "update_interval": "5m4s"
154         },{
155           ...
156         }],
157       "services": [{
158           "name": "some service",
159           "last_update": "2001-02-03 04:05:06 +0700",
160           "update_interval": "5m4s"
161         },{
162           ...
163     }]},{
164       ...
165     }]
167 SEE ALSO
168 --------
169 *sysdb*(1)
171 AUTHOR
172 ------
173 SysDB was written by Sebastian "tokkee" Harl <sh@tokkee.org>.
175 COPYRIGHT
176 ---------
177 Copyright (C) 2012-2014 Sebastian "tokkee" Harl <sh@tokkee.org>
179 This is free software under the terms of the BSD license, see the source for
180 copying conditions. There is NO WARRANTY; not even for MERCHANTABILITY or
181 FITNESS FOR A PARTICULAR PURPOSE.
183 // vim: set tw=78 sw=4 ts=4 noexpandtab spell spelllang=en_us :