Exception errors - Icinga2-PowerShell Module

I have been trying to install the windows Icinga2Agent with PowerShell Module… I am getting the below error messages… Can someone please help me on these exception errors?

Warning: The function “installIcinga2Agent” is deprecated and will be removed soon. Please use “install” instead.
Notice: Started script run…
Notice: Trying to fetch Host IP-Address for hostname: ***********************************
Notice: Setting IP ############# as primary IP for this host for all requests. Access it with &ipaddress& for all JSON requests.
Notice: Using Icinga version “”, setting certificate directory to “C:\ProgramData\icinga2\etc\icinga2\pki”
Warning: Icinga 2 Agent does not seem to be installed on the system
Notice: Downloading Icinga 2 Agent Binary from “https://packages.icinga.com/windows/Icinga2-v2.4.9-x86_64.msi
Warning: Icinga 2 Agent Installer verification disabled.
Notice: Installing Icinga 2 Agent
Fatal: Exception calling “installAgent” with “0” argument(s): “Exception calling “startProcess” with “3” argument(s): “Exception calling “Start” with “0” argument(s): “The system cannot find the file specified”””
######## The script encountered several errors during run ########
Fatal: Exception calling “installAgent” with “0” argument(s): “Exception calling “startProcess” with “3” argument(s): “Exception calling “Start” with “0” argument(s): “The system cannot find the file specified”””
1

You’re using a pretty old agent binary, have you ever tried a more recent version?

1 Like

Roland - Many thanks for your response.

Unfortunately No luck… Same issue again. I have tried with 2.10.5…

PS C:\Users\Mani.Vajrala\Desktop> & ‘.\New Text Document.ps1’

Warning: The function “installIcinga2Agent” is deprecated and will be removed soon. Please use “install” instead.
Notice: Started script run…
Notice: Trying to fetch Host IP-Address for hostname: dev-dfs-01.NICHOLASANDCO.AWS
Notice: Setting IP 172.25.13.145 as primary IP for this host for all requests. Access it with &ipaddress& for all JSON requests.
Notice: Using Icinga version “”, setting certificate directory to “C:\ProgramData\icinga2\etc\icinga2\pki”
Warning: Icinga 2 Agent does not seem to be installed on the system
Notice: Downloading Icinga 2 Agent Binary from “https://packages.icinga.com/windows/Icinga2-v2.10.5-x86_64.msi
Warning: Icinga 2 Agent Installer verification disabled.
Notice: Installing Icinga 2 Agent
Fatal: Exception calling “installAgent” with “0” argument(s): “Exception calling “startProcess” with “3” argument(s): “Exception calling “Start” with “0” argument(s): “The system cannot find the file specified”””
######## The script encountered several errors during run ########
Fatal: Exception calling “installAgent” with “0” argument(s): “Exception calling “startProcess” with “3” argument(s): “Exception calling “Start” with “0” argument(s): “The system cannot find the file specified”””

Really struggling with the issue… Can you please help me on this?

Can you share your calling function? I’d recommend to enable debug to see if there are more hints.

Do you have any AntiVirus Software running on that machine?

1 Like

Roland - Thanks for your response… Currently Antivirus not installed & i have disabled the firewall as well… Still facing the same issue… Here the Code & I am running the Powershell in admin modePowerShellModule.txt (158.6 KB)

Here attached PowerShell Script…

Ah, your handling is wrong. You see the correct syntax at the beginning of that script. It’s important to exit that module and have the parameter -RunInstaller included. In general you need only three lines and you’ll find them at your host template in the director. E.g. you don’t need the version and 2.8.4 is not ok anyway.

1 Like

Awesome… This is working… I had made those changes & on Icinga2 Director kickstart script…

One more question… i have posted in another topic

In our environment, we are running Icinga2 Master in Ubuntu 18.04 & All remote boxes are windows workshop…We don’t have any satellites & Just using Master-Client configurations.
Usually to generate the pki ticket i do run manually on Icinga2 master for every remote server to install agent. But I have been trying to understand how do i use the existing powershell module or any script/way on windows box to request from Icinga2 Server for the Pki ticket for Agent installation? So that i can pass the ticket number to Agent MSI file.

If you have any idea & can you please help me on this?

You’re looking for Self-Service-API. Just follow these instructions and then you’ll have only to steps for every new windows machine:

  1. run the powershell module
  2. deploy (newly created hosts objects)
1 Like

Powershellmodule_ps.txt.txt (158.6 KB)

Thanks Roland Sommer… Coming back again…
Here, attached my powershell module. After i ran the poweshell script somehow i am not able to see the pki tickets on remote box under C:\ProgramData\icinga2\etc\icinga2\pki …

Anything wrong with the below output… After I ran the powershell script, icinga2 able to get installed & but icinga2 master pickup the stuff… I have provided correct pki ticket & servername on powershell script…
Can you please review the below script & let me know if anything is not happending correctly during icinga2 master install

PS C:\Users\Mani.Vajrala\Desktop> .\powershellmod.ps1
Notice: Started script run…
Notice: Trying to fetch Host IP-Address for hostname: dev-pnm-01.NICHOLASANDCO.AWS
Notice: Setting IP 172.25.13.114 as primary IP for this host for all requests. Access it with &ipaddress& for all JSON r
equests.
Notice: Using Icinga version “”, setting certificate directory to “C:\ProgramData\icinga2\etc\icinga2\pki”
Warning: Icinga 2 Agent does not seem to be installed on the system
Notice: Downloading Icinga 2 Agent Binary from “https://packages.icinga.com/windows/Icinga2-v2.10.5-x86_64.msi
Warning: Icinga 2 Agent Installer verification disabled.
Notice: Installing Icinga 2 Agent
Notice: Icinga 2 Agent installed.
Notice: Using Icinga version “2.10.5”, setting certificate directory to “C:\ProgramData\icinga2\var\lib\icinga2\certs”
Notice: Found Icinga 2 Agent version 2.10.5 installed at “C:\Program Files\ICINGA2”
Notice: Removing downloaded Icinga 2 Agent installer
Notice: Generating Host certificates required by Icinga 2
Notice: information/base: Writing private key to 'C:\ProgramData\icinga2\var\lib\icinga2\certs<server-namewithfdqn>.key
information/base: Writing X509 certificate to ‘C:\ProgramData\icinga2\var\lib\icinga2\certs<server-namewithfdqn>
.crt’.
Notice: Storing Icinga 2 certificates
Notice: information/cli: Retrieving X.509 certificate for ‘:5665’.

Subject: CN = server-namewithfdqn
Issuer: CN = Icinga CA
Valid From: Aug 27 19:08:36 2019 GMT
Valid Until: Aug 23 19:08:36 2034 GMT
Fingerprint: 3D D2 69 6E DE ED 39 81 9D 05 70 F7 51 9B 6E EA 7B 37 E7 F4


*** You have to ensure that this certificate actually matches the parent
*** instance’s certificate in order to avoid man-in-the-middle attacks.


information/pki: Writing certificate to file ‘C:\ProgramData\icinga2\var\lib\icinga2\certs\trusted-master.crt’.
Notice: Certificate fingerprint: “3DD2696EDEED39819D0570F7519B6EEA7B37E7F4”
Warning: CA fingerprint validation disabled
Notice: Requesting Icinga 2 certificates
Notice: information/cli: Writing CA certificate to file ‘C:\ProgramData\icinga2\var\lib\icinga2\certs\ca.crt’.
information/cli: Writing signed certificate to file ‘C:\ProgramData\icinga2\var\lib\icinga2\certs\dev-pnm-01.NICHOLASAND
CO.AWS.crt’.
Notice: Icinga 2 configuration backup successfull
Notice: Writing icinga2.conf to “C:\ProgramData\icinga2\etc\icinga2”
Notice: Icinga 2 configuration check successfull.
Notice: Trying to disable debug log for Icinga 2…
Notice: Icinga 2 debug log is not enabled or configuration not found
Notice: Trying to enable logging for Icinga 2…
Notice: Icinga 2 logging is already enabled or configuration not found
Warning: Icinga 2 Agent Firewall Rule will not be installed.
Notice: NSClient++ will not be installed on the system.
Notice: Restarting service icinga2
Notice: Icinga 2 Agent successfully restarted.

Assuming DEV-ICINGA2-01.nicholas.int is your master, you only need:

exit Icinga2AgentModule `
    -DirectorUrl       'http://DEV-ICINGA2-01.nicholas.int/icingaweb2/director/' `
    -DirectorAuthToken '<your Api Key>' `
    -RunInstaller

Yes Ronald You are right… I have tried directoricinga.txt (158.4 KB)

I was able to get icinga agent to register themselves. I was able to install icinga2 agent & NSClient++… After this i am seeing the error like
Remote icinga instance ********************* is not connected to *******************

I had to make few manually configurations to get the metrics.

  1. Update the C:\ProgramData\icinga2\etc\icinga2\features-available as shown below

From

/**

  • The API listener is used for distributed monitoring setups.
    */

object ApiListener “api” {
//accept_config = false
//accept_commands = false

ticket_salt = TicketSalt
}

to

/**

  • The API listener is used for distributed monitoring setups.
    */

object ApiListener “api” {
bind_host = “::”
bind_port = 5665

accept_config = true
accept_commands = true

}

2.Add api.conf under C:\ProgramData\icinga2\etc\icinga2\features-enabled
3. Update zones.conf appropriate endpoints & zones
4. Update C:\ProgramData\icinga2\etc\icinga2 with default configuration

After these 4 changes immediately Master started picking the alerts. Is these not included in the Icingadirector kickstart script?

Apologies for too many weird questions… Please accept my apoloiges

None of your 4 manual steps are required if everything works fine. It sounds like you haven’t configured the settings at Self Service API correctly or even not at all.

After i ran the powershell module, Here this is the output… Is there anything wrong here… Here, I have attached self service api configuration as well

Can you please adivse on this

Notice: Started script run…
Notice: Connected successfully to Icinga Director Self-Service API over API token.
Notice: Setting internal Agent Name to “"
Notice: Trying to fetch Host IP-Address for hostname: *********************************
Notice: Setting IP ######### as primary IP for this host for all requests. Access it with &ipaddress& for all JSON
requests.
Notice: Using Icinga version “”, setting certificate directory to “C:\ProgramData\icinga2\etc\icinga2\pki”
Warning: Icinga 2 Agent does not seem to be installed on the system
Notice: Downloading Icinga 2 Agent Binary from “https://packages.icinga.com/windows/Icinga2-v2.10.5-x86_64.msi
Warning: Icinga 2 Agent Installer verification disabled.
Notice: Installing Icinga 2 Agent
Notice: Icinga 2 Agent installed.
Notice: Using Icinga version “2.10.5”, setting certificate directory to “C:\ProgramData\icinga2\var\lib\icinga2\certs”
Notice: Found Icinga 2 Agent version 2.10.5 installed at “C:\Program Files\ICINGA2”
Notice: Removing downloaded Icinga 2 Agent installer
Notice: Creating host "
” over API token inside Icinga Director.
Notice: Writing host API-Key “b7d7f3a962698a082658cd2f64373d0e29067a9b” to “C:\ProgramData\icinga2\etc\icinga2\icingadir
ector.token”
Notice: Successfully fetched configuration for this host over Self-Service API.
Notice: Fetched ticket “a151f500377f595d8116ea7e60d46d8c9e093e55” from Icinga Director
Notice: Generating Host certificates required by Icinga 2
Notice: information/base: Writing private key to ‘C:\ProgramData\icinga2\var\lib\icinga2\certs*.key’.
information/base: Writing X509 certificate to 'C:\ProgramData\icinga2\var\lib\icinga2\certs*
.crt’.
Notice: Storing Icinga 2 certificates
Notice: information/cli: Retrieving X.509 certificate for '
********************:5665’.

Subject: CN = ************************
Issuer: CN = Icinga CA
Valid From: Aug 27 19:08:36 2019 GMT
Valid Until: Aug 23 19:08:36 2034 GMT
Fingerprint: 3D D2 69 6E DE ED 39 81 9D 05 70 F7 51 9B 6E EA 7B 37 E7 F4


*** You have to ensure that this certificate actually matches the parent
*** instance’s certificate in order to avoid man-in-the-middle attacks.


information/pki: Writing certificate to file ‘C:\ProgramData\icinga2\var\lib\icinga2\certs\trusted-master.crt’.
Notice: Certificate fingerprint: “3DD2696EDEED39819D0570F7519B6EEA7B37E7F4”
Warning: CA fingerprint validation disabled
Notice: Requesting Icinga 2 certificates
Notice: information/cli: Writing CA certificate to file ‘C:\ProgramData\icinga2\var\lib\icinga2\certs\ca.crt’.
information/cli: Writing signed certificate to file ‘C:\ProgramData\icinga2\var\lib\icinga2\certs\dev-bastion-02.NICHOLA
SANDCO.AWS.crt’.
Notice: Icinga 2 configuration backup successfull
Notice: Writing icinga2.conf to “C:\ProgramData\icinga2\etc\icinga2”
Notice: Icinga 2 configuration check successfull.
Notice: Trying to disable debug log for Icinga 2…
Notice: Icinga 2 debug log is not enabled or configuration not found
Notice: Trying to enable logging for Icinga 2…
Notice: Icinga 2 logging is already enabled or configuration not found
Notice: Trying to install Icinga 2 Agent Firewall Rule for port 5665
Notice: Icinga 2 Agent Firewall Rule successfully installed for port 5665
Notice: Trying to install and configure NSClient++ from “C:\Program Files\ICINGA2\sbin\NSCP.msi”
Notice: NSClient++ successfully installed.
Notice: Trying to remove NSClient++ Firewall Rule
Notice: NSClient++ Firewall Rule has been successfully removed
Notice: Trying to remove NSClient++ service
Notice: NSClient++ Service has been removed
Notice: Restarting service icinga2
Notice: Icinga 2 Agent successfully restarted.

Looks ok. Is it working as expected?

Yes roland. Its not working as expected…There are 4 changes needs to done to make it work.

  1. Update the C:\ProgramData\icinga2\etc\icinga2\Icinga2.conf file
  2. Update C:\ProgramData\icinga2\etc\icinga2\zones.conf
  3. Update C:\ProgramData\icinga2\etc\icinga2\features-available\api.conf
  4. Add api.conf file under C:\ProgramData\icinga2\etc\icinga2\features-enabled

Here I have attached a zip file that has 6 files. They named it working & not working… All not working files that are created after powershell script execution… All working files are the files that i have added to make it work… Just trying to understand anything i missed in the script or configurations? Icinga2Configs.zip (3.8 KB)

The icinga2-powershell-module creates uncommon conf files (which I don’t like and is somewhat confusing). The api staff is created in icinga2.conf, therefore, you don’t need to step 3 and 4. zones.conf is being ignored, therefore, you don’t need step 2. The endpoint object in icinga2.conf is incomplete (host is missing):

object Endpoint "DEV-ICINGA2-01.nicholas.int" {

}

and this is typical when the endpoint object in the director is incomplete. Please check the endpoint definition in your zones.conf, add the missing host part, reload icinga2 and run kickstart wizard.

Roland - This is awesome… Its working now… Thanks a bunchhhhh… Really… You help me a lot on this…

Ronald,

How are you? Hope you are doing good…We have a powershell script that does the following items

  1. Automated pki ticket generation that can register automatically
  2. icinga2/NSClient++ installation & updates the configuration

however after icinga2 agent installation & when i run the powershell again i am getting the below error with the below error… I had to drop the selfservice api key manually to make this work… Is there anyway during uninstalllatin we can drop the selfservice api key along with this? We don’t want to drop the self service api automatically… can you please advise on this

Notice: Started script run…
Notice: Reading host api token “ERROR: The host “DEV-AXDEVAOS-A.nicholas.int” has already been registered (IcingaHostSel
fServiceForm.php:103)” from “C:\ProgramData\icinga2\etc\icinga2\icingadirector.token”
Notice: Connected successfully to Icinga Director Self-Service API over stored host token.
Notice: Setting internal Agent Name to “”
Warning: You have not specified an Agent Name or turned on to auto fetch this information.
Notice: Trying to fetch Host IP-Address for host