Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NCPA Windows Agent Api Error #114

Closed
ravenich opened this issue Jan 5, 2015 · 8 comments
Closed

NCPA Windows Agent Api Error #114

ravenich opened this issue Jan 5, 2015 · 8 comments
Assignees
Labels

Comments

@ravenich
Copy link

ravenich commented Jan 5, 2015

In Windows 2008 SP2 (Russian Language) after opening agent web interface api shows this error:
Internal Server Error
Same error on the Windows Server 2008R2 SP1.
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Log file from the 2008 :
In 2008R2 og file the same.
In \Nagios\NCPA\var\ncpa_listener.log:
2015-01-05 23:34:51,621:INFO:handler:127.0.0.1 - - [2015-01-05 23:34:51] "GET /api HTTP/1.1" 301 432 0.002000
2015-01-05 23:34:51,622:DEBUG:handler:Initializing WebSocket
2015-01-05 23:34:51,624:DEBUG:handler:Validating WebSocket request
2015-01-05 23:34:51,624:DEBUG:init:Getting accessor:
2015-01-05 23:34:51,694:ERROR:app:Exception on /api/ [GET]
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\flask\app.py", line 1504, in wsgi_app
File "C:\Python27\lib\site-packages\flask\app.py", line 1264, in full_dispatch_request
File "C:\Python27\lib\site-packages\flask\app.py", line 1262, in full_dispatch_request
File "C:\Python27\lib\site-packages\flask\app.py", line 1248, in dispatch_request
File "C:\ncpa\agent\listener\server.py", line 68, in decorated
File "C:\ncpa\agent\listener\server.py", line 420, in api
File "C:\Python27\lib\site-packages\flask\helpers.py", line 120, in jsonify
File "C:\Python27\lib\json__init__.py", line 250, in dumps
File "C:\Python27\lib\json\encoder.py", line 209, in encode
File "C:\Python27\lib\json\encoder.py", line 434, in _iterencode
File "C:\Python27\lib\json\encoder.py", line 408, in _iterencode_dict
File "C:\Python27\lib\json\encoder.py", line 408, in _iterencode_dict
File "C:\Python27\lib\json\encoder.py", line 408, in _iterencode_dict
File "C:\Python27\lib\json\encoder.py", line 408, in _iterencode_dict
File "C:\Python27\lib\json\encoder.py", line 332, in _iterencode_list
File "C:\Python27\lib\json\encoder.py", line 313, in _iterencode_list
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc0 in position 0: invalid start byte
2015-01-05 23:34:51,696:INFO:handler:127.0.0.1 - - [2015-01-05 23:34:51] "GET /api/ HTTP/1.1" 500 412 0.073000
2015-01-05 23:34:51,766:DEBUG:handler:Initializing WebSocket
2015-01-05 23:34:51,766:DEBUG:handler:Validating WebSocket request
2015-01-05 23:34:51,767:INFO:handler:127.0.0.1 - - [2015-01-05 23:34:51] "GET /favicon.ico HTTP/1.1" 404 342 0.002000

@scot0357 scot0357 added the Bug label Jan 8, 2015
@scot0357 scot0357 added this to the 1.8.0 milestone Jan 8, 2015
@scot0357
Copy link
Contributor

scot0357 commented Jan 8, 2015

Yes the russian language part is definitely part of the problem as indicated by the unicode errors. Can you tell me the host name of the computer you are running it on? Can you tell me the user you are running it as? I will attempt to duplicate this.

@ravenich
Copy link
Author

Hostname of the computer is : DC2.It.local. Service running from LocalSystem Account. I try open browser from admin account. In russian called "Администратор".

@scot0357
Copy link
Contributor

@ravenich can you try to access a few trees via the web interface on the remote box for me?

https://<ncpaserver>:5693/api/disk/logical?token=mytoken
https://<ncpaserver>:5693/api/disk/physical?token=mytoken
https://<ncpaserver>:5693/api/cpu?token=mytoken
https://<ncpaserver>:5693/api/interface?token=mytoken
https://<ncpaserver>:5693/api/memory?token=mytoken
https://<ncpaserver>:5693/api/user?token=mytoken
https://<ncpaserver>:5693/api/system?token=mytoken

Do some of those break for you? Do all of those break for you?

@ravenich
Copy link
Author

Breaks only on https://:5693/api/user?token=mytoken.
Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
In ncpa_listener.log:
2015-01-12 11:26:08,562:ERROR:app:Exception on /api/user [GET]
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\flask\app.py", line 1504, in wsgi_app
File "C:\Python27\lib\site-packages\flask\app.py", line 1264, in full_dispatch_request
File "C:\Python27\lib\site-packages\flask\app.py", line 1262, in full_dispatch_request
File "C:\Python27\lib\site-packages\flask\app.py", line 1248, in dispatch_request
File "C:\ncpa\agent\listener\server.py", line 68, in decorated
File "C:\ncpa\agent\listener\server.py", line 420, in api
File "C:\Python27\lib\site-packages\flask\helpers.py", line 120, in jsonify
File "C:\Python27\lib\json__init__.py", line 250, in dumps
File "C:\Python27\lib\json\encoder.py", line 209, in encode
File "C:\Python27\lib\json\encoder.py", line 434, in _iterencode
File "C:\Python27\lib\json\encoder.py", line 408, in _iterencode_dict
File "C:\Python27\lib\json\encoder.py", line 408, in _iterencode_dict
File "C:\Python27\lib\json\encoder.py", line 408, in _iterencode_dict
File "C:\Python27\lib\json\encoder.py", line 332, in _iterencode_list
File "C:\Python27\lib\json\encoder.py", line 313, in _iterencode_list
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc0 in position 0: invalid start byte
2015-01-12 11:26:08,565:INFO:handler:127.0.0.1 - - [2015-01-12 11:26:08] "GET /api/user?token=mytoken HTTP/1.1" 500 412 0.025000

@scot0357
Copy link
Contributor

I dug into this, and there is currently a bug open to it with psutil giampaolo/psutil#565. This pull request will fix it, however, it is in psutil 2.2.1, which has not been released. I added a quick fix to cast all the items to ascii, a solution I definitely do not like, however, in the face of guessing the encoding and getting it wrong or forcing it to ascii, I think the latter is the better choice. I'm going to set this for the 1.9.0 milestone for an actual fix, but the temporary fix should fix your API access for now. Temp fix is in https://github.com/NagiosEnterprises/ncpa/tree/ascii-unicode-fix.

@scot0357 scot0357 modified the milestones: 1.9.0, 1.8.0 Jan 13, 2015
@varnar
Copy link

varnar commented Jan 16, 2015

Hello @scot0357
I have same issue, but my server is not in Russian language - it is pure English version of 2008
And I get the issue only on this server and only with this check.

2015-01-16 05:28:07,201:DEBUG:__init__:Getting accessor: agent/plugin/qt_uptime.vbs/-h/.
2015-01-16 05:28:07,201:DEBUG:__init__:Running process with command line: `cscript C:\Program Files\Nagios\NCPA\plugins\qt_uptime.vbs -h . //NoLogo`
2015-01-16 05:28:07,296:ERROR:app:Exception on /api/agent/plugin/qt_uptime.vbs/-h/. [GET]
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\flask\app.py", line 1504, in wsgi_app
  File "C:\Python27\lib\site-packages\flask\app.py", line 1264, in full_dispatch_request
  File "C:\Python27\lib\site-packages\flask\app.py", line 1262, in full_dispatch_request
  File "C:\Python27\lib\site-packages\flask\app.py", line 1248, in dispatch_request
  File "C:\ncpa\agent\listener\server.py", line 68, in decorated
  File "C:\ncpa\agent\listener\server.py", line 420, in api
  File "C:\Python27\lib\site-packages\flask\helpers.py", line 120, in jsonify
  File "C:\Python27\lib\json\__init__.py", line 250, in dumps
  File "C:\Python27\lib\json\encoder.py", line 209, in encode
  File "C:\Python27\lib\json\encoder.py", line 434, in _iterencode
  File "C:\Python27\lib\json\encoder.py", line 408, in _iterencode_dict
  File "C:\Python27\lib\json\encoder.py", line 390, in _iterencode_dict
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa9 in position 115: invalid start byte
2015-01-16 05:28:07,296:INFO:handler:10.98.6.44 - - [2015-01-16 05:28:07] "GET /api/agent/plugin/qt_uptime.vbs/-h/.?token=token&check=1 HTTP/1.0" 500 431 0.094000

And here is result of execution in cmd

cscript "C:\Program Files\Nagios\NCPA\plugins\qt_uptime.vbs" -h localhost
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

OK: Uptime=37 day(s) 14 hour(s) 47 minute(s) and 18 second(s).
FQDN=SERVER, OS Name=Microsoft® Windows Server® 2008 Standard  Service Pack 2, manufacturer=VMware,
Inc., model=VMware Virtual Platform, processor(s)=4, Last boot time (local clock)=2014-12-09 14:50:25

And here result of execution that gives @ravenich error message

https://server:5693/api/user?token=token

{
  "value": {
    "user": {
      "count": [
        3, 
        "c"
      ], 
      "list": [
        [
          "admin1", 
          "admin2", 
          "admin3"
        ], 
        "name"
      ]
    }
  }
}

@varnar
Copy link

varnar commented Jan 17, 2015

it is possible to have in 1.8?
it is blocker for our current installation

Thanks

@jomann09
Copy link
Contributor

I'm looking into this right now - it looks like psutil 2.2.1 was released a few weeks after nick's comment so I believe we can use the original fix for this and incorporate it into 1.8.0

@jomann09 jomann09 modified the milestones: 1.8.0, 1.9.0 Mar 18, 2015
@jomann09 jomann09 self-assigned this Mar 18, 2015
@jomann09 jomann09 closed this as completed Apr 6, 2015
@jomann09 jomann09 modified the milestones: 1.8.2, 1.8.0 May 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants