You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.1 KiB
29 lines
1.1 KiB
# install_uf.ps1 - install Splunk Universal forwarder script.
|
|
|
|
Param(
|
|
[string]$HostFile
|
|
)
|
|
|
|
if (!$HostFile) {
|
|
Write-Host '[*] Install Splunk Universal Forwarder on localhost'
|
|
$params = @{ReceivingIndexer=$env:SPLUNK_URL;splunk_home=$env:SPLUNK_HOME;dimensions=$env:DIMENSIONS;log_sources_param=$env:LOG_SOURCES;metrics_param=$env:METRICS;per_cpu=$env:PER_CPU;metrics_index=$env:METRICS_INDEX;receiver_port=$env:RECEIVER_PORT}
|
|
& ".\install_uf_script.ps1" @params
|
|
} else {
|
|
# if $HostFile is not specified, then
|
|
if (!(Test-Path $HostFile)) {
|
|
echo "file: $HostFile does not exist"
|
|
exit(0)
|
|
}
|
|
|
|
# read host list from $HostFile
|
|
[array]$host_list = Get-Content $HostFile
|
|
|
|
# remote execute the installation script
|
|
foreach ($h in $host_list) {
|
|
Write-Host '[*] Install Splunk Universal Forwarder remotely on' $h
|
|
Invoke-Command -FilePath install_uf_script.ps1 -ArgumentList $env:SPLUNK_URL,$env:SPLUNK_HOME,$env:DIMENSIONS,$env:LOG_SOURCES,$env:METRICS,$env:PER_CPU,$env:METRICS_INDEX,$env:RECEIVER_PORT -ComputerName $h
|
|
|
|
Write-Host '[*] ----------------------------------------'
|
|
}
|
|
}
|