{"action":"created","comment":{"url":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/comments/120317900","pull_request_review_id":42264613,"id":120317900,"diff_hunk":"@@ -4,89 +4,81 @@\n Query Exasol\n \"\"\"\n \n-import tempfile\n-import subprocess\n-import os\n-\n from zmon_worker_monitor.adapters.ifunctionfactory_plugin import IFunctionFactoryPlugin, propartial\n+from turbodbc import connect\n \n \n class ExaplusFactory(IFunctionFactoryPlugin):\n     def __init__(self):\n         super(ExaplusFactory, self).__init__()\n         # fields from config\n-        self._exacrm_cluster = None\n-        self._exacrm_user = None\n-        self._exacrm_pass = None\n+        self._exasol_user = None\n+        self._exasol_pass = None\n+        self._exasol_driver = None\n \n     def configure(self, conf):\n         \"\"\"\n         Called after plugin is loaded to pass the [configuration] section in their plugin info file\n         :param conf: configuration dictionary\n         \"\"\"\n-        self._exacrm_cluster = conf['exacrm_cluster']\n-        self._exacrm_user = conf['exacrm_user']\n-        self._exacrm_pass = conf['exacrm_pass']\n+        self._exasol_user = conf['exasol_user']\n+        self._exasol_pass = conf['exasol_pass']\n+        self._exasol_driver = conf['exasol_driver']\n \n     def create(self, factory_ctx):\n         \"\"\"\n         Automatically called to create the check function's object\n         :param factory_ctx: (dict) names available for Function instantiation\n         :return: an object that implements a check function\n         \"\"\"\n-        return propartial(ExaplusWrapper, cluster=self._exacrm_cluster, password=self._exacrm_pass,\n-                          user=self._exacrm_user)\n+        return propartial(ExaplusWrapper, cluster=factory_ctx['cluster'], password=self._exasol_pass,\n+                          user=self._exasol_user, schema=factory_ctx['schema'],\n+                          driver=self._exasol_driver)\n \n \n class ExaplusWrapper(object):\n-    def __init__(self, cluster, user='ZALANDO_NAGIOS', password='', schema=False):\n+    def __init__(self, cluster, user='', password='', schema='', driver=''):\n         self._err = None\n         self._out = None\n         self.user = user\n         self.__password = password\n         self.cluster = cluster\n         self.schema = schema\n-        self.java_opts = ['-Djava.net.preferIPv4Stack=true', '-Djava.awt.headless=true', '-Xmx512m', '-Xms128m']\n-        self.exaplus_opts = [\n-            '-recoverConnection',\n-            'OFF',\n-            '-retry',\n-            '0',\n-            '-lang',\n-            'EN',\n-            '-q',\n-            '-x',\n-            '-Q',\n-            '10',\n-            '-pipe',\n-        ]\n-        self.jar_file = '/server/exasol/exaplus/current/exaplus.jar'\n+        self.driver = driver\n \n     def query(self, query):\n-        fd, name = tempfile.mkstemp(suffix='.sql', text=True)\n         try:\n-            fh = os.fdopen(fd, 'w')\n-            fh.write('%s\\n' % query)\n-            fh.flush()\n-\n-            cmd = ['/usr/bin/java']\n-            cmd.extend(self.java_opts)\n-            cmd.extend(['-jar', self.jar_file])\n-            cmd.extend(['-c', self.cluster])\n-            cmd.extend(['-u', self.user])\n-            cmd.extend(['-p', self.__password])\n-            cmd.extend(self.exaplus_opts)\n-            if self.schema:\n-                cmd.extend(['-s', self.schema])\n-            cmd.extend(['-f', name])\n-            # print \"EXAPLUS=\"+\" \".join(cmd)\n-            sub = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)\n-            d_out, d_err = sub.communicate()\n-            self._out = d_out\n-            self._err = d_err\n-        finally:\n-            os.unlink(name)\n+            connection = connect(\n+                driver=self.driver,\n+                EXAHOST=self.cluster,\n+                EXASCHEMA=self.schema,\n+                EXAUID=self.user,\n+                EXAPWD=self.__password)\n+            cursor = connection.cursor()\n+\n+            cursor.execute(query)\n+            self._out = cursor\n+\n+        except Exception as err:\n+            self._err = err","path":"zmon_worker_extras/check_plugins/exasol.py","position":110,"original_position":110,"commit_id":"a07bab796c10f24d56adc4b2b6f1df4e8226acd6","original_commit_id":"a07bab796c10f24d56adc4b2b6f1df4e8226acd6","user":{"login":"mohabusama","id":488406,"avatar_url":"https://avatars0.githubusercontent.com/u/488406?v=3","gravatar_id":"","url":"https://api.github.com/users/mohabusama","html_url":"https://github.com/mohabusama","followers_url":"https://api.github.com/users/mohabusama/followers","following_url":"https://api.github.com/users/mohabusama/following{/other_user}","gists_url":"https://api.github.com/users/mohabusama/gists{/gist_id}","starred_url":"https://api.github.com/users/mohabusama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mohabusama/subscriptions","organizations_url":"https://api.github.com/users/mohabusama/orgs","repos_url":"https://api.github.com/users/mohabusama/repos","events_url":"https://api.github.com/users/mohabusama/events{/privacy}","received_events_url":"https://api.github.com/users/mohabusama/received_events","type":"User","site_admin":false},"body":"I suggest dropping the return ``tuple`` interface. If there is an exception then we either let it raise and bubble or we catch (filter exceptions?) and raise ``CheckError`` with a more informative message. We only return the result in the end.","created_at":"2017-06-06T10:25:35Z","updated_at":"2017-06-06T10:33:15Z","html_url":"https://github.com/zalando-zmon/zmon-worker/pull/232#discussion_r120317900","pull_request_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/232","_links":{"self":{"href":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/comments/120317900"},"html":{"href":"https://github.com/zalando-zmon/zmon-worker/pull/232#discussion_r120317900"},"pull_request":{"href":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/232"}}},"pull_request":{"url":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/232","id":123735135,"html_url":"https://github.com/zalando-zmon/zmon-worker/pull/232","diff_url":"https://github.com/zalando-zmon/zmon-worker/pull/232.diff","patch_url":"https://github.com/zalando-zmon/zmon-worker/pull/232.patch","issue_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/232","number":232,"state":"open","locked":false,"title":"Direct connection using the EXASOL driver","user":{"login":"francescomucio","id":3058143,"avatar_url":"https://avatars1.githubusercontent.com/u/3058143?v=3","gravatar_id":"","url":"https://api.github.com/users/francescomucio","html_url":"https://github.com/francescomucio","followers_url":"https://api.github.com/users/francescomucio/followers","following_url":"https://api.github.com/users/francescomucio/following{/other_user}","gists_url":"https://api.github.com/users/francescomucio/gists{/gist_id}","starred_url":"https://api.github.com/users/francescomucio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/francescomucio/subscriptions","organizations_url":"https://api.github.com/users/francescomucio/orgs","repos_url":"https://api.github.com/users/francescomucio/repos","events_url":"https://api.github.com/users/francescomucio/events{/privacy}","received_events_url":"https://api.github.com/users/francescomucio/received_events","type":"User","site_admin":false},"body":"Problem: ZMON is connecting to EXASOL using a command line tool. The query result is just a list of string, better to have it in json.\r\n\r\nSolution: Wrapper uses now Turbodbc to connect, the EXASOL driver location is in the config file.\r\n\r\nAdditional things: The cluster is now coming from the entity definition. Removed references to exacrm, now everything is just exasol.","created_at":"2017-06-02T14:51:55Z","updated_at":"2017-06-06T10:33:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6dd3143d3c2a1f034c098506293ab8b8a41493d8","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/232/commits","review_comments_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/232/comments","review_comment_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/232/comments","statuses_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/statuses/a07bab796c10f24d56adc4b2b6f1df4e8226acd6","head":{"label":"francescomucio:exasol-turbodbc-worker","ref":"exasol-turbodbc-worker","sha":"a07bab796c10f24d56adc4b2b6f1df4e8226acd6","user":{"login":"francescomucio","id":3058143,"avatar_url":"https://avatars1.githubusercontent.com/u/3058143?v=3","gravatar_id":"","url":"https://api.github.com/users/francescomucio","html_url":"https://github.com/francescomucio","followers_url":"https://api.github.com/users/francescomucio/followers","following_url":"https://api.github.com/users/francescomucio/following{/other_user}","gists_url":"https://api.github.com/users/francescomucio/gists{/gist_id}","starred_url":"https://api.github.com/users/francescomucio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/francescomucio/subscriptions","organizations_url":"https://api.github.com/users/francescomucio/orgs","repos_url":"https://api.github.com/users/francescomucio/repos","events_url":"https://api.github.com/users/francescomucio/events{/privacy}","received_events_url":"https://api.github.com/users/francescomucio/received_events","type":"User","site_admin":false},"repo":{"id":93167284,"name":"zmon-worker","full_name":"francescomucio/zmon-worker","owner":{"login":"francescomucio","id":3058143,"avatar_url":"https://avatars1.githubusercontent.com/u/3058143?v=3","gravatar_id":"","url":"https://api.github.com/users/francescomucio","html_url":"https://github.com/francescomucio","followers_url":"https://api.github.com/users/francescomucio/followers","following_url":"https://api.github.com/users/francescomucio/following{/other_user}","gists_url":"https://api.github.com/users/francescomucio/gists{/gist_id}","starred_url":"https://api.github.com/users/francescomucio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/francescomucio/subscriptions","organizations_url":"https://api.github.com/users/francescomucio/orgs","repos_url":"https://api.github.com/users/francescomucio/repos","events_url":"https://api.github.com/users/francescomucio/events{/privacy}","received_events_url":"https://api.github.com/users/francescomucio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/francescomucio/zmon-worker","description":"ZMON Python Worker","fork":true,"url":"https://api.github.com/repos/francescomucio/zmon-worker","forks_url":"https://api.github.com/repos/francescomucio/zmon-worker/forks","keys_url":"https://api.github.com/repos/francescomucio/zmon-worker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/francescomucio/zmon-worker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/francescomucio/zmon-worker/teams","hooks_url":"https://api.github.com/repos/francescomucio/zmon-worker/hooks","issue_events_url":"https://api.github.com/repos/francescomucio/zmon-worker/issues/events{/number}","events_url":"https://api.github.com/repos/francescomucio/zmon-worker/events","assignees_url":"https://api.github.com/repos/francescomucio/zmon-worker/assignees{/user}","branches_url":"https://api.github.com/repos/francescomucio/zmon-worker/branches{/branch}","tags_url":"https://api.github.com/repos/francescomucio/zmon-worker/tags","blobs_url":"https://api.github.com/repos/francescomucio/zmon-worker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/francescomucio/zmon-worker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/francescomucio/zmon-worker/git/refs{/sha}","trees_url":"https://api.github.com/repos/francescomucio/zmon-worker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/francescomucio/zmon-worker/statuses/{sha}","languages_url":"https://api.github.com/repos/francescomucio/zmon-worker/languages","stargazers_url":"https://api.github.com/repos/francescomucio/zmon-worker/stargazers","contributors_url":"https://api.github.com/repos/francescomucio/zmon-worker/contributors","subscribers_url":"https://api.github.com/repos/francescomucio/zmon-worker/subscribers","subscription_url":"https://api.github.com/repos/francescomucio/zmon-worker/subscription","commits_url":"https://api.github.com/repos/francescomucio/zmon-worker/commits{/sha}","git_commits_url":"https://api.github.com/repos/francescomucio/zmon-worker/git/commits{/sha}","comments_url":"https://api.github.com/repos/francescomucio/zmon-worker/comments{/number}","issue_comment_url":"https://api.github.com/repos/francescomucio/zmon-worker/issues/comments{/number}","contents_url":"https://api.github.com/repos/francescomucio/zmon-worker/contents/{+path}","compare_url":"https://api.github.com/repos/francescomucio/zmon-worker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/francescomucio/zmon-worker/merges","archive_url":"https://api.github.com/repos/francescomucio/zmon-worker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/francescomucio/zmon-worker/downloads","issues_url":"https://api.github.com/repos/francescomucio/zmon-worker/issues{/number}","pulls_url":"https://api.github.com/repos/francescomucio/zmon-worker/pulls{/number}","milestones_url":"https://api.github.com/repos/francescomucio/zmon-worker/milestones{/number}","notifications_url":"https://api.github.com/repos/francescomucio/zmon-worker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/francescomucio/zmon-worker/labels{/name}","releases_url":"https://api.github.com/repos/francescomucio/zmon-worker/releases{/id}","deployments_url":"https://api.github.com/repos/francescomucio/zmon-worker/deployments","created_at":"2017-06-02T13:18:17Z","updated_at":"2017-06-02T13:18:19Z","pushed_at":"2017-06-02T19:47:42Z","git_url":"git://github.com/francescomucio/zmon-worker.git","ssh_url":"git@github.com:francescomucio/zmon-worker.git","clone_url":"https://github.com/francescomucio/zmon-worker.git","svn_url":"https://github.com/francescomucio/zmon-worker","homepage":"https://zmon.io/","size":850,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"zalando-zmon:master","ref":"master","sha":"62756535a177aa7b7268160c416fe8f036cea96d","user":{"login":"zalando-zmon","id":19532842,"avatar_url":"https://avatars0.githubusercontent.com/u/19532842?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando-zmon","html_url":"https://github.com/zalando-zmon","followers_url":"https://api.github.com/users/zalando-zmon/followers","following_url":"https://api.github.com/users/zalando-zmon/following{/other_user}","gists_url":"https://api.github.com/users/zalando-zmon/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando-zmon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando-zmon/subscriptions","organizations_url":"https://api.github.com/users/zalando-zmon/orgs","repos_url":"https://api.github.com/users/zalando-zmon/repos","events_url":"https://api.github.com/users/zalando-zmon/events{/privacy}","received_events_url":"https://api.github.com/users/zalando-zmon/received_events","type":"Organization","site_admin":false},"repo":{"id":28918578,"name":"zmon-worker","full_name":"zalando-zmon/zmon-worker","owner":{"login":"zalando-zmon","id":19532842,"avatar_url":"https://avatars0.githubusercontent.com/u/19532842?v=3","gravatar_id":"","url":"https://api.github.com/users/zalando-zmon","html_url":"https://github.com/zalando-zmon","followers_url":"https://api.github.com/users/zalando-zmon/followers","following_url":"https://api.github.com/users/zalando-zmon/following{/other_user}","gists_url":"https://api.github.com/users/zalando-zmon/gists{/gist_id}","starred_url":"https://api.github.com/users/zalando-zmon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zalando-zmon/subscriptions","organizations_url":"https://api.github.com/users/zalando-zmon/orgs","repos_url":"https://api.github.com/users/zalando-zmon/repos","events_url":"https://api.github.com/users/zalando-zmon/events{/privacy}","received_events_url":"https://api.github.com/users/zalando-zmon/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zalando-zmon/zmon-worker","description":"ZMON Python Worker","fork":false,"url":"https://api.github.com/repos/zalando-zmon/zmon-worker","forks_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/forks","keys_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/teams","hooks_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/hooks","issue_events_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/events{/number}","events_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/events","assignees_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/assignees{/user}","branches_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/branches{/branch}","tags_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/tags","blobs_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/git/refs{/sha}","trees_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/statuses/{sha}","languages_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/languages","stargazers_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/stargazers","contributors_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/contributors","subscribers_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/subscribers","subscription_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/subscription","commits_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/commits{/sha}","git_commits_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/git/commits{/sha}","comments_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/comments{/number}","issue_comment_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/comments{/number}","contents_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/contents/{+path}","compare_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/merges","archive_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/downloads","issues_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues{/number}","pulls_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls{/number}","milestones_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/milestones{/number}","notifications_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/labels{/name}","releases_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/releases{/id}","deployments_url":"https://api.github.com/repos/zalando-zmon/zmon-worker/deployments","created_at":"2015-01-07T14:47:02Z","updated_at":"2017-05-04T20:28:51Z","pushed_at":"2017-06-02T19:47:44Z","git_url":"git://github.com/zalando-zmon/zmon-worker.git","ssh_url":"git@github.com:zalando-zmon/zmon-worker.git","clone_url":"https://github.com/zalando-zmon/zmon-worker.git","svn_url":"https://github.com/zalando-zmon/zmon-worker","homepage":"https://zmon.io/","size":835,"stargazers_count":13,"watchers_count":13,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":21,"forks":18,"open_issues":21,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/232"},"html":{"href":"https://github.com/zalando-zmon/zmon-worker/pull/232"},"issue":{"href":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/232"},"comments":{"href":"https://api.github.com/repos/zalando-zmon/zmon-worker/issues/232/comments"},"review_comments":{"href":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/232/comments"},"review_comment":{"href":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zalando-zmon/zmon-worker/pulls/232/commits"},"statuses":{"href":"https://api.github.com/repos/zalando-zmon/zmon-worker/statuses/a07bab796c10f24d56adc4b2b6f1df4e8226acd6"}}}}
{"actor":{"display_login":"mohabusama"}}