~ubuntu-dev/ubuntu/lucid/zabbix/lucid-201002101903

« back to all changes in this revision

Viewing changes to frontends/php/queue.php

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2009-04-05 19:10:27 UTC
  • mfrom: (1.1.9 upstream) (8.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090405191027-lxd44l6jqdcfp2bi
Tags: 1:1.6.4-1
* New upstream release.
* Fix zabbix-frontend-php.template, add missing questions for
  zabbix-server and port (Closes: #522076)
* Loosen up depends for libgnutls (Closes: #522074)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
        $page["title"] = "S_QUEUE_BIG";
26
26
        $page["file"] = "queue.php";
27
 
        $page['hist_arg'] = array('show');
 
27
        $page['hist_arg'] = array('config');
28
28
        
29
29
        define('ZBX_PAGE_DO_REFRESH', 1);
30
30
 
34
34
<?php
35
35
//              VAR                     TYPE    OPTIONAL FLAGS  VALIDATION      EXCEPTION
36
36
        $fields=array(
37
 
                "show"=>                array(T_ZBX_INT, O_OPT, P_SYS,  IN("0,1,2"),    NULL)
 
37
                "config"=>              array(T_ZBX_INT, O_OPT, P_SYS,  IN("0,1,2"),    NULL)
38
38
        );
39
39
 
40
40
        check_fields($fields);
43
43
?>
44
44
 
45
45
<?php
46
 
        $_REQUEST["show"] = get_request("show", 0);
 
46
        $_REQUEST['config'] = get_request('config', get_profile('web.queue.config', 0));
 
47
        update_profile('web.queue.config',$_REQUEST['config'], PROFILE_TYPE_INT);
47
48
 
48
49
        $form = new CForm();
49
50
        $form->SetMethod('get');
50
51
        
51
 
        $cmbMode = new CComboBox("show", $_REQUEST["show"], "submit();");
 
52
        $cmbMode = new CComboBox("config", $_REQUEST["config"], "submit();");
52
53
        $cmbMode->AddItem(0, S_OVERVIEW);
53
54
        $cmbMode->AddItem(1, S_OVERVIEW_BY_PROXY);
54
55
        $cmbMode->AddItem(2, S_DETAILS);
73
74
                        //ITEM_TYPE_HTTPTEST,
74
75
                        ITEM_TYPE_EXTERNAL);
75
76
 
76
 
        $result = DBselect('SELECT i.itemid,i.nextcheck,i.description,i.key_,i.type,h.host,h.hostid,h.proxy_hostid '.
 
77
        $result = DBselect('SELECT i.itemid,i.lastclock,i.description,i.key_,i.type,h.host,h.hostid,h.proxy_hostid,i.delay,i.delay_flex '.
77
78
                ' FROM items i,hosts h '.
78
79
                ' WHERE i.status='.ITEM_STATUS_ACTIVE.
79
80
                        ' AND i.type in ('.implode(',',$item_types).') '.
80
81
                        ' AND ((h.status='.HOST_STATUS_MONITORED.' AND h.available != '.HOST_AVAILABLE_FALSE.') '.
81
82
                                ' OR (h.status='.HOST_STATUS_MONITORED.' AND h.available='.HOST_AVAILABLE_FALSE.' AND h.disable_until<='.$now.')) '.
82
83
                        ' AND i.hostid=h.hostid '.
83
 
                        ' AND i.nextcheck + 5 <'.$now.
 
84
/*                      ' AND i.nextcheck + 5 <'.$now.*/
84
85
                        ' AND i.key_ NOT IN ('.zbx_dbstr('status').','.zbx_dbstr('icmpping').','.zbx_dbstr('icmppingsec').','.zbx_dbstr('zabbix[log]').') '.
85
86
                        ' AND i.value_type not in ('.ITEM_VALUE_TYPE_LOG.') '.
86
87
                        ' AND '.DBcondition('h.hostid',$available_hosts).
87
88
                        ' AND '.DBin_node('h.hostid', get_current_nodeid()).
88
 
                ' ORDER BY i.nextcheck,h.host,i.description,i.key_');
 
89
                ' ORDER BY i.lastclock,h.host,i.description,i.key_');
89
90
 
90
91
        $table = new CTableInfo(S_THE_QUEUE_IS_EMPTY);
91
92
 
92
 
        if($_REQUEST["show"]==0){
 
93
        if($_REQUEST["config"]==0){
93
94
 
94
95
                foreach($item_types as $type){
95
96
                        $sec_10[$type]=0;
101
102
                }
102
103
 
103
104
                while($row=DBfetch($result)){
104
 
                        if($now-$row["nextcheck"]<=10)                  $sec_10[$row["type"]]++;
105
 
                        else if($now-$row["nextcheck"]<=30)             $sec_30[$row["type"]]++;
106
 
                        else if($now-$row["nextcheck"]<=60)             $sec_60[$row["type"]]++;
107
 
                        else if($now-$row["nextcheck"]<=300)            $sec_300[$row["type"]]++;
108
 
                        else if($now-$row["nextcheck"]<=600)            $sec_600[$row["type"]]++;
109
 
                        else    $sec_rest[$row["type"]]++;
 
105
                        $nextcheck = is_null($row['lastclock']) ? 0 : calculate_item_nextcheck($row['itemid'], $row['type'],
 
106
                                        $row['delay'], $row['delay_flex'], $row['lastclock']);
 
107
                        $diff = $now - $nextcheck;
 
108
                        if ($diff <= 5)
 
109
                                continue;
 
110
 
 
111
                        if ($diff <= 10)        $sec_10[$row['type']]++;
 
112
                        else if ($diff <= 30)   $sec_30[$row['type']]++;
 
113
                        else if ($diff <= 60)   $sec_60[$row['type']]++;
 
114
                        else if ($diff <= 300)  $sec_300[$row['type']]++;
 
115
                        else if ($diff <= 600)  $sec_600[$row['type']]++;
 
116
                        else    $sec_rest[$row['type']]++;
110
117
 
111
118
                }
112
119
                
125
132
                        $table->addRow($elements);
126
133
                }
127
134
        }
128
 
        else if ($_REQUEST["show"] == 1)
 
135
        else if ($_REQUEST["config"] == 1)
129
136
        {
130
137
                $db_proxies = DBselect('select hostid from hosts where status='.HOST_STATUS_PROXY);
131
138
 
147
154
 
148
155
                while ($row = DBfetch($result))
149
156
                {
150
 
                        $diff = $now - $row['nextcheck'];
 
157
                        $nextcheck = is_null($row['lastclock']) ? 0 : calculate_item_nextcheck($row['itemid'], $row['type'],
 
158
                                        $row['delay'], $row['delay_flex'], $row['lastclock']);
 
159
                        $diff = $now - $nextcheck;
 
160
                        if ($diff <= 5)
 
161
                                continue;
151
162
 
152
163
                        if ($diff <= 10)        $sec_10[$row['proxy_hostid']]++;
153
164
                        else if ($diff <= 30)   $sec_30[$row['proxy_hostid']]++;
185
196
                );
186
197
                $table->addRow($elements);
187
198
        }
188
 
        else if ($_REQUEST["show"] == 2)
 
199
        else if ($_REQUEST["config"] == 2)
189
200
        {
 
201
                $arr = array();
 
202
 
190
203
                $table->SetHeader(array(
191
204
                                S_NEXT_CHECK,
192
205
                                is_show_subnodes() ? S_NODE : null,
194
207
                                S_DESCRIPTION
195
208
                                ));
196
209
                while($row=DBfetch($result)){
 
210
                        $nextcheck = is_null($row['lastclock']) ? 0 : calculate_item_nextcheck($row['itemid'], $row['type'],
 
211
                                        $row['delay'], $row['delay_flex'], $row['lastclock']);
 
212
                        $diff = $now - $nextcheck;
 
213
                        if ($diff <= 5)
 
214
                                continue;
 
215
 
 
216
                        array_push($arr, array($nextcheck, $row['hostid'], $row['host'], item_description($row)));
 
217
                }
 
218
 
 
219
                sort($arr);
 
220
                foreach($arr as $r){
197
221
                        $table->AddRow(array(
198
222
                                date("m.d.Y H:i:s",
199
 
                                        $row["nextcheck"]),
200
 
                                get_node_name_by_elid($row['hostid']),
201
 
                                $row['host'],
202
 
                                item_description($row)
 
223
                                        $r[0]),
 
224
                                get_node_name_by_elid($r[1]),
 
225
                                $r[2],
 
226
                                $r[3]
203
227
                                ));
204
228
                }
205
229
        }
206
230
 
207
231
        $table->Show();
208
232
 
209
 
        if($_REQUEST["show"]!=0){
 
233
        if($_REQUEST["config"]!=0){
210
234
                show_table_header(S_TOTAL.": ".$table->GetNumRows());
211
235
        }
212
236
?>