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 service
3
    class service
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
					servicestatus
10
					servicestatus
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["ok"] = $row["anz"];
18
            $rows["ok"] = $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
					servicestatus
22
					servicestatus
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["warning"] = $row["anz"];
30
            $rows["warning"] = $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
					servicestatus
34
					servicestatus
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["critical"] = $row["anz"];
42
            $rows["critical"] = $row["anz"];
42
			$sql="SELECT
43
            $sql = "SELECT
43
					count(current_state) AS anz
44
					count(current_state) AS anz
44
				FROM
45
				FROM
45
					servicestatus
46
					servicestatus
46
				WHERE
47
				WHERE
47
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
48
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
48
				AND
49
				AND
49
					current_state = 3
50
					current_state = 3
50
			";
51
			";
51
			$res = $GLOBALS["db"]->query($sql);
52
            $res = $GLOBALS["db"]->query( $sql );
52
			$row = $res->fetchRow();
53
            $row = $res->fetchRow();
53
			$rows["unknown"] = $row["anz"];
54
            $rows["unknown"] = $row["anz"];
54
			$rows["total"] = array_sum($rows);
55
            $rows["total"] = array_sum( $rows );
55
			return $rows;
56
            return $rows;
-
 
57
        }
56
		}
58
    }
57
	}
59
 
58
?>
60
?>