Revision 86 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?php/*** @package nagios-php* @author Lars Tiefland <ltiefland@gmail.com>* @copyright 2013* @version $Rev: 115 $*/// $Id: host.php 115 2013-01-05 19:05:29Z lars $/*** host** @package nagios-php* @author Lars Tiefland* @copyright 2012* @version $Rev: 115 $* @access public*/class host{public $display_name;public $host_id;public $host_object_id;public $services;/*** host::__construct()** @param mixed $id* @return*/public function __construct( $id, $is_host_object_id = false ){if ( $is_host_object_id ){$id_where = "host_object_id = $id";}else{$id_where = "host_id = $id";}$sql = "SELECThost_id,display_name,host_object_idFROMhostsWHERE" . $id_where . "ANDinstance_id = " . $GLOBALS["cfg"]["instance"] . "";$res = $GLOBALS["db"]->query( $sql );$row = $res->fetchRow();//$this->host_id=$row["host_id"];foreach ( $row as $feld => $wert ){$this->$feld = $wert;}$this->services = host::getHostServiceList( $id );}/*** host::getHostServiceList()** @param mixed $host_id* @return*/public static function getHostServiceList( $host_id ){$sql = "SELECTservice_idFROMservicesWHEREhost_object_id = $host_idANDinstance_id = " . $GLOBALS["cfg"]["instance"] . "";$res = $GLOBALS["db"]->query( $sql );while ( $row = $res->fetchRow() ){$ret[] = new service( $row["service_id"] );}return $ret;}/*** host::getStatusList()** @return*/public static function getStatusList(){$sql = "SELECTcount(current_state) AS anzFROMhoststatusWHEREinstance_id = " . $GLOBALS["cfg"]["instance"] . "ANDcurrent_state = 0";$res = $GLOBALS["db"]->query( $sql );$row = $res->fetchRow();$rows["up"] = $row["anz"];$sql = "SELECTcount(current_state) AS anzFROMhoststatusWHEREinstance_id = " . $GLOBALS["cfg"]["instance"] . "ANDcurrent_state = 1";$res = $GLOBALS["db"]->query( $sql );$row = $res->fetchRow();$rows["down"] = $row["anz"];$sql = "SELECTcount(current_state) AS anzFROMhoststatusWHEREinstance_id = " . $GLOBALS["cfg"]["instance"] . "ANDcurrent_state = 2";$res = $GLOBALS["db"]->query( $sql );$row = $res->fetchRow();$rows["unreachable"] = $row["anz"];$rows["total"] = array_sum( $rows );return $rows;}}?>