Subversion-Projekte lars-tiefland.nagios-php

Revision

Revision 9 | Revision 44 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

    class host
    {
        public $display_name;
        public $host_id;
        public $host_object_id;

        public function __construct($id)
        {
            $sql="SELECT
                    host_id,
                    display_name,
                    host_object_id
                FROM
                    hosts
                WHERE
                    host_id = $id
                AND
                    instance_id = " . $GLOBALS["cfg"]["instance"] . "
            ";
            $res = $GLOBALS["db"]->query($sql);
            $row = $res->fetchObject("host");
        }
        public static function getStatusList()
        {
            $sql = "SELECT
                                        count(current_state) AS anz
                                FROM
                                        hoststatus
                                WHERE
                                        instance_id = " . $GLOBALS["cfg"]["instance"] . "
                                AND
                                        current_state = 0
                        ";
            $res = $GLOBALS["db"]->query( $sql );
            $row = $res->fetchRow();
            $rows["up"] = $row["anz"];
            $sql = "SELECT
                                        count(current_state) AS anz
                                FROM
                                        hoststatus
                                WHERE
                                        instance_id = " . $GLOBALS["cfg"]["instance"] . "
                                AND
                                        current_state = 1
                        ";
            $res = $GLOBALS["db"]->query( $sql );
            $row = $res->fetchRow();
            $rows["down"] = $row["anz"];
            $sql = "SELECT
                                        count(current_state) AS anz
                                FROM
                                        hoststatus
                                WHERE
                                        instance_id = " . $GLOBALS["cfg"]["instance"] . "
                                AND
                                        current_state = 2
                        ";
            $res = $GLOBALS["db"]->query( $sql );
            $row = $res->fetchRow();
            $rows["unreachable"] = $row["anz"];
            $rows["total"] = array_sum( $rows );
            return $rows;
        }
    }

?>