Subversion-Projekte lars-tiefland.nagios-php

Revision

Revision 1 | Revision 42 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 1 Revision 9
Zeile 1... Zeile 1...
1
<?php
1
<?php
-
 
2
 
2
	class host
3
    class host
3
	{
4
    {
4
		public static function getStatusList()
5
        public static function getStatusList()
5
		{
6
        {
6
			$sql="SELECT
7
            $sql = "SELECT
7
					count(current_state) AS anz
8
					count(current_state) AS anz
8
				FROM
9
				FROM
9
					hoststatus
10
					hoststatus
10
				WHERE
11
				WHERE
11
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
12
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
12
				AND
13
				AND
13
					current_state = 0
14
					current_state = 0
14
			";
15
			";
15
			$res = $GLOBALS["db"]->query($sql);
16
            $res = $GLOBALS["db"]->query( $sql );
16
			$row = $res->fetchRow();
17
            $row = $res->fetchRow();
17
			$rows["up"] = $row["anz"];
18
            $rows["up"] = $row["anz"];
18
			$sql="SELECT
19
            $sql = "SELECT
19
					count(current_state) AS anz
20
					count(current_state) AS anz
20
				FROM
21
				FROM
21
					hoststatus
22
					hoststatus
22
				WHERE
23
				WHERE
23
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
24
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
24
				AND
25
				AND
25
					current_state = 1
26
					current_state = 1
26
			";
27
			";
27
			$res = $GLOBALS["db"]->query($sql);
28
            $res = $GLOBALS["db"]->query( $sql );
28
			$row = $res->fetchRow();
29
            $row = $res->fetchRow();
29
			$rows["down"] = $row["anz"];
30
            $rows["down"] = $row["anz"];
30
			$sql="SELECT
31
            $sql = "SELECT
31
					count(current_state) AS anz
32
					count(current_state) AS anz
32
				FROM
33
				FROM
33
					hoststatus
34
					hoststatus
34
				WHERE
35
				WHERE
35
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
36
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
36
				AND
37
				AND
37
					current_state = 2
38
					current_state = 2
38
			";
39
			";
39
			$res = $GLOBALS["db"]->query($sql);
40
            $res = $GLOBALS["db"]->query( $sql );
40
			$row = $res->fetchRow();
41
            $row = $res->fetchRow();
41
			$rows["unreachable"] = $row["anz"];
42
            $rows["unreachable"] = $row["anz"];
42
			$rows["total"] = array_sum($rows);
43
            $rows["total"] = array_sum( $rows );
43
			return $rows;
44
            return $rows;
-
 
45
        }
44
		}
46
    }
45
	}
47
 
46
?>
48
?>