Subversion-Projekte lars-tiefland.nagios-php

Revision

Revision 106 | Revision 108 | 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: 107 $
8
     */
9
 
10
    // $Id: hostgroup.php 107 2013-01-03 10:14:50Z lars $
11
 
12
    /**
13
     * hostGroup
14
     *
15
     * @package nagios-php
16
     * @author Lars Tiefland
17
     * @copyright 2013
18
     * @version $Id: hostgroup.php 107 2013-01-03 10:14:50Z 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 );
107 lars 68
            var_dump($sql);
63 lars 69
            while ( $row = $res->fetchRow() )
70
            {
71
                $ret[] = new hostGroup( $row["hostgroup_id"] );
72
            }
73
            return $ret;
58 lars 74
        }
75
 
86 lars 76
        /**
77
         * hostGroup::getMemberList()
78
         *
79
         * @param mixed $hg_id
80
         * @return
81
         */
106 lars 82
        private function getMemberList( $hg_id )
58 lars 83
        {
84
            $sql = "SELECT
85
                    host_object_id
86
                FROM
60 lars 87
                    hostgroup_members
58 lars 88
                WHERE
89
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
90
                AND
91
                    hostgroup_id = $hg_id
92
            ";
93
            $res = $GLOBALS["db"]->query( $sql );
94
            while ( $row = $res->fetchRow() )
95
            {
96
                $ret[] = new host( $row["host_object_id"] );
97
            }
62 lars 98
            return $ret;
58 lars 99
        }
100
    }
101
 
102
?>