Ad Widget

Collapse

Question about trigger expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krusty
    Senior Member
    • Oct 2005
    • 222

    #1

    Question about trigger expression

    I am using this expression to check if one host is down.
    Code:
    {HOST:icmpping.last(0)}=0
    Is there any way to check with trigger a single ip without creating a seperate host. Something like that:
    Code:
    {192.168.0.1:icmpping.last(0)}=0
  • Nate Bell
    Senior Member
    • Feb 2005
    • 141

    #2
    I don't think so, since the trigger must have a stored value to evaluate against. If you haven't created a host, then there can't be any stored values.

    Nate

    Comment

    • krusty
      Senior Member
      • Oct 2005
      • 222

      #3
      Can I use one own script which checks another IP?

      How can i implemented my own script? Are there any examples in this forum?

      My Scipt is the following:

      Code:
      #!/bin/bash
      
      host=$1
      ping=`/usr/sbin/fping  $host`
      tmp="$host is alive"
      
      if [ "$ping" = "$tmp" ]
      then
              fping=1
      else
              fping=0
      fi
      If the ip is up i got 1 else 0. How can i use this in the expression field?

      Comment

      • elkor
        Senior Member
        • Jul 2005
        • 299

        #4
        you could use this script as a custom item be defining it in a particular host's zabbix_agentd.conf file. (there should be examples in the default version)

        The item still needs to be attached to a host that zabbix is monitoring though (although the host does not need to be the owner of the IP you are trying to ping in this case)

        does that make sense?

        Comment

        • krusty
          Senior Member
          • Oct 2005
          • 222

          #5
          Hi,
          i don´t use the agentd. All of my hosts are routers, so i can´t use agentd. Could i insert this into the server.conf file? There is a point where you can add your own scrips, but i don´t know how to use this script then. Has anybody use this function? If there is one please post how to set up. Thanks.

          Comment

          • krusty
            Senior Member
            • Oct 2005
            • 222

            #6
            At the morning i have looked into the config file of zabbix_server. I found the follow entry
            Code:
            #Location for custom alert scripts
            AlertScriptsPath=/home/zabbix/bin/
            If i understand the meaning of this entry right I can use my own scripts with zabbix. I have read the manual but i didn't find anything about this issue. Can somebody explain it?

            Comment

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

              #7
              In configuration of media types select Type="Script". Script Name is name of a script from the directory. Recipient, subject and message will be passed to the script as 1st, 2nd and 3rd parameters accordingly.
              Alexei Vladishev
              Creator of Zabbix, Product manager
              New York | Tokyo | Riga
              My Twitter

              Comment

              • krusty
                Senior Member
                • Oct 2005
                • 222

                #8
                Originally posted by Alexei
                In configuration of media types select Type="Script". Script Name is name of a script from the directory. Recipient, subject and message will be passed to the script as 1st, 2nd and 3rd parameters accordingly.
                okay i have added the script, but how can i use it? culd i made a trigger or something else?

                Comment

                • Nate Bell
                  Senior Member
                  • Feb 2005
                  • 141

                  #9
                  These scripts get run when a trigger goes off. If the media script is assigned to a user, and the alter level for the script is set to one or more levels, then any action for a trigger that includes that user and alert level will activate the script. So basically, this script, while very handy, isn't going to help you with your initial problem.

                  I would recommend setting up an agentd on your Zabbix server, and writing a custom UserParameter that takes in an IP address, checks for availability, and returns a value. You could then have a items like:
                  Host: ZabbixServer
                  Key: checkhost[192.168.0.1]

                  And triggers like:

                  {ZabbixServer:checkhost[192.168.0.1].last(0)}=0
                  {ZabbixServer:checkhost[192.168.0.2].last(0)}=0
                  etc...

                  I use my Zabbix Server's agentd to run a lot of custom scripts and items that check services that can be checked from any machine, such as if a website is up or not via a wget.

                  Nate

                  Comment

                  • krusty
                    Senior Member
                    • Oct 2005
                    • 222

                    #10
                    Hi nate bell,

                    thanks for your discription. I have added a the item and set a trigger. But i still have a problem. If i want to start the program with user zabbix permission i only get the follow error.

                    Code:
                    This program can only be run by root, or it must be setuid root.
                    I have this permissions set on the script.

                    Code:
                    -rwsrwxrwx  1 zabbix users 155 Feb  9 08:42 ping.sh*

                    Comment

                    • elkor
                      Senior Member
                      • Jul 2005
                      • 299

                      #11
                      well you need to be the root user to start it

                      while it does have setuid bit set, the owner of the file is zabbix so that won't work.

                      try switching to the root user and trying again but I think you'll wind up needing to chown the file to root and re-apply the suid perms.

                      Also.. I'd really make sure that script is exploit proof and that the host it's sitting on is fairly secure. having a suid root shell script flying around on your system is like running with scissors, naked, during an avalanche

                      Comment

                      • Nate Bell
                        Senior Member
                        • Feb 2005
                        • 141

                        #12
                        Hi, few quick questions: Is this related to your other thread about permission errors? Is there really an asterisk at the end of that script's filename, or is that cruft from copy/pasting?

                        I'm assuming this script is the one you showed us earlier in this thread. If so, it looks like fping can only be run as root. You have a few options here, and which you choose depends on the level of security you need on your Zabbix server. Elkor mentioned a few, and I would also suggest lookings into using sudo to run fping. So basically your permissions on the script itself are fine (sort of, I'd strip out that world write permission if I were you: chmod o-w ping.sh maybe take out the group write as well unless you want every system user to be able to edit the file) but it looks like you're trying to execute something in the script that user zabbix doesn't have permissions for.

                        Nate

                        Comment

                        Working...