diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
index da41e2a..f49a99f 100644
--- a/nbproject/private/private.xml
+++ b/nbproject/private/private.xml
@@ -10,15 +10,6 @@
file:/home/vitex/Projects/VitexSoftware/iciedit/src/includes/Configure.php
-
- file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/UI/MainMenu.php
- file:/home/vitex/Projects/VitexSoftware/icinga_configurator/debian/install
- file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/Script.php
- file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/cfgconfirm.php
- file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/index.php
- file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/downtime.php
- file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/ExternalCommand.php
- file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/script.php
-
+
diff --git a/src/classes/NSCPConfigBatGenerator.php b/src/classes/NSCPConfigBatGenerator.php
index 7d004d8..6885d7e 100644
--- a/src/classes/NSCPConfigBatGenerator.php
+++ b/src/classes/NSCPConfigBatGenerator.php
@@ -9,6 +9,18 @@
*/
class NSCPConfigBatGenerator extends \Ease\Atom
{
+ /**
+ * Files in this format Suffix
+ * @var comment
+ */
+ public $formatSuffix = 'bat';
+
+ /**
+ * Comment mark
+ * @var string
+ */
+ public $comment = 'REM';
+
/**
* Objekt hostu
* @var Engine\Host
@@ -25,7 +37,7 @@ class NSCPConfigBatGenerator extends \Ease\Atom
* Config file fragments
* @var array
*/
- public $nscBatArray = [];
+ public $nscConfArray = [];
/**
* Active mode
@@ -49,13 +61,19 @@ class NSCPConfigBatGenerator extends \Ease\Atom
* How to call %NSCLIENT variable ?
* @var string
*/
- private $nscvar = '';
+ protected $nscvar = '';
/**
* Scripts to deploy listing
* @var array
*/
- private $scriptsToDeploy = [];
+ public $scriptsToDeploy = [];
+
+ /**
+ * List of script filenames to deploy
+ * @var array
+ */
+ public $scriptsToDeployNames = [];
/**
* NSC++ Configuration Generator
@@ -92,9 +110,9 @@ public function __construct($host)
* @param string $key
* @param string $value
*/
- private function addCfg($path, $key, $value)
+ protected function addCfg($path, $key, $value)
{
- $this->nscBatArray[] = "\n".$this->nscvar.' settings --path "'.$path.'" --key "'.$key.'" --set "'.$value.'"';
+ $this->nscConfArray[] = "\n".$this->nscvar.' settings --path "'.$path.'" --key "'.$key.'" --set "'.$value.'"';
}
/**
@@ -112,7 +130,7 @@ private function setPlatform($platform)
*
* @param string $platform
*/
- private function setnscvar($platform)
+ public function setnscvar($platform)
{
switch ($platform) {
case 'windows':
@@ -135,7 +153,7 @@ function cfgInit()
{
switch ($this->platform) {
case 'windows':
- $this->nscBatArray = ['
+ $this->nscConfArray = ['
@ECHO OFF
powershell Set-ExecutionPolicy ByPass
set NSCDIR=%ProgramFiles%\NSClient++\
@@ -146,15 +164,15 @@ function cfgInit()
rename "%NSCDIR%\nsclient.ini" nsclient.old
'];
- $this->nscBatArray[] = "\n".'SET ICIEDIT_HTML="%NSCDIR%/icinga-editor.htm"';
- $this->nscBatArray[] = "\n".'echo ^ > %ICIEDIT_HTML%';
- $this->nscBatArray[] = "\n".'echo ^
^^ >> %ICIEDIT_HTML%';
- $this->nscBatArray[] = "\n".'echo ^ >> %ICIEDIT_HTML%
+ $this->nscConfArray[] = "\n".'SET ICIEDIT_HTML="%NSCDIR%/icinga-editor.htm"';
+ $this->nscConfArray[] = "\n".'echo ^ > %ICIEDIT_HTML%';
+ $this->nscConfArray[] = "\n".'echo ^^^ >> %ICIEDIT_HTML%';
+ $this->nscConfArray[] = "\n".'echo ^ >> %ICIEDIT_HTML%
';
break;
case 'linux':
- $this->nscBatArray = ['
+ $this->nscConfArray = ['
export NSCLIENT=`which nscp`
export ICINGA_SERVER="'.$this->prefs['serverip'].'"
'.$this->nscvar.' service --stop
@@ -172,7 +190,7 @@ function cfgInit()
'];
break;
}
- $this->nscBatArray[] = $this->nscvar.' settings --generate';
+ $this->nscConfArray[] = $this->nscvar.' settings --generate';
}
/**
@@ -302,6 +320,7 @@ function cfgServices()
$script_id = $command->getDataValue('script_id');
if ($script_id) {
$this->scriptsToDeploy[$command->getName()] = $script_id;
+ $this->scriptsToDeployNames[$script_id] = $command->getDataValue('command_line');
}
$commandsCache[$remote] = $command->getData();
}
@@ -342,10 +361,10 @@ function cfgServices()
$serviceParams = $service['check_command-params'];
switch ($this->platform) {
case 'windows':
- $this->nscBatArray[] = "\n\nREM #".$service['service_id'].' '.$serviceName."\n";
+ $this->nscConfArray[] = "\n\n".$this->comment." #".$service['service_id'].' '.$serviceName."\n";
break;
case 'linux':
- $this->nscBatArray[] = "\n\n# #".$service['service_id'].' '.$serviceName."\n";
+ $this->nscConfArray[] = "\n\n# #".$service['service_id'].' '.$serviceName."\n";
break;
default:
break;
@@ -396,39 +415,39 @@ public function cfgEnding()
}
switch ($this->platform) {
case 'windows':
- $this->nscBatArray[] = "\n".'echo ^'._('Konfigurace hosta').' '.$this->host->getName().'^
>> %ICIEDIT_HTML%';
- $this->nscBatArray[] = "\n".'echo ^
^'._('Host Configuration').'^ >> %ICIEDIT_HTML%';
- $this->nscBatArray[] = "\n".'echo ^
^'._('Refresh sensor installation').' '.$this->host->getName().'_nscp.bat'.'^ >> %ICIEDIT_HTML%';
+ $this->nscConfArray[] = "\n".'echo ^'._('Konfigurace hosta').' '.$this->host->getName().'^
>> %ICIEDIT_HTML%';
+ $this->nscConfArray[] = "\n".'echo ^
^'._('Host Configuration').'^ >> %ICIEDIT_HTML%';
+ $this->nscConfArray[] = "\n".'echo ^
^'._('Refresh sensor installation').' '.$this->host->getName().'_nscp.bat'.'^ >> %ICIEDIT_HTML%';
if ($this->host->getDataValue('host_is_server') == 0) {
$dtUrl = Engine\Configurator::getBaseURL().'downtime.php?host_id='.$this->host->getId();
- $this->nscBatArray[] = "\n".'echo ^
^'._('Start host downtime').'^ >> %ICIEDIT_HTML%';
- $this->nscBatArray[] = "\n".'echo ^
^'._('End host downtime').'^ >> %ICIEDIT_HTML%';
+ $this->nscConfArray[] = "\n".'echo ^
^'._('Start host downtime').'^ >> %ICIEDIT_HTML%';
+ $this->nscConfArray[] = "\n".'echo ^
^'._('End host downtime').'^ >> %ICIEDIT_HTML%';
}
- $this->nscBatArray[] = "\n".'echo ^
^'._('Potvrzení konfigurace').'^ >> %ICIEDIT_HTML%';
- $this->nscBatArray[] = "\n".'echo ^ >> %ICIEDIT_HTML%';
- $this->nscBatArray[] = "\n".'echo ^ >> %ICIEDIT_HTML%
+ $this->nscConfArray[] = "\n".'echo ^
^'._('Potvrzení konfigurace').'^ >> %ICIEDIT_HTML%';
+ $this->nscConfArray[] = "\n".'echo ^ >> %ICIEDIT_HTML%';
+ $this->nscConfArray[] = "\n".'echo ^ >> %ICIEDIT_HTML%
';
if ($this->host->getDataValue('host_is_server') == 0) {
$upfile = 'C:\\Windows\\System32\\GroupPolicy\\Machine\\Scripts\\Startup\\hostup.ps1';
- $this->nscBatArray[] = "\n".'echo (new-object System.Net.WebClient).DownloadFile("'.$dtUrl.'&state=stop","C:\tmp\hostup.txt") > '.$upfile;
+ $this->nscConfArray[] = "\n".'echo (new-object System.Net.WebClient).DownloadFile("'.$dtUrl.'&state=stop","C:\tmp\hostup.txt") > '.$upfile;
$downfile = 'C:\\Windows\\System32\\GroupPolicy\\Machine\\Scripts\\Shutdown\\hostdown.ps1';
- $this->nscBatArray[] = "\n".'echo (new-object System.Net.WebClient).DownloadFile("'.$dtUrl.'&state=start","C:\tmp\hostdown.txt") > '.$downfile;
+ $this->nscConfArray[] = "\n".'echo (new-object System.Net.WebClient).DownloadFile("'.$dtUrl.'&state=start","C:\tmp\hostdown.txt") > '.$downfile;
}
- $this->nscBatArray[] = "\n".'
+ $this->nscConfArray[] = "\n".'
'.$this->nscvar.' service --start
start "" %ICIEDIT_HTML%
';
break;
case 'linux':
- $this->nscBatArray[] = "\n".'
+ $this->nscConfArray[] = "\n".'
curl "'.$this->getCfgConfirmUrl().'"
service nscp start
';
break;
default:
- $this->nscBatArray[] = $this->nscBatArray[] = "\n".'
+ $this->nscConfArray[] = $this->nscConfArray[] = "\n".'
';
break;
}
@@ -442,7 +461,7 @@ public function cfgEnding()
*/
public function getCfg($send = TRUE)
{
- $nscbat = implode('', $this->nscBatArray);
+ $nscbat = implode('', $this->nscConfArray);
if ($send) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
@@ -454,7 +473,7 @@ public function getCfg($send = TRUE)
switch ($this->platform) {
case 'windows':
if ($send) {
- header('Content-Disposition: attachment; filename='.$this->host->getName().'_nscp.bat');
+ header('Content-Disposition: attachment; filename='.$this->host->getName().'_nscp.'.$this->formatSuffix);
}
$nscbat = str_replace("\n", "\r\n", $nscbat);
break;
@@ -474,6 +493,11 @@ public function getCfg($send = TRUE)
}
}
+ /**
+ * Where To confirm sensor status ?
+ *
+ * @return string
+ */
function getCfgConfirmUrl()
{
return Engine\Configurator::getBaseURL().'cfgconfirm.php?hash='.$this->host->getConfigHash().'&host_id='.$this->host->getId();
@@ -487,7 +511,7 @@ public function deployScripts()
if (count($this->scriptsToDeploy)) {
switch ($this->platform) {
case 'windows':
- $this->nscBatArray[] = "\n".'echo ^'._('Skripty').'^
>> %ICIEDIT_HTML%
+ $this->nscConfArray[] = "\n".'echo ^'._('Skripty').'^
>> %ICIEDIT_HTML%
';
break;
}
@@ -496,17 +520,17 @@ public function deployScripts()
foreach ($this->scriptsToDeploy as $script_name => $script_id) {
switch ($this->platform) {
case 'windows':
- $this->nscBatArray[] = "\n".'echo ^'.$script_name.'^^
>> %ICIEDIT_HTML%
+ $this->nscConfArray[] = "\n".'echo ^'.$script_name.'^^
>> %ICIEDIT_HTML%
';
break;
case 'linux':
- $this->nscBatArray[] = "\n".'
+ $this->nscConfArray[] = "\n".'
# '.$script_name.'
curl "'.Engine\Configurator::getBaseURL().'scriptget.php?script_id='.$script_id.'"
';
break;
default:
- $this->nscBatArray[] = $this->nscBatArray[] = "\n".'
+ $this->nscConfArray[] = $this->nscConfArray[] = "\n".'
'.$this->nscvar.' test
';
break;
diff --git a/src/classes/NSCPConfigPS1Generator.php b/src/classes/NSCPConfigPS1Generator.php
new file mode 100644
index 0000000..d5d425a
--- /dev/null
+++ b/src/classes/NSCPConfigPS1Generator.php
@@ -0,0 +1,271 @@
+nscvar = $nsclient;
+ }
+
+ /**
+ * Připraví nouvou konfiguraci
+ */
+ function cfgInit()
+ {
+ switch ($this->platform) {
+ case 'windows':
+ $this->nscConfArray = ['
+$NSCDIR = ${Env:ProgramFiles} + "\\NSCLient++"
+$NSCLIENT = $NSCDIR + "\\nscp.exe"
+$NSCSCRIPTSDIR = $NSCDIR + "\\Scripts"
+$ICINGA_SERVER = "'.$this->prefs['serverip'].'"
+'.$this->nscvar.' service --stop
+If (Test-Path "$NSCDIR\\nsclient.old"){ Remove-Item "$NSCDIR\\nsclient.old" }
+If (Test-Path "$NSCDIR\\nsclient.ini"){ Rename-Item "$NSCDIR\\nsclient.ini" "$NSCDIR\\nsclient.old" }
+'];
+
+ $this->nscConfArray[] = "\n".'$ICIEDIT_HTML= $NSCDIR + "\\icinga-editor.htm"';
+ $this->nscConfArray[] = "\n".'echo "" | Out-File $ICIEDIT_HTML';
+ $this->nscConfArray[] = "\n".'echo "" | Out-File $ICIEDIT_HTML -Append';
+ $this->nscConfArray[] = "\n".'echo "" | Out-File $ICIEDIT_HTML -Append
+';
+
+ break;
+ case 'linux':
+ $this->nscConfArray = ['
+export NSCLIENT=`which nscp`
+export ICINGA_SERVER="'.$this->prefs['serverip'].'"
+'.$this->nscvar.' service --stop
+export INI="/etc/nsclient/nsclient.ini"
+rm "$INI"
+
+echo "[/paths]" >> $INI
+echo "" >> $INI
+echo "shared-path=/usr/share/nsclient/" >> $INI
+echo "module-path=/usr/lib/nsclient/modules/" >> $INI
+echo "log-path=/var/log/nsclient" >> $INI
+echo "" >> $INI
+echo "[/settings/log]" >> $INI
+echo "file name=${log-path}/nsclient.log" >> $INI
+'];
+ break;
+ }
+ $this->nscConfArray[] = $this->nscvar.' settings --generate';
+ }
+
+ /**
+ * Make HTML and start service
+ */
+ public function cfgEnding()
+ {
+ if (count($this->scriptsToDeploy)) {
+ $this->deployScripts();
+ }
+ switch ($this->platform) {
+ case 'windows':
+ $this->nscConfArray[] = "\n".'echo "'._('Konfigurace hosta').' '.$this->host->getName().'
" | Out-File $ICIEDIT_HTML -Append';
+ $this->nscConfArray[] = "\n".'echo "
'._('Host Configuration').'" | Out-File $ICIEDIT_HTML -Append';
+ $this->nscConfArray[] = "\n".'echo "
'._('Refresh sensor installation').' '.$this->host->getName().'_nscp.ps1'.'" | Out-File $ICIEDIT_HTML -Append';
+ if ($this->host->getDataValue('host_is_server') == 0) {
+ $dtUrl = Engine\Configurator::getBaseURL().'downtime.php?host_id='.$this->host->getId();
+ $this->nscConfArray[] = "\n"."echo '
"._('Start host downtime')."' | Out-File \$ICIEDIT_HTML -Append";
+ $this->nscConfArray[] = "\n"."echo '
"._('End host downtime')."' | Out-File \$ICIEDIT_HTML -Append";
+ }
+ $this->nscConfArray[] = "\n"."echo '
getCfgConfirmUrl()."\">"._('Potvrzení konfigurace')."' | Out-File \$ICIEDIT_HTML -Append";
+ $this->nscConfArray[] = "\n".'echo "" | Out-File $ICIEDIT_HTML -Append';
+ $this->nscConfArray[] = "\n".'echo "" | Out-File $ICIEDIT_HTML -Append
+';
+ if ($this->host->getDataValue('host_is_server') == 0) {
+ $this->nscConfArray[] = "\n".$this->registryUpdaterCode();
+
+ $upfile = 'C:\\Windows\\System32\\GroupPolicy\\Machine\\Scripts\\Startup\\hostup.ps1';
+ $this->nscConfArray[] = "\n"."echo '(New-Object System.Net.WebClient).DownloadFile(\"$dtUrl\"&\"state=stop\",\"C:\\WINDOWS\\TEMP\\UP.TXT\")' | Out-File $upfile";
+
+ $downfile = 'C:\\Windows\\System32\\GroupPolicy\\Machine\\Scripts\\Shutdown\\hostdown.ps1';
+ $this->nscConfArray[] = "\n"."echo '(New-Object System.Net.WebClient).DownloadFile(\"$dtUrl\"&\"state=start\",\"C:\\WINDOWS\\TEMP\\DOWN.TXT\")' | Out-File $downfile";
+ }
+
+ $this->nscConfArray[] = "\n".'
+'.$this->nscvar.' service --start
+(New-Object System.Net.WebClient).DownloadFile("'.parent::getCfgConfirmUrl().'", $NSCDIR + "\\CONFIRM.HTM")
+';
+
+ $this->nscConfArray[] = "\n".
+ "echo '(New-Object System.Net.WebClient).DownloadFile(\"".Engine\Configurator::getBaseURL().'nscpcfggen.php?host_id='.$this->host->getId().'&format=ps1&user='.\Ease\Shared::user()->getUserLogin().'","'.$this->host->getName().'_nscp.ps1")\' | Out-File $NSCDIR + \"\\refresh.ps1"';
+ $this->nscConfArray[] = "\n".
+ "echo '& ".$this->host->getName().'_nscp.ps1 | Out-File $NSCDIR + \"\\refresh.ps1" -Append';
+
+ break;
+ case 'linux':
+ $this->nscConfArray[] = "\n".'
+curl "'.$this->getCfgConfirmUrl().'"
+service nscp start
+';
+ break;
+ default:
+ $this->nscConfArray[] = $this->nscConfArray[] = "\n".'
+';
+ break;
+ }
+ }
+
+ /**
+ * Nasazení externích skriptů
+ */
+ public function deployScripts()
+ {
+ if (count($this->scriptsToDeploy)) {
+ switch ($this->platform) {
+ case 'windows':
+ $this->nscConfArray[] = "\n".'echo "'._('Skripty').'
" | Out-File $ICIEDIT_HTML -Append
+';
+ break;
+ }
+
+
+ foreach ($this->scriptsToDeploy as $script_name => $script_id) {
+ switch ($this->platform) {
+ case 'windows':
+ $this->nscConfArray[] = "\n"."echo '$script_name
' | Out-File \$ICIEDIT_HTML -Append\n";
+ $this->nscConfArray[] = "\n"."(New-Object System.Net.WebClient).DownloadFile(\"".Engine\Configurator::getBaseURL()."scriptget.php?script_id=$script_id\", \$NSCSCRIPTSDIR + \"\\\" + \"".$this->scriptsToDeployNames[$script_id]."\")\n";
+ break;
+ case 'linux':
+ $this->nscConfArray[] = "\n".'
+# '.$script_name.'
+curl "'.Engine\Configurator::getBaseURL().'scriptget.php?script_id='.$script_id.'"
+';
+ break;
+ default:
+ $this->nscConfArray[] = $this->nscConfArray[] = "\n".'
+'.$this->nscvar.' test
+';
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Where To confirm sensor status ?
+ *
+ * @return string
+ */
+ function getCfgConfirmUrl()
+ {
+ return str_replace('&', '"&"', parent::getCfgConfirmUrl());
+ }
+
+public static function registryUpdaterCode()
+ {
+ return '$reg = "0"
+$PathGP = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\"
+
+$ScriptPathShutdown = "$PathGP"+"Scripts\Shutdown\0\"
+$PathScriptShutdown = "$ScriptPathShutdown"+"$reg"
+
+$ScriptPathStartup = "$PathGP"+"Scripts\Startup\0\"
+$PathScriptStartup = "$ScriptPathStartup"+"$reg"
+
+$ScriptShutdown = "hostdown.ps1"
+$ScriptStartup = "hostup.ps1"
+
+IF {
+$PatternShutdown = Get-ItemPropertyValue -Path "$PathScriptShutdown" -Name "Script"
+IF {
+New-Item -Path $ScriptPathShutdown -Name $reg -Force
+New-ItemProperty -Path "$PathScriptShutdown" -Name "Script" -Value $ScriptShutdown -Force
+New-ItemProperty -Path "$PathScriptShutdown" -Name "Parameters" -Value "" -Force
+New-ItemProperty -Path "$PathScriptShutdown" -Name "IsPowershell" -Value "1" -Force -PropertyType DWORD
+New-ItemProperty -Path "$PathScriptShutdown" -Name "ExecTime" -Value "0" -Force -PropertyType QWORD
+
+New-ItemProperty -Path $ScriptPathShutdown -Name "DisplayName" -Value "Místní zásady skupiny"
+New-ItemProperty -Path $ScriptPathShutdown -Name "FileSysPath" -Value "C:\WINDOWS\System32\GroupPolicy\Machine"
+New-ItemProperty -Path $ScriptPathShutdown -Name "GPO-ID" -Value "LocalGPO"
+New-ItemProperty -Path $ScriptPathShutdown -Name "GPOName" -Value "Místní zásady skupiny"
+New-ItemProperty -Path $ScriptPathShutdown -Name "PSScriptOrder" -Value "1" -PropertyType DWORD
+New-ItemProperty -Path $ScriptPathShutdown -Name "SOM-ID" -Value "Local"
+}
+}
+ELSE {
+New-Item -Path $ScriptPathShutdown -Name $reg -Force
+New-ItemProperty -Path "$PathScriptShutdown" -Name "Script" -Value $ScriptShutdown -Force
+New-ItemProperty -Path "$PathScriptShutdown" -Name "Parameters" -Value "" -Force
+New-ItemProperty -Path "$PathScriptShutdown" -Name "IsPowershell" -Value "1" -Force -PropertyType DWORD
+New-ItemProperty -Path "$PathScriptShutdown" -Name "ExecTime" -Value "0" -Force -PropertyType QWORD
+
+New-ItemProperty -Path $ScriptPathShutdown -Name "DisplayName" -Value "Místní zásady skupiny"
+New-ItemProperty -Path $ScriptPathShutdown -Name "FileSysPath" -Value "C:\WINDOWS\System32\GroupPolicy\Machine"
+New-ItemProperty -Path $ScriptPathShutdown -Name "GPO-ID" -Value "LocalGPO"
+New-ItemProperty -Path $ScriptPathShutdown -Name "GPOName" -Value "Místní zásady skupiny"
+New-ItemProperty -Path $ScriptPathShutdown -Name "PSScriptOrder" -Value "1" -PropertyType DWORD
+New-ItemProperty -Path $ScriptPathShutdown -Name "SOM-ID" -Value "Local"
+}
+
+IF {
+$PatternStartup = Get-ItemPropertyValue -Path "$PathScriptStartup" -Name "Script"
+IF {
+New-Item -Path $ScriptPathStartup -Name $reg -Force
+New-ItemProperty -Path "$PathScriptStartup" -Name "Script" -Value $ScriptStartup -Force
+New-ItemProperty -Path "$PathScriptStartup" -Name "Parameters" -Value "" -Force
+New-ItemProperty -Path "$PathScriptStartup" -Name "IsPowershell" -Value "1" -Force -PropertyType DWORD
+New-ItemProperty -Path "$PathScriptStartup" -Name "ExecTime" -Value "0" -Force -PropertyType QWORD
+
+New-ItemProperty -Path $ScriptPathStartup -Name "DisplayName" -Value "Místní zásady skupiny"
+New-ItemProperty -Path $ScriptPathStartup -Name "FileSysPath" -Value "C:\WINDOWS\System32\GroupPolicy\Machine"
+New-ItemProperty -Path $ScriptPathStartup -Name "GPO-ID" -Value "LocalGPO"
+New-ItemProperty -Path $ScriptPathStartup -Name "GPOName" -Value "Místní zásady skupiny"
+New-ItemProperty -Path $ScriptPathStartup -Name "PSScriptOrder" -Value "1" -PropertyType DWORD
+New-ItemProperty -Path $ScriptPathStartup -Name "SOM-ID" -Value "Local"
+}
+}
+ELSE {
+New-Item -Path $ScriptPathStartup -Name $reg -Force
+New-ItemProperty -Path "$PathScriptStartup" -Name "Script" -Value $ScriptStartup -Force
+New-ItemProperty -Path "$PathScriptStartup" -Name "Parameters" -Value "" -Force
+New-ItemProperty -Path "$PathScriptStartup" -Name "IsPowershell" -Value "1" -Force -PropertyType DWORD
+New-ItemProperty -Path "$PathScriptStartup" -Name "ExecTime" -Value "0" -Force -PropertyType QWORD
+
+New-ItemProperty -Path $ScriptPathStartup -Name "DisplayName" -Value "Místní zásady skupiny"
+New-ItemProperty -Path $ScriptPathStartup -Name "FileSysPath" -Value "C:\WINDOWS\System32\GroupPolicy\Machine"
+New-ItemProperty -Path $ScriptPathStartup -Name "GPO-ID" -Value "LocalGPO"
+New-ItemProperty -Path $ScriptPathStartup -Name "GPOName" -Value "Místní zásady skupiny"
+New-ItemProperty -Path $ScriptPathStartup -Name "PSScriptOrder" -Value "1" -PropertyType DWORD
+New-ItemProperty -Path $ScriptPathStartup -Name "SOM-ID" -Value "Local"
+}
+ ';
+ }
+
+}
diff --git a/src/classes/SensorTool.php b/src/classes/SensorTool.php
index 93d0f3a..0695620 100644
--- a/src/classes/SensorTool.php
+++ b/src/classes/SensorTool.php
@@ -3,7 +3,7 @@
namespace Icinga\Editor;
/**
- * Description of IESensorTool
+ * Sensor Tool
*
* @author vitex
*/
@@ -11,9 +11,9 @@ class SensorTool extends \Ease\Container
{
/**
- * Stav senzoru a jeho nastavení
+ * Sensor state & settings
*
- * @param IEHost $host
+ * @param Engine\Host $host
*/
public function __construct($host)
{
@@ -29,7 +29,7 @@ public function __construct($host)
$commonWell->addItem($commonRow);
$commonRow->addColumn(4,
- new \Ease\TWB\Panel(_('Ruční nastavení stavu senzoru'), 'info',
+ new \Ease\TWB\Panel(_('Set sensor state manually'), 'info',
new UI\SensorConfirmForm($host)));
@@ -40,11 +40,12 @@ public function __construct($host)
switch ($host->getDataValue('platform')) {
case 'windows':
$pltIco = 'logos/base/win40.gif';
- $cfgGenerator = new NSCPConfigBatGenerator($host);
+ $cfgBatGenerator = new NSCPConfigBatGenerator($host);
+ $cfgPS1Generator = new NSCPConfigPS1Generator($host);
if ($host->getCfgValue('active_checks_enabled')) {
$windowsActiveTab = $sensorTabs->addTab(_('Windows NRPE'));
- $windowsActiveTab->addItem(new \Ease\Html\H1Tag(''._('aktivní NRPE pro NSC++')));
+ $windowsActiveTab->addItem(new \Ease\Html\H1Tag(''._('Active NRPE for NSClient++')));
$windowsActiveTab->addItem(new \Ease\TWB\LinkButton('http://www.nsclient.org/download/',
' NSC++ '.\Ease\TWB\Part::GlyphIcon('download'),
'success',
@@ -56,21 +57,30 @@ public function __construct($host)
$windowsActiveTab->addItem(new \Ease\TWB\LinkButton('nscpcfggen.php?host_id='.$host->getId(),
$host->getName().'_nscp.bat '.\Ease\TWB\Part::GlyphIcon('download'),
'success'));
- $windowsActiveTab->addItem(new \Ease\TWB\Container(''.htmlspecialchars($cfgGenerator->getCfg(false)).'
',
+ $windowsActiveTab->addItem(new \Ease\TWB\Container(''.htmlspecialchars($cfgBatGenerator->getCfg(false)).'
',
['font-face' => 'fixed']));
}
if ($host->getCfgValue('passive_checks_enabled')) {
$windowsPassiveTab = $sensorTabs->addTab(_('Windows NSCA'));
- $windowsPassiveTab->addItem(new \Ease\Html\H1Tag(''._('pasivní NSCA pro NSC++')));
- $windowsPassiveTab->addItem(new \Ease\TWB\LinkButton('http://www.nsclient.org/download/',
- ' NSC++ '.\Ease\TWB\Part::GlyphIcon('download'),
- 'success',
- ['style' => "background-image:url('img/nscpp.png'); width: 212px; height: 60px; ",
- 'title' => 'Download']));
- $windowsPassiveTab->addItem(new \Ease\TWB\LinkButton('nscpcfggen.php?host_id='.$host->getId(),
+ $windowsPassiveTab->addItem(new \Ease\Html\H1Tag(''._('Passive NSCA for NSClient++')));
+ $windowsPassiveTab->addItem($this->nsclientDownload());
+
+ $winNscaTabs = $windowsPassiveTab->addItem(new \Ease\TWB\Tabs('WinNSCA'));
+
+ $ps1Tab = $winNscaTabs->addTab('PowerShell Configuration Script');
+
+ $ps1Tab->addItem(new \Ease\TWB\LinkButton('nscpcfggen.php?format=ps1&host_id='.$host->getId(),
+ $host->getName().'_nscp.ps1 '.\Ease\TWB\Part::GlyphIcon('download'),
+ 'success'));
+ $ps1Tab->addItem(new \Ease\TWB\Well(''.htmlspecialchars($cfgPS1Generator->getCfg(false),
+ ENT_QUOTES).'
', ['font-face' => 'fixed']));
+
+ $batTab = $winNscaTabs->addTab(_('Deprecated BAT Configuration Script'));
+
+ $batTab->addItem(new \Ease\TWB\LinkButton('nscpcfggen.php?host_id='.$host->getId(),
$host->getName().'_nscp.bat '.\Ease\TWB\Part::GlyphIcon('download'),
'success'));
- $windowsPassiveTab->addItem(new \Ease\TWB\Well(''.htmlspecialchars($cfgGenerator->getCfg(false),
+ $batTab->addItem(new \Ease\TWB\Well(''.htmlspecialchars($cfgBatGenerator->getCfg(false),
ENT_QUOTES).'
', ['font-face' => 'fixed']));
}
@@ -87,7 +97,7 @@ public function __construct($host)
$linuxActiveTab = $sensorTabs->addTab(_('Linux NRPE'));
$linuxActiveTab->addItem(new \Ease\Html\H1Tag(''._('aktivní NRPE pro NRPE Server')));
- $linuxActiveTab->addItem(new \Ease\Html\PTag(_('Nainstalujte nejprve senzor tímto příkazem').':'));
+ $linuxActiveTab->addItem(new \Ease\Html\PTag(_('Please install sensor first by this command').':'));
$linuxActiveTab->addItem(new \Ease\Html\Div('sudo aptitude -y install nagios-nrpe-server
',
['class' => 'code']));
@@ -99,18 +109,18 @@ public function __construct($host)
['font-face' => 'fixed']));
$linuxActiveTab->addItem(new \Ease\TWB\LinkButton('host.php?action=populate&host_id='.$host->getID(),
- _('Oskenovat a sledovat služby'), null,
+ _('Scan & watch services'), null,
['onClick' => "$('#preload').css('visibility', 'visible');"]));
}
if ($host->getCfgValue('passive_checks_enabled')) {
$linuxPassiveTab = $sensorTabs->addTab(_('Linux NSCA'));
- $linuxPassiveTab->addItem(new \Ease\Html\H1Tag(''._('pasivní NSCA pro NSCP Senzor')));
+ $linuxPassiveTab->addItem(new \Ease\Html\H1Tag(''._('Passive NSCA for NSCP Sensor')));
$linuxPassiveTab->addItem(new \Ease\TWB\LinkButton('nscpcfggen.php?host_id='.$host->getId(),
$host->getName().'_nscp.sh '.\Ease\TWB\Part::GlyphIcon('download'),
'success'));
- $cfgGenerator = new NSCPConfigBatGenerator($host);
- $linuxPassiveTab->addItem(new \Ease\TWB\Container(''.htmlspecialchars($cfgGenerator->getCfg(false)).'
',
+ $cfgBatGenerator = new NSCPConfigBatGenerator($host);
+ $linuxPassiveTab->addItem(new \Ease\TWB\Container(''.htmlspecialchars($cfgBatGenerator->getCfg(false)).'
',
['font-face' => 'fixed']));
}
break;
@@ -119,7 +129,7 @@ public function __construct($host)
if ($host->getCfgValue('active_checks_enabled')) {
$genericActiveTab = $sensorTabs->addTab(_('Generic Active'));
$genericActiveTab->addItem(new \Ease\TWB\LinkButton('host.php?action=populate&host_id='.$host->getID(),
- _('Oskenovat a sledovat služby'), null,
+ _('Scan & Watch services'), null,
['onClick' => "$('#preload').css('visibility', 'visible');"]));
}
if ($host->getCfgValue('passive_checks_enabled')) {
@@ -131,4 +141,17 @@ public function __construct($host)
$this->addItem($sensorTabs);
}
+ /**
+ * Give You button link to NSClient+ download page
+ *
+ * @return \Ease\TWB\LinkButton
+ */
+ public function nsclientDownload()
+ {
+ return new \Ease\TWB\LinkButton('http://www.nsclient.org/download/',
+ ' NSC++ '.\Ease\TWB\Part::GlyphIcon('download'), 'success',
+ ['style' => "background-image:url('img/nscpp.png'); width: 212px; height: 60px; ",
+ 'title' => _('Download NSClient++')]);
+ }
+
}
diff --git a/src/classes/UI/MainMenu.php b/src/classes/UI/MainMenu.php
index cdff455..8739553 100644
--- a/src/classes/UI/MainMenu.php
+++ b/src/classes/UI/MainMenu.php
@@ -6,14 +6,13 @@
* Hlavní menu
*
* @package VitexSoftware
- * @subpackage WebUI
* @author Vitex
*/
class MainMenu extends \Ease\Html\Div
{
/**
- * Vytvoří hlavní menu
+ * Create Main Menu
*/
public function __construct()
{
@@ -33,13 +32,13 @@ private function changesButton($nav)
if ($user->getSettingValue('unsaved') == true) {
$nav->addMenuItem(
new \Ease\TWB\LinkButton(
- 'regenall.php', _('Přegenerovat vše'), 'warning'
+ 'regenall.php', _('Regenerate All'), 'warning'
), 'right'
);
} else {
$nav->addMenuItem(
new \Ease\TWB\LinkButton(
- 'regenall.php', _('Přegenerovat vše'), 'default'
+ 'regenall.php', _('Regenerate All'), 'default'
), 'right'
);
}
@@ -49,12 +48,12 @@ private function changesButton($nav)
if ($user->getSettingValue('unsaved') == true) {
$nav->addMenuItem(
new \Ease\Html\ATag(
- 'apply.php', _('Uplatnit změny'), ['class' => 'btn btn-success']
+ 'apply.php', _('Apply changes'), ['class' => 'btn btn-success']
), 'right'
);
} else {
$nav->addMenuItem(new \Ease\Html\ATag('apply.php',
- _('Uplatnit změny'), ['class' => 'btn btn-inverse']), 'right');
+ _('Apply Changes'), ['class' => 'btn btn-inverse']), 'right');
}
}
@@ -81,12 +80,12 @@ private function groupsHostsMenu($nav)
$hostsNotInGroup[$hInfo['host_name']] = $hInfo;
}
$topItems = [
- 'wizard-host.php' => \Ease\TWB\Part::GlyphIcon('forward').' '._('Průvodce založením hostu'),
+ 'wizard-host.php' => \Ease\TWB\Part::GlyphIcon('forward').' '._('New Host wizard'),
];
- $topItems['wizard-active-host.php'] = \Ease\TWB\Part::GlyphIcon('star').' '._('Nový aktivní Host');
+ $topItems['wizard-active-host.php'] = \Ease\TWB\Part::GlyphIcon('star').' '._('New Active Host');
$hostgroup = new \Icinga\Editor\Engine\Hostgroup();
- $topItems['hostgroup.php'] = \Ease\TWB\Part::GlyphIcon('plus').' '._('Nová skupina hostů'); /* ,
+ $topItems['hostgroup.php'] = \Ease\TWB\Part::GlyphIcon('plus').' '._('New hostgroup'); /* ,
'exthostinfo.php' => _('Rozšířené informace hostů'),
'hostdependency.php' => _('Závislosti hostů'),
'hostescalation.php' => _('Eskalace hostů') */
@@ -123,7 +122,7 @@ private function groupsHostsMenu($nav)
}
}
}
- $topItems['hostgroups.php'] = \Ease\TWB\Part::GlyphIcon('list-alt').' '._('Přehled skupin hostů');
+ $topItems['hostgroups.php'] = \Ease\TWB\Part::GlyphIcon('list-alt').' '._('Hostgroup Overview');
} else {
if (count($hostGroupMenuItem)) {
$hostGroupMenuItem[] = '';
@@ -140,11 +139,11 @@ private function groupsHostsMenu($nav)
}
- $topItems['hosts.php'] = \Ease\TWB\Part::GlyphIcon('list').' '._('Detailní přehled hostů');
+ $topItems['hosts.php'] = \Ease\TWB\Part::GlyphIcon('list').' '._('Detail host overview');
- $topItems['map.php'] = \Ease\TWB\Part::GlyphIcon('globe').' '._('Topologie');
+ $topItems['map.php'] = \Ease\TWB\Part::GlyphIcon('globe').' '._('Topology');
- $nav->addDropDownMenu(_('Hosti'),
+ $nav->addDropDownMenu(_('Hosts'),
array_merge($topItems, ['' => ''], $hostGroupMenuItem));
}
@@ -178,13 +177,13 @@ public function afterAdd()
// $usergroups = $this->dblink->queryToArray('SELECT * FROM user_groups' . 'usergroup_id');
- $nav->addDropDownMenu(_('Uživatelé'),
+ $nav->addDropDownMenu(_('Users'),
array_merge($userList,
[
- 'createaccount.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('Nový uživatel'),
- 'users.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Přehled uživatelů'),
- 'usergroup.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('Nová skupina uživatelů'),
- 'usergroups.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Přehled skupin uživatelů'),
+ 'createaccount.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('New User'),
+ 'users.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Users Overview'),
+ 'usergroup.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('New Usergroup'),
+ 'usergroups.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Usergroup overview'),
])
);
}
@@ -198,19 +197,19 @@ public function afterAdd()
// $nav->addDropDownMenu(_('Hosti'), $hostGroupHostsMenuItem);
if (\Ease\Shared::user()->getSettingValue('admin')) {
- $nav->addDropDownMenu(_('Služby'),
+ $nav->addDropDownMenu(_('Services'),
[
- 'wizard-service.php' => \Ease\TWB\Part::GlyphIcon('forward').' '._('Průvodce založením služby'),
- 'service.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('Nová služba'),
- 'services.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Přehled služeb'),
- 'servicegroup.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('Nová skupina služeb'),
- 'servicegroups.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Přehled skupin služeb'), /*
+ 'wizard-service.php' => \Ease\TWB\Part::GlyphIcon('forward').' '._('New Service Wizard'),
+ 'service.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('New service'),
+ 'services.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Services overview'),
+ 'servicegroup.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('New servicegroup'),
+ 'servicegroups.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Servicegroups overview'), /*
'servicedependency.php' => _('Závislosti služeb'),
'extserviceinfo.php' => _('Rozšířené informace služeb'),
'serviceescalation.php' => _('Eskalace služeb') */
'' => '',
- 'stemplate.php?action=new' => \Ease\TWB\Part::GlyphIcon('plus').' '._('Nová sada sledované služby'),
- 'stemplates.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Přehled sad sledovanych služeb')
+ 'stemplate.php?action=new' => \Ease\TWB\Part::GlyphIcon('plus').' '._('New watched services set'),
+ 'stemplates.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Watched services sets overview')
]
);
} else {
@@ -219,7 +218,7 @@ public function afterAdd()
['icon_image', 'platform']);
if (count($services)) {
- $services_menu = ['services.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Přehled služeb')];
+ $services_menu = ['services.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Services overview')];
foreach ($services as $serviceID => $serviceInfo) {
$services_menu['servicetweak.php?service_id='.$serviceID]
= $serviceInfo[$service->nameColumn];
@@ -237,7 +236,7 @@ public function afterAdd()
}
if (count($contacts)) {
- $contacts_menu = ['contacts.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Přehled Kontaktů')];
+ $contacts_menu = ['contacts.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Contacts overview')];
foreach ($contacts as $contactID => $contactInfo) {
$contacts_menu['contacttweak.php?contact_id='.$contactID] = $contactInfo[$contact->nameColumn];
}
@@ -246,35 +245,35 @@ public function afterAdd()
$contacts_menu = [];
}
- $nav->addDropDownMenu(_('Kontakty'),
+ $nav->addDropDownMenu(_('Contacts'),
array_merge($contacts_menu,
[
- 'contacts.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Přehled kontaktů'),
- 'newcontact.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('Nový kontakt'),
- 'contactgroups.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Přehled skupin kontaktů'),
- 'contactgroup.php' => \Ease\TWB\Part::GlyphIcon('edit').' '._('Nová skupina kontaktů')]
+ 'contacts.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Contacts Overview'),
+ 'newcontact.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('New Contact'),
+ 'contactgroups.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Contactgroups overview'),
+ 'contactgroup.php' => \Ease\TWB\Part::GlyphIcon('edit').' '._('New contactgroup')]
));
if ($user->getSettingValue('admin')) {
- $nav->addDropDownMenu(_('Příkaz'),
+ $nav->addDropDownMenu(_('Command'),
[
- 'command.php' => \Ease\TWB\Part::GlyphIcon('edit').' '._('Nový příkaz'),
- 'commands.php' => \Ease\TWB\Part::GlyphIcon('list-alt').' '._('Přehled příkazů'),
- 'importcommand.php' => \Ease\TWB\Part::GlyphIcon('import').' '._('Importovat'),
+ 'command.php' => \Ease\TWB\Part::GlyphIcon('edit').' '._('New command'),
+ 'commands.php' => \Ease\TWB\Part::GlyphIcon('list-alt').' '._('Commands overview'),
+ 'importcommand.php' => \Ease\TWB\Part::GlyphIcon('import').' '._('Import'),
'',
- 'script.php' => \Ease\TWB\Part::GlyphIcon('edit').' '._('Nový skript'),
- 'scripts.php' => \Ease\TWB\Part::GlyphIcon('list-alt').' '._('Přehled skriptů')]
+ 'script.php' => \Ease\TWB\Part::GlyphIcon('edit').' '._('New script'),
+ 'scripts.php' => \Ease\TWB\Part::GlyphIcon('list-alt').' '._('Scripts Overview')]
);
- $nav->addDropDownMenu(_('Rozšířené'),
+ $nav->addDropDownMenu(_('Advanced'),
[
- 'timeperiods.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Přehled časových period'),
- 'timeperiod.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('Nová časová perioda'),
- 'preferences.php' => \Ease\TWB\Part::GlyphIcon('wrench').' '._('Nastavení icingy'),
- 'regenall.php' => \Ease\TWB\Part::GlyphIcon('ok').' '._('Přegenerovat všechny konfiguráky'),
- 'reset.php' => \Ease\TWB\Part::GlyphIcon('cog').' '._('Reset Objektů'),
- 'dbrecreate.php' => \Ease\TWB\Part::GlyphIcon('wrench').' '._('Reinicializovat databázi'),
- 'fixer.php' => \Ease\TWB\Part::GlyphIcon('ok-circle').' '._('Opravit databázi'),
- 'import.php' => \Ease\TWB\Part::GlyphIcon('import').' '._('Importovat')
+ 'timeperiods.php' => \Ease\TWB\Part::GlyphIcon('list').' '._('Timeperioods overview'),
+ 'timeperiod.php' => \Ease\TWB\Part::GlyphIcon('plus').' '._('New Timeperiod'),
+ 'preferences.php' => \Ease\TWB\Part::GlyphIcon('wrench').' '._('Icinga Settings'),
+ 'regenall.php' => \Ease\TWB\Part::GlyphIcon('ok').' '._('Regenerate All Config files'),
+ 'reset.php' => \Ease\TWB\Part::GlyphIcon('cog').' '._('Objects reset'),
+ 'dbrecreate.php' => \Ease\TWB\Part::GlyphIcon('wrench').' '._('Reinicialise database'),
+ 'fixer.php' => \Ease\TWB\Part::GlyphIcon('ok-circle').' '._('Database fix'),
+ 'import.php' => \Ease\TWB\Part::GlyphIcon('import').' '._('Configuration import')
/* 'module.php' => _('definice modulů') */ ]
);
}
@@ -287,7 +286,7 @@ public function afterAdd()
$results['/icinga-web/'] = \Ease\TWB\Part::GlyphIcon('Info').' '._('Icinga Web');
}
- $nav->addDropDownMenu(_('Výsledky testů'), $results);
+ $nav->addDropDownMenu(_('Tests results'), $results);
}
}
diff --git a/src/downtime.php b/src/downtime.php
index b2af609..a894854 100644
--- a/src/downtime.php
+++ b/src/downtime.php
@@ -31,8 +31,8 @@
$extCmd->addCommand(' PROCESS_HOST_CHECK_RESULT;'.$host->getName().';1;Host go Down');
break;
case 'stop':
- $extCmd->addCommand('DEL_DOWNTIME_BY_HOST_NAME;'.$host->getName());
$extCmd->addCommand('PROCESS_HOST_CHECK_RESULT;'.$host->getName().';0;Host go Up');
+ $extCmd->addCommand('DEL_DOWNTIME_BY_HOST_NAME;'.$host->getName());
break;
default :
$oPage->addStatusMessage(sprintf(_('Unknown state %s.'), $state));
diff --git a/src/nscpcfggen.php b/src/nscpcfggen.php
index b51149c..20f955b 100644
--- a/src/nscpcfggen.php
+++ b/src/nscpcfggen.php
@@ -17,5 +17,10 @@
$hostId = $oPage->getRequestValue('host_id', 'int');
$host = new Engine\Host($hostId);
-$generator = new NSCPConfigBatGenerator($host);
+if ($oPage->getRequestValue('format') == 'ps1') {
+ $generator = new NSCPConfigPS1Generator($host);
+} else {
+ $generator = new NSCPConfigBatGenerator($host);
+}
+
$generator->getCfg();