mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-25 18:59:12 +02:00
Implemented support to user user or group configured logstream sources in commandline report generator
This commit is contained in:
parent
2b59c7db1f
commit
c64bcce98c
@ -1299,10 +1299,19 @@ function InitOutputtargetDefinitions($myReport, $outputTargetDetails)
|
|||||||
|
|
||||||
function CreateCronCommand( $myReportID, $mySavedReportID = null )
|
function CreateCronCommand( $myReportID, $mySavedReportID = null )
|
||||||
{
|
{
|
||||||
global $content, $gl_root_path;
|
global $content, $gl_root_path, $myReport;
|
||||||
|
|
||||||
if ( isset($mySavedReportID) )
|
if ( isset($mySavedReportID) )
|
||||||
{
|
{
|
||||||
|
// Get Reference to report!
|
||||||
|
$myReport = $content['REPORTS'][ $myReportID ];
|
||||||
|
|
||||||
|
// Get reference to savedreport
|
||||||
|
$mySavedReport = $myReport['SAVEDREPORTS'][ $mySavedReportID ];
|
||||||
|
|
||||||
|
// Get configured Source for savedreport
|
||||||
|
$myReportSource = $content['Sources'][ $mySavedReport['sourceid'] ];
|
||||||
|
|
||||||
$pos = strpos( strtoupper(PHP_OS), "WIN");
|
$pos = strpos( strtoupper(PHP_OS), "WIN");
|
||||||
if ($pos !== false)
|
if ($pos !== false)
|
||||||
{
|
{
|
||||||
@ -1320,6 +1329,17 @@ function CreateCronCommand( $myReportID, $mySavedReportID = null )
|
|||||||
// Enable display of report command
|
// Enable display of report command
|
||||||
$content['enableCronCommand'] = true;
|
$content['enableCronCommand'] = true;
|
||||||
$szCommand = $phpCmd . " " . $phpScript . " runreport " . $myReportID . " " . $mySavedReportID;
|
$szCommand = $phpCmd . " " . $phpScript . " runreport " . $myReportID . " " . $mySavedReportID;
|
||||||
|
|
||||||
|
// --- Check for user or group sources
|
||||||
|
if ( $myReportSource['userid'] != null )
|
||||||
|
{
|
||||||
|
$szCommand .= " " . "userid=" . $myReportSource['userid'];
|
||||||
|
}
|
||||||
|
else if ( $myReportSource['groupid'] != null )
|
||||||
|
{
|
||||||
|
$szCommand .= " " . "groupid=" . $myReportSource['userid'];
|
||||||
|
}
|
||||||
|
// ---
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -72,8 +72,8 @@ include_once($gl_root_path . 'classes/logstream.class.php');
|
|||||||
define('IN_PHPLOGCON_COMMANDLINE', true);
|
define('IN_PHPLOGCON_COMMANDLINE', true);
|
||||||
$content['IN_PHPLOGCON_COMMANDLINE'] = true;
|
$content['IN_PHPLOGCON_COMMANDLINE'] = true;
|
||||||
InitPhpLogCon();
|
InitPhpLogCon();
|
||||||
InitSourceConfigs();
|
|
||||||
InitFilterHelpers(); // Helpers for frontend filtering!
|
InitFilterHelpers(); // Helpers for frontend filtering!
|
||||||
|
InitSourceConfigs();
|
||||||
|
|
||||||
// Firts of all init List of Reports!
|
// Firts of all init List of Reports!
|
||||||
InitReportModules();
|
InitReportModules();
|
||||||
@ -107,7 +107,7 @@ function RunReport()
|
|||||||
if ( $res != SUCCESS )
|
if ( $res != SUCCESS )
|
||||||
{
|
{
|
||||||
// Print error and die!
|
// Print error and die!
|
||||||
$szError = GetAndReplaceLangStr( $content['LN_REPORTS_ERROR_ERRORCHECKINGSOURCE'], GetAndReplaceLangStr( GetErrorMessage($res), $mySavedReport['sourceid']) );
|
$szError = GetAndReplaceLangStr( $content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetAndReplaceLangStr( GetErrorMessage($res), $mySavedReport['sourceid']) );
|
||||||
if ( isset($extraErrorDescription) )
|
if ( isset($extraErrorDescription) )
|
||||||
$szError .= "<br><br>" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
|
$szError .= "<br><br>" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
|
||||||
DieWithErrorMsg( $szError );
|
DieWithErrorMsg( $szError );
|
||||||
@ -206,6 +206,34 @@ function RunReport()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
DieWithErrorMsg( $content["LN_CMD_NOSAVEDREPORTID"] );
|
DieWithErrorMsg( $content["LN_CMD_NOSAVEDREPORTID"] );
|
||||||
|
|
||||||
|
// Run Optional Params first: userid/groupid
|
||||||
|
if ( isset($_SERVER["argv"][4]) )
|
||||||
|
{
|
||||||
|
// Set to SourceID property!
|
||||||
|
$tmpvar = $_SERVER["argv"][4];
|
||||||
|
|
||||||
|
if ( strpos($tmpvar, "=") !== false )
|
||||||
|
{
|
||||||
|
$tmparr = explode("=", $tmpvar);
|
||||||
|
if ( $tmparr[0] == "userid" )
|
||||||
|
{
|
||||||
|
$userid = $tmparr[1];
|
||||||
|
$_SESSION['SESSION_LOGGEDIN'] = true;
|
||||||
|
$_SESSION['SESSION_USERID'] = $userid;
|
||||||
|
$content['SESSION_LOGGEDIN'] = true;
|
||||||
|
$content['SESSION_USERID'] = $userid;
|
||||||
|
}
|
||||||
|
else if ( $tmparr[0] == "groupid" )
|
||||||
|
{
|
||||||
|
$groupid = $tmparr[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reload Configured Sources
|
||||||
|
LoadSourcesFromDatabase();
|
||||||
|
InitSourceConfigs();
|
||||||
|
}
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
// --- Operation Handling now
|
// --- Operation Handling now
|
||||||
|
@ -985,7 +985,7 @@ function LoadSourcesFromDatabase()
|
|||||||
$myrows = DB_GetAllRows($result, true);
|
$myrows = DB_GetAllRows($result, true);
|
||||||
if ( isset($myrows) && count($myrows) > 0 )
|
if ( isset($myrows) && count($myrows) > 0 )
|
||||||
{
|
{
|
||||||
// Overwrite existing Views array
|
// Overwrite existing Sources array
|
||||||
unset($CFG['Sources']);
|
unset($CFG['Sources']);
|
||||||
|
|
||||||
// Append to Source Array
|
// Append to Source Array
|
||||||
|
Loading…
x
Reference in New Issue
Block a user