Ad Widget

Collapse

Latest data pag shows floating point numbers as decimals, notif arrive as attachments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ILIV
    Junior Member
    • Oct 2012
    • 28

    #1

    Latest data pag shows floating point numbers as decimals, notif arrive as attachments

    Hey everyone,

    I run Zabbix 2.0.2, yes I know it's kind of very old. No, I cannot upgrade it to the most recent one. I have to make do with what I have. Please, read on.

    I have this weird issue, and I think the problem is obvious but I've been banging my head against this probably for too long to see it myself.

    In essence, I have two custom checks defined via UserParameter. For one of the checks, when an associated trigger has been activated, e-mail notification's body arrives as an attachment. For the other, e-mail notification's body is what you would normally expect, i.e. just a text that makes a notification what we're all so used to seeing.

    One of these checks gets CPU cores' temperature data, the other -- which is something I've configured quickly to create a similar check for troubleshooting purposes -- gets memory information.

    So, here are the UserParameter definitions

    Code:
    UserParameter=cpu.temperature[*],/usr/bin/sensors |grep "$1" |cut -d " " -f9 | sed -e "s:^\+::g"
    and

    Code:
    UserParameter=test.free,/usr/bin/free |grep Mem | awk -F " " {'print $2'}
    And here's what happens when I run those commands manually in the terminal:

    % /usr/bin/sensors |grep "Core 0" |cut -d " " -f9 | sed -e "s:^\+::g"
    48.0
    % /usr/bin/free |grep Mem | awk -F " " {'print $2'}
    3105864
    So, for cpu.temperature[*] item settings page looks like this:



    associated trigger:



    the trigger has no dependencies configured.

    For test.free item I have almost identical configuration only Type of information is set to Numeric (unsigned), Data type Decimal. Likewise, associated trigger is a simple one that defines and expression of > N.

    So, to my great surprise this produces an unexpected result. First, on the Latest Data page numbers show up as decimal numbers (why?!)



    Then my e-mail notifications for this item/trigger pair look like this



    However, text of notifications for test.free looks like normal e-mail body, not an attachment.

    So, in UserParameter for cpu.temperature I tried to cut off the dot and anything that goes after it, to essentially create a decimal number, then adjusted cpu.temperature item's settings and set Type of information to Numeric (unsigned), Data type Decimal. Restarted Zabbix Agent, Latest data page would show data changing for both CPU cores, I could see graphs and all, but e-mail notifications would still arrive as attachments.

    I cannot see how test.free is any different from cpu.temperature, and more importantly why Latest data page shows values as decimal numbers for cpu.temperature when they come in as floating point numbers (are they?), and items are configured to be floating point numbers too!

    So, any ideas? Maybe you can see right off the bat what is wrong here?
  • ILIV
    Junior Member
    • Oct 2012
    • 28

    #2
    It is worth noting that my MTA is a combination of BASH+mailx+msmtp. Thus Zabbix uses an Alert Script that looks like this

    Code:
    #!/bin/bash
    
    to="$1"
    subject="$2"
    body="$3"
    
    echo "$body" | mail -s "$subject" "$to"

    Comment

    • ILIV
      Junior Member
      • Oct 2012
      • 28

      #3
      With volter's help on IRC this is getting somewhere finally. So, we established that it is a representation layer that cuts off trailing ".0" but the DB stores values intact. This is not very good, but technically speaking it's just how the data is shown, not stored/processed.

      For the curious

      Code:
      zabbixdb=# select itemid,lastvalue from items where name like '%CPU temper%';
       itemid | lastvalue 
      --------+-----------
        23378 | 
        23377 | 
        23379 | 23.100000
        23380 | 51.000000
      (4 rows)
      I have 2 CPU cores, I know that itemid 23379 is what I'm looking for (because I control the 23.100000 value), thus

      Code:
      select * from history where itemid=23379;
       itemid |   clock    |  value  |    ns     
      --------+------------+---------+-----------
        23379 | 1384158399 | 49.0000 | 651356265
        23379 | 1384158549 | 49.0000 | 740683899
        23379 | 1384158759 | 48.0000 | 917312576
        23379 | 1384158849 | 49.0000 | 986884868
      ...
      and so on.

      I also tried all sorts of UserParameter commands to fix e-mail notification appearing as an attachment, with no success whatsoever. Took a break and looked at the problem from a different angle. Well, here's the reason why these notifications appear as an attachment:



      Yeah, note that the unit is "°C" on item settings page and in e-mail source view, it trips up msmtp big time.

      Changed the unit to just "C". Problem solved. It had me chasing a wild goose for several days now damn it lol

      Comment

      Working...