Ad Widget

Collapse

Patch: zabbix-1.1.6 new function txtcount

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • safl
    Senior Member
    • May 2005
    • 103

    #1

    Patch: zabbix-1.1.6 new function txtcount

    Greetings,

    The patch adds a item function:

    txtcount(string search,int time_limit)
    valcount(string search,int time_limit)

    Functionality
    Basically what it does is count the number of occurrences of 'string' in items of type: "str, log and text".
    Supply a time_limit (of seconds) and it will not search the entire item history but only the 'time_limit' most recent values.

    Purpose:
    I am using this function to count the the number of occurrences of "Job Failed" in a backup log within the last 24 hours.

    The search string uses: "LIKE '%search%'" meaning it will match:

    "On machine xxx Job Failed, no media inserted."

    These messages come from an email which is parsed and imported into zabbix via zabbix_sender.
    The log is readable by human beings and with this function alertable with zabbix.

    I'm sure one can find other uses for txtcount

    EDIT:

    Indeed other uses could be found for it, a more generalized version named 'valcount' which can also count occurrences of numeric values.

    Which means if you search numeric items (float or int64) the match will be exact (value='search').
    You could use this to count count the number of times something has changed state, eg. the number of times your ftp server has gone down within the last hour or whatever you feel like.

    Patch is found below:
    Attached Files
    Last edited by safl; 09-03-2007, 16:25.
  • James Wells
    Senior Member
    • Jun 2005
    • 664

    #2
    Greetings,

    Nicely done on the patches, though I do have a quick question. Looking at the code it looks like valcount is meant to completely replace txtcount. Is that correct?
    Unofficial Zabbix Developer

    Comment

    • safl
      Senior Member
      • May 2005
      • 103

      #3
      Jep that's correct.

      Comment

      • James Wells
        Senior Member
        • Jun 2005
        • 664

        #4
        Kk. I will replace the evalfunc portion in my bulk patch. Thank you sir.
        Unofficial Zabbix Developer

        Comment

        • ZhidkovAN
          Junior Member
          • Dec 2006
          • 16

          #5
          problem with oracle 10g

          Hi!
          I have problem with oracle DB:

          030056:20070312:164438 Query::select * from (SELECT COUNT(value) FROM history_text WHERE itemid = '20977' AND value LIKE '%Healthy%' AND clock > 1173681568 ) where rownum<=1

          030056:20070312:164438 Query failed:ORA-00932: inconsistent datatypes: expected - got CLOB



          Originally posted by safl
          Greetings,

          The patch adds a item function:

          txtcount(string search,int time_limit)
          valcount(string search,int time_limit)

          Functionality
          Basically what it does is count the number of occurrences of 'string' in items of type: "str, log and text".
          Supply a time_limit (of seconds) and it will not search the entire item history but only the 'time_limit' most recent values.

          Purpose:
          I am using this function to count the the number of occurrences of "Job Failed" in a backup log within the last 24 hours.

          The search string uses: "LIKE '%search%'" meaning it will match:

          "On machine xxx Job Failed, no media inserted."

          These messages come from an email which is parsed and imported into zabbix via zabbix_sender.
          The log is readable by human beings and with this function alertable with zabbix.

          I'm sure one can find other uses for txtcount

          EDIT:

          Indeed other uses could be found for it, a more generalized version named 'valcount' which can also count occurrences of numeric values.

          Which means if you search numeric items (float or int64) the match will be exact (value='search').
          You could use this to count count the number of times something has changed state, eg. the number of times your ftp server has gone down within the last hour or whatever you feel like.

          Patch is found below:

          Comment

          • safl
            Senior Member
            • May 2005
            • 103

            #6
            ZhidkovAN> Unfortunately i haven't got an Oracle DB to test the query on.

            Is the old "count" function working for you? My function doesn't do much more than that, except for the like match. Which is quite standard SQL.

            Can you execute the query below in whatever sql client you use:

            SELECT COUNT(value) FROM history_text WHERE itemid = '20977' AND value LIKE '%Healthy%' AND clock > 1173681568

            Comment

            • Alexei
              Founder, CEO
              Zabbix Certified Trainer
              Zabbix Certified SpecialistZabbix Certified Professional
              • Sep 2004
              • 5654

              #7
              New function, count(period<,value>), has been implemented. It is already in the latest code. It works with items of any type.
              Alexei Vladishev
              Creator of Zabbix, Product manager
              New York | Tokyo | Riga
              My Twitter

              Comment

              Working...