Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $failed = $false;
- $loginDuration = (Measure-Command {
- $ncon = New-Object System.Data.SqlClient.SqlConnection `
- @( 'Data Source=1.2.3.4,16143;Database=Test;User=Test;Password=****;Pooling=false;' );
- try
- {
- $ncon.Open();
- $cmd = New-Object System.Data.SqlClient.SqlCommand `
- @( 'SELECT @@VERSION', $ncon );
- $cmd.ExecuteNonQuery();
- $ncon.Dispose();
- }
- catch
- {
- $failed = $true;
- }
- }).TotalMilliseconds;
- Write-Metric -metric 'itp.dbserver.logintime' -unit 'milliseconds' `
- -value (&{if ($failed) { 120000 } else { $loginDuration }});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement