Skip to content

Commit

Permalink
writer review
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-christophe81 committed Sep 27, 2024
1 parent e5e8d23 commit c6181ad
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 42 deletions.
2 changes: 1 addition & 1 deletion agent/installer/centreon-monitoring-agent-modify.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ${NSISCONF_3}!addplugindir /x86-ansi "nsis_pcre"
#let it after dialog boxes
!include "dlg_helper.nsi"

Name "${APPNAME} ${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}"
Name "Centreon Monitoring Agent ${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}"
Icon "resources/logo_centreon.ico"
RequestExecutionLevel admin
AllowRootDirInstall true
Expand Down
27 changes: 14 additions & 13 deletions agent/installer/centreon-monitoring-agent.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ${Using:StrFunc} StrCase
#let it after dialog boxes
!include "dlg_helper.nsi"

Name "${APPNAME} ${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}"
Name "Centreon Monitoring Agent ${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}"
Icon "resources/logo_centreon.ico"
LicenseData "resources/license.txt"
RequestExecutionLevel admin
Expand Down Expand Up @@ -101,9 +101,8 @@ Function get_plugins_url
Var /GLOBAL json_content_path
Var /GLOBAL nb_assets
GetTempFileName $json_content_path
MessageBox MB_OK $json_content_path
ClearErrors
inetc::get /header "Accept: application/vnd.github+json" ${NSCLIENT_URL} $json_content_path
inetc::get /header "Accept: application/vnd.github+json" ${NSCLIENT_URL} $json_content_path /End
${If} ${Errors}
MessageBox MB_OK|MB_ICONSTOP "Fail to get plugins informations from ${NSCLIENT_URL}"
Abort
Expand All @@ -114,7 +113,6 @@ Function get_plugins_url
Abort
${EndIf}

MessageBox MB_OK $json_content_path

nsJSON::Set /file $json_content_path
${If} ${Errors}
Expand All @@ -126,13 +124,16 @@ Function get_plugins_url
Pop $nb_assets

${ForEach} $0 0 $nb_assets + 1
ClearErrors
nsJSON::Get "assets" /index $0 "name"
Pop $1
${If} $1 == "centreon_plugins.exe"
nsJSON::Get "assets" /index $0 "browser_download_url"
Pop $plugins_url
Return
${EndIf}
${IfNot} ${Errors}
Pop $1
${If} $1 == "centreon_plugins.exe"
nsJSON::Get "assets" /index $0 "browser_download_url"
Pop $plugins_url
Return
${EndIf}
${EndIf}
${Next}

MessageBox MB_OK|MB_ICONSTOP "No Plugins Asset found at ${NSCLIENT_URL}"
Expand All @@ -144,7 +145,7 @@ Section "Plugins"
Call get_plugins_url
CreateDirectory ${PLUGINS_DIR}
DetailPrint "download plugins from $plugins_url"
inetc::get /caption "plugins" /banner "plugins download" "$plugins_url" "${PLUGINS_DIR}/centreon_plugins.exe"
inetc::get /caption "plugins" /banner "Downloading plugins..." "$plugins_url" "${PLUGINS_DIR}/centreon_plugins.exe"
SectionEnd


Expand Down Expand Up @@ -245,11 +246,11 @@ function un.onInit
!insertmacro VerifyUserIsAdmin


MessageBox MB_YESNO "Do you want to remove centreon plugins?" IDNO no_plugins_remove
MessageBox MB_YESNO "Do you want to remove the Centreon plugins for the agents?" IDNO no_plugins_remove
rmDir ${PLUGINS_DIR}
no_plugins_remove:

MessageBox MB_YESNO "Do you want to remove Centreon Monitoring Agent?" IDYES no_cma_remove
MessageBox MB_YESNO "Do you want to remove the Centreon Monitoring Agent?" IDYES no_cma_remove
Abort
no_cma_remove:

Expand Down
44 changes: 28 additions & 16 deletions agent/installer/dlg_helper.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ FunctionEnd
Function setup_dlg_onNext
Push $0
Push $1
Var /GLOBAL reversed_checked
${NSD_GetState} $hCtl_cma_reverse $reversed_checked

SetRegView 64
${NSD_GetText} $hCtl_cma_host_name $0
${If} $0 == ""
Expand All @@ -58,7 +61,11 @@ Function setup_dlg_onNext

${NSD_GetText} $hCtl_cma_endpoint $1
${If} $1 !~ "[a-zA-Z0-9\.\-_]+:[0-9]+"
MessageBox MB_OK|MB_ICONSTOP "Endpoint must be as <IP or dns name>:<numerical port> and you have enter $1"
${If} $reversed_checked == ${BST_CHECKED}
MessageBox MB_OK|MB_ICONSTOP "The correct format for the listening interface is <IP or DNS name>:<port>."
${Else}
MessageBox MB_OK|MB_ICONSTOP "The correct format for the endpoint is <IP or DNS name>:<port>."
${EndIf}
Pop $1
Pop $0
Abort
Expand All @@ -67,8 +74,7 @@ Function setup_dlg_onNext
WriteRegStr HKLM ${CMA_REG_KEY} "host" "$0"
WriteRegStr HKLM ${CMA_REG_KEY} "endpoint" "$1"

${NSD_GetState} $hCtl_cma_reverse $0
${If} $0 == ${BST_CHECKED}
${If} $reversed_checked == ${BST_CHECKED}
WriteRegDWORD HKLM ${CMA_REG_KEY} "reversed_grpc_streaming" 1
${Else}
WriteRegDWORD HKLM ${CMA_REG_KEY} "reversed_grpc_streaming" 0
Expand All @@ -91,16 +97,22 @@ Function reverse_onClick
FunctionEnd

Function hostname_help_onClick
MessageBox MB_ICONINFORMATION "The host name as declared in Centreon, which will be associated to metrics sent by the agent"
MessageBox MB_ICONINFORMATION "This is the name of the host as defined in the Centreon interface."
FunctionEnd

Function endpoint_help_onClick
MessageBox MB_ICONINFORMATION "The endpoint is the IP address and port on which the opentelemetry server of the poller listens.\
In reverse mode (poller connects to agent), it is the interface (or 0.0.0.0) and the port on which the agent listens."
Push $0
${NSD_GetState} $hCtl_cma_reverse $0
${If} $0 == ${BST_CHECKED}
MessageBox MB_ICONINFORMATION "Interface and port on which the agent will accept connections from the poller. 0.0.0.0 means all interfaces."
${Else}
MessageBox MB_ICONINFORMATION "IP address of DNS name of the poller the agent will connect to."
${EndIf}
Pop $0
FunctionEnd

Function reverse_help_onClick
MessageBox MB_ICONINFORMATION "Used when the agent cannot connect to the poller. If active, the agent is the server and the poller is the client."
MessageBox MB_ICONINFORMATION "Use when the agent cannot connect to the poller directly: the poller will then initiate the connection."
FunctionEnd


Expand Down Expand Up @@ -210,11 +222,11 @@ FunctionEnd


Function max_files_help_onClick
MessageBox MB_ICONINFORMATION "For the rotation of logs to be active, it is necessary that both parameters 'Max File Size' and 'Max Files' are set. The space used by the logs of the agent will not exceed 'Max File Size' * 'Max Files'"
MessageBox MB_ICONINFORMATION "For the rotation of logs to be active, it is necessary that both parameters 'Max File Size' and 'Max number of files' are set. The space used by the logs of the agent will not exceed 'Max File Size' * 'Max Files'."
FunctionEnd

Function max_file_size_help_onClick
MessageBox MB_ICONINFORMATION "For the rotation of logs to be active, it is necessary that both parameters 'Max File Size' and 'Max Files' are set. The space used by the logs of the agent will not exceed 'Max File Size' * 'Max Files'"
MessageBox MB_ICONINFORMATION "For the rotation of logs to be active, it is necessary that both parameters 'Max File Size' and 'Max number of files' are set. The space used by the logs of the agent will not exceed 'Max File Size' * 'Max Files'."
FunctionEnd

Function init_encryption_dlg
Expand Down Expand Up @@ -257,14 +269,14 @@ Function encryption_dlg_onNext
${NSD_GetText} $hCtl_encryption_certificate_file_Txt $1
${If} $1 == ""
${If} $reverse_connection > 0
MessageBox MB_OK|MB_ICONSTOP "In case of reverse connection, certificate file is mandatory"
MessageBox MB_OK|MB_ICONSTOP "If encryption and poller-initiated connection are active, the certificate is mandatory."
Pop $1
Pop $0
Abort
${EndIf}
${Else}
${If} $1 !~ $0
MessageBox MB_OK|MB_ICONSTOP "Bad certificate file path"
MessageBox MB_OK|MB_ICONSTOP "Bad certificate file path."
Pop $1
Pop $0
Abort
Expand All @@ -274,15 +286,15 @@ Function encryption_dlg_onNext
${NSD_GetText} $hCtl_encryption_private_key_file_Txt $2
${If} $2 == ""
${If} $reverse_connection > 0
MessageBox MB_OK|MB_ICONSTOP "In case of reverse connection, private key file is mandatory"
MessageBox MB_OK|MB_ICONSTOP "If encryption and poller-initiated connection are active, The private key is mandatory."
Pop $2
Pop $1
Pop $0
Abort
${EndIf}
${Else}
${If} $2 !~ $0
MessageBox MB_OK|MB_ICONSTOP "Bad private key file path"
MessageBox MB_OK|MB_ICONSTOP "Bad private key file path."
Pop $2
Pop $1
Pop $0
Expand All @@ -293,7 +305,7 @@ Function encryption_dlg_onNext
${NSD_GetText} $hCtl_encryption_ca_file_Txt $3
${If} $3 != ""
${AndIf} $3 !~ $0
MessageBox MB_OK|MB_ICONSTOP "Bad ca file path"
MessageBox MB_OK|MB_ICONSTOP "Bad CA file path."
Pop $3
Pop $2
Pop $1
Expand Down Expand Up @@ -361,11 +373,11 @@ FunctionEnd


Function private_key_file_help_onClick
MessageBox MB_ICONINFORMATION "Private key file path. Mandatory in case of reverse connection (poller to agent)"
MessageBox MB_ICONINFORMATION "Private key file path. Mandatory in case of reverse connection (poller to agent)."
FunctionEnd

Function certificate_file_help_onClick
MessageBox MB_ICONINFORMATION "Public certificate file path. Mandatory in case of reverse connection (poller to agent)"
MessageBox MB_ICONINFORMATION "Public certificate file path. Mandatory in case of reverse connection (poller to agent)."
FunctionEnd

Function ca_file_help_onClick
Expand Down
2 changes: 1 addition & 1 deletion agent/installer/resources/encryption_dlg.nsddef
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Call on_encryptioncheckbox_click</CreateFunctionCustomScript>
<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" />
<Label Name="label_ca_file" Location="6, 76" Size="150, 16" Text="Trusted CA's certificate file:" TabIndex="8" />
<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" />
<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" />
Expand Down
2 changes: 1 addition & 1 deletion agent/installer/resources/encryption_dlg.nsdinc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Function fnc_encryption_Create
${NSD_OnClick} $hCtl_encryption_certificate_file_Btn fnc_hCtl_encryption_certificate_file_Click

; === label_ca_file (type: Label) ===
${NSD_CreateLabel} 12u 67u 99u 10u "Trusted CA's certificate file:"
${NSD_CreateLabel} 12u 67u 99u 10u "Trusted CA's certificate file:"
Pop $hCtl_encryption_label_ca_file

; === private_key_file_Txt (type: Text) ===
Expand Down
2 changes: 1 addition & 1 deletion agent/installer/resources/log_dlg.nsddef
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Call on_log_type_changed</CreateFunctionCustomScript>
<GroupBox Name="file_group" Location="12, 57" Size="388, 102" Text="Log File" TabIndex="0">
<Bitmap Name="max_files_help" Location="270, 67" Size="18, 18" ImageFilename="resources\info.bmp" TabIndex="0" onClick="max_files_help_onClick" />
<Bitmap Name="max_file_size_help" Location="270, 42" Size="18, 18" ImageFilename="resources\info.bmp" TabIndex="1" onClick="max_file_size_help_onClick" />
<Label Name="label_max_files" Location="8, 69" Size="100, 16" Text="Max Files:" TabIndex="2" />
<Label Name="label_max_files" Location="8, 69" Size="111, 16" Text="Max number of files:" TabIndex="2" />
<FileRequest Name="log_file" Location="122, 14" Size="260, 20" TabIndex="3" DialogMode="save" Filter=".log files|*.log" />
<Label Name="label_max_file_size" Location="8, 42" Size="111, 18" Text="Max File Size (Mo):" TabIndex="4" />
<Number Name="max_file_size" Location="122, 40" Size="142, 20" TabIndex="5" />
Expand Down
2 changes: 1 addition & 1 deletion agent/installer/resources/log_dlg.nsdinc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Function fnc_log_dlg_Create
${NSD_SetImage} $hCtl_log_dlg_max_file_size_help "$PLUGINSDIR\info.bmp" $hCtl_log_dlg_max_file_size_help_hImage

; === label_max_files (type: Label) ===
${NSD_CreateLabel} 13u 78u 66u 10u "Max Files:"
${NSD_CreateLabel} 13u 78u 73u 10u "Max number of files:"
Pop $hCtl_log_dlg_label_max_files

; === log_file_Txt (type: Text) ===
Expand Down
8 changes: 4 additions & 4 deletions agent/installer/resources/setup_dlg.nsddef
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Do not edit manually!
<Bitmap Name="endpoint_help" Location="323, 31" Size="18, 18" ImageFilename="resources\info.bmp" TabIndex="1" onClick="endpoint_help_onClick" />
<Bitmap Name="hostname_help" Location="323, 4" Size="18, 18" ImageFilename="resources\info.bmp" TabIndex="2" onClick="hostname_help_onClick" />
<Label Name="endpoint_label" Location="12, 33" Size="99, 16" Text="Poller endpoint:" Font="Microsoft Sans Serif, 8.25pt" TabIndex="3" />
<TextBox Name="host_name" Location="117, 2" Size="200, 20" TabIndex="4" />
<TextBox Name="endpoint" Location="117, 29" Size="200, 20" TabIndex="5" />
<CheckBox Name="reverse" Location="12, 69" Size="156, 24" Text="Reverse GRPC streaming" TabIndex="6" onClick="reverse_onClick" />
<Label Name="Label15" Location="12, 5" Size="79, 20" Text="Host name:" Font="Microsoft Sans Serif, 8.25pt" TabIndex="7" />
<TextBox Name="host_name" Location="129, 2" Size="188, 20" TabIndex="4" />
<TextBox Name="endpoint" Location="129, 29" Size="188, 20" TabIndex="5" />
<CheckBox Name="reverse" Location="12, 69" Size="156, 24" Text="Poller-initiated connection" TabIndex="6" onClick="reverse_onClick" />
<Label Name="Label15" Location="12, 5" Size="128, 20" Text="Host name in Centron:" Font="Microsoft Sans Serif, 8.25pt" TabIndex="7" />
</Dialog>
8 changes: 4 additions & 4 deletions agent/installer/resources/setup_dlg.nsdinc
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ Function fnc_cma_Create
Pop $hCtl_cma_endpoint_label

; === host_name (type: Text) ===
${NSD_CreateText} 77u 1u 132u 12u ""
${NSD_CreateText} 85u 1u 124u 12u ""
Pop $hCtl_cma_host_name

; === endpoint (type: Text) ===
${NSD_CreateText} 77u 18u 132u 12u ""
${NSD_CreateText} 85u 18u 124u 12u ""
Pop $hCtl_cma_endpoint

; === reverse (type: Checkbox) ===
${NSD_CreateCheckbox} 8u 42u 103u 15u "Reverse GRPC streaming"
${NSD_CreateCheckbox} 8u 42u 103u 15u "Poller-initiated connection"
Pop $hCtl_cma_reverse
${NSD_OnClick} $hCtl_cma_reverse reverse_onClick

; === Label15 (type: Label) ===
${NSD_CreateLabel} 8u 3u 52u 12u "Host name:"
${NSD_CreateLabel} 8u 3u 84u 12u "Host name in Centron:"
Pop $hCtl_cma_Label15

; CreateFunctionCustomScript
Expand Down

0 comments on commit c6181ad

Please sign in to comment.