Ad Widget

Collapse

string field value.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • red
    Junior Member
    • Jan 2015
    • 2

    #1

    string field value.

    I have a key that receives a string value build as following aaa_bbb.
    how I extract the aaa part and the bbb part.
  • ingus.vilnis
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2014
    • 908

    #2
    Hello and welcome to Zabbix forums!

    Can you post a screenshot or at least the exact item key you are using to get the data? What is the source of the data? If a text or log file, can you also post some lines from it?

    If I understand you would like to have two separate items where one
    returns first value and other the second?

    Best Regards,
    Ingus

    Comment

    • red
      Junior Member
      • Jan 2015
      • 2

      #3
      Thanks so much for your help!

      We have an existing Item named "web_productname_taskresult" of type Zabbix Trapper whose key is "localhost_6060.WEBPRODUCTNAME.ScheduledTaskNa me". This works properly, and the value returned for that key is in the following format:
      [user_id_as_text]_[duration_in_seconds]

      We now want to add 2 new Items named "web_productname_taskresult_userid" and "web_productname_taskresult_duration" which would contain the appropriate part of the existing Item.

      We were thinking they should be of Type Calculated and the formula should be something like regexp(localhost_6060.WEBPRODUCTNAME.ScheduledTask Name, "[a-zA-Z0-9]+"), but obviously that won't work because regexp only returns a 0 or 1. We also read that all functions used for Calculated items return number results.

      So it seems we can't use an Item of type Calculated to achieve our goal, but there must be some way we can split the value in the original Item into its 2 usable parts.

      Any help at all that you can provide to steer us in the right direction would be very much appreciated. Thanks!

      Comment

      • ingus.vilnis
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Mar 2014
        • 908

        #4
        Hi,

        Here I have some ideas for you.

        Option 1.
        Make two scheduled tasks instead of 1. Now your one task returns [user_id_as_text]_[duration_in_seconds] but then you can make two tasks where each returns separate value. Send them to Zabbix trapper as 2 items and done.

        Option 2.
        Make the scheduled task to write the values to a text file.
        Then add 2 log items to Zabbix.
        For user ID
        Code:
        log["path_to_the_file","([A-Za-z0-9]+)_([0-9]+)",,,,\1]
        For duration in seconds
        Code:
        log["path_to_the_file","([A-Za-z0-9]+)_([0-9]+)",,,,\2]
        I understand that this is not what you exactly may like but so far I can't think of another ways.

        Input from anybody else here would be appreciated.

        Best Regards,
        Ingus

        Comment

        Working...