Get SNMP values from host
429029
def get_data(self):
        ""
        alarm_oids = [netsnmp.Varbind(alarms[alarm_id]['oid']) for alarm_id in self.models[self.modem_type]['alarms']]
        metric_oids = [netsnmp.Varbind(metrics[metric_id]['oid']) for metric_id in self.models[self.modem_type]['metrics']]
        response = self.snmp_session.get(netsnmp.VarList(*alarm_oids + metric_oids))
        return (
            response[0:len(alarm_oids)],
            response[len(alarm_oids):]
        )
1055675
def collect_snmp(self, device, host, port, community):
        
        # Log
        self.log.info("Collecting Netscaler statistics from: %s", device)

        # Set timestamp
        timestamp = time.time()

        # Collect Netscaler System OIDs
        for k, v in self.NETSCALER_SYSTEM_GUAGES.items():
            # Get Metric Name and Value
            metricName = '.'.join([k])
            metricValue = int(self.get(v, host, port, community)[v])
            # Get Metric Path
            metricPath = '.'.join(['devices', device, 'system', metricName])
            # Create Metric
            metric = Metric(metricPath, metricValue, timestamp, 0)
            # Publish Metric
            self.publish_metric(metric)

        # Collect Netscaler System Counter OIDs
        for k, v in self.NETSCALER_SYSTEM_COUNTERS.items():
            # Get Metric Name and Value
            metricName = '.'.join([k])
            # Get Metric Path
            metricPath = '.'.join(['devices', device, 'system', metricName])
            # Get Metric Value
            metricValue = self.derivative(metricPath, long(
                self.get(v, host, port, community)[v]), self.MAX_VALUE)
            # Create Metric
            metric = Metric(metricPath, metricValue, timestamp, 0)
            # Publish Metric
            self.publish_metric(metric)

        # Collect Netscaler Services
        serviceNames = [v.strip("\'") for v in self.walk(
            self.NETSCALER_SERVICE_NAMES, host, port, community).values()]

        for serviceName in serviceNames:
            # Get Service Name in OID form
            serviceNameOid = self.get_string_index_oid(serviceName)

            # Get Service Type
            serviceTypeOid = ".".join([self.NETSCALER_SERVICE_TYPE,
                                       self._convert_from_oid(serviceNameOid)])
            serviceType = int(self.get(serviceTypeOid,
                                       host,
                                       port,
                                       community)[serviceTypeOid].strip("\'"))

            # Filter excluded service types
            if serviceType in map(lambda v: int(v),
                                  self.config.get('exclude_service_type')):
                continue

            # Get Service State
            serviceStateOid = ".".join([self.NETSCALER_SERVICE_STATE,
                                        self._convert_from_oid(serviceNameOid)])
            serviceState = int(self.get(serviceStateOid,
                                        host,
                                        port,
                                        community)[serviceStateOid].strip("\'"))

            # Filter excluded service states
            if serviceState in map(lambda v: int(v),
                                   self.config.get('exclude_service_state')):
                continue

            for k, v in self.NETSCALER_SERVICE_GUAGES.items():
                serviceGuageOid = ".".join(
                    [v, self._convert_from_oid(serviceNameOid)])
                # Get Metric Name
                metricName = '.'.join([re.sub(r'\.|\\', '_', serviceName), k])
                # Get Metric Value
                metricValue = int(self.get(serviceGuageOid,
                                           host,
                                           port,
                                           community
                                           )[serviceGuageOid].strip("\'"))
                # Get Metric Path
                metricPath = '.'.join(['devices',
                                       device,
                                       'service',
                                       metricName])
                # Create Metric
                metric = Metric(metricPath, metricValue, timestamp, 0)
                # Publish Metric
                self.publish_metric(metric)

        # Collect Netscaler Vservers
        vserverNames = [v.strip("\'") for v in self.walk(
            self.NETSCALER_VSERVER_NAMES, host, port, community).values()]

        for vserverName in vserverNames:
            # Get Vserver Name in OID form
            vserverNameOid = self.get_string_index_oid(vserverName)

            # Get Vserver Type
            vserverTypeOid = ".".join([self.NETSCALER_VSERVER_TYPE,
                                       self._convert_from_oid(vserverNameOid)])
            vserverType = int(self.get(vserverTypeOid,
                                       host,
                                       port,
                                       community)[vserverTypeOid].strip("\'"))

            # filter excluded vserver types
            if vserverType in map(lambda v: int(v),
                                  self.config.get('exclude_vserver_type')):
                continue

            # Get Service State
            vserverStateOid = ".".join([self.NETSCALER_VSERVER_STATE,
                                        self._convert_from_oid(vserverNameOid)])
            vserverState = int(self.get(vserverStateOid,
                                        host,
                                        port,
                                        community)[vserverStateOid].strip("\'"))

            # Filter excluded vserver state
            if vserverState in map(lambda v: int(v),
                                   self.config.get('exclude_vserver_state')):
                continue

            for k, v in self.NETSCALER_VSERVER_GUAGES.items():
                vserverGuageOid = ".".join(
                    [v, self._convert_from_oid(vserverNameOid)])
                # Get Metric Name
                metricName = '.'.join([re.sub(r'\.|\\', '_', vserverName), k])
                # Get Metric Value
                metricValue = int(self.get(vserverGuageOid,
                                           host,
                                           port,
                                           community
                                           )[vserverGuageOid].strip("\'"))
                # Get Metric Path
                metricPath = '.'.join(['devices',
                                       device,
                                       'vserver',
                                       metricName])
                # Create Metric
                metric = Metric(metricPath, metricValue, timestamp, 0)
                # Publish Metric
                self.publish_metric(metric)
930591
def getAllMetadata(self, remote, address):
        """"""
        try:
            return self.proxies["%s-%s" % (self._interface_id, remote)].getAllMetadata(address)
        except Exception as err:
            LOG.debug("ServerThread.getAllMetadata: Exception: %s" % str(err))
302874
private List<TaskTrackerStatus> getStatusesOnHost(String hostName) {
    List<TaskTrackerStatus> statuses = new ArrayList<TaskTrackerStatus>();
    synchronized (taskTrackers) {
      for (TaskTracker tt : taskTrackers.values()) {
        TaskTrackerStatus status = tt.getStatus();
        if (hostName.equals(status.getHost())) {
          statuses.add(status);
        }
      }
    }
    return statuses;
  }
1091862
def get_hostname(config, method=None):
    
    method = method or config.get('hostname_method', 'smart')

    # case insensitive method
    method = method.lower()

    if 'hostname' in config and method != 'shell':
        return config['hostname']

    if method in get_hostname.cached_results:
        return get_hostname.cached_results[method]

    if method == 'shell':
        if 'hostname' not in config:
            raise DiamondException(
                "hostname must be set to a shell command for"
                " hostname_method=shell")
        else:
            proc = subprocess.Popen(config['hostname'],
                                    shell=True,
                                    stdout=subprocess.PIPE)
            hostname = proc.communicate()[0].strip()
            if proc.returncode != 0:
                raise subprocess.CalledProcessError(proc.returncode,
                                                    config['hostname'])
            get_hostname.cached_results[method] = hostname
            return hostname

    if method == 'smart':
        hostname = get_hostname(config, 'fqdn_short')
        if hostname != 'localhost':
            get_hostname.cached_results[method] = hostname
            return hostname
        hostname = get_hostname(config, 'hostname_short')
        get_hostname.cached_results[method] = hostname
        return hostname

    if method == 'fqdn_short':
        hostname = socket.getfqdn().split('.')[0]
        get_hostname.cached_results[method] = hostname
        if hostname == '':
            raise DiamondException('Hostname is empty?!')
        return hostname

    if method == 'fqdn':
        hostname = socket.getfqdn().replace('.', '_')
        get_hostname.cached_results[method] = hostname
        if hostname == '':
            raise DiamondException('Hostname is empty?!')
        return hostname

    if method == 'fqdn_rev':
        hostname = socket.getfqdn().split('.')
        hostname.reverse()
        hostname = '.'.join(hostname)
        get_hostname.cached_results[method] = hostname
        if hostname == '':
            raise DiamondException('Hostname is empty?!')
        return hostname

    if method == 'uname_short':
        hostname = os.uname()[1].split('.')[0]
        get_hostname.cached_results[method] = hostname
        if hostname == '':
            raise DiamondException('Hostname is empty?!')
        return hostname

    if method == 'uname_rev':
        hostname = os.uname()[1].split('.')
        hostname.reverse()
        hostname = '.'.join(hostname)
        get_hostname.cached_results[method] = hostname
        if hostname == '':
            raise DiamondException('Hostname is empty?!')
        return hostname

    if method == 'hostname':
        hostname = socket.gethostname()
        get_hostname.cached_results[method] = hostname
        if hostname == '':
            raise DiamondException('Hostname is empty?!')
        return hostname

    if method == 'hostname_short':
        hostname = socket.gethostname().split('.')[0]
        get_hostname.cached_results[method] = hostname
        if hostname == '':
            raise DiamondException('Hostname is empty?!')
        return hostname

    if method == 'hostname_rev':
        hostname = socket.gethostname().split('.')
        hostname.reverse()
        hostname = '.'.join(hostname)
        get_hostname.cached_results[method] = hostname
        if hostname == '':
            raise DiamondException('Hostname is empty?!')
        return hostname

    if method == 'none':
        get_hostname.cached_results[method] = None
        return None

    raise NotImplementedError(config['hostname_method'])
280987
def collect_snmp(self, device, host, port, community):
        
        # Log
        self.log.info("Collecting ServerTech PDU statistics from: %s" % device)

        # Set timestamp
        timestamp = time.time()

        inputFeeds = {}

        # Collect PDU input gauge values
        for gaugeName, gaugeOid in self.PDU_SYSTEM_GAUGES.items():
            systemGauges = self.walk(gaugeOid, host, port, community)
            for o, gaugeValue in systemGauges.items():
                # Get Metric Name
                metricName = gaugeName
                # Get Metric Value
                metricValue = float(gaugeValue)
                # Get Metric Path
                metricPath = '.'.join(
                    ['devices', device, 'system', metricName])
                # Create Metric
                metric = Metric(metricPath, metricValue, timestamp, 2)
                # Publish Metric
                self.publish_metric(metric)

        # Collect PDU input feed names
        inputFeedNames = self.walk(
            self.PDU_INFEED_NAMES, host, port, community)
        for o, inputFeedName in inputFeedNames.items():
            # Extract input feed name
            inputFeed = ".".join(o.split(".")[-2:])
            inputFeeds[inputFeed] = inputFeedName

        # Collect PDU input gauge values
        for gaugeName, gaugeOid in self.PDU_INFEED_GAUGES.items():
            inputFeedGauges = self.walk(gaugeOid, host, port, community)
            for o, gaugeValue in inputFeedGauges.items():
                # Extract input feed name
                inputFeed = ".".join(o.split(".")[-2:])

                # Get Metric Name
                metricName = '.'.join([re.sub(r'\.|\\', '_',
                                              inputFeeds[inputFeed]),
                                       gaugeName])

                # Get Metric Value
                if gaugeName == "infeedVolts":
                    # Note: Voltage is in "tenth volts", so divide by 10
                    metricValue = float(gaugeValue) / 10.0
                elif gaugeName == "infeedAmps":
                    # Note: Amps is in "hundredth amps", so divide by 100
                    metricValue = float(gaugeValue) / 100.0
                else:
                    metricValue = float(gaugeValue)

                # Get Metric Path
                metricPath = '.'.join(['devices', device, 'input', metricName])
                # Create Metric
                metric = Metric(metricPath, metricValue, timestamp, 2)
                # Publish Metric
                self.publish_metric(metric)
872289
def get_default_values(data):
    """"""
    request = data.get('request')
    result = {}
    result['__datetime__'] = datetime.now()
    result['__ip_address__'] = request and get_ip(request) or '0.0.0.0'
    return result
9627
function(hostname, callback) {
  get_nodes(function(err,nodes) {
    if (err) return callback(err);

    var n = nodes.filter(function(node) {
      return node.name === hostname;
    });

    callback(null,(n.length === 1) ? n[0].ip_address : null);
  });
}
557784
def __get_host(node, vm_):
    '''
    
    '''
    if __get_ssh_interface(vm_) == 'private_ips' or vm_['external_ip'] is None:
        ip_address = node.private_ips[0]
        log.info('Salt node data. Private_ip: %s', ip_address)
    else:
        ip_address = node.public_ips[0]
        log.info('Salt node data. Public_ip: %s', ip_address)

    if ip_address:
        return ip_address

    return node.name
1164669
protected function _getShopHostInfoFromServerVars()
    {
        // got here from setup dir
        $sScript = $_SERVER['SCRIPT_NAME'];
        $iPort = (int) $_SERVER['SERVER_PORT'];
        $blSsl = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'));
        if (!$iPort) {
            $iPort = $blSsl ? 443 : 80;
        }
        $sScript = rtrim(dirname(dirname($sScript)), '/') . '/';

        return [
            'host' => $_SERVER['HTTP_HOST'],
            'port' => $iPort,
            'dir'  => $sScript,
            'ssl'  => $blSsl,
        ];
    }
1212196
def retrieveVals(self):
        """"""
        ntpinfo = NTPinfo()
        stats = ntpinfo.getPeerStats()
        if stats:
            if self.hasGraph('ntp_peer_stratum'):
                self.setGraphVal('ntp_peer_stratum', 'stratum', 
                                 stats.get('stratum'))
            if self.hasGraph('ntp_peer_stats'):
                self.setGraphVal('ntp_peer_stats', 'offset', 
                                 stats.get('offset'))
                self.setGraphVal('ntp_peer_stats', 'delay', 
                                 stats.get('delay'))
                self.setGraphVal('ntp_peer_stats', 'jitter', 
                                 stats.get('jitter'))
34122
def get_snmp_value(sess, helper, oid):
        
        snmp_result = sess.get_oids(oid)[0]
        if snmp_result is None:
            helper.exit(summary="No response from device for oid " + oid, exit_code=unknown, perfdata='')

        else:
            return snmp_result
981328
def get_snmp_information(self):
        """"""
        snmp_information = {}

        snmp_config = junos_views.junos_snmp_config_table(self.device)
        snmp_config.get()
        snmp_items = snmp_config.items()

        if not snmp_items:
            return snmp_information

        snmp_information = {
            py23_compat.text_type(ele[0]): ele[1] if ele[1] else ""
            for ele in snmp_items[0][1]
        }

        snmp_information["community"] = {}
        communities_table = snmp_information.pop("communities_table")
        if not communities_table:
            return snmp_information

        for community in communities_table.items():
            community_name = py23_compat.text_type(community[0])
            community_details = {"acl": ""}
            community_details.update(
                {
                    py23_compat.text_type(ele[0]): py23_compat.text_type(
                        ele[1]
                        if ele[0] != "mode"
                        else C.SNMP_AUTHORIZATION_MODE_MAP.get(ele[1])
                    )
                    for ele in community[1]
                }
            )
            snmp_information["community"][community_name] = community_details

        return snmp_information
9126
def get_num_names(include_expired=False, proxy=None, hostport=None):
    
    assert proxy or hostport, 'Need proxy or hostport'
    if proxy is None:
        proxy = connect_hostport(hostport)

    schema = {
        'type': 'object',
        'properties': {
            'count': {
                'type': 'integer',
                'minimum': 0,
            },
        },
        'required': [
            'count',
        ],
    }

    count_schema = json_response_schema(schema)

    resp = {}
    try:
        if include_expired:
            resp = proxy.get_num_names_cumulative()
        else:
            resp = proxy.get_num_names()

        resp = json_validate(count_schema, resp)
        if json_is_error(resp):
            return resp

    except ValidationError as e:
        if BLOCKSTACK_DEBUG:
            log.exception(e)

        resp = {'error': 'Server response did not match expected schema.  You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
        return resp

    except socket.timeout:
        log.error("Connection timed out")
        resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
        return resp

    except socket.error as se:
        log.error("Connection error {}".format(se.errno))
        resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
        return resp

    except Exception as ee:
        if BLOCKSTACK_DEBUG:
            log.exception(ee)

        log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
        resp = {'error': 'Failed to contact Blockstack node.  Try again with `--debug`.', 'http_status': 500}
        return resp

    return resp['count']
1188503
public static snmpmanager[] get(nitro_service service) throws Exception{
		snmpmanager obj = new snmpmanager();
		snmpmanager[] response = (snmpmanager[])obj.get_resources(service);
		return response;
	}
391669
def check(self):
        
        try:
            self.get_snmp_from_host1()
            self.get_snmp_from_host2()
        except (health_monitoring_plugins.SnmpException, TypeError, KeyError):
            self.helper.status(unknown)
            self.helper.add_summary("SNMP response incomplete or invalid")
            return

        self.helper.add_summary("Filter Status")
        self.helper.add_long_output("Power Supply 1: %s" % self.ps1_value)
        if self.ps1_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Power Supply 1: %s" % self.ps1_value)

        self.helper.add_long_output("Power Supply 2: %s" % self.ps2_value)
        if self.ps2_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Power Supply 2: %s" % self.ps2_value)

        self.helper.add_long_output("Fan 1: %s" % self.fan1_value)
        if self.fan1_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Fan 1: %s" % self.fan1_value)

        self.helper.add_long_output("Fan 2: %s" % self.fan2_value)
        if self.fan2_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Fan 2: %s" % self.fan2_value)

        self.helper.add_long_output("Battery: %s" % self.bat_value)
        if self.bat_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Battery: %s" % self.bat_value)

        self.helper.add_long_output("Temperature: %s" % self.temp_value)
        if self.temp_value != "ok":
            self.helper.status(critical)
            self.helper.add_summary("Temperature: %s" % self.temp_value)

        self.helper.add_metric(label='logfill',value=self.logfill_value, uom="%%")
        self.helper.add_long_output("Fill Level internal log: %s%%" % self.logfill_value)

        self.helper.add_long_output("Activity State: %s" % self.activity_value1)
        if self.activity_value1 == "error":
            self.helper.status(critical)
            self.helper.add_summary("Activity State: %s" % self.activity_value1)

        if self.activity_value2:
            self.helper.add_long_output("Activity State 2: %s" % self.activity_value2)
            if self.activity_value1 == "active" and self.activity_value2 == "active":
                self.helper.status(critical)
                self.helper.add_summary("Filter 1 and Filter 2 active!")
                    
            if self.activity_value1 == "standby" and self.activity_value2 == "standby":
                self.helper.status(critical)
                self.helper.add_summary("Filter 1 and Filter 2 standby!")

        self.helper.check_all_metrics()
1246364
def GetCpuStolenMs(self):
        ''''''
        counter = c_uint64()
        ret = vmGuestLib.VMGuestLib_GetCpuStolenMs(self.handle.value, byref(counter))
        if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
        return counter.value