Closed rincebrain closed 11 years ago
The actual problem appears to be that the result it's getting back has an empty "text" payload:
(Pdb) list 314 """ 315 Return the Python representation of`s`(a`str`or`unicode
316 instance containing a JSON document)
317
318 """
319 -> obj, end = self.raw_decode(s, idx=_w(s, 0).end())
320 end = _w(s, end).end()
321 if end != len(s):
322 raise ValueError(errmsg("Extra data", s, end, len(s)))
323 return obj
324
(Pdb) p s
None
(Pdb) up
/usr/lib64/python2.6/json/init.py(307)loads() -> return _default_decoder.decode(s) (Pdb) p s None (Pdb) list 302 303 """ 304 if (cls is None and encoding is None and object_hook is None and 305 parse_int is None and parse_float is None and 306 parse_constant is None and not kw): 307 -> return _default_decoder.decode(s) 308 if cls is None: 309 cls = JSONDecoder 310 if object_hook is not None: 311 kw['object_hook'] = object_hook 312 if parse_float is not None: (Pdb) up /root/nagios-api/nagios-cli(133)api() -> resobj = loads(res.text) (Pdb) p res <Response [200]> (Pdb) p res.text None
No idea what the underlying cause is at the moment.
Well, this looks like a server problem.
HTTP/1.1 200 200 OK
Content-Length: 32
Content-Type: application/json
Server: diesel-http-server
Date: Fri, 04 Jan 2013 20:36:38 UTC
{"content": {}, "success": true}```
Evidently, this is what transpires if you point the server at the state retention file and not the status file.
I'll make something detect that so that people who make stupid mistakes like that (e.g. me) can get notified and not silently proceed if they do it, and submit a pull request
No, this seems to happen even when I'm getting the correct results back.
Content-Type: application/json
Server: diesel-http-server
Date: Tue, 29 Jan 2013 18:18:09 UTC
{"content": {[elided]}
Nagios 3.4.1, Python 2.6
# nagios-cli -H localhost -p 8090 hosts Traceback (most recent call last): File "/usr/bin/nagios-cli", line 526, in <module> sys.exit(main(sys.argv[0:])) File "/usr/bin/nagios-cli", line 486, in main temp = api(['objects']) File "/usr/bin/nagios-cli", line 133, in api resobj = loads(res.text) File "/usr/lib64/python2.6/json/__init__.py", line 307, in loads return _default_decoder.decode(s) File "/usr/lib64/python2.6/json/decoder.py", line 319, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) TypeError: expected string or buffer
This is not because the server's not running - contrast:
# nagios-cli -H localhost -p 8085 hosts Failed connecting to nagios-api server