@@ -2144,20 +2144,80 @@ def test_host_passive_ws(self):
2144
2144
# -----
2145
2145
2146
2146
# -----
2147
- # 2/ Upload an host information
2147
+ # 2/ Upload an host (only) information
2148
2148
now = int (time .time ())
2149
+ # Only the host name, no live state data
2149
2150
data = {
2150
- "name" : "test_host_0" ,
2151
+ 'name' : 'test_host'
2152
+ }
2153
+ raw_data = req .post ("http://localhost:7770/host" ,
2154
+ data = json .dumps (data ),
2155
+ headers = {'Content-Type' : 'application/json' }, verify = False )
2156
+ print ("command, got (raw): %s" % (raw_data .content ))
2157
+ assert raw_data .status_code == 200
2158
+ data = raw_data .json ()
2159
+ print ("Got: %s" % data )
2160
+ # Status: OK
2161
+ # Host is alive :)
2162
+ # Created and raised an host passive check command
2163
+ # No issues
2164
+ assert data == {
2165
+ u'_status' : u'OK' ,
2166
+ u'_result' : [
2167
+ u'test_host is alive :)' ,
2168
+ u'Raised: [%s] PROCESS_HOST_CHECK_RESULT;test_host;0;' % now
2169
+ ],
2170
+ u'_issues' : []
2171
+ }
2172
+
2173
+ # Now, with live state data
2174
+ now = int (time .time ())
2175
+ data = {
2176
+ "name" : "test_host" ,
2151
2177
"livestate" : {
2152
2178
"state" : "UP" ,
2153
2179
"output" : "Output..." ,
2154
2180
"long_output" : "Long output..." ,
2155
2181
"perf_data" : "'counter'=1" ,
2156
2182
}
2157
2183
}
2184
+ raw_data = req .post ("http://localhost:7770/host" ,
2185
+ data = json .dumps (data ),
2186
+ headers = {'Content-Type' : 'application/json' }, verify = False )
2187
+ print ("command, got (raw): %s" % (raw_data .content ))
2188
+ assert raw_data .status_code == 200
2189
+ data = raw_data .json ()
2190
+ print ("Got: %s" % data )
2191
+ # Status: OK
2192
+ # Host is alive :)
2193
+ # Created and raised an host passive check command
2194
+ # No issues
2195
+ assert data == {
2196
+ u'_status' : u'OK' ,
2197
+ u'_result' : [
2198
+ u'test_host is alive :)' ,
2199
+ u"Raised: [%s] PROCESS_HOST_CHECK_RESULT;test_host;0;Output...|'counter'=1\n Long output..." % now
2200
+ ],
2201
+ u'_issues' : []
2202
+ }
2158
2203
2204
+ # -----
2205
+ # 3/ Upload an host and its services information
2206
+ now = int (time .time ())
2207
+ # Only the host and its services names, no live state data
2159
2208
data = {
2160
- 'name' : 'test_host'
2209
+ 'name' : 'test_host' ,
2210
+ "services" : [
2211
+ {
2212
+ "name" : "test_ok_0"
2213
+ },
2214
+ {
2215
+ "name" : "test_ok_1"
2216
+ },
2217
+ {
2218
+ "name" : "test_ok_2"
2219
+ }
2220
+ ]
2161
2221
}
2162
2222
raw_data = req .post ("http://localhost:7770/host" ,
2163
2223
data = json .dumps (data ),
@@ -2168,19 +2228,22 @@ def test_host_passive_ws(self):
2168
2228
print ("Got: %s" % data )
2169
2229
# Status: OK
2170
2230
# Host is alive :)
2171
- # Created and raised an host passive check command
2231
+ # Services are in OK state
2232
+ # Created and raised some host and services passive check command
2172
2233
# No issues
2173
2234
assert data == {
2174
2235
u'_status' : u'OK' ,
2175
2236
u'_result' : [
2176
2237
u'test_host is alive :)' ,
2177
- u'Raised: [%s] PROCESS_HOST_CHECK_RESULT;test_host;0;' % now
2238
+ u'Raised: [%s] PROCESS_HOST_CHECK_RESULT;test_host;0;' % now ,
2239
+ u'Raised: [%s] PROCESS_SERVICE_CHECK_RESULT;test_host;test_ok_0;0;' % now ,
2240
+ u'Raised: [%s] PROCESS_SERVICE_CHECK_RESULT;test_host;test_ok_1;0;' % now ,
2241
+ u'Raised: [%s] PROCESS_SERVICE_CHECK_RESULT;test_host;test_ok_2;0;' % now
2178
2242
],
2179
2243
u'_issues' : []
2180
2244
}
2181
2245
2182
- # -----
2183
- # 2/ Upload an host information
2246
+ # Now, with live state data
2184
2247
now = int (time .time ())
2185
2248
data = {
2186
2249
'name' : 'test_host' ,
@@ -2214,20 +2277,6 @@ def test_host_passive_ws(self):
2214
2277
},
2215
2278
]
2216
2279
}
2217
- data = {
2218
- 'name' : 'test_host' ,
2219
- "services" : [
2220
- {
2221
- "name" : "test_ok_0"
2222
- },
2223
- {
2224
- "name" : "test_ok_1"
2225
- },
2226
- {
2227
- "name" : "test_ok_2"
2228
- }
2229
- ]
2230
- }
2231
2280
raw_data = req .post ("http://localhost:7770/host" ,
2232
2281
data = json .dumps (data ),
2233
2282
headers = {'Content-Type' : 'application/json' }, verify = False )
@@ -2237,16 +2286,16 @@ def test_host_passive_ws(self):
2237
2286
print ("Got: %s" % data )
2238
2287
# Status: OK
2239
2288
# Host is alive :)
2240
- # Created and raised an host passive check command
2289
+ # Created and raised some host and services passive check command
2241
2290
# No issues
2242
2291
assert data == {
2243
2292
u'_status' : u'OK' ,
2244
2293
u'_result' : [
2245
2294
u'test_host is alive :)' ,
2246
- u' Raised: [%s] PROCESS_HOST_CHECK_RESULT;test_host;0;' % now ,
2247
- u' Raised: [%s] PROCESS_SERVICE_CHECK_RESULT;test_host;test_ok_0;3;' % now ,
2248
- u' Raised: [%s] PROCESS_SERVICE_CHECK_RESULT;test_host;test_ok_1;3;' % now ,
2249
- u' Raised: [%s] PROCESS_SERVICE_CHECK_RESULT;test_host;test_ok_2;3;' % now
2295
+ u" Raised: [%s] PROCESS_HOST_CHECK_RESULT;test_host;0;" % now ,
2296
+ u" Raised: [%s] PROCESS_SERVICE_CHECK_RESULT;test_host;test_ok_0;0;Output 0|'counter'=0 \n Long output 0" % now ,
2297
+ u" Raised: [%s] PROCESS_SERVICE_CHECK_RESULT;test_host;test_ok_1;1;Output 1|'counter'=1 \n Long output 1" % now ,
2298
+ u" Raised: [%s] PROCESS_SERVICE_CHECK_RESULT;test_host;test_ok_2;2;Output 2|'counter'=2 \n Long output 2" % now
2250
2299
],
2251
2300
u'_issues' : []
2252
2301
}
0 commit comments