Пример #1
0
 def read_sensors(self, sensorname):
     try:
         if sensorname == 'all':
             sensors = self.ipmicmd.get_sensor_descriptions()
             readings = []
             for sensor in filter(self.match_sensor, sensors):
                 try:
                     reading = self.ipmicmd.get_sensor_reading(
                         sensor['name'])
                 except pygexc.IpmiException as ie:
                     if ie.ipmicode == 203:
                         continue
                     raise
                 if hasattr(reading, 'health'):
                     reading.health = _str_health(reading.health)
                 readings.append(reading)
             self.output.put(msg.SensorReadings(readings, name=self.node))
         else:
             self.make_sensor_map()
             if sensorname not in self.sensormap:
                 self.output.put(
                     msg.ConfluentTargetNotFound(self.node,
                                                 'Sensor not found'))
                 return
             reading = self.ipmicmd.get_sensor_reading(
                 self.sensormap[sensorname])
             if hasattr(reading, 'health'):
                 reading.health = _str_health(reading.health)
             self.output.put(
                 msg.SensorReadings([reading],
                                    name=self.node))
     except pygexc.IpmiException:
         self.output.put(msg.ConfluentTargetTimeout(self.node))
Пример #2
0
def retrieve_health(configmanager, creds, node, results, element):
    wc = WebClient(node, configmanager, creds)
    hinfo = wc.fetch('/affluent/health', results)
    if hinfo:
        results.put(
            msg.HealthSummary(hinfo.get('health', 'unknown'), name=node))
        results.put(msg.SensorReadings(hinfo.get('sensors', []), name=node))
Пример #3
0
 def health(self):
     if 'read' == self.op:
         try:
             response = self.ipmicmd.get_health()
         except pygexc.IpmiException:
             self.output.put(msg.ConfluentTargetTimeout(self.node))
             return
         health = response['health']
         health = _str_health(health)
         self.output.put(msg.HealthSummary(health, self.node))
         if 'badreadings' in response:
             badsensors = []
             for reading in response['badreadings']:
                 if hasattr(reading, 'health'):
                     reading.health = _str_health(reading.health)
                 badsensors.append(reading)
             self.output.put(msg.SensorReadings(badsensors, name=self.node))
     else:
         raise exc.InvalidArgumentException('health is read-only')
Пример #4
0
def retrieve_health(configmanager, creds, node, results):
    wc = cnos_login(node, configmanager, creds)
    hinfo = wc.grab_json_response('/nos/api/sysinfo/globalhealthstatus')
    summary = hinfo['status'].lower()
    if summary == 'noncritical':
        summary = 'warning'
    results.put(msg.HealthSummary(summary, name=node))
    state = None
    badreadings = []
    if summary != 'ok':  # temperature or dump or fans or psu
        wc.grab_json_response('/nos/api/sysinfo/panic_dump')
        switchinfo = wc.grab_json_response('/nos/api/sysinfo/panic_dump')
        if switchinfo:
            badreadings.append(
                SwitchSensor('Panicdump', ['Present'], health='warning'))
        switchinfo = wc.grab_json_response('/nos/api/sysinfo/temperatures')
        for temp in switchinfo:
            if temp == 'Temperature threshold':
                continue
            if switchinfo[temp]['State'] != 'OK':
                temphealth = switchinfo[temp]['State'].lower()
                if temphealth == 'noncritical':
                    temphealth = 'warning'
                tempval = switchinfo[temp]['Temp']
                badreadings.append(
                    SwitchSensor(temp, [], value=tempval, health=temphealth))
        switchinfo = wc.grab_json_response('/nos/api/sysinfo/fans')
        for fan in switchinfo:
            if switchinfo[fan]['speed-rpm'] < 100:
                badreadings.append(
                    SwitchSensor(fan, [],
                                 value=switchinfo[fan]['speed-rpm'],
                                 health='critical'))
        switchinfo = wc.grab_json_response('/nos/api/sysinfo/power')
        for psu in switchinfo:
            if switchinfo[psu]['State'] != 'Normal ON':
                psuname = switchinfo[psu]['Name']
                badreadings.append(
                    SwitchSensor(psuname,
                                 states=[switchinfo[psu]['State']],
                                 health='critical'))
    results.put(msg.SensorReadings(badreadings, name=node))
Пример #5
0
def retrieve_sensors(configmanager, creds, node, results, element):
    wc = WebClient(node, configmanager, creds)
    sensors = wc.fetch('/affluent/sensors/hardware/all/{0}'.format(element[-1]), results)
    if sensors:
        results.put(msg.SensorReadings(sensors['sensors'], node))