Example #1
0
 /**
  * Delete action for command
  *
  * @method get
  * @route /command/[i:id]/arguments
  */
 public function getArgumentsAction()
 {
     $di = Di::getDefault();
     $router = $di->get('router');
     $requestParam = $this->getParams('named');
     $connObj = new Command();
     $currentCommandLine = $connObj->getParameters($requestParam['id'], array('command_line'));
     $myArguments = array();
     $myArguments[] = array('name' => 'Test', "value" => 'My Value', 'example' => 'My Example');
     $myArguments[] = array('name' => 'Test', "value" => 'My Value', 'example' => 'My Example');
     $myArguments[] = array('name' => 'Test', "value" => 'My Value', 'example' => 'My Example');
     $router->response()->code(200)->json($myArguments);
 }
 /**
  * 
  * @param int $id
  * @return mixed
  */
 public static function getCommandName($id)
 {
     $res = Command::get($id, "command_name");
     if (is_array($res)) {
         $returnedValue = $res['command_name'];
     } else {
         $returnedValue = -1;
     }
     return $returnedValue;
 }
Example #3
0
 /**
  * Get command of a Host
  *
  *
  * @method get
  * @route /host/[i:id]/command
  */
 public function getHostCommandAction()
 {
     $requestParam = $this->getParams('named');
     $inerithedCommand = HostRepository::getInheritanceValues($requestParam['id'], true, array('command_command_id'));
     $commandName = "";
     if (isset($inerithedCommand['command_command_id']) && !is_null($inerithedCommand['command_command_id'])) {
         $command = Command::getParameters($inerithedCommand['command_command_id'], 'command_name');
         $commandName = $command['command_name'];
     }
     $this->router->response()->json($commandName);
 }
 /**
  * Get the full text of a numeric value
  *
  * @param string $name The key name
  * @param int $value The numeric value
  * @return string
  */
 public static function getTextValue($name, $value)
 {
     switch ($name) {
         case 'domain_id':
             $domain = Domain::get($value);
             return $domain['name'];
         case 'command_command_id':
         case 'command_command_id2':
             $command = Command::get($value);
             return $command['command_name'];
         case 'timeperiod_tp_id':
             $timeperiod = Timeperiod::get($value);
             return $timeperiod['tp_name'];
         case 'service_is_volatile':
         case 'service_active_checks_enabled':
         case 'service_passive_checks_enabled':
         case 'service_obsess_over_service':
         case 'service_check_freshness':
         case 'service_event_handler_enabled':
         case 'service_flap_detection_enabled':
             if ($value == 0) {
                 return _('No');
             } else {
                 if ($value == 1) {
                     return _('Yes');
                 } else {
                     return _('Default');
                 }
             }
         default:
             return $value;
     }
 }
 /**
  * Format data so that it can be displayed in slider
  *
  * @param array $data
  * @return array $checkdata
  */
 public static function formatDataForSlider($data)
 {
     /* Check data */
     $checkdata = array();
     $checkdata[_('id')] = $data['configurationData']['host_id'];
     $checkdata[_('name')] = $data['configurationData']['host_name'];
     $checkdata[_('command')] = "";
     if (isset($data['configurationData']['command_command_id']) && !is_null($data['configurationData']['command_command_id'])) {
         $command = Command::getParameters($data['configurationData']['command_command_id'], 'command_name');
         $checkdata[_('command')] = $command['command_name'];
     }
     $checkdata[_('time_period')] = "";
     if (isset($data['configurationData']['timeperiod_tp_id']) && !is_null($data['configurationData']['timeperiod_tp_id'])) {
         $timeperiod = Timeperiod::getParameters($data['configurationData']['timeperiod_tp_id'], 'tp_name');
         $checkdata[_('time_period')] = $timeperiod['tp_name'];
     }
     $checkdata[_('max_check attempts')] = "";
     if (isset($data['configurationData']['host_max_check_attempts'])) {
         $checkdata[_('max_check_attempts')] = $data['configurationData']['host_max_check_attempts'];
     }
     $checkdata[_('check_interval')] = "";
     if (isset($data['configurationData']['host_check_interval'])) {
         $checkdata[_('check_interval')] = $data['configurationData']['host_check_interval'];
     }
     $checkdata[_('retry_check_interval')] = "";
     if (isset($data['configurationData']['host_retry_check_interval'])) {
         $checkdata[_('retry_check_interval')] = $data['configurationData']['host_retry_check_interval'];
     }
     $checkdata[_('active_checks_enabled')] = "";
     if (isset($data['configurationData']['host_active_checks_enabled'])) {
         $checkdata[_('active_checks_enabled')] = YesNoDefault::toString($data['configurationData']['host_active_checks_enabled']);
     }
     $checkdata[_('passive_checks_enabled')] = "";
     if (isset($data['configurationData']['host_passive_checks_enabled'])) {
         $checkdata[_('passive_checks_enabled')] = YesNoDefault::toString($data['configurationData']['host_passive_checks_enabled']);
     }
     if (!empty($data['configurationData']['icon'])) {
         $checkdata[_('icon')] = $data['configurationData']['icon'];
     }
     $checkdata[_('status')] = "";
     if (!empty($data['realtimeData']['status'])) {
         $checkdata[_('status')] = $data['realtimeData']['status'];
     }
     $checkdata[_('state')] = "";
     if (!empty($data['realtimeData']['state_type'])) {
         $checkdata[_('state')] = $data['realtimeData']['state_type'];
     }
     $checkdata[_('last_check')] = "";
     if (!empty($data['realtimeData']['last_check'])) {
         $checkdata[_('last_check')] = Datetime::humanReadable(time() - $data['realtimeData']['last_check'], Datetime::PRECISION_FORMAT, 2);
     }
     $checkdata[_('next_check')] = "";
     if (!empty($data['realtimeData']['next_check'])) {
         $checkdata[_('next_check')] = Datetime::humanReadable(time() - $data['realtimeData']['next_check'], Datetime::PRECISION_FORMAT, 2);
     }
     $checkdata[_('acknowledged')] = "";
     if (!empty($data['realtimeData']['acknowledged'])) {
         $checkdata[_('acknowledged')] = $data['realtimeData']['acknowledged'];
     }
     $checkdata[_('downtime')] = "";
     if (!empty($data['realtimeData']['scheduled_downtime_depth'])) {
         $checkdata[_('downtime')] = $data['realtimeData']['scheduled_downtime_depth'];
     }
     return $checkdata;
 }
Example #6
0
 public function testGetColumns()
 {
     $this->assertEquals(array('command_id', 'connector_id', 'command_name', 'command_line', 'command_example', 'command_type', 'enable_shell', 'command_comment', 'graph_id', 'cmd_cat_id', 'organization_id'), Command::getColumns());
 }
Example #7
0
 /**
  * Used for inserting relation into database
  *
  * @param int $fkey
  * @param int $skey
  * @return void
  */
 public static function insert($fkey, $skey = null)
 {
     ExternalCommand::update($skey, array('connector_id' => $fkey));
 }
 /**
  * Get the full text of a numeric value
  *
  * @param string $name The key name
  * @param int $value The numeric value
  * @return string
  */
 public static function getTextValue($name, $value)
 {
     switch ($name) {
         case 'command_command_id':
         case 'command_command_id2':
             $command = Command::get($value);
             return $command['command_name'];
         case 'timeperiod_tp_id':
             $timeperiod = Timeperiod::get($value);
             return $timeperiod['tp_name'];
         case 'host_active_checks_enabled':
         case 'host_obsess_over_host':
         case 'host_check_freshness':
         case 'flap_detection_options':
         case 'host_event_handler_enabled':
             if ($value == 0) {
                 return _('No');
             } else {
                 if ($value == 1) {
                     return _('Yes');
                 } else {
                     return _('Default');
                 }
             }
         default:
             return $value;
     }
 }