~ubuntu-dev/ubuntu/lucid/zabbix/lucid-201002110857

« back to all changes in this revision

Viewing changes to frontends/php/alarms.php

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2007-07-02 09:06:51 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070702090651-8l6fl3fjw9rh6l2u
Tags: 1:1.4.1-2
Add patch from SVN in order to fix Incorrect processing of character '%'
in user parameters and remote commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/* 
3
 
** ZABBIX
4
 
** Copyright (C) 2000-2005 SIA Zabbix
5
 
**
6
 
** This program is free software; you can redistribute it and/or modify
7
 
** it under the terms of the GNU General Public License as published by
8
 
** the Free Software Foundation; either version 2 of the License, or
9
 
** (at your option) any later version.
10
 
**
11
 
** This program is distributed in the hope that it will be useful,
12
 
** but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
** GNU General Public License for more details.
15
 
**
16
 
** You should have received a copy of the GNU General Public License
17
 
** along with this program; if not, write to the Free Software
18
 
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
 
**/
20
 
?>
21
 
<?php
22
 
        include "include/config.inc.php";
23
 
        $page["title"] = "S_ALARMS";
24
 
        $page["file"] = "alarms.php";
25
 
        $page["menu.url"] = "tr_status.php";
26
 
 
27
 
        show_header($page["title"],0,0);
28
 
?>
29
 
 
30
 
<?php
31
 
        if(!check_right_on_trigger("R",$_REQUEST["triggerid"]))
32
 
        {
33
 
                show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
34
 
                show_page_footer();
35
 
                exit;
36
 
        }
37
 
?>
38
 
 
39
 
<?php
40
 
        $_REQUEST["limit"] = get_request("limit","NO");
41
 
        if(is_numeric($_REQUEST["limit"]))
42
 
                $_REQUEST["limit"] = 100;
43
 
 
44
 
        $trigger=get_trigger_by_triggerid($_REQUEST["triggerid"]);
45
 
 
46
 
        $expression=$trigger["expression"];
47
 
 
48
 
        $expression=explode_exp($expression,1);
49
 
        $description=expand_trigger_description($_REQUEST["triggerid"]);
50
 
 
51
 
        $form = new CForm();
52
 
        $form->AddVar("triggerid",$_REQUEST["triggerid"]);
53
 
        $cmbLimit = new CComboBox("limit",$_REQUEST["limit"],"submit()");
54
 
        $cmbLimit->AddItem('NO',S_SHOW_ALL);
55
 
        $cmbLimit->AddItem("100",S_SHOW_ONLY_LAST_100);
56
 
        $form->AddItem($cmbLimit);
57
 
 
58
 
        show_header2(S_ALARMS_BIG.":$description<br>$expression", $form);
59
 
?>
60
 
 
61
 
<?php
62
 
        $sql="select * from alarms where triggerid=".$_REQUEST["triggerid"].
63
 
                " order by clock desc";
64
 
        $result=DBselect($sql, $_REQUEST["limit"]);
65
 
 
66
 
        $table = new CTableInfo();
67
 
        $table->SetHeader(array(S_TIME,S_STATUS,S_ACKNOWLEDGED,S_DURATION,S_SUM,"%"));
68
 
        $table->ShowStart();
69
 
 
70
 
        $truesum=0;
71
 
        $falsesum=0;
72
 
        $dissum=0;
73
 
        $clock=mktime();
74
 
        while($row=DBfetch($result))
75
 
        {
76
 
                $lclock=$clock;
77
 
                $clock=$row["clock"];
78
 
                $leng=$lclock-$row["clock"];
79
 
 
80
 
//              if($row["value"]==0)            { echo "<TR BGCOLOR=#EEFFEE>"; }
81
 
//              elseif($row["value"]==2)        { echo "<TR BGCOLOR=#EEEEEE>"; }
82
 
//              else                            { echo "<TR BGCOLOR=#FFDDDD>"; }
83
 
 
84
 
//              table_td(date("Y.M.d H:i:s",$row["clock"]),"");
85
 
                if($row["value"]==1)
86
 
                {
87
 
                        $istrue=new CCol(S_TRUE_BIG,"on");
88
 
                        $truesum=$truesum+$leng;
89
 
                        $sum=$truesum;
90
 
                }
91
 
                elseif($row["value"]==0)
92
 
                {
93
 
                        $istrue=new CCol(S_FALSE_BIG,"off");
94
 
                        $falsesum=$falsesum+$leng;
95
 
                        $sum=$falsesum;
96
 
                }
97
 
                elseif($row["value"]==3)
98
 
                {
99
 
                        $istrue=new CCol(S_DISABLED_BIG,"unknown");
100
 
                        $dissum=$dissum+$leng;
101
 
                        $sum=$dissum;
102
 
                }
103
 
                elseif($row["value"]==2)
104
 
                {
105
 
                        $istrue=new CCol(S_UNKNOWN_BIG,"unknown");
106
 
                        $dissum=$dissum+$leng;
107
 
                        $sum=$dissum;
108
 
                }
109
 
        
110
 
                $proc=(100*$sum)/($falsesum+$truesum+$dissum);
111
 
                $proc=round($proc*100)/100;
112
 
                $proc="$proc%";
113
 
 
114
 
//              table_td("<B>$istrue</B>","");
115
 
                if($leng>60*60*24)
116
 
                {
117
 
                        $leng= round(($leng/(60*60*24))*10)/10;
118
 
                        $leng="$leng days";
119
 
                }
120
 
                elseif ($leng>60*60)
121
 
                {
122
 
                        $leng= round(($leng/(60*60))*10)/10;
123
 
                        $leng="$leng hours"; 
124
 
                }
125
 
                elseif ($leng>60)
126
 
                {
127
 
                        $leng= round(($leng/(60))*10)/10;
128
 
                        $leng="$leng mins";
129
 
                }
130
 
                else
131
 
                {
132
 
                        $leng="$leng secs";
133
 
                }
134
 
 
135
 
                if($sum>60*60*24)
136
 
                {
137
 
                        $sum= round(($sum/(60*60*24))*10)/10;
138
 
                        $sum="$sum days";
139
 
                }
140
 
                elseif ($sum>60*60)
141
 
                {
142
 
                        $sum= round(($sum/(60*60))*10)/10;
143
 
                        $sum="$sum hours"; 
144
 
                }
145
 
                elseif ($sum>60)
146
 
                {
147
 
                        $sum= round(($sum/(60))*10)/10;
148
 
                        $sum="$sum mins";
149
 
                }
150
 
                else
151
 
                {
152
 
                        $sum="$sum secs";
153
 
                }
154
 
  
155
 
//              table_td($leng,"");
156
 
//              table_td($sum,"");
157
 
//              table_td($proc,"");
158
 
//              echo "</TR>";
159
 
                $ack = "-";
160
 
                if($row["value"] == 1 && $row["acknowledged"] == 1)
161
 
                {
162
 
                        $db_acks = get_acknowledges_by_alarmid($row["alarmid"]);
163
 
                        $rows=0;
164
 
                        while($a=DBfetch($db_acks))     $rows++;
165
 
                        $ack=array(
166
 
                                new CSpan(S_YES,"off"),
167
 
                                SPACE."(".$rows.SPACE,
168
 
                                new CLink(S_SHOW,
169
 
                                        "acknow.php?alarmid=".$row["alarmid"],"action"),
170
 
                                ")"
171
 
                                );
172
 
                }
173
 
 
174
 
                $table->ShowRow(array(
175
 
                        date("Y.M.d H:i:s",$row["clock"]),
176
 
                        $istrue,
177
 
                        $ack,
178
 
                        $leng,
179
 
                        $sum,
180
 
                        $proc
181
 
                        ));
182
 
        }
183
 
        $table->ShowEnd();
184
 
?>
185
 
 
186
 
<?php
187
 
        show_page_footer();
188
 
?>