{"action":"created","comment":{"url":"https://api.github.com/repos/sosreport/sos/pulls/comments/189818958","pull_request_review_id":122068931,"id":189818958,"diff_hunk":"@@ -0,0 +1,90 @@\n+# Copyright (C) 2018 Red Hat, Inc., Reid Wahl <nwahl@redhat.com>\n+\n+# This program is free software; you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation; either version 2 of the License, or\n+# (at your option) any later version.\n+\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+\n+# You should have received a copy of the GNU General Public License\n+# along with this program; if not, write to the Free Software\n+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n+'''Collect info from watchdog to add to sosreport.\n+\n+Classes:\n+Watchdog -- collects watchdog configs, custom executables, and logs\n+'''\n+\n+import re\n+\n+from sos.plugins import Plugin, RedHatPlugin\n+\n+\n+class Watchdog(Plugin, RedHatPlugin):\n+    '''Collect watchdog configurations, custom executables, and logs.\n+\n+    Methods:\n+    parse_watchdog_conf -- parse variables from config file\n+    setup -- assemble watchdog info for sosreport\n+\n+    Instance variables:\n+    limit -- maximum log size\n+    watchdog_conf -- watchdog service configuration file\n+    conf_vars -- variables from watchdog config file\n+    log_dir -- directory containing watchdog stderr and stdout logs\n+    '''\n+\n+    plugin_name = 'watchdog'\n+    profiles = ('system',)\n+    packages = ('watchdog',)\n+\n+    def __init__(self, commons):\n+        '''Initialize Watchdog class.'''\n+        Plugin.__init__(self, commons)\n+        self.limit = self.get_option('log_size')\n+        self.watchdog_conf = '/etc/watchdog.conf'\n+        self.conf_vars = dict()\n+        self.log_dir = None\n+\n+    def parse_watchdog_conf(self):\n+        '''Parse variables from watchdog config file.'''\n+        comment_pattern = re.compile(r'#.*')\n+        eq_pattern = re.compile(r'\\s*=\\s*')\n+\n+        with open(self.watchdog_conf, 'r') as conf_file:\n+            for line in conf_file:\n+                line = comment_pattern.sub('', line)\n+                line = line.strip()\n+\n+                try:\n+                    (key, value) = eq_pattern.split(line, 1)\n+                    self.conf_vars[key] = value","path":"sos/plugins/watchdog.py","position":65,"original_position":65,"commit_id":"8c30a12c51b07d691f7a3e40709fbf53676a7bf6","original_commit_id":"8c30a12c51b07d691f7a3e40709fbf53676a7bf6","user":{"login":"nrwahl2","id":30487349,"avatar_url":"https://avatars1.githubusercontent.com/u/30487349?v=4","gravatar_id":"","url":"https://api.github.com/users/nrwahl2","html_url":"https://github.com/nrwahl2","followers_url":"https://api.github.com/users/nrwahl2/followers","following_url":"https://api.github.com/users/nrwahl2/following{/other_user}","gists_url":"https://api.github.com/users/nrwahl2/gists{/gist_id}","starred_url":"https://api.github.com/users/nrwahl2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrwahl2/subscriptions","organizations_url":"https://api.github.com/users/nrwahl2/orgs","repos_url":"https://api.github.com/users/nrwahl2/repos","events_url":"https://api.github.com/users/nrwahl2/events{/privacy}","received_events_url":"https://api.github.com/users/nrwahl2/received_events","type":"User","site_admin":false},"body":"That is a good point. I normally try to take a general, extensible approach to parsing log files, as I've done here. However, I don't foresee any other parameters in `/etc/watchdog.conf` being useful now or in the future in this context.\r\n\r\nI can put together an alternate version using only `log-dir` in the morning (it's late here now) if you want, and we can decide which one looks cleaner. Readability is going to trump computational/memory efficiency here IMO, with this being such a small file to parse.","created_at":"2018-05-22T08:39:49Z","updated_at":"2018-05-22T08:39:50Z","html_url":"https://github.com/sosreport/sos/pull/1305#discussion_r189818958","pull_request_url":"https://api.github.com/repos/sosreport/sos/pulls/1305","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/sosreport/sos/pulls/comments/189818958"},"html":{"href":"https://github.com/sosreport/sos/pull/1305#discussion_r189818958"},"pull_request":{"href":"https://api.github.com/repos/sosreport/sos/pulls/1305"}},"in_reply_to_id":189804556},"pull_request":{"url":"https://api.github.com/repos/sosreport/sos/pulls/1305","id":189565716,"html_url":"https://github.com/sosreport/sos/pull/1305","diff_url":"https://github.com/sosreport/sos/pull/1305.diff","patch_url":"https://github.com/sosreport/sos/pull/1305.patch","issue_url":"https://api.github.com/repos/sosreport/sos/issues/1305","number":1305,"state":"open","locked":false,"title":"[watchdog] Add watchdog plugin","user":{"login":"nrwahl2","id":30487349,"avatar_url":"https://avatars1.githubusercontent.com/u/30487349?v=4","gravatar_id":"","url":"https://api.github.com/users/nrwahl2","html_url":"https://github.com/nrwahl2","followers_url":"https://api.github.com/users/nrwahl2/followers","following_url":"https://api.github.com/users/nrwahl2/following{/other_user}","gists_url":"https://api.github.com/users/nrwahl2/gists{/gist_id}","starred_url":"https://api.github.com/users/nrwahl2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrwahl2/subscriptions","organizations_url":"https://api.github.com/users/nrwahl2/orgs","repos_url":"https://api.github.com/users/nrwahl2/repos","events_url":"https://api.github.com/users/nrwahl2/events{/privacy}","received_events_url":"https://api.github.com/users/nrwahl2/received_events","type":"User","site_admin":false},"body":"This new plugin collects information related to the watchdog service,\r\nincluding configuration, custom executables for test-binary and\r\nrepair-binary, and stdout/stderr log files.\r\n\r\nThis will be helpful to support teams seeking to understand why an\r\nunexpected reboot occurred or, conversely, why a reboot did not\r\noccur as expected.\r\n\r\nSigned-off-by: Reid Wahl <nwahl@redhat.com>\r\n\r\n---\r\nPlease place an 'X' inside each '[]' to confirm you adhere to our [Contributor Guidelines](https://github.com/sosreport/sos/wiki/Contribution-Guidelines)\r\n\r\n- [X] Is the commit message split over multiple lines and hard-wrapped at 72 characters?\r\n- [X] Is the subject and message clear and concise?\r\n- [X] Does the subject start with **[plugin_name]** if submitting a plugin patch or a **[section_name]** if part of the core sosreport code?\r\n- [X] Does the commit contain a **Signed-off-by: First Lastname <email@example.com>**?\r\n","created_at":"2018-05-22T07:06:43Z","updated_at":"2018-05-22T08:39:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"45c00cd904bbe06291884d9bd78ed5a9b00bb53a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sosreport/sos/pulls/1305/commits","review_comments_url":"https://api.github.com/repos/sosreport/sos/pulls/1305/comments","review_comment_url":"https://api.github.com/repos/sosreport/sos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sosreport/sos/issues/1305/comments","statuses_url":"https://api.github.com/repos/sosreport/sos/statuses/8c30a12c51b07d691f7a3e40709fbf53676a7bf6","head":{"label":"nrwahl2:nrwahl2-add_watchdog_plugin","ref":"nrwahl2-add_watchdog_plugin","sha":"8c30a12c51b07d691f7a3e40709fbf53676a7bf6","user":{"login":"nrwahl2","id":30487349,"avatar_url":"https://avatars1.githubusercontent.com/u/30487349?v=4","gravatar_id":"","url":"https://api.github.com/users/nrwahl2","html_url":"https://github.com/nrwahl2","followers_url":"https://api.github.com/users/nrwahl2/followers","following_url":"https://api.github.com/users/nrwahl2/following{/other_user}","gists_url":"https://api.github.com/users/nrwahl2/gists{/gist_id}","starred_url":"https://api.github.com/users/nrwahl2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrwahl2/subscriptions","organizations_url":"https://api.github.com/users/nrwahl2/orgs","repos_url":"https://api.github.com/users/nrwahl2/repos","events_url":"https://api.github.com/users/nrwahl2/events{/privacy}","received_events_url":"https://api.github.com/users/nrwahl2/received_events","type":"User","site_admin":false},"repo":{"id":115230457,"name":"sos","full_name":"nrwahl2/sos","owner":{"login":"nrwahl2","id":30487349,"avatar_url":"https://avatars1.githubusercontent.com/u/30487349?v=4","gravatar_id":"","url":"https://api.github.com/users/nrwahl2","html_url":"https://github.com/nrwahl2","followers_url":"https://api.github.com/users/nrwahl2/followers","following_url":"https://api.github.com/users/nrwahl2/following{/other_user}","gists_url":"https://api.github.com/users/nrwahl2/gists{/gist_id}","starred_url":"https://api.github.com/users/nrwahl2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrwahl2/subscriptions","organizations_url":"https://api.github.com/users/nrwahl2/orgs","repos_url":"https://api.github.com/users/nrwahl2/repos","events_url":"https://api.github.com/users/nrwahl2/events{/privacy}","received_events_url":"https://api.github.com/users/nrwahl2/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nrwahl2/sos","description":"A unified tool for collecting system logs and other debug information","fork":true,"url":"https://api.github.com/repos/nrwahl2/sos","forks_url":"https://api.github.com/repos/nrwahl2/sos/forks","keys_url":"https://api.github.com/repos/nrwahl2/sos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nrwahl2/sos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nrwahl2/sos/teams","hooks_url":"https://api.github.com/repos/nrwahl2/sos/hooks","issue_events_url":"https://api.github.com/repos/nrwahl2/sos/issues/events{/number}","events_url":"https://api.github.com/repos/nrwahl2/sos/events","assignees_url":"https://api.github.com/repos/nrwahl2/sos/assignees{/user}","branches_url":"https://api.github.com/repos/nrwahl2/sos/branches{/branch}","tags_url":"https://api.github.com/repos/nrwahl2/sos/tags","blobs_url":"https://api.github.com/repos/nrwahl2/sos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nrwahl2/sos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nrwahl2/sos/git/refs{/sha}","trees_url":"https://api.github.com/repos/nrwahl2/sos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nrwahl2/sos/statuses/{sha}","languages_url":"https://api.github.com/repos/nrwahl2/sos/languages","stargazers_url":"https://api.github.com/repos/nrwahl2/sos/stargazers","contributors_url":"https://api.github.com/repos/nrwahl2/sos/contributors","subscribers_url":"https://api.github.com/repos/nrwahl2/sos/subscribers","subscription_url":"https://api.github.com/repos/nrwahl2/sos/subscription","commits_url":"https://api.github.com/repos/nrwahl2/sos/commits{/sha}","git_commits_url":"https://api.github.com/repos/nrwahl2/sos/git/commits{/sha}","comments_url":"https://api.github.com/repos/nrwahl2/sos/comments{/number}","issue_comment_url":"https://api.github.com/repos/nrwahl2/sos/issues/comments{/number}","contents_url":"https://api.github.com/repos/nrwahl2/sos/contents/{+path}","compare_url":"https://api.github.com/repos/nrwahl2/sos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nrwahl2/sos/merges","archive_url":"https://api.github.com/repos/nrwahl2/sos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nrwahl2/sos/downloads","issues_url":"https://api.github.com/repos/nrwahl2/sos/issues{/number}","pulls_url":"https://api.github.com/repos/nrwahl2/sos/pulls{/number}","milestones_url":"https://api.github.com/repos/nrwahl2/sos/milestones{/number}","notifications_url":"https://api.github.com/repos/nrwahl2/sos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nrwahl2/sos/labels{/name}","releases_url":"https://api.github.com/repos/nrwahl2/sos/releases{/id}","deployments_url":"https://api.github.com/repos/nrwahl2/sos/deployments","created_at":"2017-12-24T00:37:55Z","updated_at":"2017-12-24T00:37:57Z","pushed_at":"2018-05-22T07:05:27Z","git_url":"git://github.com/nrwahl2/sos.git","ssh_url":"git@github.com:nrwahl2/sos.git","clone_url":"https://github.com/nrwahl2/sos.git","svn_url":"https://github.com/nrwahl2/sos","homepage":"http://sos.rtfd.org","size":5583,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sosreport:master","ref":"master","sha":"ac33925bac828246229a93da0f9b4e9218bca6b8","user":{"login":"sosreport","id":908256,"avatar_url":"https://avatars2.githubusercontent.com/u/908256?v=4","gravatar_id":"","url":"https://api.github.com/users/sosreport","html_url":"https://github.com/sosreport","followers_url":"https://api.github.com/users/sosreport/followers","following_url":"https://api.github.com/users/sosreport/following{/other_user}","gists_url":"https://api.github.com/users/sosreport/gists{/gist_id}","starred_url":"https://api.github.com/users/sosreport/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sosreport/subscriptions","organizations_url":"https://api.github.com/users/sosreport/orgs","repos_url":"https://api.github.com/users/sosreport/repos","events_url":"https://api.github.com/users/sosreport/events{/privacy}","received_events_url":"https://api.github.com/users/sosreport/received_events","type":"Organization","site_admin":false},"repo":{"id":2031428,"name":"sos","full_name":"sosreport/sos","owner":{"login":"sosreport","id":908256,"avatar_url":"https://avatars2.githubusercontent.com/u/908256?v=4","gravatar_id":"","url":"https://api.github.com/users/sosreport","html_url":"https://github.com/sosreport","followers_url":"https://api.github.com/users/sosreport/followers","following_url":"https://api.github.com/users/sosreport/following{/other_user}","gists_url":"https://api.github.com/users/sosreport/gists{/gist_id}","starred_url":"https://api.github.com/users/sosreport/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sosreport/subscriptions","organizations_url":"https://api.github.com/users/sosreport/orgs","repos_url":"https://api.github.com/users/sosreport/repos","events_url":"https://api.github.com/users/sosreport/events{/privacy}","received_events_url":"https://api.github.com/users/sosreport/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sosreport/sos","description":"A unified tool for collecting system logs and other debug information","fork":false,"url":"https://api.github.com/repos/sosreport/sos","forks_url":"https://api.github.com/repos/sosreport/sos/forks","keys_url":"https://api.github.com/repos/sosreport/sos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sosreport/sos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sosreport/sos/teams","hooks_url":"https://api.github.com/repos/sosreport/sos/hooks","issue_events_url":"https://api.github.com/repos/sosreport/sos/issues/events{/number}","events_url":"https://api.github.com/repos/sosreport/sos/events","assignees_url":"https://api.github.com/repos/sosreport/sos/assignees{/user}","branches_url":"https://api.github.com/repos/sosreport/sos/branches{/branch}","tags_url":"https://api.github.com/repos/sosreport/sos/tags","blobs_url":"https://api.github.com/repos/sosreport/sos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sosreport/sos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sosreport/sos/git/refs{/sha}","trees_url":"https://api.github.com/repos/sosreport/sos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sosreport/sos/statuses/{sha}","languages_url":"https://api.github.com/repos/sosreport/sos/languages","stargazers_url":"https://api.github.com/repos/sosreport/sos/stargazers","contributors_url":"https://api.github.com/repos/sosreport/sos/contributors","subscribers_url":"https://api.github.com/repos/sosreport/sos/subscribers","subscription_url":"https://api.github.com/repos/sosreport/sos/subscription","commits_url":"https://api.github.com/repos/sosreport/sos/commits{/sha}","git_commits_url":"https://api.github.com/repos/sosreport/sos/git/commits{/sha}","comments_url":"https://api.github.com/repos/sosreport/sos/comments{/number}","issue_comment_url":"https://api.github.com/repos/sosreport/sos/issues/comments{/number}","contents_url":"https://api.github.com/repos/sosreport/sos/contents/{+path}","compare_url":"https://api.github.com/repos/sosreport/sos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sosreport/sos/merges","archive_url":"https://api.github.com/repos/sosreport/sos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sosreport/sos/downloads","issues_url":"https://api.github.com/repos/sosreport/sos/issues{/number}","pulls_url":"https://api.github.com/repos/sosreport/sos/pulls{/number}","milestones_url":"https://api.github.com/repos/sosreport/sos/milestones{/number}","notifications_url":"https://api.github.com/repos/sosreport/sos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sosreport/sos/labels{/name}","releases_url":"https://api.github.com/repos/sosreport/sos/releases{/id}","deployments_url":"https://api.github.com/repos/sosreport/sos/deployments","created_at":"2011-07-11T16:58:15Z","updated_at":"2018-05-21T15:14:24Z","pushed_at":"2018-05-22T07:06:44Z","git_url":"git://github.com/sosreport/sos.git","ssh_url":"git@github.com:sosreport/sos.git","clone_url":"https://github.com/sosreport/sos.git","svn_url":"https://github.com/sosreport/sos","homepage":"http://sos.rtfd.org","size":5575,"stargazers_count":194,"watchers_count":194,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":234,"mirror_url":null,"archived":false,"open_issues_count":211,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":234,"open_issues":211,"watchers":194,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sosreport/sos/pulls/1305"},"html":{"href":"https://github.com/sosreport/sos/pull/1305"},"issue":{"href":"https://api.github.com/repos/sosreport/sos/issues/1305"},"comments":{"href":"https://api.github.com/repos/sosreport/sos/issues/1305/comments"},"review_comments":{"href":"https://api.github.com/repos/sosreport/sos/pulls/1305/comments"},"review_comment":{"href":"https://api.github.com/repos/sosreport/sos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sosreport/sos/pulls/1305/commits"},"statuses":{"href":"https://api.github.com/repos/sosreport/sos/statuses/8c30a12c51b07d691f7a3e40709fbf53676a7bf6"}},"author_association":"NONE"}}
{"actor":{"display_login":"nrwahl2"}}