File: command.phps

package info (click to toggle)
icinga 1.0.2-2%2Bsqueeze2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 33,964 kB
  • ctags: 13,294
  • sloc: xml: 154,821; ansic: 99,198; sh: 14,761; sql: 5,852; php: 5,126; perl: 2,838; makefile: 1,268
file content (49 lines) | stat: -rw-r--r-- 2,144 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?

/*
 * send command through pipe
 */
$config = array(
	'pipe'			=> '/usr/local/icinga/var/rw/icinga.cmd',
);
$cmd = IcingaApi::getCommandObject();
$cmd->setCommand('SCHEDULE_SVC_CHECK')->setTarget(IcingaApi::COMMAND_INSTANCE, '1')->setTarget(IcingaApi::COMMAND_HOST, 'linux-www-20')->setTarget(IcingaApi::COMMAND_SERVICE, 'apache-procs')->setTarget(IcingaApi::COMMAND_CHECKTIME, '1251449262');
$cmdDisp = IcingaApi::getCommandDispatcher();
$cmdDisp->setInterface(IcingaApi::COMMAND_PIPE, $config)->setCommand($cmd)->send();

/*
 * send command by ssh
 */
$config = array (
	'ssh_bin'		=> '/usr/bin/ssh',
	'ssh_user'		=> 'icinga',
	'ssh_host'		=> 'icinga_host',
	'ssh_port'		=> 22,
	'ssh_timeout'	=> 20,
	'ssh_pipe'		=> '/usr/local/icinga/var/rw/icinga.cmd',
);
$cmd = IcingaApi::getCommandObject();
$cmd->setCommand('SCHEDULE_SVC_CHECK')->setTarget(IcingaApi::COMMAND_INSTANCE, '1')->setTarget(IcingaApi::COMMAND_HOST, 'linux-www-20')->setTarget(IcingaApi::COMMAND_SERVICE, 'apache-procs')->setTarget(IcingaApi::COMMAND_CHECKTIME, '1251449262');
$cmdDisp = IcingaApi::getCommandDispatcher();
$cmdDisp->setInterface(IcingaApi::COMMAND_SSH, $config)->setCommand($cmd)->send();

/*
 * send multiple commands
 */
$config = array(
	'pipe'			=> '/usr/local/icinga/var/rw/icinga.cmd',
);
$cmd = IcingaApi::getCommandObject();
$cmd->setCommand('SCHEDULE_SVC_CHECK')->setTarget(IcingaApi::COMMAND_INSTANCE, '1')->setTarget(IcingaApi::COMMAND_HOST, 'linux-www-20')->setTarget(IcingaApi::COMMAND_SERVICE, 'apache-procs')->setTarget(IcingaApi::COMMAND_CHECKTIME, '1251449262');
$cmd2 = IcingaApi::getCommandObject();
$cmd2->setCommand('SCHEDULE_SVC_CHECK')->setTarget(IcingaApi::COMMAND_INSTANCE, '1')->setTarget(IcingaApi::COMMAND_HOST, 'linux-db-3')->setTarget(IcingaApi::COMMAND_SERVICE, 'mysql-procs')->setTarget(IcingaApi::COMMAND_CHECKTIME, '1251449265');
$cmdDisp = IcingaApi::getCommandDispatcher();
$cmdDisp->setInterface(IcingaApi::COMMAND_PIPE, $config)->setCommand(array($cmd, $cmd2))->send();


/*
 * get call stack AFTER sending command via dispatcher (for error output and further checking)
 */
$callStack = $cmdDisp->getCallStack();

?>