Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Everyone,
Here you will find a solution to a problem that I have tried to solve this week, and that could be useful in every Qlik infrastructure.
For anyone who has tried to get a global view of the Qlik services states, here is the solution I found.
@marcus_sommer I thought this might interest you
1.
* with "append" option to be able to schedule the script to run at a certain frequency on a day and don't lose the lines created each time.
2.
Below the Powershell Script:
#Define a list of servers $servers = @("xxx-xxx-xxx","xxx-xxx-xxx","xxx-xxx-xxx"...) #Loop on the servers defined above foreach ($server in $servers) { #Get the actual date $getDate = Get-Date #Get the state of all Qlik services $statusQlikviewDirectoryServiceConnector = (get-service "QlikviewDirectoryServiceConnector" -ComputerName $server).Status $statusQlikViewDistributionService = (get-service "QlikViewDistributionService" -ComputerName $server).Status $statusQlikviewManagementService = (get-service "QlikviewManagementService" -ComputerName $server).Status $statusQlikviewServer = (get-service "QlikviewServer" -ComputerName $server).Status $statusQlikViewSettingsService = (get-service "QlikViewSettingsService" -ComputerName $server).Status #Verify if the QlikviewDirectoryServiceConnector is Running if ($statusQlikviewDirectoryServiceConnector -eq "Running") { "$getDate $servers QlikviewDirectoryServiceConnector is up" $vExportQlikviewDirectoryServiceConnector = @{ Date=$getDate Server=$servers Service='QlikviewDirectoryServiceConnector' Status=$statusQlikviewDirectoryServiceConnector } $results = New-Object psobject -Property $vExportQlikviewDirectoryServiceConnector $results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append } else { "$getDate $servers QlikviewDirectoryServiceConnector is down" $vExportQlikviewDirectoryServiceConnector = @{ Date=$getDate Server=$servers Service='QlikviewDirectoryServiceConnector' Status=$statusQlikviewDirectoryServiceConnector } $results = New-Object psobject -Property $vExportQlikviewDirectoryServiceConnector $results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append } #Verify if the Service QlikViewDistributionService is Running if ($statusQlikViewDistributionService -eq "Running") { "$getDate $servers QlikViewDistributionService is up" $vExportQlikViewDistributionService = @{ Date=$getDate Server=$servers Service='QlikViewDistributionService' Status=$statusQlikViewDistributionService } $results = New-Object psobject -Property $vExportQlikViewDistributionService $results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append } else { "$getDate $servers QlikViewDistributionService is down" $vExportQlikViewDistributionService = @{ Date=$getDate Server=$servers Service='QlikViewDistributionService' Status=$statusQlikViewDistributionService } $results = New-Object psobject -Property $vExportQlikViewDistributionService $results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append } #Verify if the service QlikviewManagementService is running if ($statusQlikviewManagementService -eq "Running") { "$getDate $servers QlikviewManagementService is up" $vExportQlikviewManagementService = @{ Date=$getDate Server=$servers Service='QlikviewManagementService' Status=$statusQlikviewManagementService } $results = New-Object psobject -Property $vExportQlikviewManagementService $results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append } else { "$getDate $servers QlikviewManagementService is down" $vExportQlikviewManagementService = @{ Date=$getDate Server=$servers Service='QlikviewManagementService' Status=$statusQlikviewManagementService } $results = New-Object psobject -Property $vExportQlikviewManagementService $results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append } #Verify if the service QlikviewServer is Running if ($statusQlikviewServer -eq "Running") { "$getDate $servers QlikviewServer is up" $vExportQlikviewServer = @{ Date=$getDate Server=$servers Service='QlikviewServer' Status=$statusQlikviewServer } $results = New-Object psobject -Property $vExportQlikviewServer $results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append } else { "$getDate $servers QlikviewServer is down" $vExportQlikviewServer = @{ Date=$getDate Server=$servers Service='QlikviewServer' Status=$statusQlikviewServer } $results = New-Object psobject -Property $vExportQlikviewServer $results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append } #Verify if the service QlikViewSettingsService is running if ($statusQlikViewSettingsService -eq "Running") { "$getDate $servers QlikViewSettingsService is up" $vExportQlikViewSettingsService = @{ Date=$getDate Server=$servers Service='QlikViewSettingsService' Status=$statusQlikViewSettingsService } $results = New-Object psobject -Property $vExportQlikViewSettingsService $results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append } else { "$getDate $servers QlikViewSettingsService is down" $vExportQlikViewSettingsService = @{ Date=$getDate Server=$servers Service='QlikViewSettingsService' Status=$statusQlikViewSettingsService } $results = New-Object psobject -Property $vExportQlikViewSettingsService $results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append } }
Here is the output of the file export using the script above:
"Date","Status","Server","Service"
"06/03/2019 17:22:34","Running","vw-d-rxx-05","QlikviewDirectoryServiceConnector"
"06/03/2019 17:22:34","Running","vw-d-rxx-05","QlikViewDistributionService"
"06/03/2019 17:22:34","Running","vw-d-rxx-05","QlikviewManagementService"
"06/03/2019 17:22:34","Running","vw-d-rxx-05","QlikviewServer"
"06/03/2019 17:22:34","Running","vw-d-rxx-05","QlikViewSettingsService"
If you need more details on how you run all this and get the schedueling done, don't hesitate to leave a comment or send me a direct message.
Have a great day !
Youssef
Great job!
Thank you @marcus_sommer 🙂
Hi,
I am getting error. can we run this file through remote desktop?
Regards,
Khalander
Try to give more details about the error.
With remote desktop, you're connected on the machine on which you need to run the script, so it will work.
the code above need some changes espcially on the the variable $servers and all the -Paths
Also, you'll need to verify that all the services listed on the script above are present and launched on your windows server..
Regards,
Youssef
Hi Youssef,
Thanks for the reply.
I am getting below error.
Export- Csv : Cannot append CSV content to the following file c...Exposrt.csv
Thanks,
Khalander
I forgot to tell you that you also need to change your -Path:
$results | Export-Csv -path C:\Temp\Powershell\Eventlogs.csv -NoTypeInformation -Append
Make sure to create your own Path on a disk on which you have write access
Yes Youssef,
I did the same thing but getting same error. I have changed the path which i have access.
Thanks Youssef, It is working now 🙂
It is really Great script.
@khalander I'm pleased that it is useful for community members 😀
Good luck !