Ad Widget

Collapse

Two values in one item

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fizz
    Junior Member
    • Aug 2007
    • 4

    #1

    Two values in one item

    Hi all ,
    I'm new to Zabbix and I seem to like it.
    I'd like to have the ability to feed Zabbix with two or more values in one item, I really need it to run in one script due to the fact that its querying the database and I wouldn't like to overload the database with multiple queries

    I couldn't find any documentation describing how may I do that and any help would be very appreciated.

    Thanks a lot,
    --fizz
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    It cannot be done currently. Communication protocol will be extended to support this in 1.6.
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • fizz
      Junior Member
      • Aug 2007
      • 4

      #3
      Thanks for the reply Alexei.
      I wonder then, what would be the best way to feed Zabbix with multiple values from one query?
      Thanks,
      --fizz

      Comment

      • ninguno
        Junior Member
        • Nov 2011
        • 29

        #4
        Is this supported now? I couldn't find the way to do it and have the same problem, a query that return some values. And It would be much better to get all the values in one run and not do multiple queries to the database.

        Thanks in advance!

        Comment

        • ninguno
          Junior Member
          • Nov 2011
          • 29

          #5
          Sorry to reask, anyone has any clues on this?

          Comment

          • Axilla
            Senior Member
            • Aug 2010
            • 130

            #6
            Originally posted by ninguno
            Sorry to reask, anyone has any clues on this?
            you can do it at the MySQL level

            and create your own custom pages and load them into a screen. that'd be my suggestion, and that's how i'm doing it.

            // CONFIGURATION

            $user = "user";
            $pass = "pass";
            $dbserver = "localhost";

            // database lookups / connections

            $con = mysql_connect($dbserver,$user,$pass);
            if (!$con)
            {
            die('Could not connect: ' . mysql_error());
            }

            mysql_select_db("zabbix", $con);

            // Formulate Query and store in variable

            $query = sprintf("SELECT device_chassis, device_type, device_url_1, device_url_2, poc_1_name, poc_1_email, poc_1_phone_1, site_street_1 FROM hosts_profiles_ext WHERE device_alias = '$elementid' ");

            // Perform Query
            $result = mysql_query($query);

            // Check For Results
            if (!$result) {
            $message = 'Invalid query: ' . mysql_error() . "\n";
            $message .= 'Whole query: ' . $query;
            die($message);
            }



            I think make a PHP page that outputs this query into a table or something like so.

            // Display results table
            echo "<center><table class='imagetable'>
            <tr>
            <th>Site Code</th><th>Site Tech</th><th>Site Number</th><th>Tech e-Mail</th></tr>";
            while($row = mysql_fetch_assoc($result))
            {
            echo "<tr>";
            echo "<td><center>" . $row['site_street_1'] . "</center></td>" . "<td><center>" . $row['poc_1_name'] . "</center></td>" . "<td><center>" . $row['poc_1_phone_1'] . "</center></td>" . "<td><center>" . $row['poc_1_email'] . "</center></td>";
            echo "</tr>";
            echo "<tr><th>Brand</th><th>Model</th><th>VM IP</th><th>PBX IP</th></tr>";
            echo "<tr>";
            echo "<br /><td><center>" . $row['device_chassis'] . "</center></td>" . "<td><center>" . $row['device_type'] . "</center></td>" . "<td><center>" . $row['device_url_2'] . "</center></td>" . "<td><center>" . $row['device_url_1'] . "</center></td>";
            echo "</tr>";
            }
            echo "</table></center>";

            mysql_free_result($result);
            ?>

            you could in theory do inserts in the same method with a script that sends the captured data directly to the DB.
            Last edited by Axilla; 21-11-2011, 22:01.

            Comment

            • ninguno
              Junior Member
              • Nov 2011
              • 29

              #7
              Thanks Axillia for your response. But I didn't understand very well your solution, maybe cause i'm a little tired .

              My idea is to be able to create a database item in a host that return and stores mutiple values. If I don't get it wrong, your solution tries to do a query outside zabbix and your proposal is to insert manually the data in the database?

              Comment

              • Axilla
                Senior Member
                • Aug 2010
                • 130

                #8
                Originally posted by ninguno
                Thanks Axillia for your response. But I didn't understand very well your solution, maybe cause i'm a little tired .

                My idea is to be able to create a database item in a host that return and stores mutiple values. If I don't get it wrong, your solution tries to do a query outside zabbix and your proposal is to insert manually the data in the database?
                Yes my solution is to do the query outside of zabbix. I do my query directly to MySQL and do a join. I then create a custom screen to display this data. In a custom screen you can display a webpage.. I create a custom PHP page which displays this data for me. Basically it can be done, it just needs to be done completely manually and outside of zabbix. It can then interface with zabbix.

                You can request multiple query's from MySQL in 1 Query. You can also do inserts directly to the database. So you could in theory(al though i've never tried) right a custom scrips that harvest whatever multiple values you want then does a direct insert into the database. I highly suggest doing this in a test environment first as you don't want to play around with your production database. you could do something like a join of the tables/columns/rows of the multiple values you wanted this way and display them on your custom page.

                What my example does is get the results for 8 or 9 seperate items from the MySQL database and then stores them in an array. I think call each item individually from the array in my table to display the data in Zabbix screens.

                Comment

                • ninguno
                  Junior Member
                  • Nov 2011
                  • 29

                  #9
                  Originally posted by Axilla
                  Yes my solution is to do the query outside of zabbix. I do my query directly to MySQL and do a join. I then create a custom screen to display this data. In a custom screen you can display a webpage.. I create a custom PHP page which displays this data for me. Basically it can be done, it just needs to be done completely manually and outside of zabbix. It can then interface with zabbix.

                  You can request multiple query's from MySQL in 1 Query. You can also do inserts directly to the database. So you could in theory(al though i've never tried) right a custom scrips that harvest whatever multiple values you want then does a direct insert into the database. I highly suggest doing this in a test environment first as you don't want to play around with your production database. you could do something like a join of the tables/columns/rows of the multiple values you wanted this way and display them on your custom page.

                  What my example does is get the results for 8 or 9 seperate items from the MySQL database and then stores them in an array. I think call each item individually from the array in my table to display the data in Zabbix screens.
                  Thanks Axilla, now I understood you better, I didn't know before your post about the screen feature of zabbix.

                  My first try was finding something that zabbix has to do this but it seems that can't be done (items with multiple values) so I'll try your solution. Thank you very much for your explanation!

                  Comment

                  Working...