[ZBXNEXT-2216] Items without history do not have last value and triggers do not work. Created: 2014 Mar 19  Updated: 2017 May 31  Resolved: 2016 Mar 05

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Server (S)
Affects Version/s: 2.2.2
Fix Version/s: None

Type: Change Request Priority: Minor
Reporter: Sergey Kuksa Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: history, lastvalue, triggers
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File ZBXNEXT-2216_testlog.rtf     Text File ZBXNEXT-2216_testlog2.txt    
Issue Links:
Duplicate
duplicates ZBX-10374 triggers do not work for items with "... Closed

 Description   

Hello, team.

I collect items where I do not need history, only triggers if it changed or too small. For example it can be equipment serial number, system uptime, admin state of interface and so on.
Using Zabbix 2.0.x I created items with 0 days history and 0 days trends and it works very good.

This scheme does not work with Zabbix 2.2.x.
Of course I can keep data for such items for a day and housekeeper will clear useless data, but due to large number of hosts and items I do not use housekeeper.

Thanks, Sergey.



 Comments   
Comment by richlv [ 2014 Mar 19 ]

same cause as ZBX-7548

zalex_ua Currently it mainly asks to document limitations when history is 0.

Comment by richlv [ 2014 Mar 19 ]

although triggers should work... can you please show expression that fails and how exactly does it fail ?

Comment by Sergey Kuksa [ 2014 Mar 20 ]

Hello richlv.

Thanks for your answer. Please find in the attachment full test log for test host and items.
I'm sure this problem is differ from ZBX-7548, such as server was not restarted.

WBR, Sergey.

Comment by richlv [ 2014 Mar 20 ]

huh. may i point at https://www.zabbix.org/wiki/Docs/bug_reporting_guidelines ?

Comment by Sergey Kuksa [ 2014 Mar 20 ]

Sorry, ok.

But, what about feature request.
I understood in 2.2.x lastvalue and prevvalue was deleted as a field and only history tables have its.
Can I ask you to return these fields (I think separate one to one table to items table will be fine) at least as option in new 2.4.x Zabbix.

I collect last values from a lot of items (up to millions) from zabbix to our other systems and I understood it would not work good in 2.2.x.
It's too sad if I will need to find other monitoring system.

Thanks, Sergey

Comment by richlv [ 2014 Mar 21 ]

hmm. all you sure that triggers do not work for you ?

Comment by Sergey Kuksa [ 2014 Mar 22 ]

Yes.
Please some strings from my log.

Triger TestIntT {TestHost:TestInt.last()}<10

1. History is 60 days (default).

   ["name"]=>          string(7) "TestInt"
   ["key_"]=>          string(7) "TestInt"
   ["history"]=        string(2) "90"
   ["lastvalue"]=>     string(3) "100"
   ["description"]=>   string(8) "TestIntT"
   ["value"]=>         string(1) "0"

zabbix_sender -z 127.0.0.1 -s TestHost -k TestInt -o 1
   ["lastvalue"]=>     string(1) "1"
   ["description"]=>   string(8) "TestIntT"
   ["value"]=>         string(1) "1"

Trigger works.

2. History - 0 days.

   ["name"]=>          string(7) "TestInt"
   ["key_"]=>          string(7) "TestInt"
   ["history"]=>       string(1) "0"
   ["lastvalue"]=>     string(4) "1000"
   ["description"]=>   string(8) "TestIntT"
   ["value"]=>         string(1) "0"

zabbix_sender -z 127.0.0.1 -s TestHost -k TestInt -o 1
   ["lastvalue"]=>     string(4) "1000"
   ["description"]=>   string(8) "TestIntT"
   ["value"]=>         string(1) "0"

Trigger does not work, lastvalue does not change.

I will check this with clear test instance zabbix last version.
But on Monday only.

Comment by Sergey Kuksa [ 2014 Mar 24 ]

Hello.

I did test with Zabbix 2.2.2 clear installation. Please find log and scripts in ZBXNEXT-2216_testlog2.txt attachment.

The test description:
1. I created TestHost host.
2. I created zabbix trapper TestItem item with 60 days history.
3. I created simple trigger TestTrigger

{TestHost:TestItem.last()}

=0
4. I connected item value to inventory "tag" field.
5. I wrote simple test scripts which get data via API.
6. I checked initial configuration vith test.sh script, result in log.
7. I sent value 1 via zabbix_sender and check result with test1.sh, value was accepted and placed to lastvalue and inventory tag.
8. I sent value 0 and check result. Value was accepted and placed to lastvalue and inventory tag, prevvalue was changed, trigger value was changed to 1 according the rule.
9. I sent value 10. All worked correctly, trigger value was changed to 0.
10. I changed history to 0 and waited for a 10 minutes to be sure configuration synced.
11. I check parameters - all correct.
12. I sent value 1. Lastvalue and prevvalue was not changed, but inventory tag was changed, so value was accepted correctly.
13. I sent value 0. Trigger value was not changed also as lastvalue and prevvalue.

I hope this test can help you.

Thanks. Sergey.

Comment by Sergey Kuksa [ 2014 Mar 27 ]

Hello once again.

I guess I fixed my problem with the patch:below.
Please correct me if I mistaken.
Lastvalue does not shown but trigger works now:

[skuksa@opmon01 zabbix]$ zabbix_sender -z 127.0.0.1 -p 10081 -s TestHost -k TestItem -o 7
info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000093"
sent: 1; skipped: 0; total: 1

[skuksa@opmon01 zabbix]$ sleep 3; ./test1.sh
["itemid"]=> string(5) "23661"
["key_"]=> string(8) "TestItem"
["history"]=> string(1) "0"
["description"]=> string(0) ""
["lastvalue"]=> string(1) "0"
["prevvalue"]=> string(1) "0"
["triggerid"]=> string(5) "13558"
["description"]=> string(10) "TestTriger"
["value"]=> string(1) "0"
["tag"]=> string(1) "7"
[skuksa@opmon01 zabbix]$ zabbix_sender -z 127.0.0.1 -p 10081 -s TestHost -k TestItem -o 0
info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000031"
sent: 1; skipped: 0; total: 1

[skuksa@opmon01 zabbix]$ sleep 3; ./test1.sh
["itemid"]=> string(5) "23661"
["key_"]=> string(8) "TestItem"
["history"]=> string(1) "0"
["description"]=> string(0) ""
["lastvalue"]=> string(1) "0"
["prevvalue"]=> string(1) "0"
["triggerid"]=> string(5) "13558"
["description"]=> string(10) "TestTriger"
["value"]=> string(1) "1"
["tag"]=> string(1) "0"

WBR, Sergey.

--- src/libs/zbxdbcache/dbcache.c.orig  2014-03-27 14:39:52.947717510 +0400
+++ src/libs/zbxdbcache/dbcache.c       2014-03-27 17:27:30.660266338 +0400
@@ -1786,8 +1786,8 @@
        if (sql_offset > 16)    /* In ORACLE always present begin..end; */
                rc = DBexecute("%s", sql);

-       if (ZBX_DB_OK <= rc && 0 != (daemon_type & ZBX_DAEMON_TYPE_SERVER) &&
-                       0 != h_num + huint_num + hstr_num + htext_num + hlog_num)
+       if ((ZBX_DB_OK <= rc && 0 != (daemon_type & ZBX_DAEMON_TYPE_SERVER)) ||
+               sql_offset <17 )
        {
                /* the history values were written into database, now add to value cache */
                zbx_log_value_t log;
@@ -1799,7 +1799,7 @@

                for (i = 0; i < history_num; i++)
                {
-                       if (0 == history[i].keep_history || 0 != history[i].value_null)
+                       if (0 != history[i].value_null)
                                continue;

                        switch (history[i].value_type)
Comment by Oleksii Zagorskyi [ 2016 Mar 05 ]

Let's close this one as duplicate of ZBX-10374, which supposed to be really fixed.

Generated at Tue May 13 10:03:07 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.