Uliska - Main library for Uliska scanner.

NAME

Uliska - Main library for Uliska scanner.


SYNOPSIS

    use Uliska;
    read_config;
    $ENV{PATH} = $config{path};
    executeList(read_commands('generic', 1)); # 1 - means requried
    executeList(read_commands($result{kernel_name}));
    my $os = Uliska->init($result{kernel_name});


DESCRIPTION

Package Uliska.pm provides functions that are used in main uliska executable script. Additionally function init() is a factory inintializer, it loads specific OS/archtecture etc. modules when required.

EXPORTED FUNCTIONS

    &read_commands
    &executeList
    &read_config
    &init
    &output_result

GLOBAL VARIABLES

    %config
    %result


FUNCTIONS

init

Init a factory module on demand. Module is searched in the ./lib/Uliska directory. If module exists, it's required and instance returned. If module file does not exist, undef is returned.

Loaded module must provide run() function.

Parameter

$module_file

Module PATH starting from $config{lib_dir}/Uliska/. Can include nested subdirectories.

Example

   my $os = Uliska->init($result{kernel_name});
   $os->run() if defined $os;
   my $os = Uliska->init("Linux");
   my $os = Uliska->init("Linux/RedHat");
   my $os = Uliska->init("Linux/RedHat/5");

output_result

Print collected data to file or STDOUT. Function outputs YAML formatted global hash %result;

TODO

read_config

Read script configuration file and override defaults, that are set in the Uliska package.

TODO

executeList

Execute list of commands. Parameter is array with list of commands. Function can be called multiple times during script run: shift array while executing, so that commands not executed twice on successive calls.

read_commands

Read command list from file and push into @commands array. If 2nd parameter $must_exist is not true, simply ignore if commands list file does not exist: make it a responsibility of user to populate lists.

Return array @commands

run

Execute command and populate global hash variable %result.

trim

Strip \n and spaces from string

to_yaml

Take Hash input and convert it to YAML string. Hash key is command or alias, values are arrays of lines of output. Special keys are __COMMANDS__ and __ERRORS__: list of all commands executed by script, and execution errors.

Return YAML formatted string.

to_log

Push log messages to $result{__LOG__}

to_log("Message")

missing

Report missing modules or configuration files.


AUTHOR

Dmytro Kovalov

dmytro.kovalov@gmail.com

Started January 2012

 Uliska - Main library for Uliska scanner.