def cleanWarningConfigForRsyslog(self): """ function: clean rsyslog config input : NA output: NA """ # clean rsyslog config on client and server cmd = "(if [ -s '%s' ]; then " % RSYSLOG_CONFIG_FILE cmd += \ "sed -i -e '/^$ModLoad imjournal.*$/d' %s " % RSYSLOG_CONFIG_FILE cmd += "-e '/^$ModLoad imudp.*$/d' %s " % RSYSLOG_CONFIG_FILE cmd += "-e '/^$UDPServerRun 514.*$/d' %s " % RSYSLOG_CONFIG_FILE cmd += \ "-e '/^$imjournalRatelimitInterval.*$/d' %s " % RSYSLOG_CONFIG_FILE cmd += "-e '/^$imjournalRatelimitBurst.*$/d' %s " % RSYSLOG_CONFIG_FILE cmd += "-e '/^%s.*$/d' %s; " % (AP_RSYSLOG_FACILITY_LEVEL, RSYSLOG_CONFIG_FILE) cmd += "fi) " self.logger.debug("Command for cleaning crash rsyslog: %s." % cmd) (status, output) = subprocess.getstatusoutput(cmd) if (status != 0): self.logger.logExit(ErrorCode.GAUSS_502["GAUSS_50207"] % 'crash rsyslog' + " Error: \n%s" % output) # restart the rsyslog service (status, output) = g_service.manageOSService("rsyslog", "restart") if (status != 0): self.logger.logExit(ErrorCode.GAUSS_508["GAUSS_50802"] % "restart rsyslog" + " Error: \n%s" % output)
def doCheck(self): (status, output) = g_service.manageOSService('sshd', 'status') self.result.raw = output if (status == 0 and output.find('running')): self.result.rst = ResultStatus.OK self.result.val = "The sshd service is normal." else: self.result.val = "There is no sshd service." self.result.rst = ResultStatus.NG
def doCheck(self): (status, crondInfo) = g_service.manageOSService('crond', 'status') self.result.raw = crondInfo # Resolve and outputs the execution results of each node if (status != 0 or crondInfo.find('running') < 0): self.result.val = "There is no cron service." self.result.rst = ResultStatus.NG else: self.result.rst = ResultStatus.OK self.result.val = "The cron service is normal."
def cleanWarningConfigForSyslogng(self): """ function: clean syslog-ng config input : NA output: NA """ # clean client syslog-ng configure cmd = "(if [ -s '%s' ]; then " % SYSLOG_NG_CONFIG_FILE cmd += \ "sed -i -e '/^filter f_gaussdb.*$/d' %s " % SYSLOG_NG_CONFIG_FILE cmd += "-e '/^destination d_gaussdb.*$/d' %s " % SYSLOG_NG_CONFIG_FILE cmd += \ "-e '/^log { source(src); filter(f_gaussdb); " \ "destination(d_gaussdb); };$/d' %s;fi;) " % SYSLOG_NG_CONFIG_FILE self.logger.debug("Command for cleaning client system log: %s" % cmd) (status, output) = subprocess.getstatusoutput(cmd) if (status != 0): self.logger.logExit(ErrorCode.GAUSS_514["GAUSS_51400"] % cmd + " Error:\n%s" % output) # clean server syslog-ng configure cmd = "(if [ -s '%s' ]; then " % SYSLOG_NG_CONFIG_FILE cmd += \ "sed -i -e '/^template t_gaussdb.*$/d' %s " % SYSLOG_NG_CONFIG_FILE cmd += "-e '/^source s_gaussdb.*$/d' %s " % SYSLOG_NG_CONFIG_FILE cmd += "-e '/^filter f_gaussdb.*$/d' %s " % SYSLOG_NG_CONFIG_FILE cmd += "-e '/^destination d_gaussdb.*$/d' %s " % SYSLOG_NG_CONFIG_FILE cmd += \ "-e '/^log { source(s_gaussdb); " \ "filter(f_gaussdb); destination(d_gaussdb); };$/d' %s;" \ "fi; " % SYSLOG_NG_CONFIG_FILE cmd += "if [ -s '%s' ]; then " % SYSLOG_NG_CONFIG_FILE_SERVER cmd += \ "sed -i -e '/^SYSLOGD_OPTIONS=\\\"-r -m 0\\\"/d' %s " \ % SYSLOG_NG_CONFIG_FILE_SERVER cmd += "-e '/^KLOGD_OPTIONS=\\\"-x\\\"/d' %s; " \ % SYSLOG_NG_CONFIG_FILE_SERVER cmd += "fi) " self.logger.debug("Command for cleaning server system log: %s" % cmd) (status, output) = subprocess.getstatusoutput(cmd) if (status != 0): self.logger.logExit(ErrorCode.GAUSS_514["GAUSS_51400"] % cmd + " Error:\n%s" % output) # restart the syslog service (status, output) = g_service.manageOSService("syslog", "restart") if (status != 0): self.logger.logExit(ErrorCode.GAUSS_508["GAUSS_50802"] % "restart syslog" + " Error: \n%s" % output)
def doCheck(self): (status, output) = g_service.manageOSService("firewall", "status") if (output.find(SUSE_FLAG) > 0 or output.find(REDHAT6_FLAG) > 0 or output.find(REDHAT7_FLAG) > 0): firewallStatus = "disabled" else: firewallStatus = "enabled" if (firewallStatus == ""): self.result.rst = ResultStatus.OK elif (firewallStatus != EXPECTED_VALUE): self.result.rst = ResultStatus.NG else: self.result.rst = ResultStatus.OK if (not self.result.raw): self.result.raw = output else: self.result.raw = output self.result.val = firewallStatus