Subversion-Projekte lars-tiefland.nagios-php

Revision

Revision 63 | Revision 86 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
58 lars 1
<?php
2
 
3
    class hostGroup
4
    {
5
        public $alias;
6
        public $hostgroup_id;
7
        public $members;
8
        public function __construct( $id )
9
        {
10
            $sql = "SELECT
11
                    alias,
12
                    hostgroup_id
13
                FROM
14
                    hostgroups
15
                WHERE
16
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
17
                AND
18
                    hostgroup_id = $id
19
            ";
20
            $res = $GLOBALS["db"]->query( $sql );
21
            $row = $res->fetchRow();
22
            foreach ( $row as $feld => $wert )
23
            {
24
                $this->$feld = $wert;
25
            }
61 lars 26
            $this->members = $this->getMemberList( $id );
58 lars 27
        }
28
 
29
        public static function getList()
30
        {
63 lars 31
            $sql="SELECT
32
                    hostgroup_id
33
                FROM
34
                    hostgroups
35
                WHERE
36
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
37
            ";
38
            $res = $GLOBALS["db"]->query( $sql );
39
            while ( $row = $res->fetchRow() )
40
            {
41
                $ret[] = new hostGroup( $row["hostgroup_id"] );
42
            }
43
            return $ret;
58 lars 44
        }
45
 
46
        public function getMemberList( $hg_id )
47
        {
48
            $sql = "SELECT
49
                    host_object_id
50
                FROM
60 lars 51
                    hostgroup_members
58 lars 52
                WHERE
53
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
54
                AND
55
                    hostgroup_id = $hg_id
56
            ";
57
            $res = $GLOBALS["db"]->query( $sql );
58
            while ( $row = $res->fetchRow() )
59
            {
60
                $ret[] = new host( $row["host_object_id"] );
61
            }
62 lars 62
            return $ret;
58 lars 63
        }
64
    }
65
 
66
?>