aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakayoshi Tanaka <tatanaka@redhat.com>2018-04-12 03:36:18 -0400
committerBryn M. Reeves <bmr@redhat.com>2018-06-18 15:33:18 +0100
commitb34637a009dc1f2c2693966aeb795b6c64b81703 (patch)
treed9688eea2103d02e2453a909ff6dc2c024e8ffc7
parent1becd754a8cae83cd993662a467f19aeedcc4750 (diff)
downloadsos-b34637a009dc1f2c2693966aeb795b6c64b81703.tar.gz
[mssql] Add new plugin
Adds a new plugin for Microsoft SQL Server on Linux. Collect log files. Collect journal logs. Collect keytab file info if AD auth is configured. Resolves: #1326 Signed-off-by: Takayoshi Tanaka <tatanaka@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/mssql.py92
1 files changed, 92 insertions, 0 deletions
diff --git a/sos/plugins/mssql.py b/sos/plugins/mssql.py
new file mode 100644
index 00000000..8209cbe9
--- /dev/null
+++ b/sos/plugins/mssql.py
@@ -0,0 +1,92 @@
+# Copyright (C) 2018 Red Hat, K.K., Takayoshi Tanaka <tatanaka@redhat.com>
+#
+# This file is part of the sos project: https://github.com/sosreport/sos
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# version 2 of the GNU General Public License.
+#
+# See the LICENSE file in the source distribution for further information.
+
+from sos.plugins import Plugin, RedHatPlugin
+import os
+
+
+class MsSQL(Plugin, RedHatPlugin):
+ """Microsoft SQL Server on Linux
+ """
+
+ plugin_name = "mssql"
+ profiles = ('services',)
+ packages = ('mssql-server',)
+
+ option_list = [
+ ('mssql_conf', 'SQL Server configuration file.', '',
+ '/var/opt/mssql/mssql.conf')
+ ]
+
+ def setup(self):
+ mssql_conf = self.get_option('mssql_conf')
+
+ # Pick error log file from mssql_conf.
+ # Expecting the following format
+ # ```
+ # [filelocation]
+ # errorlogfile = /var/opt/mssql/log
+ # [sqlagent]
+ # errorlogfile = /var/opt/mssql/log/sqlagentstartup.log
+ # [network]
+ # kerberoskeytabfile = /var/opt/mssql/secrets/mssql.keytab
+ # ```
+ section = ''
+ # default values
+ errorlogfile = '/var/opt/mssql/log'
+ sqlagent_errorlogfile = '/var/opt/mssql/log/sqlagentstartup.log'
+ kerberoskeytabfile = None
+ try:
+ for line in open(mssql_conf).read().splitlines():
+ if line.startswith('['):
+ section = line
+ continue
+ words = line.split('=')
+ if words[0].strip() == 'errorlogfile':
+ if section == '[filelocation]':
+ errorlogfile = words[1].strip()
+ elif section == '[sqlagent]':
+ sqlagent_errorlogfile = words[1].strip()
+ elif words[0].strip() == 'kerberoskeytabfile':
+ if section == '[network]':
+ kerberoskeytabfile = words[1].strip()
+ except IOError as ex:
+ self._log_error('Could not open conf file %s: %s' %
+ (mssql_conf, ex))
+ return
+
+ # Collect AD authentication configuratoin
+ keytab_err = ('keytab file is specfieid in mssql_conf'
+ ' but not found in %s' % kerberoskeytabfile)
+ if kerberoskeytabfile is not None:
+ if os.path.isfile(kerberoskeytabfile):
+ self.add_cmd_output('ls -l %s' % kerberoskeytabfile)
+ self.add_cmd_output('klist -e -k %s' % kerberoskeytabfile)
+ else:
+ self._log_error(keytab_err)
+
+ # Expecting mssql_conf doesn't includeno sensitive information.
+ self.add_copy_spec([
+ mssql_conf,
+ errorlogfile + '/*',
+ sqlagent_errorlogfile
+ ])
+
+ if not self.get_option('all_logs'):
+ limit = self.get_option('log_size')
+ self.add_copy_spec(errorlogfile + '/*', sizelimit=limit)
+ self.add_copy_spec(sqlagent_errorlogfile, sizelimit=limit)
+ else:
+ self.add_copy_spec(errorlogfile + '/*')
+ self.add_copy_spec(sqlagent_errorlogfile)
+
+ self.add_journal(units=['mssql-server'])
+
+# vim: set et ts=4 sw=4 :