Functions from webminlog module
webminlog-lib.pl
This module contains functions for parsing the Webmin actions log file.
foreign_require("webminlog");
my @actions = webminlog::list_webmin_log(undef, "useradmin", undef, undef);
foreach my $a (@actions) {
print webminlog::get_action_description($a),"\n";
}
list_webmin_log([only-user], [only-module], [start-time, end-time])
Returns an array of matching Webmin log events, each of which is a hash ref in the format returned by parse_logline
(see below). By default all actions will be returned, but you can limit it to a subset using by setting the following parameters:
only-user
- Only return actions by this Webmin useronly-module
- Only actions in this modulestart-time
- Limit to actions at or after this Unix timeend-time
- Limit to actions at or before this Unix time
parse_logline(line)
Converts a line of text in the format used in /var/webmin/webmin.log
into a hash ref containing the following keys:
time
- Unix time the action happenedid
- A unique ID for the actionuser
- The Webmin user who did itsid
- The user’s session IDip
- The IP address they were logged in frommodule
- The Webmin module name in which the action was performedscript
- Relative filename of the script that performed the actionaction
- A short action name, like ‘create’type
- The kind of object being operated on, like ‘user’object
- Name of the object being operated on, like ‘joe’params
- A hash ref of additional information about the action
list_diffs(&action)
Returns details of file changes made by this action. Each of which is a hash ref with the keys:
type
- The change type, such as create, modify, delete, exec, sql or killobject
- The file or database the change was made todiff
- A diff of the file change madeinput
- Input to the command run, if available
list_files(&action)
Returns details of original files before this action was taken. Each is a hash ref containing keys:
type
- One of create, modify or deletefile
- Full path to the filedata
- Original file contents, if any
get_annotation(&action)
Returns the text of the log annotation for this action, or undef if none.
save_annotation(&action, text)
Updates the annotation for some action.
expand_base_dir(base)
Finds files either under some dir, or starting with some path in the same directory.
can_user(username)
Returns 1 if the current Webmin user can view log entries for the given user.
can_mod(module)
Returns 1 if the current Webmin user can view log entries for the given module.
get_action(id)
Returns the structure for some action identified by an ID, in the same format as returned by parse_logline
.
build_log_index(&index)
Updates the given hash with mappings between action IDs and file positions. For internal use only really.
get_action_description(&action, [long])
Returns a human-readable description of some action. This is done by calling the log_parser.pl
file in the action’s source module. If the long parameter is set to 1 and the module provides a more detailed description for the action, it will be returned.