Ad Widget

Collapse

Need help with date() function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luise_linnet
    Junior Member
    • May 2021
    • 4

    #1

    Need help with date() function

    Hello,
    new zabbix user here. few hours of testing with no luck. Maybe somebody could help me here.
    I have item value 20210527. I need to create trigger which give me alert when this value is not equal to current date. I tried to use function date() whick "Returns current date in YYYYMMDD format." Seems simple task, but I do something wrong.
    Tried expression: {test_vm:http_request.last()}<>"date()"
    Where is my mistake? Maybe I can achieve needed result differently?
    Thanks for help
  • luise_linnet
    Junior Member
    • May 2021
    • 4

    #2
    Originally posted by splitek
    First: https://www.zabbix.com/documentation...onfig/triggers

    Second: value of item is type string/integer? And what type return date function? Should be same type.
    Third: You put function in quotes, why? I don't think it will change int to string.
    Fourth: String comparisons work from zabbix v5. What your version?

    Other way: add dependant item for this item, in dependent add preprocessing "javascript", write your logic inside it and return some easy to understand value and add trigger based on this dependent item (or even you can do it without dependent item - just preprocessing).
    1. Yes, I read it. My items update interval is 30s
    2. Item type is numeric unsigned. And I know that typically functions return numeric values too. date() returns current date in YYYYMMDD format. Looks good for me.
    3. Expression constuctor put quotes. I can't save without it: Incorrect trigger expression. Check expression part starting from ">date()".
    4. My version is 5.0.8

    Thanks for other way solution. Seems to complicated for me, but I will try it if date() don't help for me.

    Comment

    • luise_linnet
      Junior Member
      • May 2021
      • 4

      #3
      Originally posted by cyber
      Docs (pre 5.4) define trigger expression as:
      {<server>:<key>.<function>(<parameter>)}<operator> <constant>

      you are trying to implement
      {<server>:<key>.<function1>(<parameter>)}<operator> <function2>(<parameter>)

      This kind of expression is not possible.

      you should try
      {<server>:<key>.<function1>(<parameter>)}<operator> {<server>:<key>.<function2>(<parameter>)}

      {test_vm:http_request.last()}<>{test_vm:http_reque st.date()}
      Seems your suggestion working. You save my day Thank you very much. I had feeling that my problem is really easy solvable, but not new user like me.
      Thanks guys for help.

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        Docs (pre 5.4) define trigger expression as:
        {<server>:<key>.<function>(<parameter>)}<operator > <constant>

        you are trying to implement
        {<server>:<key>.<function1>(<parameter>)}<operato r > <function2>(<parameter>)

        This kind of expression is not possible.

        you should try
        {<server>:<key>.<function1>(<parameter>)}<operato r > {<server>:<key>.<function2>(<parameter>)}

        {test_vm:http_request.last()}<>{test_vm:http_reque st.date()}
        Last edited by cyber; 24-12-2021, 19:45.

        Comment

        Working...