Subversion-Projekte lars-tiefland.nagios-php

Revision

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

Revision Autor Zeilennr. Zeile
58 lars 1
<?php
2
 
86 lars 3
    /**
4
     * @package nagios-php
5
     * @author Lars Tiefland <ltiefland@gmail.com>
6
     * @copyright 2013
7
     * @version $Rev: 108 $
8
     */
9
 
10
    // $Id: hostgroup.php 108 2013-01-03 10:15:31Z lars $
11
 
12
    /**
13
     * hostGroup
14
     *
15
     * @package nagios-php
16
     * @author Lars Tiefland
17
     * @copyright 2013
18
     * @version $Id: hostgroup.php 108 2013-01-03 10:15:31Z lars $
19
     * @access public
20
     */
58 lars 21
    class hostGroup
22
    {
23
        public $alias;
24
        public $hostgroup_id;
25
        public $members;
86 lars 26
        /**
27
         * hostGroup::__construct()
28
         *
29
         * @param mixed $id
30
         * @return
31
         */
58 lars 32
        public function __construct( $id )
33
        {
34
            $sql = "SELECT
35
                    alias,
36
                    hostgroup_id
37
                FROM
38
                    hostgroups
39
                WHERE
40
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
41
                AND
42
                    hostgroup_id = $id
43
            ";
44
            $res = $GLOBALS["db"]->query( $sql );
45
            $row = $res->fetchRow();
46
            foreach ( $row as $feld => $wert )
47
            {
48
                $this->$feld = $wert;
49
            }
61 lars 50
            $this->members = $this->getMemberList( $id );
58 lars 51
        }
52
 
86 lars 53
        /**
54
         * hostGroup::getList()
55
         *
56
         * @return
57
         */
58 lars 58
        public static function getList()
59
        {
63 lars 60
            $sql="SELECT
61
                    hostgroup_id
62
                FROM
63
                    hostgroups
64
                WHERE
65
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
66
            ";
67
            $res = $GLOBALS["db"]->query( $sql );
68
            while ( $row = $res->fetchRow() )
69
            {
70
                $ret[] = new hostGroup( $row["hostgroup_id"] );
71
            }
72
            return $ret;
58 lars 73
        }
74
 
86 lars 75
        /**
76
         * hostGroup::getMemberList()
77
         *
78
         * @param mixed $hg_id
79
         * @return
80
         */
106 lars 81
        private function getMemberList( $hg_id )
58 lars 82
        {
83
            $sql = "SELECT
84
                    host_object_id
85
                FROM
60 lars 86
                    hostgroup_members
58 lars 87
                WHERE
88
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
89
                AND
90
                    hostgroup_id = $hg_id
91
            ";
92
            $res = $GLOBALS["db"]->query( $sql );
93
            while ( $row = $res->fetchRow() )
94
            {
95
                $ret[] = new host( $row["host_object_id"] );
96
            }
62 lars 97
            return $ret;
58 lars 98
        }
99
    }
100
 
101
?>