[GUIDE] Add custom log files to WebUI

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

    • [GUIDE] Add custom log files to WebUI

      If you want to display additional custom log files in the WebGUI at 'Diagnostics | System Logs' then you have to do the following.

      Create a file called 99mylogspecs.inc in /usr/share/openmediavault/engined/inc. Here you can add your log file specifications. An example for a simple log file may look like this:

      PHP Source Code

      1. <?php
      2. require_once("openmediavault/functions.inc");
      3. \OMV\System\LogFileSpec::registerSpecification("clamav", [
      4. "filename" => "clamav",
      5. "filepath" => "/var/log/clamav/clamav.log",
      6. "regex" => "/^(\S+\s+\S+\s+\d+\s+\S+\s+\d+)\s+->\s+(.*)$/",
      7. "columns" => [
      8. "ts" => [
      9. "index" => 1,
      10. "func" => function($v) { return strpdate($v,"D M j H:i:s Y"); }
      11. ],
      12. "date" => [
      13. "index" => 1,
      14. "func" => function($v) {
      15. return strftime("%c", strpdate($v,"D M j H:i:s Y"));
      16. }
      17. ],
      18. "message" => 2
      19. ]]);
      Display All
      The description of the structure can be found here. The first argument of the registerSpecification must be a unique identifier. This must be used later in the JavaScript code, too.

      If you want to retrieve the data from an external application, e.g. journalctl, then a log file specification should look like this

      PHP Source Code

      1. <?php
      2. require_once("openmediavault/functions.inc");
      3. // Oct 17 18:19:00 vmomv5 proftpd[17127]: 192.167.178.101 (::ffff:192.168.178.254[::ffff:192.168.178.254]) - USER test: Login successful.
      4. // Oct 17 18:20:00 vmomv5 proftpd: pam_unix(proftpd:session): session closed for user test
      5. \OMV\System\LogFileSpec::registerSpecification("proftpd", [
      6. "command" => "export SYSTEMD_COLORS=0; journalctl --quiet --no-pager ".
      7. "SYSLOG_IDENTIFIER='proftpd' --output=short",
      8. "filename" => "proftpd.log",
      9. "regex" => "/^(\S+\s+\d+\s+\d{2}:\d{2}:\d{2})\s+(\S+)\sproftpd\[\d+\]:\s+(.*)$/",
      10. "columns" => [
      11. "ts" => [
      12. "index" => 1,
      13. "func" => function($v) { return strpdate($v,"M j G:i:s"); }
      14. ],
      15. "date" => [
      16. "index" => 1,
      17. "func" => function($v) {
      18. return strftime("%c", strpdate($v,"M j G:i:s"));
      19. }
      20. ],
      21. "hostname" => 2,
      22. "message" => 3
      23. ]]);
      Display All
      To take your changes into action you simply have to restart the OMV engine.

      Shell-Script

      1. monit restart omv-engined
      During development you should manually start the engine to see if there are any errors. They will be displayed immediatelly.

      Shell-Script

      1. omv-engined -d -f
      More examples for the backend part can be found here.

      To display the log file in the WebUI, you have to add a JavaScript file at /var/www/openmediavault/js/omv/module/admin/diagnostic/log/plugin, e.g. MyLogFile.js.

      Source Code

      1. // require("js/omv/grid/column/WhiteSpace.js")
      2. // require("js/omv/module/admin/diagnostic/log/plugin/Plugin.js")
      3. Ext.define("OMV.module.admin.diagnostic.log.plugin.ftp.Syslog", {
      4. extend: "OMV.module.admin.diagnostic.log.plugin.Plugin",
      5. alias: "omv.plugin.diagnostic.log.ftp.syslog",
      6. requires: [
      7. "OMV.grid.column.WhiteSpace"
      8. ],
      9. id: "proftpd",
      10. text: _("FTP"),
      11. stateful: true,
      12. stateId: "da26708e-9212-11e6-8222-0002b3a176b4",
      13. isLogDeletable: false,
      14. columns: [{
      15. text: _("Date & Time"),
      16. sortable: true,
      17. dataIndex: "rownum",
      18. stateId: "date",
      19. renderer: function(value, metaData, record) {
      20. return record.get("date");
      21. }
      22. },{
      23. text: _("Hostname"),
      24. hidden: true,
      25. sortable: true,
      26. dataIndex: "hostname",
      27. stateId: "hostname"
      28. },{
      29. xtype: "whitespacecolumn",
      30. text: _("Message"),
      31. sortable: true,
      32. dataIndex: "message",
      33. stateId: "message",
      34. flex: 1
      35. }],
      36. rpcParams: {
      37. id: "proftpd"
      38. },
      39. rpcFields: [
      40. { name: "rownum", type: "int" },
      41. { name: "ts", type: "int" },
      42. { name: "date", type: "string" },
      43. { name: "hostname", type: "string" },
      44. { name: "message", type: "string" }
      45. ]
      46. });
      Display All
      The name of the JavaScript class must be unique. By default it is the same name as used in the registerSpecification method above. The same name must be defined for the id and rpcParams.id attributes. The stateId attribute must be an unique UUIDv4. The rpcFields attribue describes the log data that is returned by the RPC. The columns attribute is an array of columns to be displayed. The Sencha ExtJS API can be found here.

      More examples can be found here.
      Absolutely no support through PM!

      I must not fear.
      Fear is the mind-killer.
      Fear is the little-death that brings total obliteration.
      I will face my fear.
      I will permit it to pass over me and through me.
      And when it has gone past I will turn the inner eye to see its path.
      Where the fear has gone there will be nothing.
      Only I will remain.

      Litany against fear by Bene Gesserit