opinkerfi / adagios

Adagios - Web Based Nagios Configuration
GNU Affero General Public License v3.0
330 stars 75 forks source link

Error when editing service such as ssh or http, Exception Type: KeyError at /rest/pynag/json/check_command #486

Closed sschueller closed 9 years ago

sschueller commented 9 years ago

I tried to change the port on which ssh is checked but I get the following error after a clean install of adagios on debian Wheezy 7.6

KeyError at /rest/pynag/json/check_command
'None'

Request Method: POST
Request URL: http://mydomain.com/adagios/rest/pynag/json/check_command
Django Version: 1.4.5
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path: ['/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7']
Server time: Sun, 30 Nov 2014 16:35:46 +0000
Installed Applications:
['django.contrib.sites',
 'adagios.objectbrowser',
 'adagios.rest',
 'adagios.misc',
 'adagios.pnp',
 'adagios.status',
 'adagios.pages',
 'adagios.bi']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware')

Traceback:
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  109.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view
  77.         return view_func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/adagios/rest/views.py" in handle_request
  62.             result = item(**arguments)
File "/usr/lib/python2.7/dist-packages/adagios/misc/helpers.py" in check_command
  306.         my_object = Model.Service.objects.get_by_name(name)
File "/usr/lib/python2.7/dist-packages/pynag/Model/__init__.py" in get_by_name
  480.         return ObjectFetcher._cached_names[self.object_type][object_name]

Exception Type: KeyError at /rest/pynag/json/check_command
Exception Value: 'None'
Request information:
GET: No GET data

POST:
service_description = u'SSH'
check_command = u'check_ssh'
host_name = u'None'
name = u'None'

FILES: No FILES data

COOKIES:
csrftoken = 'PQGtsl7n2DQJknNJaRXur7ua6XCJs093'
wooTracker = 'tjX90yl3NdPe'

META:
AUTH_TYPE = 'Basic'
mod_wsgi.listener_port = '80'
HTTP_REFERER = 'http://mydomain.com/adagios/objectbrowser/id=2392497936279264025'
mod_wsgi.listener_host = ''
SERVER_SOFTWARE = 'Apache/2.2.22 (Debian)'
SCRIPT_NAME = u'/adagios'
mod_wsgi.handler_script = ''
SERVER_SIGNATURE = '<address>Apache/2.2.22 (Debian) Server at mydomain.com Port 80</address>\n'
REQUEST_METHOD = 'POST'
PATH_INFO = u'/rest/pynag/json/check_command'
HTTP_ORIGIN = 'http://mydomain.com'
SERVER_PROTOCOL = 'HTTP/1.1'
QUERY_STRING = ''
CONTENT_LENGTH = '72'
HTTP_USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'
HTTP_CONNECTION = 'keep-alive'
HTTP_COOKIE = 'wooTracker=tjX90yl3NdPe; csrftoken=PQGtsl7n2DQJknNJaRXur7ua6XCJs093'
SERVER_NAME = 'mydomain.com'
REMOTE_ADDR = '0.0.0.0'
mod_wsgi.request_handler = 'wsgi-script'
wsgi.url_scheme = 'http'
PATH_TRANSLATED = '/var/www/rest/pynag/json/check_command'
SERVER_PORT = '80'
wsgi.multiprocess = True
mod_wsgi.input_chunked = '0'
SERVER_ADDR = '0.0.0.0'
DOCUMENT_ROOT = '/var/www'
mod_wsgi.process_group = 'adagios'
HTTP_PRAGMA = 'no-cache'
HTTP_X_REQUESTED_WITH = 'XMLHttpRequest'
SCRIPT_FILENAME = '/usr/lib/python2.7/dist-packages/adagios/wsgi.py'
SERVER_ADMIN = 'webmaster@localhost'
wsgi.input = <mod_wsgi.Input object at 0x7f7e4c555630>
REMOTE_USER = 'nagiosadmin'
HTTP_HOST = 'mydomain.com'
wsgi.multithread = True
mod_wsgi.callable_object = 'application'
HTTP_CACHE_CONTROL = 'no-cache'
REQUEST_URI = '/adagios/rest/pynag/json/check_command'
HTTP_ACCEPT = 'application/json, text/javascript, */*; q=0.01'
wsgi.version = 
GATEWAY_INTERFACE = 'CGI/1.1'
wsgi.run_once = False
wsgi.errors = <mod_wsgi.Log object at 0x7f7e4c555930>
REMOTE_PORT = '16364'
HTTP_ACCEPT_LANGUAGE = 'en-US,en;q=0.8,de-CH;q=0.6,de;q=0.4,es;q=0.2'
mod_wsgi.version = 
CONTENT_TYPE = 'application/json'
mod_wsgi.application_group = 'mydomain.com|/adagios'
mod_wsgi.script_reloading = '1'
wsgi.file_wrapper = ''
CSRF_COOKIE = 'PQGtsl7n2DQJknNJaRXur7ua6XCJs093'
HTTP_ACCEPT_ENCODING = 'gzip, deflate'

Settings:
Using settings module adagios.settings
USE_L10N = True
USE_THOUSAND_SEPARATOR = False
CSRF_COOKIE_SECURE = False
LANGUAGE_CODE = 'en-us'
ROOT_URLCONF = 'adagios.urls'
MANAGERS = 
DEFAULT_CHARSET = 'utf-8'
STATIC_ROOT = ''
ALLOWED_HOSTS = ['*']
MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'
EMAIL_SUBJECT_PREFIX = '[Django] '
FILE_UPLOAD_PERMISSIONS = None
URL_VALIDATOR_USER_AGENT = 'Django/1.4.5 (https://www.djangoproject.com)'
STATICFILES_FINDERS = 
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_NAME = 'sessionid'
ADMIN_FOR = 
TIME_INPUT_FORMATS = 
DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'TEST_MIRROR': None, 'NAME': '/tmp/test', 'TEST_CHARSET': None, 'TIME_ZONE': 'UTC', 'TEST_COLLATION': None, 'PORT': '', 'HOST': '', 'USER': '', 'TEST_NAME': None, 'PASSWORD': u'********************', 'OPTIONS': {}}}
SERVER_EMAIL = 'root@localhost'
FILE_UPLOAD_HANDLERS = 
DEFAULT_CONTENT_TYPE = 'text/html'
APPEND_SLASH = True
FIRST_DAY_OF_WEEK = 0
DATABASE_ROUTERS = []
YEAR_MONTH_FORMAT = 'F Y'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
CACHES = {'default': {'LOCATION': '', 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
SESSION_COOKIE_PATH = '/'
USE_X_FORWARDED_HOST = False
MIDDLEWARE_CLASSES = 
USE_I18N = True
THOUSAND_SEPARATOR = ','
SECRET_KEY = u'********************'
LANGUAGE_COOKIE_NAME = 'django_language'
DEFAULT_INDEX_TABLESPACE = ''
TRANSACTIONS_MANAGED = False
LOGGING_CONFIG = 'django.utils.log.dictConfig'
SEND_BROKEN_LINK_EMAILS = False
TEMPLATE_LOADERS = 
WSGI_APPLICATION = None
TEMPLATE_DEBUG = True
X_FRAME_OPTIONS = 'SAMEORIGIN'
AUTHENTICATION_BACKENDS = 'django.contrib.auth.backends.ModelBackend'
FORCE_SCRIPT_NAME = None
CACHE_BACKEND = 'locmem://'
SIGNING_BACKEND = 'django.core.signing.TimestampSigner'
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_DOMAIN = None
FILE_CHARSET = 'utf-8'
DEBUG = True
SESSION_FILE_PATH = None
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
INSTALLED_APPS = ['django.contrib.sites', 'adagios.objectbrowser', 'adagios.rest', 'adagios.misc', 'adagios.pnp', 'adagios.status', 'adagios.pages', 'adagios.bi']
LANGUAGES = 
COMMENTS_ALLOW_PROFANITIES = False
STATICFILES_DIRS = 
PREPEND_WWW = False
SECURE_PROXY_SSL_HEADER = None
SESSION_COOKIE_HTTPONLY = True
DEBUG_PROPAGATE_EXCEPTIONS = False
MONTH_DAY_FORMAT = 'F j'
LOGIN_URL = '/accounts/login/'
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
TIME_FORMAT = 'P'
DATE_INPUT_FORMATS = 
CSRF_COOKIE_NAME = 'csrftoken'
EMAIL_HOST_PASSWORD = u'********************'
PASSWORD_RESET_TIMEOUT_DAYS = u'********************'
CACHE_MIDDLEWARE_ALIAS = 'default'
SESSION_SAVE_EVERY_REQUEST = False
NUMBER_GROUPING = 0
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
CSRF_FAILURE_VIEW = 'django.views.csrf.csrf_failure'
CSRF_COOKIE_PATH = '/'
LOGIN_REDIRECT_URL = '/accounts/profile/'
LOGGING = {'loggers': {'django.request': {'handlers': ['mail_admins'], 'propagate': True, 'level': 'ERROR'}}, 'version': 1, 'disable_existing_loggers': False, 'filters': {'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse'}}, 'handlers': {'mail_admins': {'class': 'django.utils.log.AdminEmailHandler', 'filters': ['require_debug_false'], 'level': 'ERROR'}}}
IGNORABLE_404_URLS = 
LOCALE_PATHS = 
TEMPLATE_STRING_IF_INVALID = ''
LOGOUT_URL = '/accounts/logout/'
EMAIL_USE_TLS = False
FIXTURE_DIRS = 
EMAIL_HOST = 'localhost'
DATE_FORMAT = 'N j, Y'
MEDIA_ROOT = '/usr/lib/python2.7/dist-packages/adagios/media/'
DEFAULT_EXCEPTION_REPORTER_FILTER = 'django.views.debug.SafeExceptionReporterFilter'
ADMINS = 
FORMAT_MODULE_PATH = None
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
MEDIA_URL = 'media/'
DATETIME_FORMAT = 'N j, Y, P'
TEMPLATE_DIRS = '/usr/lib/python2.7/dist-packages/adagios/templates'
SITE_ID = 1
DISALLOWED_USER_AGENTS = 
ALLOWED_INCLUDE_ROOTS = 
DECIMAL_SEPARATOR = '.'
SHORT_DATE_FORMAT = 'm/d/Y'
TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner'
CACHE_MIDDLEWARE_KEY_PREFIX = u'********************'
TIME_ZONE = None
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_TABLESPACE = ''
TEMPLATE_CONTEXT_PROCESSORS = 
SESSION_COOKIE_AGE = 1209600
SETTINGS_MODULE = 'adagios.settings'
USE_ETAGS = False
LANGUAGES_BIDI = 
FILE_UPLOAD_TEMP_DIR = None
INTERNAL_IPS = 
STATIC_URL = None
EMAIL_PORT = 25
USE_TZ = True
SHORT_DATETIME_FORMAT = 'm/d/Y P'
PASSWORD_HASHERS = u'********************'
ABSOLUTE_URL_OVERRIDES = {}
CACHE_MIDDLEWARE_SECONDS = 600
DATETIME_INPUT_FORMATS = 
EMAIL_HOST_USER = ''
PROFANITIES_LIST = u'********************'

You're seeing this error because you have DEBUG = True in your
Django settings file. Change that to False, and Django will
display a standard 500 page.

Any suggetions?

palli commented 9 years ago

Hey, thanks for the bug report.

Can you give us a little bit more information, specifically:

From the output it looks like adagios is trying to get a check command called 'None' which looks erroneous. It would help to see the definitions to know what exactly is going on, and so that we can reproduce this locally.

sschueller commented 9 years ago

Hi,

I installed it on a fresh machine from here: https://github.com/opinkerfi/adagios/wiki/Install-guide

pynag 0.7.0-1 adagios 1.2.8.git.1.gbdd91aa1

I am opening the service to edit it, In the second tab it just sais loading. in the chrome inspector I see that the request above failed with that error. I have deleted the service now and recreated them which seems to work.

Additionally when I create a new host I get an error (Unable to get object) but I can go back and edit the host fine afterwards.

I just saw that version 1.6.1 is the latest stable so I will try that. Why isn't that version in the repository?

Thanks

palli commented 9 years ago

Oh boy, that is really old (our users come from the rhel world, and centos6 packages are up to date)

I will take a look at the outdated packages. In the meantime if you are anxious to try, you can use pip:

pip install --upgrade https://github.com/opinkerfi/adagios/zipball/master

The debian packages were preferred because they handle all of the configuration for you (like creating apache configuration for example) so it will always be less hazzle to use deb packages... But they kind of have to be up to date :)

sschueller commented 9 years ago

I got it to work with PIP and a few manual adjustments. I think the django version in the wheezy repo is also too old.

Works good now. If I get a chance I will try to update the docs for getting it to run on Debian and do a PR.

Thanks.

palli commented 9 years ago

Thanks for the update @sschueller .. Let us know if you do a documentation update.

Marking this as closed.