Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: include/common.h
- ===================================================================
- --- include/common.h (revision 33506)
- +++ include/common.h (working copy)
- @@ -475,6 +475,7 @@
- ITEM_STATUS_NOTSUPPORTED = 3,
- /*ITEM_STATUS_DELETED 4*/
- /*ITEM_STATUS_NOTAVAILABLE 5*/
- + ITEM_STATUS_CHECKNOW = 6
- } zbx_item_status_t;
- /* trigger types */
- Index: src/libs/zbxdbcache/dbconfig.c
- ===================================================================
- --- src/libs/zbxdbcache/dbconfig.c (revision 33506)
- +++ src/libs/zbxdbcache/dbconfig.c (working copy)
- @@ -864,6 +864,20 @@
- }
- }
- + if (ITEM_STATUS_CHECKNOW == status)
- + {
- + /* set nextcheck for item with delay "1" */
- + zabbix_log(LOG_LEVEL_DEBUG, "Found CHECK_NOW status for item %d",itemid);
- + item->nextcheck = calculate_item_nextcheck(item->interfaceid, itemid,
- + item->type, 1, row[16], now, NULL);
- +
- + /* update status for item in database */
- + DBexecute("update items set status=%d where itemid=%d", ITEM_STATUS_ACTIVE, itemid);
- +
- + /* set item status in ACTIVE for dbcache */
- + status = ITEM_STATUS_ACTIVE;
- + }
- +
- item->status = status;
- item->delay = delay;
- @@ -2308,10 +2322,10 @@
- " from items i,hosts h"
- " where i.hostid=h.hostid"
- " and h.status in (%d)"
- - " and i.status in (%d,%d)"
- + " and i.status in (%d,%d,%d)"
- ZBX_SQL_NODE,
- HOST_STATUS_MONITORED,
- - ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED,
- + ITEM_STATUS_ACTIVE, ITEM_STATUS_NOTSUPPORTED, ITEM_STATUS_CHECKNOW,
- DBand_node_local("i.itemid"));
- isec = zbx_time() - sec;
- Index: frontends/php/latest.php
- ===================================================================
- --- frontends/php/latest.php (revision 33506)
- +++ frontends/php/latest.php (working copy)
- @@ -50,6 +50,8 @@
- 'hostid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
- 'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL),
- +// actions
- + 'checkbutton'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
- // filter
- 'select'=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL),
- 'show_without_data'=> array(T_ZBX_INT, O_OPT, NULL, IN('0,1'), NULL),
- @@ -76,6 +78,22 @@
- }
- //--------
- +/* Actions */
- +if (isset($_REQUEST['checkbutton'])) {
- + $group_itemid = $_REQUEST['checkbutton'];
- +
- + DBstart();
- + $go_result = checknow_item($group_itemid);
- + DBend($go_result);
- +
- + $new_get = $_GET;
- + unset($new_get['checkbutton']);
- + $new_get_string = http_build_query($new_get);
- +
- + print "<META HTTP-EQUIV='Refresh' CONTENT='0; URL=latest.php?".$new_get_string."'>";
- +}
- +//--------
- +
- /* FILTER */
- if (!isset($_REQUEST['show_without_data'])) {
- $_REQUEST['show_without_data'] = 0;
- @@ -193,6 +211,8 @@
- make_sorting_header(_('Last check'), 'i.lastclock'),
- _('Last value'),
- _x('Change', 'noun in latest data'),
- + _('Current status'),
- + _('Force check'),
- _('History')
- ));
- @@ -260,7 +280,7 @@
- ' WHERE '.dbConditionInt('ia.applicationid',$db_appids).
- ' AND i.itemid=ia.itemid'.
- ($_REQUEST['show_without_data'] ? '' : ' AND i.lastvalue IS NOT NULL').
- - ' AND (i.status='.ITEM_STATUS_ACTIVE.' OR i.status='.ITEM_STATUS_NOTSUPPORTED.')'.
- + ' AND i.status in ('.ITEM_STATUS_ACTIVE.', '.ITEM_STATUS_NOTSUPPORTED.', '.ITEM_STATUS_CHECKNOW.')'.
- ' AND '.dbConditionInt('i.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)).
- order_by('i.name,i.itemid,i.lastclock');
- @@ -316,6 +336,21 @@
- $change = ' - ';
- }
- + /* create "checknow" button for this item */
- + $checknow = '';
- + if ( !in_array($db_item['type'], itemsblacklist2array()) ) {
- + $dbHostStatuses = DBselect('SELECT h.status'.
- + ' FROM hosts h,items i'.
- + ' WHERE h.hostid='.$db_item['hostid']);
- + $dbHostStatus = DBfetch($dbHostStatuses);
- + if (($dbHostStatus['status']==0) && ($db_item['delay'] > ITEM_CHECKNOW_MINDELAY)) {
- + $checknow = new CButton("checkbutton", _('Force check'), 'javascript:'.
- + ' if (confirm("This may cause a false trigger alarm. Are you sure?")){'.
- + ' var uri = new Curl(location.href); uri.setArgument("checkbutton",'.
- + $db_item['itemid'].'); location.href = uri.getUrl();}');
- + }
- + }
- +
- if(($db_item['value_type']==ITEM_VALUE_TYPE_FLOAT) || ($db_item['value_type']==ITEM_VALUE_TYPE_UINT64)){
- $actions = new CLink(_('Graph'),'history.php?action=showgraph&itemid='.$db_item['itemid']);
- }
- @@ -333,6 +368,8 @@
- new CCol($lastclock, $item_status),
- new CCol($lastvalue, $item_status),
- new CCol($change, $item_status),
- + item_status2str($db_item['status']),
- + $checknow,
- $actions
- )));
- }
- @@ -378,7 +415,7 @@
- $col = new CCol(array(bold($db_app['name']),SPACE.'('._n('%1$s Item', '%1$s Items', $db_app['item_cnt']).')'));
- - $col->setColSpan(5);
- + $col->setColSpan(7);
- // host JS menu link
- $hostSpan = null;
- @@ -554,7 +591,7 @@
- $col = new CCol(array(bold('- '.('other').' -'), SPACE.'('._n('%1$s Item', '%1$s Items', $db_host['item_cnt']).')'));
- - $col->setColSpan(5);
- + $col->setColSpan(7);
- // host JS menu link
- $hostSpan = null;
- Index: frontends/php/include/defines.inc.php
- ===================================================================
- --- frontends/php/include/defines.inc.php (revision 33506)
- +++ frontends/php/include/defines.inc.php (working copy)
- @@ -330,7 +330,13 @@
- define('ITEM_TYPE_TELNET', 14);
- define('ITEM_TYPE_CALCULATED', 15);
- define('ITEM_TYPE_JMX', 16);
- +define('ITEM_TYPE_SNMPTRAP', 17);
- +define('ITEM_CHECKNOW_BLACKLIST', ITEM_TYPE_TRAPPER.', '.
- + ITEM_TYPE_ZABBIX_ACTIVE.', '.
- + ITEM_TYPE_SNMPTRAP);
- +define('ITEM_CHECKNOW_MINDELAY', 59);
- +
- define('ITEM_VALUE_TYPE_FLOAT', 0);
- define('ITEM_VALUE_TYPE_STR', 1);
- define('ITEM_VALUE_TYPE_LOG', 2);
- @@ -356,9 +362,8 @@
- define('ITEM_STATUS_ACTIVE', 0);
- define('ITEM_STATUS_DISABLED', 1);
- define('ITEM_STATUS_NOTSUPPORTED', 3);
- +define('ITEM_STATUS_CHECKNOW', 6);
- -define('ITEM_TYPE_SNMPTRAP', 17);
- -
- define('ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV', 0);
- define('ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV', 1);
- define('ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV', 2);
- Index: frontends/php/include/items.inc.php
- ===================================================================
- --- frontends/php/include/items.inc.php (revision 33506)
- +++ frontends/php/include/items.inc.php (working copy)
- @@ -148,7 +148,8 @@
- $types = array(
- ITEM_STATUS_ACTIVE => _('Enabled'),
- ITEM_STATUS_DISABLED => _('Disabled'),
- - ITEM_STATUS_NOTSUPPORTED => _('Not supported')
- + ITEM_STATUS_NOTSUPPORTED => _('Not supported'),
- + ITEM_STATUS_CHECKNOW => _('Forced checking')
- );
- if (is_null($type)) {
- return $types;
- @@ -165,6 +166,8 @@
- switch ($status) {
- case ITEM_STATUS_ACTIVE:
- return 'off';
- + case ITEM_STATUS_CHECKNOW:
- + return 'off';
- case ITEM_STATUS_DISABLED:
- return 'on';
- case ITEM_STATUS_NOTSUPPORTED:
- Index: frontends/php/include/views/configuration.item.list.php
- ===================================================================
- --- frontends/php/include/views/configuration.item.list.php (revision 33506)
- +++ frontends/php/include/views/configuration.item.list.php (working copy)
- @@ -61,7 +61,8 @@
- make_sorting_header(_('Type'), 'type'),
- _('Applications'),
- make_sorting_header(_('Status'), 'status'),
- - _('Error')
- + _('Error'),
- + _('Force check')
- ));
- foreach ($this->data['items'] as $item) {
- @@ -93,6 +94,21 @@
- }
- $statusIcons = array($error);
- + /* create "checknow" button for this item */
- + $checknow = '';
- + if (!in_array($item['type'], itemsblacklist2array()) ) {
- + $dbHostStatuses = DBselect('SELECT h.status'.
- + ' FROM hosts h,items i'.
- + ' WHERE h.hostid='.$item['hostid']);
- + $dbHostStatus = DBfetch($dbHostStatuses);
- + if (($dbHostStatus['status'] == 0) && ($item['delay'] > ITEM_CHECKNOW_MINDELAY)) {
- + $checknow = new CButton("checkbutton", _('Force check'), 'javascript:'.
- + ' var uri = new Curl(location.href); uri.setArgument("go","checknow");'.
- + ' uri.setArgument("group_itemid",'.$item['itemid'].
- + '); location.href = uri.getUrl();');
- + }
- + }
- +
- // discovered item lifetime indicator
- if ($item['flags'] == ZBX_FLAG_DISCOVERY_CREATED && $item['itemDiscovery']['ts_delete']) {
- $deleteError = new CDiv(SPACE, 'status_icon iconwarning');
- @@ -228,7 +244,8 @@
- item_type2str($item['type']),
- new CCol($item['applications_list'], 'wraptext'),
- $status,
- - $statusIcons
- + $statusIcons,
- + $checknow
- ));
- }
- @@ -242,6 +259,11 @@
- $goOption->setAttribute('confirm', _('Disable selected items?'));
- $goComboBox->addItem($goOption);
- +$goOption = new CComboItem('checknow', _('Force check to selected'));
- +$goOption->setAttribute('confirm', _('Checking a large number of items at the same time
- +can degrade the performance of the server!'));
- +$goComboBox->addItem($goOption);
- +
- $goOption = new CComboItem('massupdate', _('Mass update'));
- $goComboBox->addItem($goOption);
- Index: frontends/php/include/forms.inc.php
- ===================================================================
- --- frontends/php/include/forms.inc.php (revision 33506)
- +++ frontends/php/include/forms.inc.php (working copy)
- @@ -431,7 +431,7 @@
- // status select
- $cmbStatus = new CComboBox('filter_status', $filter_status);
- $cmbStatus->addItem(-1, _('all'));
- - foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED, ITEM_STATUS_NOTSUPPORTED) as $status) {
- + foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED, ITEM_STATUS_NOTSUPPORTED, ITEM_STATUS_CHECKNOW) as $status) {
- $cmbStatus->addItem($status, item_status2str($status));
- }
- Index: frontends/php/include/func.inc.php
- ===================================================================
- --- frontends/php/include/func.inc.php (revision 33506)
- +++ frontends/php/include/func.inc.php (working copy)
- @@ -661,6 +661,23 @@
- return $value;
- }
- +/**
- + * Converts ITEM_CHECKNOW_BLACKLIST to array
- + *
- + * @return array of int
- + */
- +function itemsblacklist2array() {
- + $tempblacklistarray = explode(", ", ITEM_CHECKNOW_BLACKLIST);
- + $blacklistarray = array();
- +
- + for ($i = 0; $i < count($tempblacklistarray); $i++) {
- + if (isset($blacklistarray[$i])) {
- + array_unshift($blacklistarray, constant($tempblacklistarray[i]));
- + }
- + }
- + return $blacklistarray;
- +}
- +
- /************* ZBX MISC *************/
- function zbx_avg($values) {
- zbx_value2array($values);
- @@ -2459,3 +2476,25 @@
- function checkRequiredKeys(array $array, array $keys) {
- return array_diff($keys, array_keys($array));
- }
- +
- +/**
- + * Make SQL query, then set status="Forced check" for $itemids
- + *
- + * @return bool
- + */
- +function checknow_item($itemids) {
- + zbx_value2array($itemids);
- +
- + /* first update status for child items */
- + $child_items = array();
- + $db_items = DBselect('SELECT i.itemid FROM items i,hosts h WHERE '.dbConditionInt('i.itemid', $itemids).
- + ' AND i.type NOT IN ('.ITEM_CHECKNOW_BLACKLIST.')'.
- + ' AND i.hostid=h.hostid'.
- + ' AND i.delay>'.ITEM_CHECKNOW_MINDELAY.
- + ' AND h.status=0');
- +
- + while ($item = DBfetch($db_items)) {
- + array_push($child_items, $item['itemid']);
- + }
- + return update_item_status($child_items, ITEM_STATUS_CHECKNOW);
- +}
- Index: frontends/php/items.php
- ===================================================================
- --- frontends/php/items.php (revision 33506)
- +++ frontends/php/items.php (working copy)
- @@ -150,6 +150,7 @@
- 'add_delay_flex' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
- // actions
- 'go' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
- + 'checknow' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
- 'save' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
- 'clone' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
- 'update' => array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
- @@ -180,7 +181,7 @@
- 'filter_delay' => array(T_ZBX_INT, O_OPT, P_UNSET_EMPTY, BETWEEN(0, SEC_PER_DAY), null, _('Update interval')),
- 'filter_history' => array(T_ZBX_INT, O_OPT, P_UNSET_EMPTY, BETWEEN(0, 65535), null, _('Keep history (in days)')),
- 'filter_trends' => array(T_ZBX_INT, O_OPT, P_UNSET_EMPTY, BETWEEN(0, 65535), null, _('Keep trends (in days)')),
- - 'filter_status' => array(T_ZBX_INT, O_OPT, null, IN('-1,0,1,3'), null),
- + 'filter_status' => array(T_ZBX_INT, O_OPT, null, IN('-1,0,1,3,6'), null),
- 'filter_templated_items' => array(T_ZBX_INT, O_OPT, null, IN('-1,0,1'), null),
- 'filter_with_triggers' => array(T_ZBX_INT, O_OPT, null, IN('-1,0,1'), null),
- 'filter_ipmi_sensor' => array(T_ZBX_STR, O_OPT, null, null, null),
- @@ -596,6 +597,15 @@
- $go_result = DBend($go_result);
- show_messages($go_result, _('Items disabled'), null);
- }
- +elseif ($_REQUEST['go'] == 'checknow' && isset($_REQUEST['group_itemid'])) {
- + global $USER_DETAILS;
- + $group_itemid = $_REQUEST['group_itemid'];
- +
- + DBstart();
- + $go_result = checknow_item($group_itemid);
- + $go_result = DBend($go_result);
- + show_messages($go_result, _('Forced check for item activated'), null);
- +}
- elseif ($_REQUEST['go'] == 'copy_to' && isset($_REQUEST['copy']) && isset($_REQUEST['group_itemid'])) {
- if (isset($_REQUEST['copy_targetid']) && $_REQUEST['copy_targetid'] > 0 && isset($_REQUEST['copy_type'])) {
- // host
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement