Ad Widget

Collapse

external script in action message

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ray369
    Junior Member
    • Jun 2009
    • 4

    #1

    external script in action message

    Is it possible to include the result of a script in an action message?

    Problem:
    I am monitoring firewalls that exist behind a router. For clarity, the firewall is our equipment, the router belongs to the ISP. I only need to monitor our equipment by sending a heartbeat ping. I have that working correctly. In my message I would like to give our techs the status of the ISP router.
    (ex. ping stats for <router>, sent 3, rec 0, lost 3 100% loss) Since I don't/can't monitor the router in real time w/ an item (see side note at the end), there is no data on the router for a macro to retrieve. I would like to be able to insert the ping statistics for the router into the message by calling a script in the externalscripts directory.

    The only solution I have come up w/ is executing a remote command that will send the email I want.

    ==

    On a side note, I wouldn't mind monitoring the ISP device w/ a heartbeat ping, but the simple check icmpping/icmppingsec doesn't allow passing a parameter... it uses the host ip. That would require creating two hosts for each firewall. However, If I declare two hosts (one for the firewall and one for the router), I don't have a way to reference the router stats from the action that was triggered by the firewall trigger. right?

    It would be nice to use a icmpping[<ip>] and the extended profile attribute RouterIP (icmpping[{PROFILE.ROUTERID}] to monitor the router, then in my message be able to call the last() status for both items.

    --
    Please point me in the best direction.
    Thanks,
    Ray
  • richlv
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2005
    • 3112

    #2
    i can't test it right now, but you should be able to use {host:key.func(param)} syntax in notifications (at least according to zabbix manual).
    so you can choose :

    1. create userparameter for each firewall, then include data from this userparameter in notifications;

    2. create host for router and include data from items attached to this router in notifications
    Zabbix 3.0 Network Monitoring book

    Comment

    • ray369
      Junior Member
      • Jun 2009
      • 4

      #3
      I followed the logic from suggestion #2 {host:key.func(param)}, I appoligze for even asking the question because it was in the documentation at the end of the supported macros list. I made a poor assumption that all the macros only pertained to the host/item that triggered the action.

      So to move forward w/ my project, I've used the serial number as the name of the firewall so it will be a unique name, and for the router created a second host w/ the name {myfirewallserial}-Router.

      Now in my message I can call:

      {{HOSTNAME}-Router:icmppingsec.last(#1)}
      {{HOSTNAME}-Router:icmppingsec.last(#2)}
      {{HOSTNAME}-Router:icmppingsec.last(#3)}

      to retrieve the last ping stats for the router.

      Thank you richlv

      Comment

      • cbidwell
        Senior Member
        • Aug 2006
        • 127

        #4
        Would you explain more on how the host:key.function works? I'm trying to do something similar to what you're saying but not quite sure how and WHERE to implement this at.

        It says in the documentation: {host:key.func(param)} but I'd just like to see some examples on how to use this.

        Comment

        • ray369
          Junior Member
          • Jun 2009
          • 4

          #5
          Host:Key.Func(Param) Explained

          When you're in the web admin you see the sections in the following order:
          Items, Triggers, Actions.

          In the background there is another that comes into play: functions.

          Think of an item as a harvester of data. You define an "item" using a "key" that the zabbix server recognizes: ex. icmpping, icmppingsec, tcp_perf, etc. This key tells the server what program and parameters to use to retrieve a response. Zabbix then processes and stores the result in history.

          Think of the "trigger" as it's name implies. A trigger is useless unless there is something to "trigger" it... that's where the function comes in. When you define your trigger, you also define it's function(s) in the trigger config page. As your server "harvests" data with "items" it is also testing your trigger (if defined) using the function you supplied.

          ex. {Template_Pinger:icmppingsec.count(#3,0,"eq")}=3. This example says to retrieve the last 3 values harvested by the item with key icmppingsec that was defined on the host and if three of those values (all of them in this case) == 0, "pull the trigger".

          Now at this point, if you have no action defined, the trigger is shooting blanks.

          So, in your action you have access to this same hostname:key.function(param) thing. All you need to know is the "host" you created, the "key" of the "item" you attached to the host.

          So in my message I wanted to see the last successful results for the firewall (I knew the last 3 responses failed or my trigger wouldn't have fired), and the router it's behind, like this:

          Firewall @ {IPADDRESS}
          Last 3 ICMP Failed
          4th: {{HOSTNAME}:icmppingsec.last(#4)}
          5th: {{HOSTNAME}:icmppingsec.last(#5)}
          6th: {{HOSTNAME}:icmppingsec.last(#6)}

          Router @ {PROFILE.TAG}
          1st: {{HOSTNAME}-Router:icmppingsec.last(#1)}
          2nd: {{HOSTNAME}-Router:icmppingsec.last(#2)}
          3rd: {{HOSTNAME}-Router:icmppingsec.last(#3)}

          This shows me response time 4,5,and 6 from my firewall, and response time 1,2, and 3 for my router. I used PROFILE.TAG on the fw host to store the ip address of the router so I could include it in my message.

          I had to define the router host so I used the same name as my firewall and the suffix "-router". I also had to define the icmppingsec item on the router host so Zabbix would "harvest" data. Then when this action was triggered, I retrieve that info from the history using hostname:key.func(param)

          Hope this helps.

          Comment

          • cbidwell
            Senior Member
            • Aug 2006
            • 127

            #6
            Thank you for that very indepth description.

            Perhaps you can provide a little more guidance as to my specific situation:

            I've got a file that updates through a different script but outputs into this file with this information:

            RECENTEQS_Working: 1
            server - Thu Jul 23 19:11:50 UTC 2009 - Uptime: 12:11:52 up 2 days, 26 min, 1 user, load average: 3.18, 4.21, 4.52 - Rsyncs: 3
            OK - All REQS servers appear to be operating within acceptable thresholds.

            So all I know how to do at this point is in my zabbix_agentd.conf file insert a UserParameter:

            UserParameter=EQ.Monitor_wkg,cat /home/quake/REQS_monitor/logdir/zabbix.LOG | grep "RECENTEQS_Working" | cut -d: -f2 | sed "s/\s//g"

            What I really want to do is return all of the contents of my zabbix.LOG file into zabbix itself so that can get sent as information on an email action.

            Comment

            Working...