microsoft / CSS-Exchange

Exchange Server support tools and scripts
MIT License
1.22k stars 339 forks source link

[Issue] - Health Checker - Running multiple PS instances while running the script against different target servers cause an error. #1554

Open christophemelin opened 1 year ago

christophemelin commented 1 year ago

version 23.01.17.2141 and newer

description : a script can't write in the debug file because the file is in use

context : Expected behavio I have 6 exchange servers on premise. I start the script to scan the 6 servers simultaneuously and it fails because of file in use.

this problem has already been solved by changing next line $Script:Logger = Get-NewLoggerInstance -LogName "HealthChecker-Debug" to $Script:Logger = Get-NewLoggerInstance -LogName "HealthChecker-$($Script:Server)-Debug"

version 22.05.20.1132 to version 22.11.14.1812 were OK

Best regards, Christophe

dpaulson45 commented 1 year ago

@christophemelin Health Checker isn't intended to run multiple instances of the script at the same time on the same machine.

You pass in a list of servers to the script. The current design is working towards making the script multi-threaded, so you don't need to run multiple instances of the script. This also avoids the need to run cmdlets within the script that can take a long time to complete against the organization that are coming into the script like checking on the status of AD replication against the environment.

christophemelin commented 1 year ago

Hi,

Thanks for your answer but i have the latest version of HealthChecker.ps1 and I don’t see any multi-threaded actions. I just see a loop on each server !!!

I have tried a modified version of my .cmd file to pass the list of exchange servers (6 servers) and It took six times longer to execute.

For information, I have found an old mail from Lukas Sassl @.**@.>. See attachment of August 2021) A little change had been made in the script and has been working fine during more than a year. I don't understand why this functional regression since January 2023

Kind regards,

Christophe MELIN Administrateur Messagerie

Ville et Eurométropole de Strasbourg Direction du numérique et systèmes d’information – Service informatique 1 parc de l'Étoile 67076 Strasbourg Cedex

Téléphone : +33 (0)3 68 98 60 52 Poste : 86052

[logo strasbourg.eu]

[logo facebook]https://www.facebook.com/strasbourg.eu[logo twitter]https://twitter.com/strasbourg[logo dailymotion]http://www.dailymotion.com/VilledeStrasbourg

De : David Paulson @.> Envoyé : samedi 11 mars 2023 20:46 À : microsoft/CSS-Exchange @.> Cc : MELIN Christophe @.>; Mention @.> Objet : Re: [microsoft/CSS-Exchange] [Issue] - Health Checker (Issue #1554)

@christophemelinhttps://smex-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fchristophemelin&umid=44c417ea-e14c-4e31-994c-7853ca0bfb2e&auth=998ed01b09b0dc6a471db9f314fb53c7a8bc5a6a-a762f2793116757d77ccb9c14bb074eaf1d16afc Health Checker isn't intended to run multiple instances of the script at the same time on the same machine.

You pass in a list of servers to the script. The current design is working towards making the script multi-threaded, so you don't need to run multiple instances of the script. This also avoids the need to run cmdlets within the script that can take a long time to complete against the organization that are coming into the script like checking on the status of AD replication against the environment.

— Reply to this email directly, view it on GitHubhttps://smex-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fmicrosoft%2fCSS%2dExchange%2fissues%2f1554%23issuecomment%2d1464997090&umid=44c417ea-e14c-4e31-994c-7853ca0bfb2e&auth=998ed01b09b0dc6a471db9f314fb53c7a8bc5a6a-6db8b515389ca6b7495f440aa8cb5919ac366e80, or unsubscribehttps://smex-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fnotifications%2funsubscribe%2dauth%2fATKF34NM3XN666FNGSJLVCTW3TI6LANCNFSM6AAAAAAVXST2RM&umid=44c417ea-e14c-4e31-994c-7853ca0bfb2e&auth=998ed01b09b0dc6a471db9f314fb53c7a8bc5a6a-97490d90bfecd8d70305142b5424979741d82ed8. You are receiving this because you were mentioned.Message ID: @.**@.>>

Ce message est établi à usage exclusif de son destinataire. Toute utilisation ou diffusion, partielle ou totale, doit être préalablement autorisée.

Tout message électronique est susceptible d'altération et son intégrité ne peut être assurée. L'expéditeur décline toute responsabilité au titre de ce message s'il a été modifié ou falsifié.

Si vous n'êtes pas destinataire de ce message, merci de le détruire et d'avertir l'expéditeur.

Ville et Eurométropole de Strasbourg

dpaulson45 commented 1 year ago

As I have provided, we are working towards that design.

dpaulson45 commented 1 year ago

Could be possible fix this issue by including fractions of seconds in the log file name. The execution must be happening so quick that we are having 2 sessions or more with the same second starting.

https://github.com/microsoft/CSS-Exchange/blob/0d4812ee9a713999b3248edfe94650b2ad92d99f/Shared/LoggerFunctions.ps1#L23

((Get-Date).ToString('yyyyMMddHHmmssffff'))

This could work as a workaround till we get to the multithread logic. Before we get to that stage, need to clean up some of the pending work items on Health Checker.

christophemelin commented 1 year ago

Hello,

Thanks for your answer. I have solved my problem by an other way.

When calling get-NewLoggerInstance : $Script:Logger = Get-NewLoggerInstance -LogName "HealthChecker-Debug" -LogDirectory $Script:OutputFilePath -AppendDateTime $false ` -ErrorAction SilentlyContinue

I just add the name of the server : $Script:Logger = Get-NewLoggerInstance -LogName "HealthChecker-$($Script:Server)-Debug" -LogDirectory $Script:OutputFilePath -AppendDateTime $false ` -ErrorAction SilentlyContinue

No risk about date or time, I am sure I have a log file per server. With the filename, I know which log file for which server !

Best regards Christophe MELIN

De : David Paulson @.> Envoyé : jeudi 5 octobre 2023 15:58 À : microsoft/CSS-Exchange @.> Cc : MELIN Christophe @.>; Mention @.> Objet : Re: [microsoft/CSS-Exchange] [Issue] - Health Checker (Issue #1554)

Could be possible fix this issue by including fractions of seconds in the log file name. The execution must be happening so quick that we are having 2 sessions or more with the same second starting.

https://github.com/microsoft/CSS-Exchange/blob/0d4812ee9a713999b3248edfe94650b2ad92d99f/Shared/LoggerFunctions.ps1#L23

((Get-Date).ToString('yyyyMMddHHmmssffff'))

This could work as a workaround till we get to the multithread logic. Before we get to that stage, need to clean up some of the pending work items on Health Checker.

— Reply to this email directly, view it on GitHubhttps://smex-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fmicrosoft%2fCSS%2dExchange%2fissues%2f1554%23issuecomment%2d1748956349&umid=65360379-ccd6-4d5e-8551-28e02d85d8d9&auth=cbd39044f85c1c8f8ba4037b79b35ad2c1cc2486-9846cb225c16ff9f28403aa71595e2877fa06713, or unsubscribehttps://smex-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fnotifications%2funsubscribe%2dauth%2fATKF34PUZ6LOOIBX2QYEKDTX524FRAVCNFSM6AAAAAAVXST2ROVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBYHE2TMMZUHE&umid=65360379-ccd6-4d5e-8551-28e02d85d8d9&auth=cbd39044f85c1c8f8ba4037b79b35ad2c1cc2486-fbe8dcc0f9a7bc9b0aef23c7b99b365e51e9f1e9. You are receiving this because you were mentioned.Message ID: @.**@.>>

Ce message est établi à usage exclusif de son destinataire. Toute utilisation ou diffusion, partielle ou totale, doit être préalablement autorisée.

Tout message électronique est susceptible d'altération et son intégrité ne peut être assurée. L'expéditeur décline toute responsabilité au titre de ce message s'il a été modifié ou falsifié.

Si vous n'êtes pas destinataire de ce message, merci de le détruire et d'avertir l'expéditeur.

Ville et Eurométropole de Strasbourg