Subversion-Projekte lars-tiefland.nagios-php

Revision

Revision 62 | Revision 86 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

    class hostGroup
    {
        public $alias;
        public $hostgroup_id;
        public $members;
        public function __construct( $id )
        {
            $sql = "SELECT
                    alias,
                    hostgroup_id
                FROM
                    hostgroups
                WHERE
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
                AND
                    hostgroup_id = $id
            ";
            $res = $GLOBALS["db"]->query( $sql );
            $row = $res->fetchRow();
            foreach ( $row as $feld => $wert )
            {
                $this->$feld = $wert;
            }
            $this->members = $this->getMemberList( $id );
        }

        public static function getList()
        {
            $sql="SELECT
                    hostgroup_id
                FROM
                    hostgroups
                WHERE
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
            ";
            $res = $GLOBALS["db"]->query( $sql );
            while ( $row = $res->fetchRow() )
            {
                $ret[] = new hostGroup( $row["hostgroup_id"] );
            }
            return $ret;
        }

        public function getMemberList( $hg_id )
        {
            $sql = "SELECT
                    host_object_id
                FROM
                    hostgroup_members
                WHERE
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
                AND
                    hostgroup_id = $hg_id
            ";
            $res = $GLOBALS["db"]->query( $sql );
            while ( $row = $res->fetchRow() )
            {
                $ret[] = new host( $row["host_object_id"] );
            }
            return $ret;
        }
    }

?>