Ad Widget

Collapse

Triggers output a through CLI

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tpoder
    Junior Member
    • Mar 2009
    • 6

    #1

    Triggers output a through CLI

    Hi Everyone,
    I've tried to use zabbix to replace our current monitoring system. Zabbix really looks excellent, but I've have a follow problem.

    In current system damaged devices are reported to the another system. The system reads data through a text based interface by a simple protocol. In the protocol informations with damaged devices are exchanged.

    Currently I am looking for a way how to read this data from zabbix. I thought about a SQL query which pick up data from the database and print them out. I need a very simple output which looks follow:

    <hostname> <triger status - up/down> <tiger descr>

    This output should by very similar to output provided by a "Overview" page in the web interface. Of course I could use a Overview page and parse it, but it isn't a clear solution.

    So I've tried inspect a database but the schema doesn't look easy and I didn't find any description of the schema. So I want to ask if somebody have solved a similar issue? Even a small idea is very useful for me :-).

    Thanks for ideas
    Tomas Podermanski
  • tpoder
    Junior Member
    • Mar 2009
    • 6

    #2
    A solution was easier than I expected. I've created the script in perl that loads the data from DB and returns follow outputs:

    [root@marmot bin]# ./zabbix_show servers
    # servers GROUP [ZABBIX GROUP] Servers
    up servers:zabbix_server 127.0.0.1 [ZABBIX] OK
    up servers:hawk hawk.cis.vutbr.cz [ZABBIX] OK
    up servers:tun-fit tun-fit.liberouter.org [ZABBIX] OK
    up servers:marmot marmot.cis.vutbr.cz [ZABBIX] OK
    up servers:coyote coyote.cis.vutbr.cz [ZABBIX] OK
    down servers:jackal jackal.net.vutbr.cz [ZABBIX] BAD: system.cpu.load[,avg1]
    up servers:fw-ant fw-ant.net.vutbr.cz [ZABBIX] OK
    up servers:fw-kou fw-kou.net.vutbr.cz [ZABBIX] OK
    up servers:routvev routvev.net.vutbr.cz [ZABBIX] OK
    up servers:win win.cis.vutbr.cz [ZABBIX] OK
    up servers:fw-list2 fw-list2.mgmt.net.vutbr.cz [ZABBIX] OK
    up servers:routmeo routmeo.net.vutbr.cz [ZABBIX] OK
    up servers:routant routant.net.vutbr.cz [ZABBIX] OK

    Probably that might be usefull to someone. I placed it on http://hawk.cis.vutbr.cz/~tpoder/SW/zabbix/ .

    TP

    Comment

    • dotneft
      Senior Member
      • Nov 2008
      • 699

      #3
      only MySQL((( and not working for me(
      Last edited by dotneft; 12-04-2009, 11:47.

      Comment

      • tpoder
        Junior Member
        • Mar 2009
        • 6

        #4
        Originally posted by dotneft
        only MySQL((( and not working for me(
        I think it is not a big problem. If you change the follow line:


        if (!($DBH = DBI->connect("DBI:mysql:$DATABASE:$HOSTNAME", $DBUSER, $DBPASSWD))) {

        with a valid connection string to your DB the script should work correctly. SQL command should work on MySQL and PgSQL. If want to use any other DBMS you have to change the line:
        my $tbh = $DBH->prepare("SELECT value, acknowledged FROM events WHERE objectid = ? AND source = 0 AND object = 0 ORDER BY eventid DESC LIMIT 1");

        to

        my $tbh = $DBH->prepare("SELECT value, acknowledged FROM events WHERE objectid = ? AND source = 0 AND object = 0 ORDER BY eventid DESC");

        (remove "LIMIT 1" part).

        TP

        Comment

        Working...