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
require_once("openmediavault/functions.inc");
\OMV\System\LogFileSpec::registerSpecification("clamav", [
"filename" => "clamav",
"filepath" => "/var/log/clamav/clamav.log",
"regex" => "/^(\S+\s+\S+\s+\d+\s+\S+\s+\d+)\s+->\s+(.*)$/",
"columns" => [
"ts" => [
"index" => 1,
"func" => function($v) { return strpdate($v,"D M j H:i:s Y"); }
],
"date" => [
"index" => 1,
"func" => function($v) {
return strftime("%c", strpdate($v,"D M j H:i:s Y"));
}
],
"message" => 2
]]);
Alles anzeigen
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
require_once("openmediavault/functions.inc");
// 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.
// Oct 17 18:20:00 vmomv5 proftpd: pam_unix(proftpd:session): session closed for user test
\OMV\System\LogFileSpec::registerSpecification("proftpd", [
"command" => "export SYSTEMD_COLORS=0; journalctl --quiet --no-pager ".
"SYSLOG_IDENTIFIER='proftpd' --output=short",
"filename" => "proftpd.log",
"regex" => "/^(\S+\s+\d+\s+\d{2}:\d{2}:\d{2})\s+(\S+)\sproftpd\[\d+\]:\s+(.*)$/",
"columns" => [
"ts" => [
"index" => 1,
"func" => function($v) { return strpdate($v,"M j G:i:s"); }
],
"date" => [
"index" => 1,
"func" => function($v) {
return strftime("%c", strpdate($v,"M j G:i:s"));
}
],
"hostname" => 2,
"message" => 3
]]);
Alles anzeigen
To take your changes into action you simply have to restart the OMV engine.
During development you should manually start the engine to see if there are any errors. They will be displayed immediatelly.
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.
// require("js/omv/grid/column/WhiteSpace.js")
// require("js/omv/module/admin/diagnostic/log/plugin/Plugin.js")
Ext.define("OMV.module.admin.diagnostic.log.plugin.ftp.Syslog", {
extend: "OMV.module.admin.diagnostic.log.plugin.Plugin",
alias: "omv.plugin.diagnostic.log.ftp.syslog",
requires: [
"OMV.grid.column.WhiteSpace"
],
id: "proftpd",
text: _("FTP"),
stateful: true,
stateId: "da26708e-9212-11e6-8222-0002b3a176b4",
isLogDeletable: false,
columns: [{
text: _("Date & Time"),
sortable: true,
dataIndex: "rownum",
stateId: "date",
renderer: function(value, metaData, record) {
return record.get("date");
}
},{
text: _("Hostname"),
hidden: true,
sortable: true,
dataIndex: "hostname",
stateId: "hostname"
},{
xtype: "whitespacecolumn",
text: _("Message"),
sortable: true,
dataIndex: "message",
stateId: "message",
flex: 1
}],
rpcParams: {
id: "proftpd"
},
rpcFields: [
{ name: "rownum", type: "int" },
{ name: "ts", type: "int" },
{ name: "date", type: "string" },
{ name: "hostname", type: "string" },
{ name: "message", type: "string" }
]
});
Alles anzeigen
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.