Licenses: Updated the list of licenses and added a PDF containing all license texts
[check_mk.git] / .werks / 3585
blob94ea88e6d0c6983d6b299e28e30b7a56c5c874bd
1 Title: Implemented API for exporting the full host inventory
2 Level: 2
3 Component: inv
4 Class: feature
5 Compatible: compat
6 State: unknown
7 Version: 1.4.0i1
8 Date: 1464704941
10 The HW/SW inventory data can now be exported using a webservice. This webservice
11 outputs the raw structured inventory data of a host.
13 The URL to this webservice is:
15 C+:
16 http://[MONITORING-SERVER]/[SITE]/check_mk/host_inv_api.py?host=[HOST]&output_format=json
17 C-:
19 You choose one of these output formats: <tt>json</tt>, <tt>xml</tt>, <tt>python</tt>.
21 The data provided by this webservice looks as follows:
23 C+:
25     "result": {
26         "hardware": {
27             "memory": {
28                 "total_ram_usable": 16697331712,
29                 "total_swap": 17049841664,
30                 "total_vmalloc": 35184372087808
31             }
32         },
33         "networking": {
34             "hostname": "Klappspaten"
35         }
36     },
37     "result_code": 0
39 C-:
41 The data below the key <tt>result</tt> is the HW/SW inventory data.
43 In case an error occurs during processing of the request, for example a host can not be found,
44 the <tt>result_code</tt> is set to 1 and the result contains the error message:
46 C+:
47 {"result": "Found no inventory data for this host.", "result_code": 1}
48 C-:
51 You can also request data of multiple hosts at once. In this case, you need to specify your request like this:
53 C+:
54 http://[MONITORING-SERVER]/[SITE]/check_mk/host_inv_api.py?request={"hosts": ["host1", "host2"]}&output_format=json
55 C-:
57 You will then get an answer that is similar to the answer above. With the difference that the top level dictionary
58 uses the host names as keys and the values are the inventory tree of this host.
60 C+:
62     "result": {
63         "gestern": {
64             "hardware": {
65                 "memory": {
66                     "total_ram_usable": 16697307136,
67                     "total_swap": 17049841664,
68                     "total_vmalloc": 35184372087808
69                 }
70             },
71             "networking": {
72                 "hostname": "Klappspaten"
73             }
74         },
75         "heute": {
76             "hardware": {
77                 "memory": {
78                     "total_ram_usable": 16697307136,
79                     "total_swap": 17049841664,
80                     "total_vmalloc": 35184372087808
81                 }
82             },
83             "networking": {
84                 "hostname": "Klappspaten"
85             }
86         },
87         "slave": {}
88     },
89     "result_code": 0
91 C-:
93 Another difference in this mode: When a host has no inventory data, the host has an empty dictionary as value
94 instead of providing an error result.
97 If you want to only have a subset of inventory data, you can specify a list of <i>inventory paths</i> which are then
98 used to filter the tree. Only hosts that have those paths will show the trees.
100 For example, if you only want to see the total and swap memory information of a single host, you can use the following URL:
103 http://[MONITORING-SERVER]/[SITE]/check_mk/host_inv_api.py?host=[HOST]&request={"paths": [".hardware.memory.total_ram_usable", ".hardware.memory.total_swap"]}&output_format=json
106 You will get back only the requested data:
110     "result": {
111         "": {
112             "hardware": {
113                 "memory": {
114                     "total_ram_usable": 16697307136,
115                     "total_swap": 17049841664
116                 }
117             }
118         }
119     },
120     "result_code": 0