Ad Widget

Collapse

Send multiple key/value pairs with zabbix_sender via trapper

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mgoodman
    Member
    • Apr 2011
    • 33

    #1

    Send multiple key/value pairs with zabbix_sender via trapper

    Hey,

    I need to monitor remote systems using custom scripts. However, due to security concerns with being able to run remote scripts from Zabbix server, I would prefer that these scripts are run on the client and then send data to Zabbix server via the zabbix_sender / trapper service.

    Doing this for one key/value pair seems feasible. However, to do it for multiple pairs, it seems that I would need to spawn a new zabbix_sender process (and therefore connection) for each pair -- which seems excessive. Is there a way to send multiple?

    I found this post: http://www.zabbix.com/forum/showpost...69&postcount=2 -- but my remote hosts don't necessarily have php, and I need something cross-platform and consistent using the built-in binaries.

    ALSO, I was wondering how I could create a trigger on the Zabbix server if no data was sent over the trapper for n seconds. It seems the trapper just sends data to cause a trigger, but Zabbix server won't alert if nothing is sent (i.e. the resident agent script dies).

    Essentially, let's say we have data on the agent that it is gathering:
    Key1.value (int)
    Key2.value (int)
    Key3.value (int)
    Key4.value (int)

    How can I send them all to the Zabbix server, and have Zabbix server alert if it doesn't receive a value?

    Thanks!

    Michael
  • richlv
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2005
    • 3112

    #2
    see zabbix_sender --help - especially the part about using an input file & passing standard input as a file. that should allow to send multiple values within a single connection.

    as for trigger, i'd suggest creating a new thread, otherwise things are extremely hard to find afterwards
    Zabbix 3.0 Network Monitoring book

    Comment

    • untergeek
      Senior Member
      Zabbix Certified Specialist
      • Jun 2009
      • 512

      #3
      Rich is right.

      In addition, my experience has been that a file is limited to 250 lines. Anything after that is effectively dropped and not sent.

      I got around this by splitting the file, then sending all files in a loop:

      Code:
      ALL_VALUES="/var/tmp/ZBX_SENDER.$MY_RAND"
      SPLIT_FILE="$ALL_VALUES.split"
      
      if [ "$(wc -l $ALL_VALUES | awk '{print $1}')" -gt "250" ]; then
         split -l 250 $ALL_VALUES "$SPLIT_FILE."
      
         for file in $(ls $SPLIT_FILE.*); do
            zabbix_sender -z ${ZABBIX_SERVER} -i $file
         done
      
         rm $ALL_VALUES $SPLIT_FILE.*
      else
         zabbix_sender -z ${ZABBIX_SERVER} -i $ALL_VALUES
         rm $ALL_VALUES
      fi

      Comment

      • richlv
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Oct 2005
        • 3112

        #4
        split -l might be a bit faster, though
        Zabbix 3.0 Network Monitoring book

        Comment

        • JBo
          Senior Member
          • Jan 2011
          • 310

          #5
          Hi,

          Originally posted by untergeek
          In addition, my experience has been that a file is limited to 250 lines. Anything after that is effectively dropped and not sent.
          Are you sure of that ?
          I am using it in a script that sends 288 values in one call to zabbix_sender.
          I get:
          Code:
          Info from server: "Processed 250 Failed 0 Total 250 Seconds spent 0.002181"
          Info from server: "Processed 38 Failed 0 Total 38 Seconds spent 0.000289"
          sent: 288; skipped: 0; total: 288
          I am using zabbix_sender 1.8.4

          Regards,
          JBo

          Comment

          • untergeek
            Senior Member
            Zabbix Certified Specialist
            • Jun 2009
            • 512

            #6
            Perhaps they've fixed that. When I first noticed the 250 limitation, I was using 1.8.0 or .1 or .2

            My _sender binaries on most of my monitored boxes are 1.8.3 now. Perhaps I will have to retest.

            Comment

            • richlv
              Senior Member
              Zabbix Certified Trainer
              Zabbix Certified SpecialistZabbix Certified Professional
              • Oct 2005
              • 3112

              #7
              i decided to check that 250 line limit

              1.8.5rc1

              Code:
              # zabbix_sender -z 127.0.0.1 -i /tmp/traptest.txt 
              Info from server: "Processed 250 Failed 0 Total 250 Seconds spent 0.002668"
              Info from server: "Processed 50 Failed 0 Total 50 Seconds spent 0.000540"
              sent: 300; skipped: 0; total: 300
              all the values are there, so it seems to be fixed by now. note how sender batches them at 250 values automatically
              Zabbix 3.0 Network Monitoring book

              Comment

              Working...