Skip to content

Commit

Permalink
Merge pull request #632 from it-novum/ITC-1380
Browse files Browse the repository at this point in the history
ITC-1380 Refactor SudoServer - Add missing satellite_id to services/b…
  • Loading branch information
oliver-mueller authored Jul 20, 2017
2 parents 3b48cd0 + 6859746 commit c4c382f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
38 changes: 31 additions & 7 deletions app/Plugin/NagiosModule/Model/Externalcommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -1150,14 +1150,38 @@ public function test()
private function _write($content = '', $satellite_id = 0)
{
if ($satellite_id > 0) {
//Host or service on SAT system or command for $SAT$_nagios.cmd
$this->Satellite = ClassRegistry::init('DistributeModule.Satellite');
$sat = $this->Satellite->findById($satellite_id);
if (isset($sat['Satellite']['name'])) {
$file = fopen('/opt/openitc/nagios/var/rw/'.md5($sat['Satellite']['name']).'_nagios.cmd', 'a+');
fwrite($file, $this->_prefix().$content.PHP_EOL);
fclose($file);
//Loading distributed Monitoring support, if plugin is loaded/installed
$modulePlugins = array_filter(CakePlugin::loaded(), function ($value) {
return strpos($value, 'Module') !== false;
});

if (in_array('DistributeModule', $modulePlugins)) {
//DistributeModule is loaded and installed...
//Host or service on SAT system or command for $SAT$_nagios.cmd
$Satellite = ClassRegistry::init('DistributeModule.Satellite');

//Host or service on SAT system or command for $SAT$_nagios.cmd
$result = $Satellite->find('first', [
'recursive' => -1,
'conditions' => [
'Satellite.id' => $satellite_id
],
'fields' => [
'Satellite.id',
'Satellite.name'
]
]);
if (isset($result['Satellite']['name'])) {
$file = fopen('/opt/openitc/nagios/var/rw/'.md5($result['Satellite']['name']).'_nagios.cmd', 'a+');
fwrite($file, $this->_prefix().$content.PHP_EOL);
fclose($file);
}
unset($result);

}else{
return false;
}

} else {
//Host or service from master system or command for master nagios.cmd
if ($this->_is_resource()) {
Expand Down
2 changes: 1 addition & 1 deletion app/View/Services/browser.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ $Servicestatus = new Servicestatus($servicestatus['Servicestatus']);
</div>
<?php else: ?>
<h5><?php
echo $this->Form->input('satellite_id', ['type' => 'hidden', 'value' => $service['Host']['satellite_id']]); ?>
echo $this->Form->input('satellite_id', ['type' => 'hidden', 'value' => $service['Host']['satellite_id'], 'id' => 'nag_commandSatelliteId']); ?>
<span class="nag_command submitRescheduleService">
<i class="fa fa-refresh"></i>
<?php echo __('Reset check time'); ?>
Expand Down

0 comments on commit c4c382f

Please sign in to comment.