Ejemplo n.º 1
0
     usage("Unknown type (-t) |{$type}|");
 }
 if (!is_numeric($warn)) {
     usage("Warning (-w) is not numeric {$warn}");
 }
 if (!is_numeric($crit)) {
     usage("Critical (-c) is not numeric {$crit}");
 }
 if ($warn > $crit) {
     throw new Exception("Warning must be less than critical");
 }
 if (strlen($name) == 0) {
     usage("Name (-n) must be set and must either be a zone or pod name (depends on type |-t| variable)");
 }
 $id = $stats[$type]['level'] == 'pod' ? getPodId($name) : getZoneId($name);
 $result = $cloudstack->listCapacity(array('type' => $stats[$type]['id'], 'zoneid' => $stats[$type]['level'] == 'pod' ? '' : $id, 'podid' => $stats[$type]['level'] == 'pod' ? $id : ''));
 //print_r($result);
 $perfdata = array();
 for ($i = 0; $i < count($result->capacity) && empty($value); $i++) {
     $comp = $stats[$type]['level'] == 'pod' ? $result->capacity[$i]->podid : $result->capacity[$i]->zoneid;
     if ($comp == $id) {
         $value = $result->capacity[$i]->percentused;
         $perfdata[] = sprintf("'%s'=%s%s;%s;%s;0;100", $type, $value, '%', $warn, $crit);
     }
 }
 if (empty($value)) {
     $msg = "UNKNOWN: unable to determine value for {$type}";
     $status = 3;
 } elseif ($value > $crit) {
     $msg = "ERROR: {$type} is too high ({$value}% > {$crit}%)";
     $status = 2;