Beispiel #1
0
def check_status(config, root_pw=None):
    if not os.path.exists(config.pid_file):
        logger.debug("%s: server not up - pid file '%s' not found" %
                     (config.package_name, config.pid_file))
        return False
    file = open(config.pid_file, "rb")
    data = file.read()
    file.close()
    pid = int(data)
    if iuprocess.is_process_alive(pid)==False:
        logger.debug("%s: server not up - process %d not alive" %
                     (config.package_name, pid))
        return False
    if root_pw==None: root_pw = config.admin_password
    cfg_filename = _make_config_file("mysqladmin", None, root_pw,
                                     config.port)
    args = [config.mysqladmin_path, "--defaults-file=%s" % cfg_filename,
            "--socket=%s" % config.socket_file,
            "ping"]
    re_map = {'alive': 'mysqld\\ is\\ alive'}
    try:
        (rc, map) = iuprocess.run_program_and_scan_results(args, re_map,
                                                           logger,
                                                           log_output=True)
    finally:
        os.remove(cfg_filename)
    if rc!=0 or map['alive']==False:
        logger.debug("%s: server not up - mysqladmin ping failed" %
                     config.package_name)
        return False
    else:
        logger.debug("%s: server up, pid is %d" %
                     (config.package_name, pid))
        return True
Beispiel #2
0
 def run(self, mysql_admin_props):
     p = mysql_admin_props
     self._check_admin_props(p)
     pid_file = p.pid_file_template % {"hostname": gethostname()}
     if not os.path.exists(pid_file):
         logger.debug("Mysql pid file %s not found, assuming db down" % pid_file)
         return False
     pid = int(procutils.sudo_cat_file(pid_file, self.ctx.logger,
                                       self.ctx._get_sudo_password(self)))
     result = procutils.is_process_alive(pid)
     if result:
         logger.debug("Mysql process %d is alive" % pid)
         return True
     else:
         logger.debug("Mysql process %d is not alive" % pid)
         return False