Ahh I understand now, so for now it only works if you apply this to a template due to how the config for dedicated services is rendered. Thanks Thomas for all your hard work, I've enjoyed learning Icinga and Director!
Posts by VeXed
This forum was archived to /woltlab and is now in read-only mode.
-
-
Got ya, so is this just a matter of how the config is being rendered in director and not something I'm doing wrong? I know director is a work in progress, hopefully I've been helping you find out some of the bugs!
-
Sure:
{
attrs: {
__name: "MTAPP02.xxxxxxx.local!Check Windows Backup",
acknowledgement: 0,
acknowledgement_expiry: 0,
action_url: "",
active: true,
check_attempt: 1,
check_command: "PowerShell",
check_interval: 64800,
check_period: "",
check_timeout: null,
command_endpoint: "",
display_name: "Check Windows Backup",
enable_active_checks: true,
enable_event_handler: true,
enable_flapping: false,
enable_notifications: true,
enable_passive_checks: true,
enable_perfdata: true,
event_command: "",
flapping: false,
flapping_last_change: 1465936778.450407,
flapping_negative: 9054,
flapping_positive: 0,
flapping_threshold: 30,
force_next_check: false,
force_next_notification: false,
groups: [],
ha_mode: 0,
host_name: "MTAPP02.xxxxxxx.local",
icon_image: "",
icon_image_alt: "",
last_check: 1465936778.450394,
last_check_result: {
active: true,
check_source: "icinga2.xxxxxxx.local",
command: [
"C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
"-command",
"& \'C:\\scripts\\check_backup.ps1\'"
],
execution_end: 1465936778.450354,
execution_start: 1465936778.450198,
exit_status: 128,
output: "execvpe(C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe) failed: No such file or directory",
performance_data: [],
schedule_end: 1465936778.450394,
schedule_start: 1466001578.450000,
state: 3,
type: "CheckResult",
vars_after: {
attempt: 1,
reachable: true,
state: 3,
state_type: 1
},
vars_before: {
attempt: 1,
reachable: true,
state: 3,
state_type: 1
}
},
last_hard_state: 3,
last_hard_state_change: 1465923804.485645,
last_in_downtime: false,
last_reachable: true,
last_state: 3,
last_state_change: 1465923685.713711,
last_state_critical: 0,
last_state_ok: 0,
last_state_type: 1,
last_state_unknown: 1465936778.450400,
last_state_unreachable: 0,
last_state_warning: 0,
max_check_attempts: 5,
name: "Check Windows Backup",
next_check: 1466001578.450000,
notes: "",
notes_url: "",
original_attributes: null,
package: "director",
paused: false,
retry_interval: 1800,
state: 3,
state_type: 1,
templates: [
"Check Windows Backup",
"Check Windows Backup",
"Agent Based Service"
],
type: "Service",
vars: { ps_command: "& \'C:\\scripts\\check_backup.ps1\'" },
version: 0,
volatile: false,
zone: "icinga2.xxxxxxx.local"
},
joins: {
check_command: {
__name: "PowerShell",
active: true,
arguments: {
-command: {
order: -1,
value: "$ps_command$"
}
},
command: [
"C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
],
env: null,
execute: { type: "Function" },
ha_mode: 0,
name: "PowerShell",
original_attributes: null,
package: "director",
paused: false,
templates: [
"PowerShell"
],
timeout: 60,
type: "CheckCommand",
vars: null,
version: 0,
zone: "director-global"
},
host: {
__name: "MTAPP02.xxxxxxx.local",
acknowledgement: 0,
acknowledgement_expiry: 0,
action_url: "",
active: true,
address: "MTAPP02.xxxxxxx.local",
address6: "",
check_attempt: 1,
check_command: "hostalive4",
check_interval: 300,
check_period: "",
check_timeout: null,
command_endpoint: "",
display_name: "MTAPP02",
enable_active_checks: true,
enable_event_handler: true,
enable_flapping: false,
enable_notifications: true,
enable_passive_checks: true,
enable_perfdata: true,
event_command: "",
flapping: false,
flapping_last_change: 1465998047.731859,
flapping_negative: 2995,
flapping_positive: 0,
flapping_threshold: 30,
force_next_check: false,
force_next_notification: true,
groups: [
"Windows Server 2012 R2 Standard"
],
ha_mode: 0,
icon_image: "",
icon_image_alt: "",
last_check: 1465998047.731837,
last_check_result: {
active: true,
check_source: "icinga2.xxxxxxx.local",
command: [
"/usr/lib/nagios/plugins/check_ping",
"-4",
"-H",
"MTAPP02.xxxxxxx.local",
"-c",
"5000,100%",
"-w",
"3000,80%"
],
execution_end: 1465998047.731793,
execution_start: 1465998043.730177,
exit_status: 0,
output: "PING OK - Packet loss = 0%, RTA = 0.24 ms",
performance_data: [
"rta=0.237000ms;3000.000000;5000.000000;0.000000",
"pl=0%;80;100;0"
],
schedule_end: 1465998047.731837,
schedule_start: 1465998343.730000,
state: 0,
type: "CheckResult",
vars_after: {
attempt: 1,
reachable: true,
state: 0,
state_type: 1
},
vars_before: {
attempt: 1,
reachable: true,
state: 0,
state_type: 1
}
},
last_hard_state: 0,
last_hard_state_change: 1463540765.893679,
last_in_downtime: false,
last_reachable: true,
last_state: 0,
last_state_change: 1463540765.893679,
last_state_down: 0,
last_state_type: 1,
last_state_unreachable: 0,
last_state_up: 1465998047.731851,
max_check_attempts: 3,
name: "MTAPP02.xxxxxxx.local",
next_check: 1465998343.730000,
notes: "",
notes_url: "",
original_attributes: null,
package: "director",
paused: false,
retry_interval: 60,
state: 0,
state_type: 1,
templates: [
"MTAPP02.xxxxxxx.local",
"Windows Servers",
"Icinga Agent"
],
type: "Host",
vars: {
object_sid: "S-1-5-21-2969318330-2621487994-1129126803-5694",
operatingsystem: "Windows Server 2012 R2 Standard",
operatingsystemversion: "6.3 (9600)"
},
version: 0,
volatile: false,
zone: "icinga2.xxxxxxx.local"
}
},
meta: {},
name: "MTAPP02.xxxxxxx.local!Check Windows Backup",
type: "Service"
} -
Why is it trying to execute using execvpe?
This is my command setup:
http://imgur.com/NxZUTOm
http://imgur.com/RvdZPnh
http://imgur.com/YJHoXADI then applied this service to a host that has the check_backup.ps1 script in the scripts folder.... It's like it's trying to execute locally on the icinga server instead of the host.
-
This should already work fine. Please have a look at this Powershell module: Icinga 2 Powershell Module. It does a great job in abstracting what you are looking for. Just use it like a library and build your own logic around it.
It has been written by one of our sales(!!) people. Really, I'm not kidding. I gave some assistance and guidance, but he mostly wrote it alone. Guess how skilled our developers are if this is what our sales people doI want a future Icinga Director version to provide single shot installation and/or upgrade scripts based on this module. They will be offered for download through web, commandline and API and rendered dedicatedly for each single host. Similar to what Director currently shows for Linux Agents. Just better. This will include the key signing ticket and an opinionated Agent-only config with correct zone and endpoint definitions for Windows systems.
But you do not need the Director for this at all. The module has been written with automation and unattended installation in mind. It works quite well, he really did an amazing job on this.
Cheers,
ThomasWill this work in conjunction with Director? I'm trying to get some remote powershell scripts to work via the agent but I'm not having any luck via Director. I've already got director working for a lot of other stuff - but I need powershell to check some things that are not included with the built in checks such as checking to see if the daily backup failed..etc.
-
Trying to get this working as well following these instructions: https://wiki.icinga.org/displa…ecuting+Powershellscripts but I can't get it working. Keep getting:
Plugin Output
execvpe(C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe) failed: No such file or directory -
Notifications are not currently working with director. Hopefully there will be an update soon that will allow us to get them working!
-
Do you have the windows plugins enabled on the master?
include <windows-plugins>
in /etc/icinga2/icinga2.conf
-
It will import them so that you can reference them in new stuff, just doesn't let you edit the old hosts.
-
Any update on this, I'm currently stuck at this part as well.