Ad Widget

Collapse

Set multiple items from one call/command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ppoetsma
    Junior Member
    • Mar 2009
    • 9

    #1

    Set multiple items from one call/command

    Hi,

    I am looking into remotely monitoring using ssh. Can I run a, for example "df -m" command, remotely, retrieve the output on the Zabbix server and put the values in the right items? Running a command once and feeding multiple items would be extremely efficient over running n times the command where n equals the amount of filesystems.

    I look forward to any suggestions how to optimize the impact of the monitoring itself.

    Regards,
    Paul
  • alixen
    Senior Member
    • Apr 2006
    • 474

    #2
    Hi,

    Originally posted by ppoetsma
    I am looking into remotely monitoring using ssh. Can I run a, for example "df -m" command, remotely, retrieve the output on the Zabbix server and put the values in the right items? Running a command once and feeding multiple items would be extremely efficient over running n times the command where n equals the amount of filesystems.

    I look forward to any suggestions how to optimize the impact of the monitoring itself.
    It will not be possible with "SSH agent" items in Zabbix.
    What you can do is to setup an item that will have "external script" type.
    Each time this script is called, it will run "df -h" via ssh, analyze output and feed several Zabbix items at once with zabbix_sender command.
    Those items must be "Zabbix trapper" type.

    I use that kind of solution (not with ssh but with web services) and it works.

    Regards,
    Alixen
    http://www.alixen.fr/zabbix.html

    Comment

    • ppoetsma
      Junior Member
      • Mar 2009
      • 9

      #3
      Thanks, this seems to be what I am looking for. I can't find much about the trapper in the documentation but let's get started. In babysteps:

      1) on the Zabbix server I run a script
      2) the script uses SSH to run a command on a remote server
      3) the remote server runs the command and returns the output
      4) the script processes the output
      5) for every required piece of data that is picked from the output, zabbix_sender is ran to "upload" the data to the appropriate items of type "Zabbix trapper"

      I see that zabbix_sender supports uploading data of another server so that will work otherwise all data would be assigned to localhost. And it can even send a list of data from a textfile which reduces the amount of load to run zabbix_sender multiple times.

      Good feedback alixen, and if I am wrong in my text above, let me know please.

      Regards,
      Paul

      Comment

      • ppoetsma
        Junior Member
        • Mar 2009
        • 9

        #4
        I have done some tests and it works. From the item I call a script which gets passed the IP address of the host that runs the items. In the script I use that to know where to SSH to. The command is run and the data is returned and processed to be fed to zabbix_sender.

        But zabbix_sender wants to have the "-s host" argument, which is not the IP address but in some cases the hostname and in other cases a descriptive name. How can I tell the item to pass that name to the script? I found macros but have not been successful in find the right one yet. Now I have this in the key field: testcmd.sh[-p 22]. I expect the clue to be here, can you help?

        Regards,
        Paul

        Comment

        • ppoetsma
          Junior Member
          • Mar 2009
          • 9

          #5
          Found it with trial and error: testcmd.sh[-p 22 -h {HOSTNAME}].

          Paul

          Comment

          • uxorious
            Junior Member
            • Nov 2015
            • 3

            #6
            Need help ... with the script

            Great explanation. Do you have sample script with all the counters ?

            Thx in advance....

            Comment

            • ppoetsma
              Junior Member
              • Mar 2009
              • 9

              #7
              I do not use Zabbix anymore so I can't help you.

              Comment

              • uxorious
                Junior Member
                • Nov 2015
                • 3

                #8
                What system do you use if don't mind sharing the name ?

                Whats the reason for switch ?

                Comment

                Working...