Ad Widget

Collapse

PATCH: External scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • juampe
    Junior Member
    • Apr 2007
    • 17

    #46
    external agent v2 minihowto

    Now whe have the external script running, we can use several cunstom scripts.
    "external agent"
    1. It is not an afortunate name, can cause misunderstanding with external script
    2. It is like any other external excript, but it intenaly is a framework to make agents
    external agent born to help making perl agent

    older version was a shared file version an was documente in this thread

    v2 is a shared memory version an it is alpha code


    To optimize external perl execution
    perlcc -o external -B external.pl

    Untar the external tar into zabbixexternal directory

    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 script itself
    /external
    *external agent store
    /agents

    The external script is made in perl and the external agents must be made in perl
    The external script offer a simple API to aim the agent execution:

    rcmd
    First verify the host passed by zabbix and later make a ssh connection ir order to exec remotely a command

    $param
    Store the zabbix's item

    store($item,$value)
    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

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


    A. We use rcmd to exec the ping to in the remote host $param, 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 store with item id "$param".
    D Store 0 or 2 with key "$param", 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

    Comment

    • Umair
      Member
      • Feb 2007
      • 86

      #47
      Brilliant !!!
      The external scripts now work perfectly !!
      Sorry for the late reply, i was busy migrating from 1.1.7 to 1.3.8.

      Still, Thanx for your help Juampe.

      Comment

      • alexwaller
        Junior Member
        • Dec 2006
        • 11

        #48
        Hostname in External check

        Hi!
        I found that (in Zabbix 1.3.4) external scripts are called with the "Name" and not with "IP" or "DNS-Hostname".
        Thats not very cool and gave me lots of problems, till I discovered it.
        Can I change that behavior easily ?

        Comment

        • alexwaller
          Junior Member
          • Dec 2006
          • 11

          #49
          Emulation of &quot;Not supported&quot;

          Hi!
          Is it possible to tell "External Script"-function that a value is "Not supported" ?
          I use external scripts in templates, but not all hosts have the same informations available...

          Comment

          Working...