malformed JSON string bei bloonix-load-plugins

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • malformed JSON string bei bloonix-load-plugins

      Hallo zusammen, vielleicht weiß jemand ad-hoc bescheid.
      Hab ein Plugin geschrieben was einen wert aus einer datenbank holt und den auswertet und mir bei einer definierten condition entsprechend rückmeldung gibt. Konkret geht es darum zu überprüfen ob in einer Web Anwendung ein service fest steckt beim abarbeiten von XML Files in einem hot folder.

      Das Plugin heißt check-wave, dazu gibt es eine plugin-wave file. Wenn ich nun versuche mittels bloonix-load-plugins --path=/pfad/zum/ordner das Plugin in bloonix zu laden bekomme ich folgende meldung:

      Source Code

      1. sudo bloonix-load-plugins --path /home/phi/wavetest/
      2. Load plugin /home/phi/wavetest/plugin-wave
      3. malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "plugin {\n\tid 10010...") at /usr/share/perl5/Bloonix/PluginLoader.pm line 84.




      Führe ich den check manuell aus geht es.

      der check sieht so aus:


      Perl Source Code

      1. #!/usr/bin/perl
      2. use strict;
      3. use warnings;
      4. use DBI;
      5. use Bloonix::Plugin;
      6. use DateTime::Format::Strptime;
      7. my $warn=3;
      8. my $crit=5;
      9. #declare variables
      10. my $plugin = Bloonix::Plugin->new(version => "0.1");
      11. $plugin->example(
      12. description => "Check WAVE Service Status",
      13. arguments => [
      14. warning => 5,
      15. critical => 10,
      16. db_host => "127.0.0.1"
      17. ]
      18. );
      19. $plugin->add_option(
      20. name => "Database Host / IP",
      21. option => "host",
      22. value_type => "string",
      23. value_desc => "Host which has the database where the wave status is tracked",
      24. mandatory => 1,
      25. mutiple => 0,
      26. description => "The host which has the database where the WAVE Status is been tracked"
      27. );
      28. $plugin->add_option(
      29. name => "Warning threshold",
      30. option => "warning",
      31. value_type => "number",
      32. value_desc => "minutes",
      33. mandatory => 1,
      34. multiple => 0,
      35. default => 3,
      36. description => "Trigger a WARNING status if the request takes longer."
      37. );
      38. $plugin->add_option(
      39. name => "Crtitical threshold",
      40. option => "critical",
      41. value_type => "number",
      42. value_desc => "minutes",
      43. mandatory => 1,
      44. multiple => 0,
      45. default => 5,
      46. description => "Trigger a CRITICAL status if the request takes longer."
      47. );
      48. $plugin->add_option(
      49. name => "Password",
      50. option => "password",
      51. value_type => "string",
      52. value_desc => "Database Password",
      53. mandatory => 1,
      54. multiple => 0,
      55. description => "Password which is needed to connect to the database"
      56. );
      57. $plugin->add_option(
      58. name => "Username",
      59. option => "username",
      60. value_type => "string",
      61. value_desc => "Database User",
      62. mandatory => 1,
      63. multiple => 0,
      64. description => "User which is needed to connect to the database"
      65. );
      66. my $opt = $plugin->parse_options;
      67. $plugin->runtime;
      68. my $fmt = '%Y-%m-%d %H:%M:%S';
      69. my $parser = DateTime::Format::Strptime->new(pattern => $fmt);
      70. my $db_host=$opt->{"host"};
      71. my ($db_user, $db_name, $db_pass) = ($opt->{"username"}, 'pdb_hub',$opt->{"password"});
      72. my $service='core_update';
      73. ##Timeout on connection error max 30s !!
      74. #connect to db
      75. my $dbh = DBI->connect("DBI:mysql:$db_name;host=$db_host", $db_user, $db_pass);
      76. #prepare query
      77. my $query_test = $dbh->prepare("SELECT last_action, last_progress FROM al_sys_svc WHERE act LIKE '$service'");
      78. #fire query, return error string on failure
      79. $query_test->execute() or die $query_test->err_str;
      80. # get values from database
      81. my $status = "OK";
      82. my ($seconds,$minutes,$done,$from,$total);
      83. while (my ($col_1, $col_2) = $query_test->fetchrow_array() ) {
      84. if ($col_1 eq 'finished'){
      85. }else{
      86. ($done,$from,$total) = $col_1 =~ /(\d+)/g;
      87. }
      88. my $lastcheck = $parser->parse_datetime($col_2) or die;
      89. my $now = DateTime->now(time_zone=>'local');
      90. my $diff = $now - $lastcheck;
      91. $minutes = $diff->minutes;
      92. $seconds = $diff->seconds;
      93. if ($minutes >= $crit and $minutes > $warn)
      94. {
      95. $status = "CRITICAL";
      96. }elsif( $minutes >= $warn and $minutes < $crit)
      97. {
      98. $status = "WARNING";
      99. }
      100. }
      101. #disconnect
      102. $dbh->disconnect();
      103. my $rtime = ($minutes*60+$seconds)*1000;
      104. $plugin->exit(
      105. status => $status,
      106. message => "response time $rtime msec",
      107. stats => {
      108. time => $rtime,
      109. donefiles => $done,
      110. qeuedfiles => $from,
      111. totalfiles => $total
      112. }
      113. );
      Display All

      die plugin-wave Datei sieht folgendermaßen aus:

      Source Code

      1. plugin {
      2. id 100100
      3. plugin Test.Wave
      4. command check-wave
      5. datatype statistic
      6. category Network,Webserver
      7. netaccess yes
      8. prefer localhost
      9. abstract Checks WAVE Service Status
      10. description Checks WAVE Service status by accessing database and reading service table
      11. }
      12. statistic {
      13. statkey time
      14. alias Response time
      15. datatype integer
      16. units ms
      17. description Time in milliseconds waiting for response.
      18. }
      19. chart {
      20. id 1
      21. title Wave Service Queue - response time
      22. options {
      23. ylabel time in ms
      24. chart-type area
      25. series {
      26. name time
      27. color \#005467
      28. }
      29. }
      30. }
      Display All


      Für hilfe wäre ich dankbar.
    • New

      bloonix-load-plugins benötigt einen Mix aus dem Check (check-wave --plugin-info) und dem Meta File. Dafür gibt es ein Skript namens bloonix-create-plugin, welches im Paket bloonix-plugin-config enthalten ist, Sourcecode gibts hier: github.com/bloonix/bloonix-plu…bin/bloonix-create-plugin. Das Paket ist für gewöhnlich dort installiert, wo auch die WebGUI läuft. Leg also am besten beide Dateien (check-* und plugin-*) auf dem Server ab, wo die WebGUI läuft.

      Dann folgendes ausführen:

      Source Code

      1. #> ls -1
      2. check-wave
      3. plugin-wave
      4. #> bloonix-create-plugin plugin-wave >plugin-wave.json
      5. #> bloonix-load-plugins --plugin plugin-wave.json
      plugin-wave.json ist dann die Datei, welche sich importieren lässt. Ok? :)