Hello,
I am pretty new to Cacti and have recently deployed it to Ubuntu Server with some Windows Server devices that successfully show graphs of disks, cpu...now I want a little more out of it besides default "templates".
Is there any way to implement powershell scripts into cacti server that would monitor and get data about installed programs and running/not running services that should be running on Windows Servers 2016+.
Upon looking into this I found out that you should place scripts in following folder on ubuntu cacti server:
/var/www/html/cacti/scripts
Example powershell script for installed programs i would like to use (I dropped it into /var/www/html/cacti/scripts/GetInstalledPrograms.ps1):
# PowerShell script to get a list of installed programs on Windows
# Get the list of installed programs
$installedPrograms = Get-WmiObject -Class Win32_Product | Select-Object Name, Version, Vendor
# Output the results in a format suitable for Cacti
foreach ($program in $installedPrograms) {
Write-Output "$program.Name,$program.Version,$program.Vendor"
}
Then i created new Data Input Method With type "Script/command" and input string "/var/www/html/cacti/scripts/GetInstalledPrograms.ps1".
In output fields I Added name ProgramInfo.
Then I created device template WindowsProgramsInfo, that points to internal data source name "ProgramInfo", that I created previosly.
Is this the right approach so far and what steps should i make next so I can see this data next to my graphs in device tree.
Many thanks!
Powershell scripts (Installed programs and running/not running services)
Moderators: Developers, Moderators
Re: Powershell scripts (Installed programs and running/not running services)
From my attempts its not so simple.
The powershell cmdlet get-wmiobject only works on the local instance - So you need to pipe out through Invoke-Command to the remote server. Unfortunately the Ubuntu implementation of PS dosent support Invoke-command. So I used some Python code to connect to the remote WinRM interface.
See viewtopic.php?t=62823 for some work I used to go down this route. It works to collect basic information so should work for anything else if you put sufficient scripting in place.
It might be simpler to start with cacti on a windows server or at least a remote poller on windows but ive not tried that route yet.
Post back if you get anywhere.
The powershell cmdlet get-wmiobject only works on the local instance - So you need to pipe out through Invoke-Command to the remote server. Unfortunately the Ubuntu implementation of PS dosent support Invoke-command. So I used some Python code to connect to the remote WinRM interface.
See viewtopic.php?t=62823 for some work I used to go down this route. It works to collect basic information so should work for anything else if you put sufficient scripting in place.
It might be simpler to start with cacti on a windows server or at least a remote poller on windows but ive not tried that route yet.
Post back if you get anywhere.
Who is online
Users browsing this forum: No registered users and 0 guests