Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MON-155395 CMA native event log #2097

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/scripts/agent_installer_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -337,38 +337,38 @@ $expected = @{ 'endpoint' = '127.0.0.3:4317'; 'host' = 'my_host_name_2'; 'log_ty
test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $exe_args $expected

$exe_args = '/S', '--install_cma', '--hostname', "my_host_name_2", "--endpoint", "127.0.0.4:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma.log", "--log_level", "trace", "--encryption", "--private_key", "C:\Users crypto\private.key", "--public_cert", "D:\tutu\titi.crt", "--ca", "C:\Users\Public\ca.crt", "--ca_name", "tls_ca_name"
$expected = @{ 'endpoint' = '127.0.0.4:4317'; 'host' = 'my_host_name_2'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi.crt'; 'private_key' = 'C:\Users crypto\private.key'; 'ca_certificate' = 'C:\Users\Public\ca.crt'; 'ca_name' = 'tls_ca_name' }
$expected = @{ 'endpoint' = '127.0.0.4:4317'; 'host' = 'my_host_name_2'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'public_cert' = 'D:\tutu\titi.crt'; 'private_key' = 'C:\Users crypto\private.key'; 'ca_certificate' = 'C:\Users\Public\ca.crt'; 'ca_name' = 'tls_ca_name' }
test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $exe_args $expected

$exe_args = '/S', '--install_cma', '--hostname', "my_host_name_2", "--endpoint", "127.0.0.5:4317", "--log_type", "file", "--log_file", "C:\Users\Public\cma_rev.log", "--log_level", "trace", "--encryption", "--reverse", "--private_key", "C:\Users crypto\private_rev.key", "--public_cert", "D:\tutu\titi_rev.crt", "--ca", "C:\Users\Public\ca_rev.crt", "--ca_name", "tls_ca_name_rev"
$expected = @{ 'endpoint' = '127.0.0.5:4317'; 'host' = 'my_host_name_2'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma_rev.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 1; 'certificate' = 'D:\tutu\titi_rev.crt'; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
$expected = @{ 'endpoint' = '127.0.0.5:4317'; 'host' = 'my_host_name_2'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma_rev.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 1; 'public_cert' = 'D:\tutu\titi_rev.crt'; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
test_args_to_registry "agent/installer/centreon-monitoring-agent.exe" $exe_args $expected


Write-Host "############################ modifier test ############################"

$exe_args = '/S', '--hostname', "my_host_name_10", "--endpoint", "127.0.0.10:4317", "--no_reverse"
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma_rev.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev.crt'; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'File'; 'log_level' = 'trace'; 'log_file' = 'C:\Users\Public\cma_rev.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'public_cert' = 'D:\tutu\titi_rev.crt'; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected

$exe_args = '/S', "--log_type", "file", "--log_file", "C:\Users\Public\cma_rev2.log", "--log_level", "debug", "--log_max_file_size", "50", "--log_max_files", "20"
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'File'; 'log_level' = 'debug'; 'log_file' = 'C:\Users\Public\cma_rev2.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev.crt'; 'log_max_file_size' = 50; 'log_max_files' = 20; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'File'; 'log_level' = 'debug'; 'log_file' = 'C:\Users\Public\cma_rev2.log'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'public_cert' = 'D:\tutu\titi_rev.crt'; 'log_max_file_size' = 50; 'log_max_files' = 20; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected

$exe_args = '/S', "--log_type", "event-log", "--log_level", "error"
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev.crt'; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'public_cert' = 'D:\tutu\titi_rev.crt'; 'private_key' = 'C:\Users crypto\private_rev.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected

$exe_args = '/S', "--private_key", "C:\Users crypto\private_rev2.key", "--public_cert", "D:\tutu\titi_rev2.crt"
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev2.crt'; 'private_key' = 'C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'public_cert' = 'D:\tutu\titi_rev2.crt'; 'private_key' = 'C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev.crt'; 'ca_name' = 'tls_ca_name_rev' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected

$exe_args = '/S', "--ca", "C:\Users\Public\ca_rev2.crt", "--ca_name", "tls_ca_name_rev2"
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev2.crt'; 'private_key' = 'C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev2.crt'; 'ca_name' = 'tls_ca_name_rev2' }
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 1; 'reversed_grpc_streaming' = 0; 'public_cert' = 'D:\tutu\titi_rev2.crt'; 'private_key' = 'C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev2.crt'; 'ca_name' = 'tls_ca_name_rev2' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected

$exe_args = '/S', "--no_encryption"
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 0; 'reversed_grpc_streaming' = 0; 'certificate' = 'D:\tutu\titi_rev2.crt'; 'private_key' = 'C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev2.crt'; 'ca_name' = 'tls_ca_name_rev2' }
$expected = @{ 'endpoint' = '127.0.0.10:4317'; 'host' = 'my_host_name_10'; 'log_type' = 'event-log'; 'log_level' = 'error'; 'encryption' = 0; 'reversed_grpc_streaming' = 0; 'public_cert' = 'D:\tutu\titi_rev2.crt'; 'private_key' = 'C:\Users crypto\private_rev2.key'; 'ca_certificate' = 'C:\Users\Public\ca_rev2.crt'; 'ca_name' = 'tls_ca_name_rev2' }
test_args_to_registry "agent/installer/centreon-monitoring-agent-modify.exe" $exe_args $expected


Expand Down
2 changes: 1 addition & 1 deletion agent/bench/create_many_linux_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def create_agent_config_file(host_ip:str, first_agent_index:int):
"log_max_files":3,
"endpoint":"{endpoint}",
"encryption":false,
"certificate":"",
"public_cert":"",
"private_key":"",
"ca_certificate":"",
"ca_name":"",
Expand Down
2 changes: 1 addition & 1 deletion agent/conf/centagent.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"log_max_files":3,
"endpoint":"<poller ip>:4317",
"encryption":false,
"certificate":"",
"public_cert":"",
"private_key":"",
"ca_certificate":"",
"ca_name":"",
Expand Down
Binary file modified agent/conf/centagent.reg
Binary file not shown.
4 changes: 2 additions & 2 deletions agent/installer/dlg_helper.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Function init_encryption_dlg
${OrIf} $0 > 0
${NSD_Check} $hCtl_encryption_EncryptionCheckBox
${EndIf}
ReadRegStr $0 HKLM ${CMA_REG_KEY} "certificate"
ReadRegStr $0 HKLM ${CMA_REG_KEY} "public_cert"
${NSD_SetText} $hCtl_encryption_certificate_file_Txt $0
ReadRegStr $0 HKLM ${CMA_REG_KEY} "private_key"
${NSD_SetText} $hCtl_encryption_private_key_file_Txt $0
Expand Down Expand Up @@ -361,7 +361,7 @@ Function encryption_dlg_onNext
Abort
${EndIf}

WriteRegStr HKLM ${CMA_REG_KEY} "certificate" $1
WriteRegStr HKLM ${CMA_REG_KEY} "public_cert" $1
WriteRegStr HKLM ${CMA_REG_KEY} "private_key" $2
WriteRegStr HKLM ${CMA_REG_KEY} "ca_certificate" $3
${NSD_GetText} $hCtl_encryption_ca_name $1
Expand Down
4 changes: 2 additions & 2 deletions agent/installer/resources/encryption_dlg.nsddef
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Call on_encryptioncheckbox_click</CreateFunctionCustomScript>
<TextBox Name="ca_name" Location="162, 103" Size="193, 20" TabIndex="4" />
<Label Name="label_ca_name" Location="6, 106" Size="140, 17" Text="Certificate Common Name" TabIndex="5" />
<FileRequest Name="ca_file" Location="162, 72" Size="193, 20" TabIndex="6" Filter="*.crt files|*.crt" />
<FileRequest Name="certificate_file" Location="162, 42" Size="193, 20" TabIndex="7" Filter="*.key files|*.key" />
<FileRequest Name="certificate_file" Location="162, 42" Size="193, 20" TabIndex="7" Filter="*.crt files|*.crt" />
<Label Name="label_ca_file" Location="6, 76" Size="150, 16" Text="Trusted CA's certificate file:" TabIndex="8" />
<FileRequest Name="private_key_file" Location="162, 12" Size="193, 20" TabIndex="9" Filter="*.crt files|*.crt" />
<FileRequest Name="private_key_file" Location="162, 12" Size="193, 20" TabIndex="9" Filter="*.key files|*.key" />
<Label Name="label_certificate_file" Location="6, 46" Size="100, 16" Text="Certificate file:" TabIndex="10" />
<Label Name="label_private_key_file" Location="6, 16" Size="100, 16" Text="Private key file:" TabIndex="11" />
</GroupBox>
Expand Down
4 changes: 2 additions & 2 deletions agent/installer/resources/encryption_dlg.nsdinc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Function fnc_hCtl_encryption_certificate_file_Click
Pop $R0
${If} $R0 == $hCtl_encryption_certificate_file_Btn
${NSD_GetText} $hCtl_encryption_certificate_file_Txt $R0
nsDialogs::SelectFileDialog open "$R0" "*.key files|*.key"
nsDialogs::SelectFileDialog open "$R0" "*.crt files|*.crt"
Pop $R0
${If} "$R0" != ""
${NSD_SetText} $hCtl_encryption_certificate_file_Txt "$R0"
Expand All @@ -170,7 +170,7 @@ Function fnc_hCtl_encryption_private_key_file_Click
Pop $R0
${If} $R0 == $hCtl_encryption_private_key_file_Btn
${NSD_GetText} $hCtl_encryption_private_key_file_Txt $R0
nsDialogs::SelectFileDialog open "$R0" "*.crt files|*.crt"
nsDialogs::SelectFileDialog open "$R0" "*.key files|*.key"
Pop $R0
${If} "$R0" != ""
${NSD_SetText} $hCtl_encryption_private_key_file_Txt "$R0"
Expand Down
6 changes: 3 additions & 3 deletions agent/installer/silent.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Function cmd_line_to_registry
Call silent_fatal_error
${EndIf}
${EndIf}
WriteRegStr HKLM ${CMA_REG_KEY} "certificate" $0
WriteRegStr HKLM ${CMA_REG_KEY} "public_cert" $0

StrCpy $0 ""
${GetOptions} $cmdline_parameters "--ca" $0
Expand Down Expand Up @@ -360,7 +360,7 @@ Function silent_update_conf
Strcpy $1 "Bad certificate file path."
Call silent_fatal_error
${EndIf}
WriteRegStr HKLM ${CMA_REG_KEY} "certificate" $0
WriteRegStr HKLM ${CMA_REG_KEY} "public_cert" $0
${EndIf}
${GetOptions} $cmdline_parameters "--ca" $0
${IfNot} ${Errors}
Expand Down Expand Up @@ -396,7 +396,7 @@ Function silent_update_conf
Strcpy $1 "If encryption and poller-initiated connection are active, the private key is mandatory."
Call silent_fatal_error
${EndIf}
ReadRegStr $0 HKLM ${CMA_REG_KEY} "certificate"
ReadRegStr $0 HKLM ${CMA_REG_KEY} "public_cert"
${If} $0 == ""
WriteRegDWORD HKLM ${CMA_REG_KEY} "encryption" 0
Strcpy $1 "If encryption and poller-initiated connection are active, the certificate is mandatory."
Expand Down
Loading