1<?php
2
3// Pandora FMS - http://pandorafms.com
4// ==================================================
5// Copyright (c) 2011 Artica Soluciones Tecnologicas
6// Please see http://pandorafms.org for full contribution list
7
8// This program is free software; you can redistribute it and/or
9// modify it under the terms of the  GNU Lesser General Public License
10// as published by the Free Software Foundation; version 2
11
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16
17// Get critical agents by using the status code in modules.
18
19function os_agents_critical ($id_os) {
20
21	//TODO REVIEW ORACLE AND POSTGRES
22
23	return db_get_sql("
24		SELECT COUNT(*)
25		FROM tagente
26		WHERE tagente.disabled=0 AND
27			critical_count>0 AND id_os=$id_os");
28}
29
30// Get ok agents by using the status code in modules.
31
32function os_agents_ok($id_os) {
33
34	return db_get_sql ("
35		SELECT COUNT(*)
36		FROM tagente
37		WHERE tagente.disabled=0 AND
38			normal_count=total_count AND id_os=$id_os");
39}
40
41// Get warning agents by using the status code in modules.
42
43function os_agents_warning ($id_os) {
44
45	return db_get_sql ("
46		SELECT COUNT(*)
47		FROM tagente
48		WHERE tagente.disabled=0 AND
49			critical_count=0 AND warning_count>0 AND id_os=$id_os");
50}
51
52// Get unknown agents by using the status code in modules.
53
54function os_agents_unknown ($id_os) {
55
56	return db_get_sql ("
57		SELECT COUNT(*)
58		FROM tagente
59		WHERE tagente.disabled=0 AND
60			critical_count=0 AND warning_count=0 AND
61			unknown_count>0 AND id_os=$id_os");
62}
63
64// Get the name of a group given its id.
65function os_get_name($id_os) {
66	return db_get_value ('name', 'tconfig_os', 'id_os', (int) $id_os);
67}
68
69
70function os_get_os() {
71	$op_systems = db_get_all_rows_in_table('tconfig_os');
72	if (empty($op_systems))
73		$op_systems = array();
74
75	return $op_systems;
76}
77?>
78