Adding new option log_module

This commit is contained in:
alejandro 2022-04-21 10:31:20 +02:00
parent 73bee44d93
commit 8845e37447

View File

@ -469,15 +469,21 @@ sub parse_log ($$$$$$$$) {
# Go to starting position # Go to starting position
seek(LOGFILE, $Idx_pos, 0); seek(LOGFILE, $Idx_pos, 0);
$buffer .= "<module>\n"; if ($type eq "log_module"){
$buffer .= "<name><![CDATA[" . $Module_name . "]]></name>\n"; $buffer = "<log_module>\n";
$buffer .= "<description><![CDATA[" . $Description . "]]></description>\n"; $buffer .= "<source><![CDATA[" . $Module_name . "]]></source>\n";
$buffer .= "<data><![CDATA[";
if ($type eq "return_ocurrences"){
$buffer .= "<type>generic_data</type>\n";
} else { } else {
$buffer .= "<type><![CDATA[async_string]]></type>\n"; $buffer .= "<module>\n";
$buffer .= "<datalist>\n"; $buffer .= "<name><![CDATA[" . $Module_name . "]]></name>\n";
$buffer .= "<description><![CDATA[" . $Description . "]]></description>\n";
if ($type eq "return_ocurrences"){
$buffer .= "<type>generic_data</type>\n";
} else {
$buffer .= "<type><![CDATA[async_string]]></type>\n";
$buffer .= "<datalist>\n";
}
} }
while ($line = <LOGFILE>) { while ($line = <LOGFILE>) {
@ -503,6 +509,11 @@ sub parse_log ($$$$$$$$) {
$buffer .= "<data><value><![CDATA[".$line."]]></value></data>\n"; $buffer .= "<data><value><![CDATA[".$line."]]></value></data>\n";
} }
if ($type eq "log_module") {
$line =~ s/\]\]/]]]]><![CDATA[/g;
$buffer .= $line."\n";
}
# Critical severity will prevail over other matches # Critical severity will prevail over other matches
if ($severity eq ""){ if ($severity eq ""){
$severity = $value->{"severity"}; $severity = $value->{"severity"};
@ -515,11 +526,12 @@ sub parse_log ($$$$$$$$) {
} }
} }
} }
if ($type ne "log_module"){
if ($type eq "return_ocurrences"){ if ($type eq "return_ocurrences"){
$buffer .= "<data><![CDATA[".$count."]]></data>\n"; $buffer .= "<data><![CDATA[".$count."]]></data>\n";
} else { } else {
$buffer .= "</datalist>\n"; $buffer .= "</datalist>\n";
}
} }
# Execute action if any match (always for last match) # Execute action if any match (always for last match)
@ -527,13 +539,18 @@ sub parse_log ($$$$$$$$) {
`$action`; `$action`;
} }
# Write severity field in XML if ($type ne "log_module"){
if ($severity ne ""){ # Write severity field in XML
$buffer .= "<status>$severity</status>\n"; if ($severity ne ""){
} $buffer .= "<status>$severity</status>\n";
}
# End XML # End XML
$buffer .= "</module>\n"; $buffer .= "</module>\n";
}else {
$buffer .= "]]></data>\n";
$buffer .= "</log_module>\n";
}
# Update Index # Update Index
$Idx_pos = tell(LOGFILE); $Idx_pos = tell(LOGFILE);
@ -746,4 +763,4 @@ while (my ($key, $value) = each (@{$plugin_setup{"log"}})) {
print "\n"; print "\n";
} }