Kiln » KilnSupportScripts Powershell Scripts to help monitor a Kiln environment. Contact Fog Creek support before using.
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

sorting kiln monitoring scripts by version

Changeset 1d21f02417e3

Parent 83bf5d18aa2a

by Profile picture of User 1563Quentin Schroeder <quentin@fogcreek.com>

Changes to 6 files · Browse files at 1d21f02417e3 Showing diff from parent 83bf5d18aa2a Diff from another changeset...

Show Entire File KilnMonitor/​2.7/​README.TXT Stacked
renamed from README.TXT
(No changes)
Show Entire File KilnMonitor/​2.7/​checkBackend.ps1 Stacked
renamed from checkBackend.ps1
(No changes)
Show Entire File KilnMonitor/​2.7/​run-checkBackend.example.ps1 Stacked
renamed from run-checkBackend.example.ps1
(No changes)
Show Entire File KilnMonitor/​2.7/​test-checkBackend.ps1 Stacked
renamed from test-checkBackend.ps1
(No changes)
Show Entire File KilnMonitor/​2.7/​tools.ps1 Stacked
renamed from tools.ps1
(No changes)
Change 1 of 1 Show Entire File KilnMonitor/​2.9/​Monitor-Kiln.ps1 Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
@@ -0,0 +1,72 @@
+#----------------------------------------------------------------------------- +# This script will check that Kiln is running and healthy by hitting a variety of HTTP endpoints +# +# Usage example: +# ./Monitor-Kiln.ps1 -kilnURL "http://localhost/fogbugz/kiln" +# +#----------------------------------------------------------------------------- + + +param([string]$kilnURL = "http://localhost/fogbugz/kiln", + [string]$backendVersionUrl = "http://localhost:56783/version", + [string]$EsUrl = "http://localhost:9200/", + [string]$QueueStatsUrl = "http://localhost:56785/stats.json") + + + +function Write-WithTime($msg){ + write "$(Get-Date -format o) $msg" +} + + +function Test-ProcessRunning($processName, $count = 1) +{ + Write-WithTime "Checking that $count instance(s) of $processName are running..." + $result = (Get-Process $processName -ea SilentlyContinue | select id | measure).count -ge $count + if ($result) { Write-WithTime "Success!" } + else { Write-WithTime "FAILURE!" } +} + + + +function Test-ElasticSearchRunning() +{ + Write-WithTime "Checking that 1 instances(s) of ElasticSearch are running..." + $result = (Get-WmiObject win32_process -Filter "name like 'java.exe'" | select commandline | select-string "ElasticSearch" | measure).count -eq 1 + if ($result) { Write-WithTime "Success!" } + else { Write-WithTime "FAILURE!" } +} + + + +function Test-HttpResponse($url, $searchString) +{ + Write-WithTime "Checking for expected response from URL ($url)..." + + try + { + $response = (New-Object net.webclient).DownloadString($url) + $response = (New-Object net.webclient).DownloadString($url) + $result = $response | select-string $searchString + if ($result) { Write-WithTime "Success!" } + else { Write-WithTime "FAILURE!" } + } + catch [Net.WebException] + { + Write-WithTime $_.Exception.ToString() + } +} + + + +Test-ProcessRunning "backend" +Test-ProcessRunning "redis-server" 2 +Test-ProcessRunning "QueueService" +Test-ElasticSearchRunning + +Test-HttpResponse $kilnURL "Log on to Kiln" +Test-HttpResponse $backendVersionUrl '"hg_version"' +Test-HttpResponse $EsUrl '"status" : 200' +Test-HttpResponse $QueueStatsUrl '"queueName":"Kiln"' + +# TODO: Parse the QueueStats data and alert when poor behavior is detected. Attempt automatic restart? \ No newline at end of file