Call ey-agent to return nginx or apache status as well as database status
554834
def ey_agent_check
      results = {
        :description => 'Run ey-agent to monitor haproxy and monitor'
      }

      agent_results = JSON.load( `sudo ey-agent` )

      results.update(
        :message => agent_results.inspect,
        :status => agent_results && agent_results.any?{|k,v| v == 'down' }
      )
    rescue => e
      return results.update( :status => :failure, :exception => e )
    end
387443
def _do_http(opts, profile='default'):
    '''
    
    '''

    ret = {}

    url = __salt__['config.get']('modjk:{0}:url'.format(profile), '')
    user = __salt__['config.get']('modjk:{0}:user'.format(profile), '')
    passwd = __salt__['config.get']('modjk:{0}:pass'.format(profile), '')
    realm = __salt__['config.get']('modjk:{0}:realm'.format(profile), '')
    timeout = __salt__['config.get']('modjk:{0}:timeout'.format(profile), '')

    if not url:
        raise Exception('missing url in profile {0}'.format(profile))

    if user and passwd:
        auth = _auth(url=url, realm=realm, user=user, passwd=passwd)
        _install_opener(auth)

    url += '?{0}'.format(_urlencode(opts))

    for line in _urlopen(url, timeout=timeout).read().splitlines():
        splt = line.split('=', 1)
        if splt[0] in ret:
            ret[splt[0]] += ',{0}'.format(splt[1])
        else:
            ret[splt[0]] = splt[1]

    return ret
344676
def status(host=DEFAULT_HOST, port=DEFAULT_PORT):
    '''
    
    '''
    conn = _connect(host, port)
    try:
        stats = _check_stats(conn)[0]
    except (CommandExecutionError, IndexError):
        return False
    else:
        return {stats[0]: stats[1]}
1110743
def connect_to_agent(env=None, sp=subprocess):
    """"""
    sock_path = get_agent_sock_path(sp=sp, env=env)
    # Make sure the original gpg-agent is running.
    check_output(args=['gpg-connect-agent', '/bye'], sp=sp)
    sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    sock.connect(sock_path)
    return sock
560668
def query(host=None, quiet=False):
    '''
    
    '''
    if quiet:
        log.warning("'quiet' is deprecated. Please migrate to --quiet")
    ret = {}
    client = salt.client.get_local_client(__opts__['conf_file'])
    try:
        for info in client.cmd_iter('virtual:physical',
                                    'virt.full_info', tgt_type='grain'):
            if not info:
                continue
            if not isinstance(info, dict):
                continue
            chunk = {}
            id_ = next(six.iterkeys(info))
            if host:
                if host != id_:
                    continue
            if not isinstance(info[id_], dict):
                continue
            if 'ret' not in info[id_]:
                continue
            if not isinstance(info[id_]['ret'], dict):
                continue
            chunk[id_] = info[id_]['ret']
            ret.update(chunk)
            if not quiet:
                __jid_event__.fire_event({'data': chunk, 'outputter': 'virt_query'}, 'progress')
    except SaltClientError as client_error:
        print(client_error)
    return ret
1083930
def server_powerstatus(host=None,
                       admin_username=None,
                       admin_password=None,
                       module=None):
    '''
    
    '''
    ret = __execute_ret('serveraction powerstatus',
                        host=host, admin_username=admin_username,
                        admin_password=admin_password,
                        module=module)

    result = {'retcode': 0}
    if ret['stdout'] == 'ON':
        result['status'] = True
        result['comment'] = 'Power is on'
    if ret['stdout'] == 'OFF':
        result['status'] = False
        result['comment'] = 'Power is on'
    if ret['stdout'].startswith('ERROR'):
        result['status'] = False
        result['comment'] = ret['stdout']

    return result
1036972
function(site, env) {

    // Placeholder for drush usings
    var shouldUseDrush;

    // Check for wheter we can use drush or not
    return useDrush(site, env)

    // Get the connection info or drush version
    .then(function(response) {
      shouldUseDrush = response;
      if (shouldUseDrush) {
        return terminus.getDrushVersion(site, env);
      }
      else {
        return terminus.connectionInfo(site, env);
      }
    })

    // Construct the command and optimize if needed
    .then(function(data) {

      // Construct the alias
      var alias = ['@pantheon', site, env].join('.');

      // Basic import command
      var cmd = (shouldUseDrush) ? drushSqlDumpCmd(alias) : mysqlDumpCmd(data);

      // If this is drush import and we are drush 7+ then optimize
      if (useDrush && data >= 7) {
        cmd.push('--structure-tables-list=' + getDrupalSkipData());
      }

      // Return cmd
      return cmd;

    });

  }
7905
def get_operation_status(kwargs=None, conn=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The show_instance function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    if 'id' not in kwargs:
        raise SaltCloudSystemExit('A request ID must be specified as "id"')

    if not conn:
        conn = get_conn()

    data = conn.get_operation_status(kwargs['id'])
    ret = {
        'http_status_code': data.http_status_code,
        'id': kwargs['id'],
        'status': data.status
    }
    if hasattr(data.error, 'code'):
        ret['error'] = {
            'code': data.error.code,
            'message': data.error.message,
        }

    return ret
14292
def status
      logger.info "Retrieving Vagrant status for #{description}"
      output = connection.execute!(:status).stdout
      Derelict::Parser::Status.new(output)
    end
920292
def status(DomainName,
             region=None, key=None, keyid=None, profile=None):
    '''
    

    '''

    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    try:
        domain = conn.describe_elasticsearch_domain(DomainName=DomainName)
        if domain and 'DomainStatus' in domain:
            domain = domain.get('DomainStatus', {})
            keys = ('Endpoint', 'Created', 'Deleted',
                    'DomainName', 'DomainId', 'EBSOptions', 'SnapshotOptions',
                    'AccessPolicies', 'Processing', 'AdvancedOptions', 'ARN',
                    'ElasticsearchVersion')
            return {'domain': dict([(k, domain.get(k)) for k in keys if k in domain])}
        else:
            return {'domain': None}
    except ClientError as e:
        return {'error': __utils__['boto3.get_error'](e)}
900805
def a2dissite(site):
    '''
    
    '''
    ret = {}
    command = ['a2dissite', site]

    try:
        status = __salt__['cmd.retcode'](command, python_shell=False)
    except Exception as e:
        return e

    ret['Name'] = 'Apache2 Disable Site'
    ret['Site'] = site

    if status == 256:
        ret['Status'] = 'Site {0} Not found'.format(site)
    elif status == 0:
        ret['Status'] = 'Site {0} disabled'.format(site)
    else:
        ret['Status'] = status

    return ret
297106
def status():
    '''
    
    '''
    puppet = _Puppet()

    if os.path.isfile(puppet.disabled_lockfile):
        return 'Administratively disabled'

    if os.path.isfile(puppet.run_lockfile):
        try:
            with salt.utils.files.fopen(puppet.run_lockfile, 'r') as fp_:
                pid = int(salt.utils.stringutils.to_unicode(fp_.read()))
                os.kill(pid, 0)  # raise an OSError if process doesn't exist
        except (OSError, ValueError):
            return 'Stale lockfile'
        else:
            return 'Applying a catalog'

    if os.path.isfile(puppet.agent_pidfile):
        try:
            with salt.utils.files.fopen(puppet.agent_pidfile, 'r') as fp_:
                pid = int(salt.utils.stringutils.to_unicode(fp_.read()))
                os.kill(pid, 0)  # raise an OSError if process doesn't exist
        except (OSError, ValueError):
            return 'Stale pidfile'
        else:
            return 'Idle daemon'

    return 'Stopped'
971684
def daemon_status(self):
        
        url = self._build_url(constants.DAEMON_STATUS_ENDPOINT)
        json = self.client.get(url, timeout=self.timeout)
        return json
691907
def query(method='servers', server_id=None, command=None, args=None,
          http_method='GET', root='api_root'):
    ''' 
    '''

    if root == 'api_root':
        default_url = 'https://cp-par1.scaleway.com'
    else:
        default_url = 'https://api-marketplace.scaleway.com'

    base_path = six.text_type(config.get_cloud_config_value(
        root,
        get_configured_provider(),
        __opts__,
        search_global=False,
        default=default_url
    ))

    path = '{0}/{1}/'.format(base_path, method)

    if server_id:
        path += '{0}/'.format(server_id)

    if command:
        path += command

    if not isinstance(args, dict):
        args = {}

    token = config.get_cloud_config_value(
        'token', get_configured_provider(), __opts__, search_global=False
    )

    data = salt.utils.json.dumps(args)

    request = __utils__["http.query"](path,
                                      method=http_method,
                                      data=data,
                                      status=True,
                                      decode=True,
                                      decode_type='json',
                                      data_render=True,
                                      data_renderer='json',
                                      headers=True,
                                      header_dict={'X-Auth-Token': token,
                                                   'User-Agent': "salt-cloud",
                                                   'Content-Type': 'application/json'})
    if request['status'] > 299:
        raise SaltCloudSystemExit(
            'An error occurred while querying Scaleway. HTTP Code: {0}  '
            'Error: \'{1}\''.format(
                request['status'],
                request['error']
            )
        )

    # success without data
    if request['status'] == 204:
        return True

    return salt.utils.json.loads(request['body'])
1052212
def status(name):
    '''
    
    '''
    # Get volume status
    root = _gluster_xml('volume status {0}'.format(name))
    if not _gluster_ok(root):
        # Most probably non-existing volume, the error output is logged
        # This return value is easy to test and intuitive
        return None

    ret = {'bricks': {}, 'nfs': {}, 'healers': {}}

    def etree_legacy_wrap(t):
        ret = _etree_to_dict(t)
        ret['online'] = (ret['status'] == '1')
        ret['host'] = ret['hostname']
        return ret

    # Build a hash to map hostname to peerid
    hostref = {}
    for node in _iter(root, 'node'):
        peerid = node.find('peerid').text
        hostname = node.find('hostname').text
        if hostname not in ('NFS Server', 'Self-heal Daemon'):
            hostref[peerid] = hostname

    for node in _iter(root, 'node'):
        hostname = node.find('hostname').text
        if hostname not in ('NFS Server', 'Self-heal Daemon'):
            path = node.find('path').text
            ret['bricks'][
                '{0}:{1}'.format(hostname, path)] = etree_legacy_wrap(node)
        elif hostname == 'NFS Server':
            peerid = node.find('peerid').text
            true_hostname = hostref[peerid]
            ret['nfs'][true_hostname] = etree_legacy_wrap(node)
        else:
            peerid = node.find('peerid').text
            true_hostname = hostref[peerid]
            ret['healers'][true_hostname] = etree_legacy_wrap(node)

    return ret
163834
function checkStatus() {
  return server.ping(this, function(err, res) {
    if (err) {
      return out.error("error occurred: %j", err);
    }
    if (res.running) {
      return out.success("service running");
    }
    return out.error("service not running");
  });
}
1342201
function getStatus(url) {
  var client = new HttpClient(url);
  var executor = new Executor(client);
  var command = new Command(CommandName.GET_SERVER_STATUS);
  return executor.execute(command);
}