Ad Widget

Collapse

PATCH: External scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AlfieRB
    Junior Member
    • Oct 2006
    • 16

    #31
    Hello,

    I'm running version 1.1.4 and am trying to get this patch...the link above to download the patch for 1.1.2 doesn't seem to work. Can anyone point me in the right direction?

    Thanks,
    Alfonso

    Comment

    • monsieurcanard
      Member
      • Mar 2007
      • 40

      #32
      New patch for v1.3.3 beta

      Hi guys,

      This is my first time modifying C but hopefully it will be of some use. I've updated this patch to work with Zabbix 1.3.3 beta. I haven't tested it fully yet but it compiles, runs and no errors so far. I haven't yet tried running any external scripts or collecting any data using it.

      Please see patch attached.

      Hope it helps!
      Matt :-)
      Attached Files

      Comment

      • bbrendon
        Senior Member
        • Sep 2005
        • 870

        #33
        Just to verify, this new feature runs scripts stored on the zabbix server on any zabbix agent? Does it work on active only agents?

        I'm assuming this is a UNIX only thing?
        Unofficial Zabbix Expert
        Blog, Corporate Site

        Comment

        • James Wells
          Senior Member
          • Jun 2005
          • 664

          #34
          Originally posted by infinity005
          Just to verify, this new feature runs scripts stored on the zabbix server on any zabbix agent? Does it work on active only agents?
          Yes and no. It runs scripts on the Zabbix Server only, but the data returned by the scripts are stored as items for the host you have them configured for.

          I'm assuming this is a UNIX only thing?
          Yes, this is server side only, however, if you have a script on your server that makes an RPC call to a windows machine, then this could work as well.
          Unofficial Zabbix Developer

          Comment

          • bbrendon
            Senior Member
            • Sep 2005
            • 870

            #35
            Excellent! I get it! ...Now we can have agentless hosts! ssh+authorized keys and its a whole new world
            Unofficial Zabbix Expert
            Blog, Corporate Site

            Comment

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

              #36
              The "ssh + authorized keys"-only world can be quite slow!
              Alexei Vladishev
              Creator of Zabbix, Product manager
              New York | Tokyo | Riga
              My Twitter

              Comment

              • juampe
                Junior Member
                • Apr 2007
                • 17

                #37
                patch from sarek updated to 1.3.4 beta



                To test it

                create /etc/zabbix/externalscripts/test

                #!/bin/bash
                date > /tmp/zabbix_external_test
                echo 1
                exit 0

                chmod 755 /etc/zabbix/externalscripts/test

                Item Example
                test(1)

                Trigger Example
                {host:test(1).max(120)}<1

                Comment

                • juampe
                  Junior Member
                  • Apr 2007
                  • 17

                  #38
                  I apologize for dupplication (I need a big gasses)

                  I apologize,I make a dupplication efford :X, I only read the first page of this trhead.
                  (I normaly work with mailing list :P)

                  Only one comment to the monsieurcanard patch

                  diff -uprN zabbix-1.3.4/src/zabbix_server/server.c zabbix-1.3.4.new/src/zabbix_server/server.c
                  --- zabbix-1.3.4/src/zabbix_server/server.c 2007-03-27 11:34:17.000000000 +0200
                  +++ zabbix-1.3.4.new/src/zabbix_server/server.c 2007-04-13 10:46:06.000000000 +0200
                  @@ -209,7 +209,7 @@ void init_config(void)
                  }
                  if(CONFIG_EXTERNALSCRIPTS == NULL)
                  {
                  - CONFIG_EXTERNALSCRIPTS=strdup("/etc/zabbix/externalscripts");
                  + CONFIG_EXTERNALSCRIPTS=strdup("/etc/zabbix/externalscripts/");
                  }
                  }

                  Comment

                  • monsieurcanard
                    Member
                    • Mar 2007
                    • 40

                    #39
                    Agreed :-D Realized this with my own server just this evening. Thanks Juampe!

                    Comment

                    • juampe
                      Junior Member
                      • Apr 2007
                      • 17

                      #40
                      external command to exec external agents -&gt; external

                      Enjoy it!

                      EXTERNAL COMMAND
                      What is this?
                      The external command is perl script, that permits external agent execution in zabbix.
                      external is agent executor, uses rsh/ssh to remotely exec and have and store to cache items polled to external agent

                      Morphology
                      By default zabbix have the external command directory in /etc/zabbix/externalscripts, the external command need the following infraestructure of files and directories:
                      *ssh configuration files
                      ssh default parameters
                      /ssh/ssh_config
                      Private ssh key iin order to accest ssh hosts
                      /ssh/id_dsa
                      *external command itself
                      /external
                      *Item store-cache
                      /store
                      *exteranl agetn store
                      /agents

                      The external command is made in perl and the external agents must be made in perl
                      The external command offer a simple API to aim the agent execution:
                      rcmd
                      Fiers verify the by icm the host an later make a ssh connection ir order to exec remotely acommand

                      $host
                      Store the zabbix host which the agent must retrieve information

                      $param
                      Store the zabbix's item

                      $time
                      Store the current unix epoch time

                      %store
                      Store-hash to store the items-value pairs and agent status information



                      Steps to make ane external agent:
                      A Exec someching in the remote host
                      B Get the output of the execution
                      C Process the information obtained in order to make one o severals item->value pairs uniques for this host
                      D Store such items with the curren time and the value obtained

                      ZABBIX FRONTEND
                      The external command is executed in the following way:
                      We have the command:
                      external(agent item [ttl])
                      will be exec the following command:
                      external host agente item [ttl]
                      host is the host to make the agent execution
                      agent is the exteranl agent
                      item is the agent parameter
                      ttl is opcional and by default is set to 60 seconds

                      EXAMPLE
                      external agent example: rping
                      /etc/zabbix/externalscripts/agents/rping


                      #!/usr/bin/perl
                      #Juan Pedro Paredes <[email protected]>
                      #Remote Solaris Ping agent, makes a ping i a remote host to other host
                      #Its very useful in host firewalled enviroments

                      ($out)=rcmd($host,"ping $param 2");
                      chomp $out;
                      $store{"$host/$param"}{'time'}=$time;
                      if($out=~/is alive/){
                      $store{"$host/$param"}{'data'}=1; #Up
                      }else{
                      $store{"$host/$param"}{'data'}=2; #Unreachable
                      }

                      A. We use rcmd to exec the ping to $param in the remote host $host, now we have the execution step.
                      B In $out we have the output of the remote execution
                      C Process the output, and check if the string "is alive" is contained, therefore we use the hash key "$host/$param" to assure uniqueness respect ro the host an the item in the store
                      D Assign the time to the time storeage's item and 0 or 2 in the data storage's item, deppending of the string "is alive" was collected

                      In zabbix frontend we must use the following item and trigger
                      *host item key:
                      external(rping otherhost)
                      *trigger:
                      {host:external(rping otherhost).max(120)}>0



                      External Patch

                      External Agent


                      Directory tree and permissions
                      drwxr-xr-x 2 root root 96 Apr 15 20:09 agents
                      -rwxr-xr-x 1 root root 2727 Apr 15 20:08 external
                      drwxr-xr-x 2 root root 104 Apr 16 01:10 ssh
                      drwxr-xr-x 2 zabbix root 48 Apr 16 01:10 store
                      -rwxr-xr-x 1 root root 75 Apr 13 12:00 test

                      drwxr-xr-x 2 root root 104 Apr 16 01:10 .
                      drwxr-xr-x 5 root root 168 Apr 16 00:49 ..
                      -rw-r----- 1 root zabbix 75 Apr 16 01:09 id_dsa
                      -rw-r--r-- 1 root root 119 Apr 16 01:10 ssh_config

                      Comment

                      • Umair
                        Member
                        • Feb 2007
                        • 86

                        #41
                        Hello,
                        I have tried downloading the files for the External Script Patch.
                        But the link does not seem to work.
                        Is there any other way i can download the files ?

                        Comment

                        • juampe
                          Junior Member
                          • Apr 2007
                          • 17

                          #42
                          sorry was down

                          the server iquis.com is in service again

                          Comment

                          • Umair
                            Member
                            • Feb 2007
                            • 86

                            #43
                            Hey Thanx !

                            Comment

                            • Umair
                              Member
                              • Feb 2007
                              • 86

                              #44
                              Hello,
                              I am a little dubious about the External Scripts execution in Zabbix!
                              I hope someone helps me out.

                              Just to be on the same line,
                              External Script is a script which would be executed by Zabbix on the Server Machine and the results obtained will be displayed somehow to the user.
                              We are therefore talking of an agent less/ non-SNMP World !

                              Here are the two possibilities which i have dug up so far:


                              1). Courtesy: Shawn Badger :
                              Use the "UserParameter" in the zabbix_agentd.conf file. The only real catch is that it
                              has to return a value in .5 second. Here is a basic run down on how to use this functionality.

                              a). create the script and test
                              b). add it to the bottom of the config file and restart the agent
                              c). create a new item for that host that points to the newly created
                              script.


                              here is what the user parameter should look like:
                              UserParameter=ITEM_NAME,SCRIPT OR COMMAND TO RUN

                              All we need to do is, add the server as a host in the configuration file of the agent.
                              The script can then be executed and the result obtained shown as a graph !

                              This is pretty straight forward and one does not need to tweak the application by applying any patches to add the functionality of external Scripts!
                              But Still, we are using The Agents...!! (Something which should be ignored !)

                              Can any one tell me as why we should not be using this technique of external scripting?
                              This seems to be the most straight forward solution!

                              2). Courtesy: Juampe :
                              The previous thread of Juampe stating the same mechanism of SSH secure Tunneling and external Agent.



                              I tried using the solution from Juampe as well.The installation went smooth on Zabbix 1.1.7
                              I used the same scripts example as given by him.
                              The only problem is that I really don't know if the script(example script) is working with Zabbix or not.I cannot see any output in any form.
                              Even the /store/ folder remains empty after the execution.

                              I am pretty sure that i am missing something.
                              I would appreciate if i could be loaded with your responses !

                              Comment

                              • juampe
                                Junior Member
                                • Apr 2007
                                • 17

                                #45
                                external script minihowto

                                The patch:


                                Making an external script:

                                /etc/zabbix/externalscripts/test:
                                #!/bin/bash
                                #use dumps to afile to debug causet zabix not permits yet execute and dump the output #from the interface
                                #check i to si if it works and the latest data entry in zabbix interface
                                #see zabbix-server.log too
                                date > /tmp/debug_info.log
                                #use posicional parameters to pass parameter to the script
                                #$1 is always the host $2 an so on, were the parameters we passed in the item definition
                                #ouput is always a positive integer in only one line.
                                echo $2
                                exit 0

                                We give it exec permisions
                                chmod 755 /etc/zabbix/externalscripts/test

                                su zabbix /etc/zabbix/externalscripts/test host 1

                                Item Example (External script flavour) into a host
                                test(1)

                                Trigger Example
                                {host:test(1).max(120)}<1

                                Comment

                                Working...