Ad Widget

Collapse

openvz container load monitoring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uid0
    Junior Member
    • Aug 2013
    • 8

    #1

    openvz container load monitoring

    Hello everybody!

    I need your help. I am trying since 2 days to monitor all openvz containers by load but i dont have any success.

    I want, that zabbix agent runs "vzlist -o veid,laverage -H" and the zabbix server imports the veid and laverage. Then i want to create a trigger of load 1min/5min/15min.

    Output of vzlist -o veid,laverage -H would be:
    100 0.00/0.00/0.00
    130 0.00/0.00/0.00
    140 0.40/0.22/0.19
    150 0.00/0.00/0.00
    160 0.00/0.00/0.00
    Could somebody *please* give me tips how i could do it and how zabbix can split the result of vzlist to make a trigger? I play since 2 days and have no success. I am not such a expert but have read already serveral faqs without goals

    Would be really, really awesome if somebody could help me out.

    Thanks a lot!
  • steveboyson
    Senior Member
    • Jul 2013
    • 582

    #2
    You need to split/parse the values before sending them into Zabbix.

    You could use something like that:

    #!/usr/bin/perl
    use strict;

    open(IN, "vzlist -o veid,laverage -H |") or "can't spawn: $!";
    while (my $l = <IN>)
    {
    if ($l =~ /^(\d+) (.*?)\/(.*?)\/(.*?)$/)
    {
    my $id = $1;
    my $v1 = $2;
    my $v2 = $3;
    my $v3 = $4;
    print "zabbix_sender -z <your_zabbix_server> -s <your_zabbix_host> -k laverage_on_$id\[v1] -v $v1\n";
    print "zabbix_sender -z <your_zabbix_server> -s <your_zabbix_host> -k laverage_on_$id\[v2] -v $v2\n";
    print "zabbix_sender -z <your_zabbix_server> -s <your_zabbix_host> -k laverage_on_$id\[v3] -v $v3\n";
    }
    }
    close(IN);
    ################

    Substitute the "print" sequences with correct values.

    Comment

    • uid0
      Junior Member
      • Aug 2013
      • 8

      #3
      Hello,

      thanks for your help. I tryed it but zabbix dont display the values. There is nothing about it in the zabbix logs.

      I changed the script to this:
      Code:
      #!/usr/bin/perl
      use strict;
      
      open(IN, "vzlist -o veid,laverage -H") or "can't spawn: $!";
      while (my $l = <IN>)
      {
      if ($l =~ /^(\d+) (.*?)\/(.*?)\/(.*?)$/)
      {
      my $id = $1;
      my $v1 = $2;
      my $v2 = $3;
      my $v3 = $4;
      print "zabbix_sender -z 10.0.0.4 -s 10.0.0.1 -k laverage -v -o $id\n";
      print "zabbix_sender -z 10.0.0.4 -s 10.0.0.1 -k laverage -v -o $v1\n";
      print "zabbix_sender -z 10.0.0.4 -s 10.0.0.1 -k laverage -v -o $v2\n";
      print "zabbix_sender -z 10.0.0.4 -s 10.0.0.1 -k laverage -v -o $v3\n";
      }
      }
      close(IN);
      My itemconfiguration is this:

      If i manually send a string over zabbix_sender then it get added into zabbix. Maybe there is something missing in the script?
      It seems that there get nothing sended, because "Last check" dont change in zabbix. There is still the date of my manual string.

      My skills at perl and bash are very limited, i hope there is some help for me.

      Thanks a lot!

      Comment

      • steveboyson
        Senior Member
        • Jul 2013
        • 582

        #4
        First:
        the "print" statements only _PRINTS_ the commands. Copy and paste them into your shell to see if the values make it to zabbix. Then change "print" to "system", e.g.:

        system ("zabbix_sender -z <your_zabbix_server> -s <your_zabbix_host> -k laverage_on_$id\[v1] -o $v1");

        and repeat that for all needed values to send.

        Second:
        With your changes, you're overwriting the values for the key "laverage". Thus I scripted to use different keys (-k laverage_on_$id\[v1] ...)

        What is the script output if you launch it in a command line?

        P.S. Sorry, I had an error, "-v" must be "-o". Mea culpa. "-v" is "verbose". You may omit that.
        Last edited by steveboyson; 09-09-2013, 00:46.

        Comment

        • steveboyson
          Senior Member
          • Jul 2013
          • 582

          #5
          This is under the assumption, that your posted lines

          Code:
          100 0.00/0.00/0.00
          130 0.00/0.00/0.00
          140 0.40/0.22/0.19
          150 0.00/0.00/0.00
          160 0.00/0.00/0.00
          do mean:
          ID value1/value2/value3

          You cannot put all three values to the same key "ID".

          Therefore I created 3 keys:

          laverage_on_{ID}[v1]
          laverage_on_{ID}[v2]
          laverage_on_{ID}[v3]

          which you can use to store all three values:

          laverage_on_{ID}[v1] = value1
          laverage_on_{ID}[v2] = value2
          laverage_on_{ID}[v3] = value3

          Comment

          Working...