Subversion-Projekte lars-tiefland.nagios-php

Revision

Revision 9 | Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
	class service
3
	{
4
		public static function getStatusList()
5
		{
6
			$sql="SELECT
7
					count(current_state) AS anz
8
				FROM
9
					servicestatus
10
				WHERE
11
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
12
				AND
13
					current_state = 0
14
			";
15
			$res = $GLOBALS["db"]->query($sql);
16
			$row = $res->fetchRow();
17
			$rows["ok"] = $row["anz"];
18
			$sql="SELECT
19
					count(current_state) AS anz
20
				FROM
21
					servicestatus
22
				WHERE
23
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
24
				AND
25
					current_state = 1
26
			";
27
			$res = $GLOBALS["db"]->query($sql);
28
			$row = $res->fetchRow();
29
			$rows["warning"] = $row["anz"];
30
			$sql="SELECT
31
					count(current_state) AS anz
32
				FROM
33
					servicestatus
34
				WHERE
35
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
36
				AND
37
					current_state = 2
38
			";
39
			$res = $GLOBALS["db"]->query($sql);
40
			$row = $res->fetchRow();
41
			$rows["critical"] = $row["anz"];
42
			$sql="SELECT
43
					count(current_state) AS anz
44
				FROM
45
					servicestatus
46
				WHERE
47
					instance_id = " . $GLOBALS["cfg"]["instance"] . "
48
				AND
49
					current_state = 3
50
			";
51
			$res = $GLOBALS["db"]->query($sql);
52
			$row = $res->fetchRow();
53
			$rows["unknown"] = $row["anz"];
54
			$rows["total"] = array_sum($rows);
55
			return $rows;
56
		}
57
	}
58
?>