function sendDowntime($host_id = -1, $service_id = -1, $author = '', $comment = '', $flexible = '0', $start_time = '0', $end_time = '0', $duration = '3600', $operation = '') { global $DB; if ($host_id == -1 && $service_id == -1) { return false; } $pmTag = new PluginMonitoringTag(); $pmService = new PluginMonitoringService(); $pmService->getFromDB($service_id); $service_description = $pmService->getName(array('shinken' => '1')); $pmHost = new PluginMonitoringHost(); $pmHost->getFromDB($host_id == -1 ? $pmService->getHostID() : $host_id); $hostname = $pmHost->getName(true); // Downtime an host ... $acknowledgeServiceOnly = true; $a_fields = array(); if ($host_id == -1) { $tag = PluginMonitoringEntity::getTagByEntities($pmService->getEntityID()); } else { // ... one service of the host. $tag = PluginMonitoringEntity::getTagByEntities($pmHost->getEntityID()); } $ip = $pmTag->getIP($tag); $auth = $pmTag->getAuth($tag); $port = $pmTag->getPort($tag); $url = 'http://' . $ip . ':' . $port . '/'; $action = 'downtime'; $a_fields = array('action' => empty($operation) ? 'add' : $operation, 'host_name' => $hostname, 'service_description' => $service_description, 'author' => $author, 'comment' => mb_convert_encoding($comment, "iso-8859-1"), 'flexible' => $flexible, 'start_time' => PluginMonitoringServiceevent::convert_datetime_timestamp($start_time), 'end_time' => PluginMonitoringServiceevent::convert_datetime_timestamp($end_time), 'trigger_id' => '0', 'duration' => $duration); // Send downtime command ... return $this->sendCommand($url, $action, $a_fields, '', $auth); }
static function showService($items_id, $itemtype, $businessrules_id = 0) { global $LANG; if (!empty($items_id)) { $item = new $itemtype(); $item->getFromDB($items_id); echo "\n<table width='100%'><tr>"; echo "<td>"; echo "<input type='hidden' name='services_id[]' value='" . $items_id . "' />"; echo "<strong>" . $item->getName() . "</strong>"; echo " " . $LANG['networking'][25] . " "; $pmHost = new PluginMonitoringHost(); $pmHost->getFromDB($item->fields['plugin_monitoring_hosts_id']); $itemtype2 = $pmHost->fields['itemtype']; $item2 = new $itemtype2(); $item2->getFromDB($pmHost->fields['items_id']); echo $item2->getLink(1); echo "</td><td width='100'>"; echo "<input type='hidden' name='businessrules_id' value='" . $businessrules_id . "' />"; echo " <input type='submit' class='submit' name='delete' value='" . $LANG['buttons'][6] . "'"; echo "</td></tr></table>\n"; } else { echo "\n<table width='100%'><tr>"; echo "<td class='left'>"; self::dropdownService($items_id, array('name' => 'type')); echo "</td>\n"; echo "</tr></table>\n"; } }
static function displayHostLine($data) { global $DB, $CFG_GLPI; $pm_Host = new PluginMonitoringHost(); $pm_Host->getFromDB($data['id']); if ($data[3]['displayname'] == '') { $data[3]['displayname'] = 'UNKNOWN'; $data[4]['displayname'] = 'SOFT'; } $shortstate = $pm_Host->getState($data[3]['displayname'], $data[4]['displayname'], $data[6]['displayname'], $pm_Host->isCurrentlyAcknowledged()); echo "<td>"; echo $data[0]['displayname']; echo "</td>"; echo "<td>"; $item = new $data[1]['displayname'](); echo $item->getTypeName(); echo "</td>"; echo "<td>"; echo "<span>" . $pm_Host->getLink() . "</span>"; echo "</td>"; echo "<td class='center'>"; echo "<div class='page foldtl resource" . $data[3]['displayname'] . " resource" . $data[4]['displayname'] . "'>"; echo "<div style='vertical-align:middle;'>"; echo "<span>"; echo $data[3]['displayname']; echo "</span>"; echo "</div>"; echo "</div>"; echo "</td>"; if (isset($data['host_command_name'])) { $scriptName = $CFG_GLPI['root_doc'] . "/plugins/monitoring/scripts/" . $data['host_command_command']; $scriptArgs = $data[2]['displayname'] . " " . $data['ip']; echo "<td class='center'>"; echo "<form name='form' method='post'\n action='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/" . $data['host_command_command'] . ".php'>"; echo "<input type='hidden' name='host_id' value='" . $data[9]['displayname'] . "' />"; echo "<input type='hidden' name='host_name' value='" . $data[2]['displayname'] . "' />"; echo "<input type='hidden' name='host_ip' value='" . $data['ip'] . "' />"; echo "<input type='hidden' name='host_state' value='" . $data[3]['displayname'] . "' />"; echo "<input type='hidden' name='host_statetype' value='" . $data[4]['displayname'] . "' />"; echo "<input type='hidden' name='host_event' value='" . $data[6]['displayname'] . "' />"; echo "<input type='hidden' name='host_perfdata' value='" . $data[7]['displayname'] . "' />"; echo "<input type='hidden' name='host_last_check' value='" . $data[5]['displayname'] . "' />"; echo "<input type='hidden' name='glpi_users_id' value='" . $_SESSION['glpiID'] . "' />"; echo "<input type='submit' name='host_command' value=\"" . $data['host_command_name'] . "\" class='submit'>"; Html::closeForm(); echo "</td>"; } echo "<td class='center'>"; echo "<div class='page foldtl resource" . $data['host_services_state'] . "'>"; echo "<div style='vertical-align:middle;'>"; echo "<span>"; if (Session::haveRight("plugin_monitoring_service", READ)) { $link = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php?hidesearch=1" . "&criteria[0][field]=1" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=" . $data[9]['displayname'] . "&itemtype=PluginMonitoringService" . "&start=0'"; echo '<a href="' . $link . '">' . $data['host_services_state'] . "</a>"; } else { echo '<span>' . $data['host_services_state'] . "</span>"; } if (!empty($data['host_services_state_list'])) { echo " " . Html::showToolTip($data['host_services_state_list'], array('display' => false)); } echo "</span>"; echo "</div>"; echo "</div>"; echo "</td>"; echo "<td>"; echo $data['ip']; echo "</td>"; echo "<td>"; echo Html::convDate($data[5]['displayname']) . ' ' . substr($data[5]['displayname'], 11, 8); echo "</td>"; echo "<td>"; echo $data[6]['displayname']; echo "</td>"; echo "<td>"; echo $data[7]['displayname']; echo "</td>"; if (Session::haveRight("plugin_monitoring_acknowledge", READ) || Session::haveRight("plugin_monitoring_downtime", READ)) { echo "<td>"; // Manage downtimes for an host if (Session::haveRight("plugin_monitoring_downtime", READ)) { if ($pm_Host->isInScheduledDowntime()) { $pmDowntime = new PluginMonitoringDowntime(); $pmDowntime->getFromDBByQuery("WHERE `" . $pmDowntime->getTable() . "`.`plugin_monitoring_hosts_id` = '" . $pm_Host->getID() . "' ORDER BY end_time DESC LIMIT 1"); $downtime_id = $pmDowntime->getID(); // Toolbox::logInFile("pm", "Host ".$pm_Host->getName()." is in downtime period \n"); if (Session::haveRight("plugin_monitoring_downtime", CREATE)) { echo "<div style='float: left; margin-right: 10px;'>"; echo "<span>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/downtime.form.php?host_id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/downtime_scheduled.png'" . " alt='" . htmlspecialchars(__('Edit the downtime scheduled for the host', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('Edit the downtime scheduled for the host', 'monitoring'), ENT_QUOTES) . "'/>" . "</a>"; echo " </span>"; echo "</div>"; } else { echo "<div style='float: left; margin-right: 10px;'>"; echo "<span>"; echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/downtime_scheduled.png'" . " alt='" . htmlspecialchars(__('A downtime is scheduled for the host', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('A downtime is scheduled for the host', 'monitoring'), ENT_QUOTES) . "'/>"; echo " </span>"; echo "</div>"; } } else { if (Session::haveRight("plugin_monitoring_downtime", CREATE)) { echo "<div style='float: left; margin-right: 10px;'>"; echo "<span>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/downtime.form.php?id=-1&host_id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/downtime_to_schedule.png'" . " alt='" . htmlspecialchars(__('Schedule a downtime for the host', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('Schedule a downtime for the host', 'monitoring'), ENT_QUOTES) . "'/>" . "</a>"; echo " </span>"; echo "</div>"; } } } echo "<div style='float: left;'>"; // Manage acknowledgement for an host if ($pm_Host->isCurrentlyAcknowledged()) { if (Session::haveRight("plugin_monitoring_acknowledge", CREATE)) { echo "<span>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/acknowledge.form.php?itemtype=Host&items_id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/acknowledge_ok.png'" . " alt='" . htmlspecialchars(__('Modify acknowledge comment for the host', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('Modify acknowledge comment for the host', 'monitoring'), ENT_QUOTES) . "'" . " width='25' height='20'/>" . "</a>"; echo " </span>"; } else { echo "<span>"; echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/acknowledge_ok.png'" . " alt='" . htmlspecialchars(__('Host problem has been acknowledged', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('Host problem has been acknowledged', 'monitoring'), ENT_QUOTES) . "'" . " width='25' height='20'/>"; echo " </span>"; } // Display acknowledge data ... $pm_Host->getAcknowledge(); } else { if ($shortstate == 'red' || $shortstate == 'yellow' || $shortstate == 'orange' || !empty($data['host_services_state_list'])) { if (Session::haveRight("plugin_monitoring_acknowledge", CREATE)) { echo "<span>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/acknowledge.form.php?itemtype=Host&items_id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/acknowledge_ko.png'" . " alt='" . htmlspecialchars(__('Add an acknowledge for the host and all faulty services of the host', 'monitoring'), ENT_QUOTES) . "'" . " title='" . htmlspecialchars(__('Add an acknowledge for the host and all faulty services of the host', 'monitoring'), ENT_QUOTES) . "'" . " width='25' height='20'/>" . "</a>"; echo " </span>"; } } } echo "</div>"; echo "</td>"; } }
/** * Form to modify acknowledge of an host */ function showUpdateAcknowledgeForm($id=-1) { global $CFG_GLPI; Session::checkRight("plugin_monitoring_acknowledge", UPDATE); if ($id == -1) { $pm_Host = $this; } else { $pm_Host = new PluginMonitoringHost(); $pm_Host->getFromDB($id); } $hostname = $pm_Host->getName(); echo "<form name='form' method='post' action='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/acknowledge.form.php'>"; echo "<input type='hidden' name='host_id' value='$id' />"; echo "<input type='hidden' name='hostname' value='$hostname' />"; echo "<input type='hidden' name='hostAcknowledge' value='$hostname' />"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='2'>"; echo __('Modify acknowledge for the host', 'monitoring').' : '.$pm_Host->getLink(); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo __('Acknowledge comment', 'monitoring'); echo "</td>"; echo "<td>"; echo "<textarea cols='80' rows='4' name='acknowledge_comment' >".$pm_Host->fields['acknowledge_comment']."</textarea>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' align='center'>"; echo "<input type='hidden' name='id' value='".$pm_Host->fields['id']."' />"; echo "<input type='hidden' name='is_acknowledged' value='1' />"; echo "<input type='hidden' name='acknowledge_users_id' value='".$_SESSION['glpiID']."' />"; echo "<input type='hidden' name='referer' value='".$_SERVER['HTTP_REFERER']."' />"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo __('Acknowledge user', 'monitoring'); echo "</td>"; echo "<td>"; $user = new User(); $user->getFromDB($pm_Host->fields['acknowledge_users_id']); echo $user->getName(1); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='3' align='center'>"; echo "<input type='submit' name='update' value=\"".__('Update acknowledge comment', 'monitoring')."\" class='submit'>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); }
function showWidgetFrame($id, $reduced_interface = false, $is_minemap = FALSE) { global $DB, $CFG_GLPI; $pmParentSC = new PluginMonitoringServicescatalog(); $pMonitoringBusinessrule = new PluginMonitoringBusinessrule(); $pMonitoringBusinessrulegroup = new PluginMonitoringBusinessrulegroup(); $pMonitoringService = new PluginMonitoringService(); $this->getFromDB($id); $derivated = false; if ($this->getField('plugin_monitoring_servicescatalogs_id') > 0) { $derivated = true; $pmParentSC->getFromDB($this->getField('plugin_monitoring_servicescatalogs_id')); } $data = $this->fields; // Toolbox::logInFile("pm", "SC : ".$data['id'].", name : ".$data['name'].", derivated : ".$derivated."\n"); $colorclass = 'ok'; switch ($data['state']) { case 'CRITICAL': case 'DOWNTIME': $colorclass = 'crit'; break; case 'WARNING': case 'UNKNOWN': case 'RECOVERY': case 'FLAPPING': case '': $colorclass = 'warn'; break; } echo '<br/><div class="ch-itemup"> <div class="ch-info-' . $colorclass . '"> <h1><a href="' . $CFG_GLPI['root_doc'] . '/plugins/monitoring/front/servicescatalog.form.php?id=' . $data['id'] . '&detail=1">'; echo $data['name']; if ($data['comment'] != '') { echo ' ' . $this->getComments(); } echo '</a></h1> </div> </div>'; // If SC is derivated from a template, get groups from its parent ... if ($derivated) { $a_group = $pMonitoringBusinessrulegroup->find("`plugin_monitoring_servicescatalogs_id`='" . $pmParentSC->fields['id'] . "'"); } else { $a_group = $pMonitoringBusinessrulegroup->find("`plugin_monitoring_servicescatalogs_id`='" . $data['id'] . "'"); } // Array updated dynamically with groups/hosts/services status ... $colorclass = 'ok'; $a_gstate = array(); $cs_info = array(); foreach ($a_group as $gdata) { // Toolbox::logInFile("pm", "BR group : ".$gdata['id'].", name : ".$gdata['name']."\n"); $a_brules = $pMonitoringBusinessrule->find("`plugin_monitoring_businessrulegroups_id`='" . $gdata['id'] . "'"); $state = array(); $state['OK'] = 0; $state['WARNING'] = 0; $state['CRITICAL'] = 0; $cs_info_hosts = array(); $cs_info_services = array(); foreach ($a_brules as $brulesdata) { // If SC is derivated from a template, do not care about services not from the same entity ... if (!$pMonitoringService->getFromDB($brulesdata['plugin_monitoring_services_id'])) { continue; } if ($derivated && $pMonitoringService->getField('entities_id') != $this->getField('entities_id')) { continue; } // Toolbox::logInFile("pm", "BR : ".$brulesdata['id'].", service : ".$brulesdata['plugin_monitoring_services_id']."\n"); if (!isset($cs_info_hosts[$pMonitoringService->getHostName()])) { $cs_info_hosts[$pMonitoringService->getHostName()] = array(); } $cs_info_hosts[$pMonitoringService->getHostName()]['id'] = $pMonitoringService->getHostId(); $cs_info_hosts[$pMonitoringService->getHostName()]['name'] = $pMonitoringService->getHostName(); $cs_info_hosts[$pMonitoringService->getHostName()]['services'][$pMonitoringService->getName()]['id'] = $pMonitoringService->fields['id']; $cs_info_hosts[$pMonitoringService->getHostName()]['services'][$pMonitoringService->getName()]['state'] = $pMonitoringService->fields['state']; $cs_info_hosts[$pMonitoringService->getHostName()]['services'][$pMonitoringService->getName()]['last_check'] = $pMonitoringService->fields['last_check']; $cs_info_hosts[$pMonitoringService->getHostName()]['services'][$pMonitoringService->getName()]['event'] = $pMonitoringService->fields['event']; // Get all host services except if state is ok or is already acknowledged ... $a_ret = PluginMonitoringHost::getServicesState($pMonitoringService->getHostId(), "`glpi_plugin_monitoring_services`.`state` != 'OK'"); $cs_info_hosts[$pMonitoringService->getHostName()]['state'] = $a_ret[0]; $cs_info_services[$pMonitoringService->getName()] = $pMonitoringService->fields['plugin_monitoring_components_id']; switch ($pMonitoringService->fields['state']) { case 'UP': case 'OK': $state['OK']++; break; case 'DOWN': case 'UNREACHABLE': case 'CRITICAL': case 'DOWNTIME': $state['CRITICAL']++; break; case 'WARNING': case 'UNKNOWN': case 'RECOVERY': case 'FLAPPING': $state['WARNING']++; break; } } if ($state['CRITICAL'] >= 1) { $a_gstate[$gdata['id']] = "CRITICAL"; } else { if ($state['WARNING'] >= 1) { $a_gstate[$gdata['id']] = "WARNING"; } else { $a_gstate[$gdata['id']] = "OK"; } } $cs_info[$gdata['id']] = array(); $cs_info[$gdata['id']]['name'] = $gdata['name']; $cs_info[$gdata['id']]['state'] = $a_gstate[$gdata['id']]; $cs_info[$gdata['id']]['hosts'] = $cs_info_hosts; $cs_info[$gdata['id']]['services'] = $cs_info_services; } $state = array(); $state['OK'] = 0; $state['WARNING'] = 0; $state['CRITICAL'] = 0; foreach ($a_gstate as $value) { $state[$value]++; } $color = 'green'; if ($state['CRITICAL'] > 0) { $color = 'red'; $colorclass = 'crit'; } else { if ($state['WARNING'] > 0) { $color = 'orange'; $colorclass = 'warn'; } } echo '<div class="ch-itemdown"> <div class="ch-info-' . $colorclass . '"> <p><font style="font-size: 20px;">'; if ($colorclass != 'ok') { echo __('Degraded mode', 'monitoring') . '!'; } echo '</font></p> </div> </div>'; // Show a minemap if requested ... echo "<div class='minemapdiv' align='center'>" . "<a onclick='\$(\"#minemapSC-" . $id . "\").toggle();'>" . __('Minemap', 'monitoring') . "</a></div>"; if (!$is_minemap) { echo '<div class="minemapdiv" id="minemapSC-' . $id . '" style="display: none; z-index: 1500">'; } else { echo '<div class="minemapdiv" id="minemapSC-' . $id . '">'; } echo '<table class="tab_cadrehov">'; foreach ($cs_info as $groupName => $group) { echo '<table class="tab_cadrehov">'; echo '<tr>'; echo '<th colspan="' . (1 + count($group['services'])) . '">' . __('Business rules group', 'monitoring') . " : " . $group['name'] . '</th>'; echo '</tr>'; echo '<tr>'; echo "<th>"; echo __('Hosts', 'monitoring'); echo "</th>"; foreach ($group['services'] as $serviceName => $service) { if (Session::haveRight("plugin_monitoring_service", READ)) { $link = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php?hidesearch=1" . "&criteria[0][field]=2" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=" . $service . "&itemtype=PluginMonitoringService" . "&start=0'"; echo '<th class="vertical">'; echo '<a href="' . $link . '"><div class="rotated-text"><span class="rotated-text__inner">' . $serviceName . '</span></div></a>'; echo '</th>'; } else { echo '<th class="vertical">'; echo '<div class="rotated-text"><span class="rotated-text__inner">' . $serviceName . '</span></div>'; echo '</th>'; } } echo '</tr>'; foreach ($group['hosts'] as $host) { echo "<tr class='tab_bg_2' style='height: 50px;'>"; if (Session::haveRight("plugin_monitoring_service", READ)) { $link = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php?hidesearch=1" . "&criteria[0][field]=20" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=" . $host['id'] . "&itemtype=PluginMonitoringService" . "&start=0'"; echo "<td class='left'><a href='" . $link . "'>" . $host['name'] . "</a></td>"; } else { echo "<td class='left'>" . $host['name'] . "</td>"; } // echo "<td class='left'>".$host['name']."</td>"; foreach ($host['services'] as $serviceName => $service) { echo '<td>'; echo '<div title="' . $service['last_check'] . ' - ' . $service['event'] . '" class="service service' . $service['state'] . '"></div>'; echo '</td>'; } echo '</tr>'; } echo '</table>'; } echo '</table>'; echo '</div>'; }
if ($_POST["idtable"] && class_exists($_POST["idtable"])) { $table = getTableForItemType($_POST["idtable"]); // Link to user for search only > normal users $link = "dropdownValue.php"; $rand = mt_rand(); $use_ajax = false; if ($CFG_GLPI["use_ajax"] && countElementsInTable($table) > $CFG_GLPI["ajax_limit_count"]) { $use_ajax = true; } $paramsallitems = array('searchText' => '__VALUE__', 'table' => $table, 'itemtype' => $_POST["idtable"], 'rand' => $rand, 'myname' => $_POST["myname"], 'displaywith' => array('otherserial', 'serial'), 'display_emptychoice' => true); if (isset($_POST['value'])) { $paramsallitems['value'] = $_POST['value']; } if (isset($_POST['entity_restrict'])) { $paramsallitems['entity_restrict'] = $_POST['entity_restrict']; } if (isset($_POST['condition'])) { $paramsallitems['condition'] = stripslashes($_POST['condition']); } $pmHost = new PluginMonitoringHost(); $classname = $_POST['idtable']; $class = new $classname(); $a_list = $pmHost->find("`itemtype`='" . $classname . "'"); $a_elements = array(); foreach ($a_list as $data) { $class->getFromDB($data['items_id']); $a_elements[$data['id']] = $class->getName(); } asort($a_elements); Dropdown::showFromArray($_POST['myname'], $a_elements); }
function showWidgetFrame($id, $reduced_interface=false, $is_minemap=FALSE) { global $DB, $CFG_GLPI; $this->getFromDB($id); $data = $this->fields; $ret = $this->getInfoOfCatalog($id); $nb_ressources = $ret[0]; if ($nb_ressources == 0) { echo '<div class="ch-item"> <div> <h1>'.__('Nothing to display ...', 'monitoring').'</h1> </div> </div>'; return; } $stateg = $ret[1]; $hosts_ids = $ret[2]; $services_ids = $ret[3]; $hosts_ressources = $ret[4]; $hosts_states = $ret[5]; $colorclass = 'ok'; $count = 0; $link = ''; // Toolbox::logInFile("pm", "stateg $id - ".serialize($stateg)."\n"); if ($stateg['CRITICAL'] > 0) { $count = $stateg['CRITICAL']; $colorclass = 'crit'; $link = $CFG_GLPI['root_doc']. "/plugins/monitoring/front/service.php?hidesearch=1" // . "&reset=reset&" . "criteria[0][field]=3" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=CRITICAL" . "&criteria[1][link]=AND" . "&criteria[1][field]=9" . "&criteris[1][searchtype]=equals" . "&criteria[1][value]=".$id . "&itemtype=PluginMonitoringService" . "&start=0"; } else if ($stateg['WARNING'] > 0) { $count = $stateg['WARNING']; $colorclass = 'warn'; $link = $CFG_GLPI['root_doc']. "/plugins/monitoring/front/service.php?hidesearch=1" // . "&reset=reset" . "&criteria[0][field]=3" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=WARNING" . "&criteria[1][link]=AND" . "&criteria[1][field]=9" . "&criteria[1][searchtype]=equals" . "&criteria[1][value]=".$id . "&criteria[2][link]=OR" . "&criteria[2][field]=3" . "&criteria[2][searchtype]=equals" . "&criteria[2][value]=UNKNOWN" . "&criteria[3][link]=AND" . "&criteria[3][field]=9" . "&criteria[3][searchtype]=equals" . "&criteria[3][value]=".$id . "&criteria[4][link]=OR" . "&criteria[4][field]=3" . "&criteria[4][searchtype]=equals" . "&criteria[4][value]=RECOVERY" . "&criteria[5][link]=AND" . "&criteria[5][field]=9" . "&criteria[5][searchtype]=equals" . "&criteria[5][value]=".$id . "&criteria[6][link]=OR" . "&criteria[6][field]=3" . "&criteria[6][searchtype]=equals" . "&criteria[6][value]=FLAPPING" . "&criteria[7][link]=AND" . "&criteria[7][field]=9" . "&criteria[7][searchtype]=equals" . "&criteria[7][value]=".$id . "&itemtype=PluginMonitoringService" . "&start=0"; } else { $count = $stateg['OK']; $count += $stateg['ACKNOWLEDGE']; $count += $stateg['UNKNOWN']; $link = $CFG_GLPI['root_doc']. "/plugins/monitoring/front/service.php?hidesearch=1" // . "&reset=reset" . "&criteria[0][field]=3" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=OK" . "&criteria[1][link]=AND" . "&criteria[1][field]=9" . "&criteria[1][searchtype]=equals" . "&criteria[1][value]=".$id . "&criteria[2][link]=OR" . "&criteria[2][field]=3" . "&criteria[2][searchtype]=equals" . "&criteria[2][value]=UP" . "&itemtype=PluginMonitoringService" . "&start=0"; } if (Session::haveRight("plugin_monitoring_service", READ)) { $link_catalog = $CFG_GLPI['root_doc']. "/plugins/monitoring/front/service.php?hidesearch=1" // . "&reset=reset" . "&criteria[0][field]=9" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=".$id . "&itemtype=PluginMonitoringService" . "&start=0"; echo '<div class="ch-item"> <div class="ch-info-'.$colorclass.'"> <h1><a href="'.$link_catalog.'">'.ucfirst($data['name']); if ($data['comment'] != '') { echo ' '.$this->getComments(); } echo '</a></h1> <p><a href="'.$link.'">'.$count.'</a><font style="font-size: 14px;">/ '. ($stateg['CRITICAL'] + $stateg['WARNING'] + $stateg['OK'] + $stateg['ACKNOWLEDGE'] + $stateg['UNKNOWN']).'</font></p> </div> </div>'; } else { echo '<div class="ch-item"> <div class="ch-info-'.$colorclass.'"> <h1>'.ucfirst($data['name']); if ($data['comment'] != '') { echo ' '.$this->getComments(); } echo '</h1> <p>'.$count.'<font style="font-size: 14px;">/ '. ($stateg['CRITICAL'] + $stateg['WARNING'] + $stateg['OK'] + $stateg['ACKNOWLEDGE'] + $stateg['UNKNOWN']).'</font></p> </div> </div>'; } // Get services list ... $services = array(); $i = 0; foreach ($hosts_ressources as $resources) { foreach ($resources as $resource=>$status) { $services[$i++] = $resource; } break; } sort($services); echo "<div class='minemapdiv' align='center'>" ."<a onclick='$(\"#minemapCC-".$id."\").toggle();'>" .__('Minemap', 'monitoring')."</a></div>"; if (!$is_minemap) { echo '<div class="minemapdiv" id="minemapCC-'.$id.'" style="display: none; z-index: 1500">'; } else { echo '<div class="minemapdiv" id="minemapCC-'.$id.'">'; } echo '<table class="tab_cadrehov" >'; // Header with services name and link to services list ... echo "<tr>"; echo "<th colspan='2'>"; echo __('Hosts', 'monitoring'); echo "</th>"; for ($i = 0; $i < count($services); $i++) { // Do not display fake host service ... if ($services[$i] == '_fake_') continue; if (Session::haveRight("plugin_monitoring_service", READ)) { $link = $CFG_GLPI['root_doc']. "/plugins/monitoring/front/service.php?hidesearch=1" // . "&reset=reset" . "&criteria[0][field]=2" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=".$services_ids[$services[$i]] . "&itemtype=PluginMonitoringService" . "&start=0'"; echo '<th class="vertical">'; echo '<a href="'.$link.'"><div class="rotated-text"><span class="rotated-text__inner">'.$services[$i].'</span></div></a>'; echo '</th>'; } else { echo '<th class="vertical">'; echo '<div class="rotated-text"><span class="rotated-text__inner">'.$services[$i].'</span></div>'; echo '</th>'; } } echo '</tr>'; $pmHost = new PluginMonitoringHost(); $entityId = -1; $overallServicesState = 'OK'; foreach ($hosts_ressources as $hosts_id=>$resources) { // Reduced array or not ? if ($reduced_interface and $hosts_states[$hosts_id]) continue; $pmHost->getFromDB($hosts_ids[$hosts_id]['id']); if ($entityId != $pmHost->fields['entities_id']) { if ($entityId != -1) { echo "</table>"; if ($overallServicesState != 'OK') { echo "<script> Ext.onReady(function(){ toggleEntity('entity-$id-$entityId'); });</script>"; $overallServicesState = 'OK'; } } // A new sub-table for each entity ... $entityId = $pmHost->fields['entities_id']; $pmEntity = new Entity(); $pmEntity->getFromDB($entityId); echo "<tr class='tab_bg_1'>"; echo "<table class='tab_cadrehov' style='height: auto;' id='entity-$id-$entityId' onClick='javascript: toggleEntity(\"entity-$id-$entityId\");'>"; $overallServicesState = 'OK'; echo "<tr class='header'><th class='left' style='height:50px;' colspan='".(count($services))."'>".$pmEntity->fields['name']."</th></tr>"; } $field_id = 20; if ($hosts_ids[$hosts_id]['itemtype'] == 'Printer') { $field_id = 21; } else if ($hosts_ids[$hosts_id]['itemtype'] == 'NetworkEquipment') { $field_id = 22; } $link = $CFG_GLPI['root_doc']. "/plugins/monitoring/front/service.php?hidesearch=1" // . "&reset=reset" . "&criteria[0][field]=".$field_id."" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=".$hosts_ids[$hosts_id]['items_id'] . "&itemtype=PluginMonitoringService" . "&start=0'"; if ($hosts_states[$hosts_id]) { echo "<tr class='services tab_bg_2' style='display:none;'>"; } else { echo "<tr class='services tab_bg_3' style='display:none;'>"; } // echo "<td><div style='width: 5px !important;'> </div></td>"; if (Session::haveRight("plugin_monitoring_service", READ)) { $item = new $hosts_ids[$hosts_id]['itemtype']; $item->getFromDB($hosts_ids[$hosts_id]['items_id']); echo "<td class='left'><a href='".$link."'>".$hosts_ids[$hosts_id]['name']."</a> ".$item->getComments()."</td>"; } else { echo "<td class='left'>".$hosts_ids[$hosts_id]['name']."</td>"; } for ($i = 0; $i < count($services); $i++) { if ($services[$i] == '_fake_') continue; if ($resources[$services[$i]]['state'] != 'OK') { $overallServicesState = $resources[$services[$i]]['state']; } echo '<td class="serviceState">'; if (Session::haveRight("plugin_monitoring_service", READ)) { $link_service = $link; $link_service .= "&link[1]=AND&field[1]=2&searchtype[1]=equals&contains[1]=". $resources[$services[$i]]['plugin_monitoring_components_id']; echo '<a href="'.$link_service.'">'. '<div title="'.$resources[$services[$i]]['state']. " - ".$resources[$services[$i]]['last_check']." - ". $resources[$services[$i]]['event']. '" class="service service'.$resources[$services[$i]]['state_type'].' service'.$resources[$services[$i]]['state'].'"></div>'. '</a>'; } else { echo '<div title="'.$resources[$services[$i]]['state']. " - ".$resources[$services[$i]]['last_check']." - ". $resources[$services[$i]]['event']. '" class="service service'.$resources[$services[$i]]['state_type'].' service'.$resources[$services[$i]]['state'].'"></div>'; } echo '</td>'; } echo '</tr>'; } echo '</table>'; echo '</div>'; if ($overallServicesState != 'OK') { echo "<script> Ext.onReady(function(){ toggleEntity('entity-$id-$entityId'); });</script>"; } }
function pluginMonitoringUpdate($current_version, $migrationname = 'Migration') { global $DB; $migration = new $migrationname($current_version); if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/weathermapbg')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg"); } $unavailability_recalculate = 0; if (!TableExists("glpi_plugin_monitoring_unavailabilities") || !FieldExists("glpi_plugin_monitoring_unavailabilities", "duration")) { $unavailability_recalculate = 1; } $unavailability_reset = 0; if (!TableExists("glpi_plugin_monitoring_unavailabilities")) { $unavailability_reset = 1; } /* * Table glpi_plugin_monitoring_servicescatalogs */ $newTable = "glpi_plugin_monitoring_servicescatalogs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'is_recursive', 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'comment', 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'last_check', 'last_check', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'state', 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'state_type', 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_checks_id', 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'calendars_id', 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'last_check', "datetime DEFAULT NULL"); $migration->addField($newTable, 'event', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_acknowledged', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_acknowledgeconfirmed', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'acknowledge_comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'acknowledge_users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'notification_interval', "int(4) NOT NULL DEFAULT '30'"); $migration->addField($newTable, 'business_priority', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'is_generic', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_servicescatalogs_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, "name"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_componentscatalogs */ $newTable = "glpi_plugin_monitoring_componentscatalogs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'is_recursive', 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'comment', 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'notification_interval', 'notification_interval', "int(4) NOT NULL DEFAULT '30'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'notification_interval', "int(4) NOT NULL DEFAULT '30'"); $migration->addKey($newTable, "name"); $migration->migrationOneTable($newTable); /* * glpi_plugin_monitoring_perfdatas */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_perfdatas'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'name' => array('type' => 'string', 'value' => NULL), 'perfdata' => array('type' => 'text', 'value' => NULL)); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * glpi_plugin_monitoring_customitems_counters */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_customitems_counters'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'name' => array('type' => 'string', 'value' => NULL), 'entities_id' => array('type' => 'integer', 'value' => NULL), 'is_recursive' => array('type' => 'bool', 'value' => NULL), 'type' => array('type' => 'string', 'value' => NULL), 'aggregate_items' => array('type' => 'text', 'value' => NULL), 'time' => array('type' => 'string', 'value' => NULL), 'time_specific' => array('type' => 'string', 'value' => NULL)); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * glpi_plugin_monitoring_customitems_gauges */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_customitems_gauges'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'name' => array('type' => 'string', 'value' => NULL), 'entities_id' => array('type' => 'integer', 'value' => NULL), 'is_recursive' => array('type' => 'bool', 'value' => NULL), 'type' => array('type' => 'string', 'value' => NULL), 'aggregate_items' => array('type' => 'text', 'value' => NULL), 'aggregate_warn' => array('type' => 'text', 'value' => NULL), 'aggregate_crit' => array('type' => 'text', 'value' => NULL), 'aggregate_limit' => array('type' => 'text', 'value' => NULL), 'time' => array('type' => 'string', 'value' => NULL), 'time_specific' => array('type' => 'string', 'value' => NULL)); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * glpi_plugin_monitoring_perfdatadetails */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_perfdatadetails'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'name' => array('type' => 'string', 'value' => NULL), 'dynamic_name' => array('type' => 'bool', 'value' => NULL), 'plugin_monitoring_perfdatas_id' => array('type' => 'integer', 'value' => NULL), 'position' => array('type' => "int(2) NOT NULL DEFAULT '0'", 'value' => NULL), 'dsname_num' => array('type' => 'tinyint(1) NOT NULL DEFAULT "1"', 'value' => NULL), 'dsname1' => array('type' => 'string', 'value' => NULL), 'dsname2' => array('type' => 'string', 'value' => NULL), 'dsname3' => array('type' => 'string', 'value' => NULL), 'dsname4' => array('type' => 'string', 'value' => NULL), 'dsname5' => array('type' => 'string', 'value' => NULL), 'dsname6' => array('type' => 'string', 'value' => NULL), 'dsname7' => array('type' => 'string', 'value' => NULL), 'dsname8' => array('type' => 'string', 'value' => NULL), 'dsname9' => array('type' => 'string', 'value' => NULL), 'dsname10' => array('type' => 'string', 'value' => NULL), 'dsname11' => array('type' => 'string', 'value' => NULL), 'dsname12' => array('type' => 'string', 'value' => NULL), 'dsname13' => array('type' => 'string', 'value' => NULL), 'dsname14' => array('type' => 'string', 'value' => NULL), 'dsname15' => array('type' => 'string', 'value' => NULL), 'dsnameincr1' => array('type' => 'bool', 'value' => 0), 'dsnameincr2' => array('type' => 'bool', 'value' => 0), 'dsnameincr3' => array('type' => 'bool', 'value' => 0), 'dsnameincr4' => array('type' => 'bool', 'value' => 0), 'dsnameincr5' => array('type' => 'bool', 'value' => 0), 'dsnameincr6' => array('type' => 'bool', 'value' => 0), 'dsnameincr7' => array('type' => 'bool', 'value' => 0), 'dsnameincr8' => array('type' => 'bool', 'value' => 0), 'dsnameincr9' => array('type' => 'bool', 'value' => 0), 'dsnameincr10' => array('type' => 'bool', 'value' => 0), 'dsnameincr11' => array('type' => 'bool', 'value' => 0), 'dsnameincr12' => array('type' => 'bool', 'value' => 0), 'dsnameincr13' => array('type' => 'bool', 'value' => 0), 'dsnameincr14' => array('type' => 'bool', 'value' => 0), 'dsnameincr15' => array('type' => 'bool', 'value' => 0)); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(array('field' => 'plugin_monitoring_perfdatas_id', 'name' => '', 'type' => 'INDEX')); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); if (countElementsInTable('glpi_plugin_monitoring_perfdatas') == 0) { include GLPI_ROOT . "/plugins/monitoring/inc/perfdata.class.php"; include GLPI_ROOT . "/plugins/monitoring/inc/perfdatadetail.class.php"; PluginMonitoringPerfdata::initDB(); } /* * Table glpi_plugin_monitoring_components */ if (TableExists('glpi_plugin_monitoring_components')) { $a_data = getAllDatasFromTable('glpi_plugin_monitoring_components'); foreach ($a_data as $data) { if (!is_numeric($data['graph_template'])) { $a_perfs = getAllDatasFromTable('glpi_plugin_monitoring_perfdatas', '`name`="' . $data['graph_template'] . '"'); if (count($a_perfs) == 0) { $DB->query("UPDATE `glpi_plugin_monitoring_components`\n SET `graph_template`='0'\n WHERE `id`='" . $data['id'] . "'"); } else { $a_perf = current($a_perfs); $DB->query("UPDATE `glpi_plugin_monitoring_components`\n SET `graph_template`='" . $a_perf['id'] . "'\n WHERE `id`='" . $data['id'] . "'"); } } } } $newTable = "glpi_plugin_monitoring_components"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); // 0.84+1.3 $migration->changeField($newTable, 'description', 'description', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_commands_id', 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'arguments', 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'plugin_monitoring_checks_id', 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'active_checks_enabled', 'active_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'passive_checks_enabled', 'passive_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'calendars_id', 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'remotesystem', 'remotesystem', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'is_arguments', 'is_arguments', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'alias_command', 'alias_command', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'graph_template', 'graph_template', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'link', 'link', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'is_weathermap', 'is_weathermap', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'weathermap_regex', 'weathermap_regex_in', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'perfname', 'perfname', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'perfnameinvert', 'perfnameinvert', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'perfnamecolor', 'perfnamecolor', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); // 0.84+1.3 $migration->addField($newTable, 'description', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'active_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'passive_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'remotesystem', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'is_arguments', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'alias_command', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'graph_template', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'link', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'is_weathermap', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'weathermap_regex_in', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'weathermap_regex_out', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'perfname', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'perfnameinvert', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'perfnamecolor', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'plugin_monitoring_eventhandlers_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'freshness_count', "int(6) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'freshness_type', "varchar(255) DEFAULT 'seconds'"); $migration->addKey($newTable, "plugin_monitoring_commands_id"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_componentscatalogs_components */ $newTable = "glpi_plugin_monitoring_componentscatalogs_components"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_componentscalalog_id', 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_components_id', 'plugin_monitoring_components_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_components_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, array('plugin_monitoring_componentscalalog_id', 'plugin_monitoring_components_id'), "unicity", "UNIQUE"); $migration->addKey($newTable, "plugin_monitoring_componentscalalog_id"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_componentscatalogs_hosts */ $newTable = "glpi_plugin_monitoring_componentscatalogs_hosts"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_componentscalalog_id', 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'is_static', 'is_static', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_static', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addKey($newTable, array('itemtype', 'items_id'), 'itemtype'); $migration->addKey($newTable, 'plugin_monitoring_componentscalalog_id'); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_componentscatalogs_rules */ $newTable = "glpi_plugin_monitoring_componentscatalogs_rules"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_componentscalalog_id', 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'condition', 'condition', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->dropField($newTable, 'entities_id'); $migration->dropField($newTable, 'is_recursive'); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'itemtype', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'condition', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addKey($newTable, 'plugin_monitoring_componentscalalog_id'); $migration->migrationOneTable($newTable); $DB->query("UPDATE `glpi_plugin_monitoring_componentscatalogs_rules`\n SET `itemtype`='Computer' WHERE `itemtype`='PluginMonitoringComputer'"); /* * Table glpi_plugin_monitoring_services */ $newTable = "glpi_plugin_monitoring_services"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_components_id', 'plugin_monitoring_components_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_componentscatalogs_hosts_id', 'plugin_monitoring_componentscatalogs_hosts_id', "int(11) NOT NULL DEFAULT '0'"); // Event should contain up to 4096 bytes (Nagios plugin specification) $migration->changeField($newTable, 'event', 'event', "varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL"); // $migration->changeField($newTable, // 'event', // 'event', // "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'state', 'state', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'state_type', 'state_type', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'last_check', 'last_check', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'arguments', 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'networkports_id', 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->dropField($newTable, 'alias_command'); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_components_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_componentscatalogs_hosts_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'event', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state_type', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'last_check', "datetime DEFAULT NULL"); $migration->addField($newTable, 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_acknowledged', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_acknowledgeconfirmed', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'acknowledge_comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'acknowledge_users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, array('state', 'state_type'), 'state'); $migration->addKey($newTable, 'plugin_monitoring_componentscatalogs_hosts_id'); $migration->addKey($newTable, 'last_check'); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contacttemplates */ $newTable = "glpi_plugin_monitoring_contacttemplates"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'is_default', 'is_default', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'shinken_administrator', 'shinken_administrator', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'shinken_can_submit_commands', 'shinken_can_submit_commands', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notifications_enabled', 'host_notifications_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notifications_enabled', 'service_notifications_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notification_period', 'service_notification_period', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notification_period', 'host_notification_period', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'service_notification_options_w', 'service_notification_options_w', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notification_options_u', 'service_notification_options_u', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notification_options_c', 'service_notification_options_c', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notification_options_r', 'service_notification_options_r', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notification_options_f', 'service_notification_options_f', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'service_notification_options_n', 'service_notification_options_n', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notification_options_d', 'host_notification_options_d', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'host_notification_options_u', 'host_notification_options_u', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'host_notification_options_r', 'host_notification_options_r', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'host_notification_options_f', 'host_notification_options_f', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notification_options_s', 'host_notification_options_s', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notification_options_n', 'host_notification_options_n', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'service_notification_commands', 'service_notification_commands', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notification_commands', 'host_notification_commands', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'is_default', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'shinken_administrator', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'shinken_can_submit_commands', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notifications_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notifications_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notification_period', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notification_period', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'service_notification_options_w', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notification_options_u', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notification_options_c', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notification_options_r', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notification_options_f', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'service_notification_options_n', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notification_options_d', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'host_notification_options_u', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'host_notification_options_r', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'host_notification_options_f', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notification_options_s', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notification_options_n', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'service_notification_commands', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notification_commands', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contacts */ $newTable = "glpi_plugin_monitoring_contacts"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'users_id', 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_contacttemplates_id', 'plugin_monitoring_contacttemplates_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_contacttemplates_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contacts_items */ $newTable = "glpi_plugin_monitoring_contacts_items"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'users_id', 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'groups_id', 'groups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'groups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_commandtemplates */ $newTable = "glpi_plugin_monitoring_commandtemplates"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_commands_id', 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'key', 'key', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'key', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_rrdtooltemplates */ $newTable = "glpi_plugin_monitoring_rrdtooltemplates"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_commands_id', 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'key', 'key', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'key', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_configs */ $newTable = "glpi_plugin_monitoring_configs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'timezones', 'timezones', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '[\"0\"]'"); $migration->changeField($newTable, 'version', 'version', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'logretention', 'logretention', "int(5) NOT NULL DEFAULT '30'"); $migration->changeField($newTable, 'nrpe_prefix_contener', 'nrpe_prefix_contener', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'append_id_hostname', 'append_id_hostname', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->dropField($newTable, 'phppath'); $migration->dropField($newTable, 'rrdtoolpath'); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'timezones', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '[\"0\"]'"); $migration->addField($newTable, 'version', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'logretention', "int(5) NOT NULL DEFAULT '30'"); $migration->addField($newTable, 'extradebug', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'nrpe_prefix_contener', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'append_id_hostname', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_displayviews */ $newTable = "glpi_plugin_monitoring_displayviews"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'is_recursive', 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'is_active', 'is_active', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'users_id', 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'counter', 'counter', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'in_central', 'in_central', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'width', 'width', "int(5) NOT NULL DEFAULT '950'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_active', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'counter', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'in_central', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'width', "int(5) NOT NULL DEFAULT '950'"); $migration->addField($newTable, 'is_frontview', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_displayviews_groups */ $newTable = "glpi_plugin_monitoring_displayviews_groups"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->addField($newTable, 'pluginmonitoringdisplayviews_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'groups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, "pluginmonitoringdisplayviews_id"); $migration->addKey($newTable, "groups_id"); $migration->addKey($newTable, "entities_id"); $migration->addKey($newTable, "is_recursive"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_displayviews_users */ $newTable = "glpi_plugin_monitoring_displayviews_users"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->addField($newTable, 'pluginmonitoringdisplayviews_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, "pluginmonitoringdisplayviews_id"); $migration->addKey($newTable, "users_id"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_displayviews_items */ $newTable = "glpi_plugin_monitoring_displayviews_items"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_displayviews_id', 'plugin_monitoring_displayviews_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'x', 'x', "int(5) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'y', 'y', "int(5) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'extra_infos', 'extra_infos', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_displayviews_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'x', "int(5) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'y', "int(5) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'extra_infos', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'is_minemap', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, "plugin_monitoring_displayviews_id"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_displayviews_rules */ $newTable = "glpi_plugin_monitoring_displayviews_rules"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_displayviews_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'itemtype', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'type', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'condition', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addKey($newTable, 'plugin_monitoring_displayviews_id'); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_entities */ $newTable = "glpi_plugin_monitoring_entities"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'tag', 'tag', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'tag', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addKey($newTable, "entities_id"); $migration->addKey($newTable, "tag"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_hostaddresses */ $newTable = "glpi_plugin_monitoring_hostaddresses"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'networkports_id', 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'ipaddresses_id', 'ipaddresses_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'ipaddresses_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_hostconfigs */ $a_hostsconfig = array(); if (TableExists('glpi_plugin_monitoring_hostconfigs') && FieldExists('glpi_plugin_monitoring_hostconfigs', 'plugin_monitoring_commands_id')) { $a_hostsconfig = getAllDatasFromTable('glpi_plugin_monitoring_hostconfigs'); } $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_hostconfigs'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'items_id' => array('type' => 'integer', 'value' => NULL), 'itemtype' => array('type' => 'varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL', 'value' => NULL), 'plugin_monitoring_components_id' => array('type' => 'integer', 'value' => NULL), 'plugin_monitoring_realms_id' => array('type' => 'integer', 'value' => NULL), 'computers_id' => array('type' => 'integer', 'value' => NULL), 'jetlag' => array('type' => 'varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL', 'value' => '0')); $a_table['oldfields'] = array('plugin_monitoring_commands_id', 'plugin_monitoring_checks_id', 'calendars_id'); $a_table['renamefields'] = array(); $a_table['keys'] = array(); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); if (count($a_hostsconfig) > 0) { // Convert commands by components foreach ($a_hostsconfig as $data) { $a_components = getAllDatasFromTable('glpi_plugin_monitoring_components', "`plugin_monitoring_commands_id`='" . $data['plugin_monitoring_commands_id'] . "'"); if (count($a_components) > 0) { $a_component = current($a_components); $DB->query("UPDATE `" . $a_table['name'] . "`\n SET `plugin_monitoring_components_id`='" . $a_component['id'] . "'\n WHERE `id`='" . $data['id'] . "'"); } } } /* * Table glpi_plugin_monitoring_hosts */ $newTable = "glpi_plugin_monitoring_hosts"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } if (TableExists($newTable)) { $a_hosts = getAllDatasFromTable($newTable, "`itemtype`='Computer'"); } // Duplicate field with event $migration->dropField($newTable, 'ouput'); $migration->migrationOneTable($newTable); $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); // Event should contain up to 4096 bytes (Nagios plugin specification) $migration->changeField($newTable, 'event', 'event', "varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'state', 'state', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'state_type', 'state_type', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'last_check', 'last_check', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'dependencies', 'dependencies', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'perf_data', 'perf_data', "text DEFAULT NULL COLLATE utf8_unicode_ci"); // Duplicate field with event // $migration->changeField($newTable, // 'output', // 'output', // "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'latency', 'latency', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'execution_time', 'execution_time', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_acknowledged', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_acknowledgeconfirmed', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'acknowledge_comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'acknowledge_users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'event', "varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state_type', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'last_check', "datetime DEFAULT NULL"); $migration->addField($newTable, 'dependencies', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'perf_data', "text COLLATE utf8_unicode_ci DEFAULT NULL"); // Duplicate field with event // $migration->addField($newTable, // 'output', // "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'latency', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'execution_time', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addKey($newTable, array('itemtype', 'items_id'), 'itemtype'); $migration->migrationOneTable($newTable); if (count($a_hosts) > 0) { // Convert commands by components foreach ($a_hosts as $data) { $a_computers = getAllDatasFromTable('glpi_computers', "`id`='" . $data['items_id'] . "'"); if (count($a_computers) > 0) { $a_computer = current($a_computers); $DB->query("UPDATE `" . $newTable . "`\n SET `entities_id`='" . $a_computer['entities_id'] . "'\n WHERE `id`='" . $data['id'] . "'"); } } } /* * Table glpi_plugin_monitoring_logs */ $newTable = "glpi_plugin_monitoring_logs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` bigint(30) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "bigint(30) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'date_mod', 'date_mod', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'user_name', 'user_name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'action', 'action', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'value', 'value', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'date_mod', "datetime DEFAULT NULL"); $migration->addField($newTable, 'user_name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'action', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'value', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_networkports */ $newTable = "glpi_plugin_monitoring_networkports"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'networkports_id', 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_realms */ $newTable = "glpi_plugin_monitoring_realms"; $insertrealm = 0; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); $insertrealm = 1; } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'comment', 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'date_mod', 'date_mod', "datetime DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'date_mod', "datetime DEFAULT NULL"); $migration->migrationOneTable($newTable); if ($insertrealm == '1') { $query = "INSERT INTO `glpi_plugin_monitoring_realms`\n (`id` ,`name` ,`comment` ,`date_mod`) VALUES (NULL , 'All', NULL , NULL)"; $DB->query($query); } /* * Table glpi_plugin_monitoring_serviceevents */ $newTable = "glpi_plugin_monitoring_serviceevents"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` bigint(30) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } // Duplicate field with event $migration->dropField($newTable, 'ouput'); $migration->migrationOneTable($newTable); $migration->changeField($newTable, 'id', 'id', "bigint(30) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_services_id', 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'date', 'date', "datetime DEFAULT NULL"); // Event should contain up to 4096 bytes (Nagios plugin specification) $migration->changeField($newTable, 'event', 'event', "varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'perf_data', 'perf_data', "text DEFAULT NULL COLLATE utf8_unicode_ci"); // Duplicate field with event // $migration->changeField($newTable, // 'output', // 'output', // "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'state', 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'state_type', 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'latency', 'latency', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'execution_time', 'execution_time', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'unavailability', 'unavailability', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'date', "datetime DEFAULT NULL"); $migration->addField($newTable, 'event', "varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'perf_data', "text DEFAULT NULL COLLATE utf8_unicode_ci"); // Duplicate field with event // $migration->addField($newTable, // 'output', // "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'latency', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'execution_time', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'unavailability', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, "plugin_monitoring_services_id"); $migration->addKey($newTable, array('plugin_monitoring_services_id', 'date'), "plugin_monitoring_services_id_2"); $migration->addKey($newTable, array('unavailability', 'state_type', 'plugin_monitoring_services_id'), "unavailability"); $migration->addKey($newTable, array('plugin_monitoring_services_id', 'id'), "plugin_monitoring_services_id_3"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_commands */ $newTable = "glpi_plugin_monitoring_commands"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'is_active', 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_name', 'command_name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_line', 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'poller_tag', 'poller_tag', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'module_type', 'module_type', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'arguments', 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->dropField($newTable, 'regex'); $migration->dropField($newTable, 'legend'); $migration->dropField($newTable, 'unit'); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'poller_tag', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'module_type', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addKey($newTable, "name"); $migration->addKey($newTable, "command_name"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_checks */ $newTable = "glpi_plugin_monitoring_checks"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'max_check_attempts', 'max_check_attempts', "int(2) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'check_interval', 'check_interval', "int(5) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'retry_interval', 'retry_interval', "int(5) NOT NULL DEFAULT '1'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'max_check_attempts', "int(2) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'check_interval', "int(5) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'retry_interval', "int(5) NOT NULL DEFAULT '1'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_businessrules */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_businessrules'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'plugin_monitoring_businessrulegroups_id' => array('type' => 'integer', 'value' => 0), 'plugin_monitoring_services_id' => array('type' => 'integer', 'value' => 0), 'is_dynamic' => array('type' => 'bool', 'value' => 0), 'is_generic' => array('type' => 'bool', 'value' => 0)); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * glpi_plugin_monitoring_businessrules_components */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_businessrules_components'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'plugin_monitoring_businessrulegroups_id' => array('type' => 'integer', 'value' => 0), 'plugin_monitoring_componentscatalogs_components_id' => array('type' => 'integer', 'value' => 0)); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * Table glpi_plugin_monitoring_businessrulegroups */ $newTable = "glpi_plugin_monitoring_businessrulegroups"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_servicescatalogs_id', 'plugin_monitoring_servicescatalogs_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'operator', 'operator', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_servicescatalogs_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'operator', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_eventhandlers */ $newTable = "glpi_plugin_monitoring_eventhandlers"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'is_active', 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_name', 'command_name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_line', 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addKey($newTable, "name"); $migration->addKey($newTable, "command_name"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_notificationcommands */ $newTable = "glpi_plugin_monitoring_notificationcommands"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'is_active', 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_name', 'command_name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_line', 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'reactionner_tag', 'reactionner_tag', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'module_type', 'module_type', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'reactionner_tag', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'module_type', "varchar(255) DEFAULT NULL"); $migration->addKey($newTable, "name"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contactgroups */ $newTable = "glpi_plugin_monitoring_contactgroups"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contacts_contactgroups */ $newTable = "glpi_plugin_monitoring_contacts_contactgroups"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_contacts_id', 'plugin_monitoring_contacts_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_contactgroups_id', 'plugin_monitoring_contactgroups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_contacts_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_contactgroups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, array('plugin_monitoring_contacts_id', 'plugin_monitoring_contactgroups_id'), "unicity", "UNIQUE"); $migration->addKey($newTable, "plugin_monitoring_contactgroups_id"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contactgroups_contactgroups */ $newTable = "glpi_plugin_monitoring_contactgroups_contactgroups"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_contactgroups_id_1', 'plugin_monitoring_contactgroups_id_1', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_contactgroups_id_2', 'plugin_monitoring_contactgroups_id_2', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_contactgroups_id_1', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_contactgroups_id_2', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, array('plugin_monitoring_contactgroups_id_1', 'plugin_monitoring_contactgroups_id_2'), "unicity", "UNIQUE"); $migration->addKey($newTable, "plugin_monitoring_contactgroups_id_2"); $migration->migrationOneTable($newTable); /* * glpi_plugin_monitoring_profiles */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_profiles'; $a_table['oldname'] = array(); $a_table['fields'] = array('profiles_id' => array('type' => 'integer', 'value' => NULL), 'config' => array('type' => 'char', 'value' => NULL), 'config_views' => array('type' => 'char', 'value' => NULL), 'config_sliders' => array('type' => 'char', 'value' => NULL), 'config_services_catalogs' => array('type' => 'char', 'value' => NULL), 'config_components_catalogs' => array('type' => 'char', 'value' => NULL), 'config_weathermap' => array('type' => 'char', 'value' => NULL), 'dashboard' => array('type' => 'char', 'value' => NULL), 'dashboard_system_status' => array('type' => 'char', 'value' => NULL), 'dashboard_hosts_status' => array('type' => 'char', 'value' => NULL), 'dashboard_all_ressources' => array('type' => 'char', 'value' => NULL), 'dashboard_views' => array('type' => 'char', 'value' => NULL), 'dashboard_sliders' => array('type' => 'char', 'value' => NULL), 'dashboard_services_catalogs' => array('type' => 'char', 'value' => NULL), 'dashboard_components_catalogs' => array('type' => 'char', 'value' => NULL), 'dashboard_perfdatas' => array('type' => 'char', 'value' => NULL), 'homepage' => array('type' => 'char', 'value' => NULL), 'homepage_views' => array('type' => 'char', 'value' => NULL), 'homepage_services_catalogs' => array('type' => 'char', 'value' => NULL), 'homepage_components_catalogs' => array('type' => 'char', 'value' => NULL), 'homepage_system_status' => array('type' => 'char', 'value' => NULL), 'homepage_hosts_status' => array('type' => 'char', 'value' => NULL), 'homepage_perfdatas' => array('type' => 'char', 'value' => NULL), 'homepage_all_ressources' => array('type' => 'char', 'value' => NULL), 'acknowledge' => array('type' => 'char', 'value' => NULL), 'downtime' => array('type' => 'char', 'value' => NULL), 'counters' => array('type' => 'char', 'value' => NULL), 'restartshinken' => array('type' => 'char', 'value' => NULL), 'host_command' => array('type' => 'char', 'value' => NULL)); $a_table['oldfields'] = array('servicescatalog', 'view', 'componentscatalog', 'viewshomepage', 'weathermap', 'component', 'command', 'check', 'allressources'); $a_table['renamefields'] = array(); $a_table['keys'] = array(); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * Table glpi_plugin_monitoring_servicedefs */ $newTable = "glpi_plugin_monitoring_servicedefs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_commands_id', 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'arguments', 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'plugin_monitoring_checks_id', 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'active_checks_enabled', 'active_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'passive_checks_enabled', 'passive_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'calendars_id', 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'remotesystem', 'remotesystem', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'is_arguments', 'is_arguments', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'alias_command', 'alias_command', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'aliasperfdata_commands_id', 'aliasperfdata_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'link', 'link', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'active_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'passive_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'remotesystem', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'is_arguments', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'alias_command', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'aliasperfdata_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'link', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_sliders */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_sliders'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'name' => array('type' => 'string', 'value' => NULL), 'entities_id' => array('type' => 'integer', 'value' => NULL), 'is_recursive' => array('type' => 'bool', 'value' => NULL), 'is_active' => array('type' => 'bool', 'value' => NULL), 'users_id' => array('type' => 'integer', 'value' => NULL), 'in_central' => array('type' => 'bool', 'value' => NULL), 'is_frontview' => array('type' => 'bool', 'value' => NULL), 'comment' => array('type' => 'text', 'value' => NULL), 'duration' => array('type' => 'integer', 'value' => '2')); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * Table glpi_plugin_monitoring_sliders_groups */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_sliders_groups'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'pluginmonitoringsliders_id' => array('type' => 'integer', 'value' => NULL), 'groups_id' => array('type' => 'integer', 'value' => NULL), 'entities_id' => array('type' => 'integer', 'value' => '-1'), 'is_recursive' => array('type' => 'bool', 'value' => NULL)); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(array('field' => 'pluginmonitoringsliders_id', 'name' => '', 'type' => 'INDEX'), array('field' => 'groups_id', 'name' => '', 'type' => 'INDEX'), array('field' => 'entities_id', 'name' => '', 'type' => 'INDEX'), array('field' => 'is_recursive', 'name' => '', 'type' => 'INDEX')); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * Table glpi_plugin_monitoring_sliders_users */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_sliders_users'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'pluginmonitoringsliders_id' => array('type' => 'integer', 'value' => NULL), 'users_id' => array('type' => 'integer', 'value' => NULL)); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(array('field' => 'pluginmonitoringsliders_id', 'name' => '', 'type' => 'INDEX'), array('field' => 'users_id', 'name' => '', 'type' => 'INDEX')); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * Table glpi_plugin_monitoring_sliders_items */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_sliders_items'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'plugin_monitoring_sliders_id' => array('type' => 'integer', 'value' => NULL), 'items_id' => array('type' => 'integer', 'value' => NULL), 'itemtype' => array('type' => 'varchar(100) DEFAULT NULL', 'value' => NULL), 'extra_infos' => array('type' => 'string', 'value' => NULL), 'is_minemap' => array('type' => 'bool', 'value' => NULL)); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(array('field' => 'plugin_monitoring_sliders_id', 'name' => '', 'type' => 'INDEX')); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * Table glpi_plugin_monitoring_unavaibilities */ $newTable = "glpi_plugin_monitoring_unavailabilities"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); $migration->addField($newTable, 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'begin_date', "datetime DEFAULT NULL"); $migration->addField($newTable, 'end_date', "datetime DEFAULT NULL"); $migration->addField($newTable, 'duration', "int(15) NOT NULL DEFAULT '0'"); // Scheduled unavailability $migration->addField($newTable, 'scheduled', "tinyint(1) NOT NULL DEFAULT '0'"); // Unavailability details $migration->addField($newTable, 'details', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addKey($newTable, "plugin_monitoring_services_id"); $migration->migrationOneTable($newTable); } /* $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); if (!FieldExists($newTable, "plugin_monitoring_services_id")) { $migration->changeField($newTable, 'items_id', 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); } $migration->migrationOneTable($newTable); $migration->changeField($newTable, 'plugin_monitoring_services_id', 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'begin_date', 'begin_date', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'end_date', 'end_date', "datetime DEFAULT NULL"); $migration->dropField($newTable, 'itemtype'); $migration->migrationOneTable($newTable); */ /* * glpi_plugin_monitoring_unavailabilitystates */ $a_table = array(); $a_table['name'] = 'glpi_plugin_monitoring_unavailabilitystates'; $a_table['oldname'] = array(); $a_table['fields'] = array('id' => array('type' => 'autoincrement', 'value' => ''), 'plugin_monitoring_services_id' => array('type' => 'integer', 'value' => 0), 'plugin_monitoring_serviceevents_id' => array('type' => 'integer', 'value' => 0)); $a_table['oldfields'] = array(); $a_table['renamefields'] = array(); $a_table['keys'] = array(); $a_table['oldkeys'] = array(); migrateTablesMonitoring($migration, $a_table); /* * Table glpi_plugin_monitoring_weathermaps */ $newTable = "glpi_plugin_monitoring_weathermaps"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'width', 'width', "smallint(6) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'height', 'height', "smallint(6) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'background', 'background', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'width', "smallint(6) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'height', "smallint(6) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'background', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_weathermapnodes */ $newTable = "glpi_plugin_monitoring_weathermapnodes"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_weathermaps_id', 'plugin_monitoring_weathermaps_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'x', 'x', "smallint(6) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'y', 'y', "smallint(6) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_weathermaps_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'x', "smallint(6) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'y', "smallint(6) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'position', "varchar(255) COLLATE utf8_unicode_ci DEFAULT 'middle'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_weathermaplinks */ $newTable = "glpi_plugin_monitoring_weathermaplinks"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_weathermapnodes_id_1', 'plugin_monitoring_weathermapnodes_id_1', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_weathermapnodes_id_2', 'plugin_monitoring_weathermapnodes_id_2', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_services_id', 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'bandwidth_in', 'bandwidth_in', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'bandwidth_out', 'bandwidth_out', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_weathermapnodes_id_1', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_weathermapnodes_id_2', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'bandwidth_in', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'bandwidth_out', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_shinkenwebservices */ $newTable = "glpi_plugin_monitoring_shinkenwebservices"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->addField($newTable, 'url', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'action', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'cnt', "tinyint(2) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'fields_string', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_tags */ $newTable = "glpi_plugin_monitoring_tags"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->addField($newTable, 'tag', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'ip', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'iplock', "bool"); $migration->addField($newTable, 'username', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'password', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'port', "varchar(255) COLLATE utf8_unicode_ci DEFAULT '7760'"); $migration->addField($newTable, 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_downtimes */ $newTable = "glpi_plugin_monitoring_downtimes"; if (!TableExists($newTable)) { $query = "CREATE TABLE `{$newTable}` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `plugin_monitoring_hosts_id` int(11) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `plugin_monitoring_hosts_id` (`plugin_monitoring_hosts_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query); } $migration->addField($newTable, 'start_time', "datetime NOT NULL DEFAULT '2014-01-01 00:00:00'"); $migration->addField($newTable, 'end_time', "datetime NOT NULL DEFAULT '2014-01-01 00:00:00'"); $migration->addField($newTable, 'flexible', "tinyint(1) DEFAULT '1'"); $migration->addField($newTable, 'duration', "int(1) DEFAULT '24'"); $migration->addField($newTable, 'duration_type', "varchar(64) DEFAULT 'days'"); $migration->addField($newTable, 'comment', "varchar(1024) DEFAULT NULL"); $migration->addField($newTable, 'users_id', "int(11) DEFAULT '-1'"); $migration->addField($newTable, 'tickets_id', "int(11) DEFAULT '0'"); $migration->addField($newTable, 'services', "tinyint(1) DEFAULT '0'"); $migration->addField($newTable, 'notified', "tinyint(1) DEFAULT '0'"); $migration->addField($newTable, 'expired', "tinyint(1) DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->changeField($newTable, 'flexible', 'flexible', "tinyint(1) DEFAULT '0'"); $migration->changeField($newTable, 'notified', 'notified', "tinyint(1) DEFAULT '0'"); $migration->changeField($newTable, 'expired', 'expired', "tinyint(1) DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_acknowledges */ $newTable = "glpi_plugin_monitoring_acknowledges"; if (!TableExists($newTable)) { $query = "CREATE TABLE `{$newTable}` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `itemtype` varchar(100) DEFAULT 'Host',\n `items_id` int(11) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `itemtype` (`itemtype`,`items_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query); } $migration->addField($newTable, 'start_time', "datetime NOT NULL DEFAULT '2014-01-01 00:00:00'"); $migration->addField($newTable, 'end_time', "datetime NOT NULL DEFAULT '2014-01-01 00:00:00'"); $migration->addField($newTable, 'sticky', "tinyint(1) DEFAULT '1'"); $migration->addField($newTable, 'persistent', "tinyint(1) DEFAULT '1'"); $migration->addField($newTable, 'notify', "tinyint(1) DEFAULT '1'"); $migration->addField($newTable, 'comment', "varchar(1024) DEFAULT NULL"); $migration->addField($newTable, 'users_id', "int(11) DEFAULT '-1'"); $migration->addField($newTable, 'notified', "tinyint(1) DEFAULT '0'"); $migration->addField($newTable, 'expired', "tinyint(1) DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->changeField($newTable, 'expired', 'expired', "tinyint(1) DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_hostcounters */ $newTable = "glpi_plugin_monitoring_hostcounters"; if (!TableExists($newTable)) { $query = "CREATE TABLE `{$newTable}` (\n `id` INT(11) NOT NULL AUTO_INCREMENT,\n `hostname` VARCHAR(255) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `hostname` (`hostname`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query); } $migration->addField($newTable, 'date', "datetime DEFAULT NULL"); $migration->addField($newTable, 'counter', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'value', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'updated', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, array('hostname', 'date', 'updated'), 'updated'); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_hostdailycounters */ $newTable = "glpi_plugin_monitoring_hostdailycounters"; if (!TableExists($newTable)) { $query = "CREATE TABLE `{$newTable}` (\n `id` INT(11) NOT NULL AUTO_INCREMENT,\n `hostname` VARCHAR(255) NOT NULL DEFAULT '',\n `day` DATE NOT NULL DEFAULT '2013-01-01',\n `dayname` varchar(16) NOT NULL DEFAULT '',\n PRIMARY KEY (`id`),\n KEY (`hostname`,`day`),\n KEY (`hostname`,`dayname`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; $DB->query($query); } /* $migration->addField($newTable, 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_services_id2', "int(11) NOT NULL DEFAULT '0'"); */ $migration->addField($newTable, 'counters', "varchar(4096) NOT NULL DEFAULT ''"); $migration->dropField($newTable, 'plugin_monitoring_services_id'); $migration->dropField($newTable, 'plugin_monitoring_services_id2'); $migration->addField($newTable, 'dayname', "varchar(16) NOT NULL DEFAULT ''"); $migration->addField($newTable, 'cPaperChanged', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cPrinterChanged', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cBinEmptied', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cPagesInitial', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cPagesTotal', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cPagesToday', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cPagesRemaining', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cRetractedInitial', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cRetractedTotal', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cRetractedToday', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cRetractedRemaining', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cPaperLoad', "int(11) NOT NULL DEFAULT '0'"); $migration->dropField($newTable, 'cCardsInsertedOk'); $migration->dropField($newTable, 'cCardsInsertedKo'); $migration->dropField($newTable, 'cCardsRemoved'); $migration->addField($newTable, 'cCardsInsertedOkToday', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cCardsInsertedOkTotal', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cCardsInsertedKoToday', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cCardsInsertedKoTotal', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cCardsRemovedToday', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'cCardsRemovedTotal', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table Delete old table not used */ if (TableExists("glpi_plugin_monitoring_servicesuggests")) { $DB->query("DROP TABLE `glpi_plugin_monitoring_servicesuggests`"); } if (TableExists("glpi_plugin_monitoring_servicegraphs")) { $DB->query("DROP TABLE `glpi_plugin_monitoring_servicegraphs`"); } if (TableExists("glpi_plugin_monitoring_securities")) { $DB->query("DROP TABLE `glpi_plugin_monitoring_securities`"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates"); } // Update calendars $query = "SELECT * FROM `glpi_calendars`\n WHERE `name`='24x7'\n LIMIT 1"; $result = $DB->query($query); if ($DB->numrows($result) == 0) { $calendar = new Calendar(); $input = array(); $input['name'] = '24x7'; $input['is_recursive'] = 1; $calendars_id = $calendar->add($input); $calendarSegment = new CalendarSegment(); $input = array(); $input['calendars_id'] = $calendars_id; $input['is_recursive'] = 1; $input['begin'] = '00:00:00'; $input['end'] = '24:00:00'; $input['day'] = '0'; $calendarSegment->add($input); $input['day'] = '1'; $calendarSegment->add($input); $input['day'] = '2'; $calendarSegment->add($input); $input['day'] = '3'; $calendarSegment->add($input); $input['day'] = '4'; $calendarSegment->add($input); $input['day'] = '5'; $calendarSegment->add($input); $input['day'] = '6'; $calendarSegment->add($input); } // Update crontasks $crontask = new CronTask(); if (!$crontask->getFromDBbyName('PluginMonitoringDowntime', 'DowntimesExpired')) { CronTask::Register('PluginMonitoringDowntime', 'DowntimesExpired', '3600', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); } if (!$crontask->getFromDBbyName('PluginMonitoringLog', 'cleanlogs')) { CronTask::Register('PluginMonitoringLog', 'cleanlogs', '96400', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); } if (!$crontask->getFromDBbyName('PluginMonitoringUnavailability', 'unavailability')) { CronTask::Register('PluginMonitoringUnavailability', 'Unavailability', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); } if (!$crontask->getFromDBbyName('PluginMonitoringDisplayview_rule', 'replayallviewrules')) { CronTask::Register('PluginMonitoringDisplayview_rule', 'replayallviewrules', '1200', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); } if ($crontask->getFromDBbyName('PluginMonitoringUnavaibility', 'unavaibility')) { $crontask->getFromDBbyName('PluginMonitoringUnavaibility', 'unavaibility'); $crontask->delete($crontask->fields); } if ($crontask->getFromDBbyName('PluginMonitoringServiceevent', 'updaterrd')) { $crontask->getFromDBbyName('PluginMonitoringServiceevent', 'updaterrd'); $crontask->delete($crontask->fields); } if ($crontask->getFromDBbyName('PluginMonitoringHostdailycounter', 'DailyCounters')) { $crontask->getFromDBbyName('PluginMonitoringHostdailycounter', 'DailyCounters'); $crontask->delete($crontask->fields); } include GLPI_ROOT . "/plugins/monitoring/inc/command.class.php"; $pmCommand = new PluginMonitoringCommand(); $a_list = $pmCommand->find(); $check_dummy_found = false; $restart_shinken_found = false; $host_action_found = false; foreach ($a_list as $data) { if ($data['command_name'] == "check_dummy") { $check_dummy_found = true; } if ($data['command_name'] == "restart_shinken") { $restart_shinken_found = true; } if ($data['command_name'] == "host_action") { $host_action_found = true; } } if (!$host_action_found) { // Host action command $pmCommand = new PluginMonitoringCommand(); $input = array(); $input['name'] = "Host action"; $input['command_name'] = "host_action"; $input['command_line'] = $DB->escape("host_action"); $pmCommand->add($input); } if (!$restart_shinken_found) { // Restart shinken command $pmCommand = new PluginMonitoringCommand(); $input = array(); $input['name'] = "Restart Shinken"; $input['command_name'] = "restart_shinken"; $input['command_line'] = $DB->escape("nohup sh -c '/usr/local/shinken/bin/stop_arbiter.sh && sleep 3 && /usr/local/shinken/bin/launch_arbiter.sh' > /dev/null 2>&1 &"); $pmCommand->add($input); } if (!$check_dummy_found) { // Check dummy command $pmCommand = new PluginMonitoringCommand(); $input = array(); $input['name'] = "Dummy check"; $input['command_name'] = "check_dummy"; $input['command_line'] = $DB->escape("\$PLUGINSDIR\$/check_dummy \$ARG1\$ \"\$ARG2\$\""); $arg = array(); $arg['ARG1'] = 'INTEGER: dummy status code'; $arg['ARG2'] = 'TEXT: dummy status output text'; $input['arguments'] = exportArrayToDB($arg); $pmCommand->add($input); } /* * Clean services not having hosts */ $query = "SELECT `glpi_plugin_monitoring_services`.* FROM `glpi_plugin_monitoring_services`\n LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`\n ON `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` = `plugin_monitoring_componentscatalogs_hosts_id`\n WHERE `is_static` IS NULL"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $queryd = "DELETE FROM `glpi_plugin_monitoring_services`\n WHERE `id`='" . $data['id'] . "'"; $DB->query($queryd); } /* * Clean components catalog not having hosts */ $query = "SELECT `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`\n FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n LEFT JOIN `glpi_computers`\n ON (`glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id` = `glpi_computers`.`id`)\n WHERE (`glpi_computers`.`name` IS NULL);"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $queryd = "DELETE FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n WHERE `id`='" . $data['id'] . "'"; $DB->query($queryd); } /* * Clean services not having valide component */ $query = "SELECT `glpi_plugin_monitoring_services`.`id`\n FROM `glpi_plugin_monitoring_services`\n LEFT JOIN `glpi_plugin_monitoring_components`\n ON (`plugin_monitoring_components_id` = `glpi_plugin_monitoring_components`.`id`)\n WHERE (`glpi_plugin_monitoring_components`.`id` IS NULL);"; $result = $DB->query($query); include GLPI_ROOT . "/plugins/monitoring/inc/service.class.php"; $pmService = new PluginMonitoringService(); while ($data = $DB->fetch_array($result)) { $pmService->delete($data); } // Update hosts config include GLPI_ROOT . "/plugins/monitoring/inc/hostconfig.class.php"; $pmHostconfig = new PluginMonitoringHostconfig(); $pmHostconfig->initConfig(); // Verify hosts include GLPI_ROOT . "/plugins/monitoring/inc/host.class.php"; $pmHost = new PluginMonitoringHost(); $pmHost->verifyHosts(); if ($insertrealm == '1') { // Insert into hostconfigs $query = "UPDATE `glpi_plugin_monitoring_hostconfigs`\n SET `plugin_monitoring_realms_id` = '1'\n WHERE `items_id` = '0'\n AND `itemtype` = 'Entity'"; $DB->query($query); } include GLPI_ROOT . "/plugins/monitoring/inc/config.class.php"; $pmConfig = new PluginMonitoringConfig(); $pmConfig->initConfig(); // Add user monitoring if not defined if (!countElementsInTable('glpi_users', "`name`='monitoring'")) { // Create $input = array('name' => 'monitoring'); $user = new User(); $user->add($input); } // Update items of views to be compatible with step of 10px instead 1 px $query = "SELECT *\n FROM `glpi_plugin_monitoring_displayviews_items`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $x = 10 * round($data['x'] / 10); $y = 10 * round($data['y'] / 10); $DB->query("UPDATE `glpi_plugin_monitoring_displayviews_items` " . "SET `x`='" . $x . "', `y`='" . $y . "' " . "WHERE `id`='" . $data['id'] . "'"); } // Udpate componentcatalog_rules with new search engine (0.85) $query = "SELECT *\n FROM `glpi_plugin_monitoring_componentscatalogs_rules`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $data_array = importArrayFromDB($data['condition']); if (!isset($data_array['searchtype'])) { continue; } $criteria = array(); foreach ($data_array['field'] as $num => $value) { $criteria[$num]['field'] = $value; } unset($data_array['field']); foreach ($data_array['searchtype'] as $num => $value) { $criteria[$num]['searchtype'] = $value; } unset($data_array['searchtype']); foreach ($data_array['contains'] as $num => $value) { $criteria[$num]['value'] = $value; } unset($data_array['contains']); if (isset($data_array['link'])) { foreach ($data_array['link'] as $num => $value) { $criteria[$num]['link'] = $value; } unset($data_array['link']); } $data_array['criteria'] = $criteria; unset($data_array['_glpi_csrf_token']); $DB->query("UPDATE `glpi_plugin_monitoring_componentscatalogs_rules` " . "SET `condition`='" . exportArrayToDB($data_array) . "' " . "WHERE `id`='" . $data['id'] . "'"); } // * Update unavailability (with table glpi_plugin_monitoring_unavailabilitystates) // include (GLPI_ROOT . "/plugins/monitoring/inc/unavailabilitystate.class.php"); // $pmUnavailabilityState = new PluginMonitoringUnavailabilityState(); // $query = "SELECT * FROM `glpi_plugin_monitoring_services`"; // $result = $DB->query($query); // while ($data=$DB->fetch_array($result)) { // if ($pmUnavailabilityState->getLastID($data['id']) == 0) { // $query2 = "SELECT id FROM `glpi_plugin_monitoring_serviceevents` // WHERE `plugin_monitoring_services_id`='".$data['id']."' // AND `unavailability`='1' // ORDER BY id DESC // LIMIT 1"; // $result2 = $DB->query($query2); // while ($data2=$DB->fetch_array($result2)) { // $pmUnavailabilityState->setLastID($data['id'], $data2['id']); // } // } // } $query = "UPDATE `glpi_plugin_monitoring_configs`\n SET `version`='" . PLUGIN_MONITORING_VERSION . "'\n WHERE `id`='1'"; $DB->query($query); }
/** * Display info of device * * @global type $DB Toolbox::logDebug($this->fields); * @param type $id */ function showWidget2Frame($id, $is_minemap = FALSE) { global $DB, $CFG_GLPI; $pmDisplayview_item = new PluginMonitoringDisplayview_item(); $pmDisplayview_item->getFromDB($id); $itemtype = $pmDisplayview_item->fields['extra_infos']; $item = new $itemtype(); $item->getFromDB($pmDisplayview_item->fields['items_id']); $critical = 0; $warning = 0; $ok = 0; $acknowledge = 0; $query = "SELECT * FROM `glpi_plugin_monitoring_services`" . " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`" . " ON `plugin_monitoring_componentscatalogs_hosts_id`=" . " `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`" . " WHERE `items_id`='" . $item->fields['id'] . "'" . " AND `itemtype`='" . $itemtype . "'" . " AND `glpi_plugin_monitoring_services`.`id` IS NOT NULL" . " ORDER BY `glpi_plugin_monitoring_services`.`name`"; $result = $DB->query($query); $services = array(); $resources = array(); $i = 0; while ($data = $DB->fetch_array($result)) { $ret = PluginMonitoringHost::getState($data['state'], $data['state_type'], '', $data['is_acknowledged']); if (strstr($ret, '_soft')) { $ok++; $resources[$data['id']]['state'] = 'OK'; } else { if ($ret == 'red') { $critical++; $resources[$data['id']]['state'] = 'CRITICAL'; } else { if ($ret == 'redblue') { $acknowledge++; $resources[$data['id']]['state'] = 'ACKNOWLEDGE'; } else { if ($ret == 'orange' || $ret == 'yellow') { $warning++; $resources[$data['id']]['state'] = 'WARNING'; } else { $ok++; $resources[$data['id']]['state'] = 'OK'; } } } } $services[$i++] = $data['id']; $resources[$data['id']]['last_check'] = $data['last_check']; $resources[$data['id']]['event'] = $data['event']; $resources[$data['id']]['name'] = $data['name']; $resources[$data['id']]['plugin_monitoring_components_id'] = $data['plugin_monitoring_components_id']; } $class = 'ok'; if ($critical > 0) { $nb_ressources = $critical; $class = 'crit'; } else { if ($warning > 0) { $nb_ressources = $warning; $class = 'warn'; } else { $nb_ressources = $ok; } } echo '<div class="ch-item"> <div class="ch-info-' . $class . '"> <h1><a href="'; if ($item->can($item->getID(), READ)) { echo $item->getFormURL() . '?id=' . $item->getID() . '&forcetab=PluginMonitoringHost$0'; } else { echo $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/displayhost.php?itemtype=" . $itemtype . "&items_id=" . $item->getID(); } echo '">' . '<span id="devicea-' . $id . '">' . $item->getName() . '</span></a></h1> <p><a>' . $nb_ressources . '</a><font style="font-size: 14px;"> / ' . ($ok + $warning + $critical + $acknowledge) . '</font></p> </div> </div>'; echo "<script>\n fittext('devicea-" . $id . "');\n </script>"; echo "<div class='minemapdiv' align='center'>" . "<a onclick='\$(\"#minemapdisplayview2-" . $id . "\").toggle()'>" . "Minemap</a></div>"; if (!$is_minemap) { echo '<div class="minemapdiv" id="minemapdisplayview2-' . $id . '" style="display: none; z-index: 1500">'; } else { echo '<div class="minemapdiv" id="minemapdisplayview2-' . $id . '">'; } echo '<table class="tab_cadrehov" >'; // Get services list ... echo '<div class="minemapdiv">'; echo '<table class="tab_cadrehov">'; // Header with services name and link to services list ... echo '<tr class="tab_bg_2">'; echo '<th colspan="2">'; echo __('Services', 'monitoring'); echo '</th>'; echo '</tr>'; // Content with host/service status and link to services list ... foreach ($services as $services_id) { $field_id = 20; if ($itemtype == 'Printer') { $field_id = 21; } else { if ($itemtype == 'NetworkEquipment') { $field_id = 22; } } $link = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php?hidesearch=1" . "&criteria[0][field]=" . $field_id . "" . "&criteria[0][searchtype]=equals" . "&criteria[0][value]=" . $item->getID() . "&criteria[1][link]=AND" . "&criteria[1][field]=2" . "&criteria[1][searchtype]=equals" . "&criteria[1][value]=" . $resources[$services_id]['plugin_monitoring_components_id'] . "&itemtype=PluginMonitoringService" . "&start=0'"; echo "<tr class='tab_bg_2'>"; echo "<td class='left'><a href='" . $link . "'>" . $resources[$services_id]['name'] . "</a></td>"; echo '<td>'; echo '<a href="' . $link . '" title="' . $resources[$services_id]['state'] . " - " . $resources[$services_id]['last_check'] . " - " . $resources[$services_id]['event'] . '">' . '<div class="service service' . $resources[$services_id]['state'] . '"></div></a>'; echo '</td>'; echo '</tr>'; } echo '</table>'; echo '</div>'; }
function post_purgeItem() { global $DB; $query = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n WHERE `itemtype`='" . $this->fields['itemtype'] . "'\n AND `items_id`='" . $this->fields['items_id'] . "'\n LIMIT 1"; $result = $DB->query($query); if ($DB->numrows($result) == 0) { $queryH = "SELECT * FROM `glpi_plugin_monitoring_hosts`\n WHERE `itemtype`='" . $this->fields['itemtype'] . "'\n AND `items_id`='" . $this->fields['items_id'] . "'\n LIMIT 1"; $resultH = $DB->query($queryH); if ($DB->numrows($resultH) == 1) { $dataH = $DB->fetch_assoc($resultH); $pmHost = new PluginMonitoringHost(); $pmHost->delete($dataH); } } }
function plugin_monitoring_MassiveActionsProcess($data) { switch ($data['action']) { case "plugin_monitoring_activatehosts": if ($data['itemtype'] == "Computer") { $pmHost = new PluginMonitoringHost(); foreach ($data['item'] as $key => $val) { if ($val == '1') { $pmHost->massiveactionAddHost($data['itemtype'], $key, $data['template_id']); } } } break; case 'plugin_monitoring_playrule_componentscatalog': $pmComponentscatalog_rule = new PluginMonitoringComponentscatalog_rule(); foreach ($data['item'] as $key => $val) { $a_rules = $pmComponentscatalog_rule->find("`plugin_monitoring_componentscalalog_id`='" . $key . "'"); foreach ($a_rules as $data) { $pmComponentscatalog_rule->getFromDB($data['id']); PluginMonitoringComponentscatalog_rule::getItemsDynamicly($pmComponentscatalog_rule); } } break; case 'plugin_monitoring_playrule_displayview': $pmDisplayview_rule = new PluginMonitoringDisplayview_rule(); foreach ($data['item'] as $key => $val) { $a_rules = $pmDisplayview_rule->find("`plugin_monitoring_displayviews_id`='" . $key . "'"); foreach ($a_rules as $data) { $pmDisplayview_rule->getFromDB($data['id']); PluginMonitoringDisplayview_rule::getItemsDynamicly($pmDisplayview_rule); } } break; } }
function generateHostsCfg($file = 0, $tag = '') { global $DB; $pmCommand = new PluginMonitoringCommand(); $pmCheck = new PluginMonitoringCheck(); $pmComponent = new PluginMonitoringComponent(); $pmEntity = new PluginMonitoringEntity(); $pmHostconfig = new PluginMonitoringHostconfig(); $pmHost = new PluginMonitoringHost(); $calendar = new Calendar(); $pmRealm = new PluginMonitoringRealm(); $networkEquipment = new NetworkEquipment(); $pmContact_Item = new PluginMonitoringContact_Item(); $profile_User = new Profile_User(); $user = new User(); $a_hosts = array(); $i = 0; $a_parents_found = array(); $a_hosts_found = array(); $a_entities_allowed = $pmEntity->getEntitiesByTag($tag); // * Prepare contacts $a_contacts_entities = array(); $a_list_contact = $pmContact_Item->find("`itemtype`='PluginMonitoringComponentscatalog'\n AND `users_id`>0"); foreach ($a_list_contact as $data) { $contactentities = getSonsOf('glpi_entities', $data['entities_id']); if (isset($a_contacts_entities[$data['items_id']][$data['users_id']])) { $contactentities = array_merge($contactentities, $a_contacts_entities[$data['items_id']][$data['users_id']]); } $a_contacts_entities[$data['items_id']][$data['users_id']] = $contactentities; } $query = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n GROUP BY `itemtype`, `items_id`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $classname = $data['itemtype']; $class = new $classname(); if ($class->getFromDB($data['items_id'])) { if (isset($a_entities_allowed['-1']) or isset($a_entities_allowed[$class->fields['entities_id']])) { $a_hosts[$i]['host_name'] = $classname . "-" . $data['items_id'] . "-" . preg_replace("/[^A-Za-z0-9]/", "", $class->fields['name']); $a_hosts_found[$a_hosts[$i]['host_name']] = 1; $a_hosts[$i]['alias'] = preg_replace("/[^A-Za-z0-9]/", "", $class->fields['name']) . " / " . $classname . "-" . $data['items_id']; if (isset($class->fields['networkequipmenttypes_id'])) { if ($class->fields['networkequipmenttypes_id'] > 0) { $a_hosts[$i]['alias'] .= " (" . Dropdown::getDropdownName("glpi_networkequipmenttypes", $class->fields['networkequipmenttypes_id']) . ")"; } } else { if (isset($class->fields['computertypes_id'])) { if ($class->fields['computertypes_id'] > 0) { $a_hosts[$i]['alias'] .= " (" . Dropdown::getDropdownName("glpi_computertypes", $class->fields['computertypes_id']) . ")"; } } else { if (isset($class->fields['printertypes_id'])) { if ($class->fields['printertypes_id'] > 0) { $a_hosts[$i]['alias'] .= " (" . Dropdown::getDropdownName("glpi_printertypes", $class->fields['printertypes_id']) . ")"; } } } } $ip = PluginMonitoringHostaddress::getIp($data['items_id'], $data['itemtype'], $class->fields['name']); $a_hosts[$i]['address'] = $ip; // Manage dependencies $parent = ''; if ($data['itemtype'] != 'NetworkEquipment') { $networkPort = new NetworkPort(); $a_networkports = $networkPort->find("`itemtype`='" . $data['itemtype'] . "'\n AND `items_id`='" . $data['items_id'] . "'"); foreach ($a_networkports as $data_n) { $networkports_id = $networkPort->getContact($data_n['id']); if ($networkports_id) { $networkPort->getFromDB($networkports_id); if ($networkPort->fields['itemtype'] == 'NetworkEquipment') { $networkEquipment->getFromDB($networkPort->fields['items_id']); $parent = 'NetworkEquipment-' . $networkPort->fields['items_id'] . '-' . preg_replace("/[^A-Za-z0-9]/", "", $networkEquipment->fields['name']); $a_parents_found[$parent] = 1; $pmHost->updateDependencies($classname, $data['items_id'], 'NetworkEquipment-' . $networkPort->fields['items_id']); } } } } $a_hosts[$i]['parents'] = $parent; $a_fields = array(); $pmCommand->getFromDB($pmHostconfig->getValueAncestor('plugin_monitoring_commands_id', $class->fields['entities_id'], $classname, $class->getID())); $a_component = current($pmComponent->find("`plugin_monitoring_commands_id`='" . $pmCommand->fields['id'] . "'", "", 1)); $a_fields = $a_component; $a_hosts[$i]['check_command'] = $pmCommand->fields['command_name']; $pmCheck->getFromDB($pmHostconfig->getValueAncestor('plugin_monitoring_checks_id', $class->fields['entities_id'], $classname, $class->getID())); $a_hosts[$i]['check_interval'] = $pmCheck->fields['check_interval']; $a_hosts[$i]['retry_interval'] = $pmCheck->fields['retry_interval']; $a_hosts[$i]['max_check_attempts'] = $pmCheck->fields['max_check_attempts']; if ($calendar->getFromDB($pmHostconfig->getValueAncestor('calendars_id', $class->fields['entities_id'], $classname, $class->getID()))) { $a_hosts[$i]['check_period'] = $calendar->fields['name']; } else { $a_hosts[$i]['check_period'] = "24x7"; } $pmRealm->getFromDB($pmHostconfig->getValueAncestor('plugin_monitoring_realms_id', $class->fields['entities_id'], $classname, $class->getID())); $a_hosts[$i]['realm'] = $pmRealm->fields['name']; $a_hosts[$i]['process_perf_data'] = '1'; $a_hosts[$i]['notification_interval'] = '30'; // For contact check if a service with this component $a_hosts[$i]['contacts'] = ''; $querycont = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n LEFT JOIN `glpi_plugin_monitoring_services`\n ON `plugin_monitoring_componentscatalogs_hosts_id`\n = `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`\n WHERE `plugin_monitoring_components_id`='" . $a_component['id'] . "'\n AND `items_id`='" . $data['items_id'] . "'\n AND `itemtype`='" . $data['itemtype'] . "'\n LIMIT 1"; $resultcont = $DB->query($querycont); if ($DB->numrows($resultcont) != 0) { $a_componentscatalogs_hosts = $DB->fetch_assoc($resultcont); // Notification interval $pmComponentscatalog = new PluginMonitoringComponentscatalog(); $pmComponentscatalog->getFromDB($a_componentscatalogs_hosts['plugin_monitoring_componentscalalog_id']); $a_hosts[$i]['notification_interval'] = $pmComponentscatalog->fields['notification_interval']; $a_contacts = array(); $a_list_contact = $pmContact_Item->find("`itemtype`='PluginMonitoringComponentscatalog'\n AND `items_id`='" . $a_componentscatalogs_hosts['plugin_monitoring_componentscalalog_id'] . "'"); foreach ($a_list_contact as $data_contact) { if (isset($a_contacts_entities[$a_componentscatalogs_hosts['plugin_monitoring_componentscalalog_id']][$data_contact['users_id']])) { if (in_array($class->fields['entities_id'], $a_contacts_entities[$a_componentscatalogs_hosts['plugin_monitoring_componentscalalog_id']][$data_contact['users_id']])) { $user->getFromDB($data_contact['users_id']); $a_contacts[] = $user->fields['name']; } } } if (count($a_contacts) > 0) { $a_contacts_unique = array_unique($a_contacts); $a_hosts[$i]['contacts'] = implode(',', $a_contacts_unique); } } if ($calendar->getFromDB($a_fields['calendars_id'])) { $a_hosts[$i]['notification_period'] = $calendar->fields['name']; } else { $a_hosts[$i]['notification_period'] = "24x7"; } $a_hosts[$i]['notification_options'] = 'd,u,r'; $i++; } } } // Check if parents all exist in hosts config foreach ($a_parents_found as $host => $num) { if (!isset($a_hosts_found[$host])) { // Delete parents not added in hosts config foreach ($a_hosts as $id => $data) { if ($data['parents'] == $host) { $a_hosts[$id]['parents'] = ''; } } } } if ($file == "1") { $config = "# Generated by plugin monitoring for GLPI\n# on " . date("Y-m-d H:i:s") . "\n\n"; foreach ($a_hosts as $data) { $config .= $this->constructFile("host", $data); } return array('hosts.cfg', $config); } else { return $a_hosts; } }
function pluginMonitoringUpdate($current_version, $migrationname = 'Migration') { global $DB; $migration = new $migrationname($current_version); if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/weathermapbg')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg"); } $unavaibility_recalculate = 0; if (!TableExists("glpi_plugin_monitoring_unavaibilities") || !FieldExists("glpi_plugin_monitoring_unavaibilities", "duration")) { $unavaibility_recalculate = 1; } /* * Table glpi_plugin_monitoring_servicescatalogs */ $newTable = "glpi_plugin_monitoring_servicescatalogs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'is_recursive', 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'comment', 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'last_check', 'last_check', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'state', 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'state_type', 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_checks_id', 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'calendars_id', 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'last_check', "datetime DEFAULT NULL"); $migration->addField($newTable, 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_acknowledged', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_acknowledgeconfirmed', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'acknowledge_comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'acknowledge_users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, "name"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_componentscatalogs */ $newTable = "glpi_plugin_monitoring_componentscatalogs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'is_recursive', 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'comment', 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'notification_interval', 'notification_interval', "int(4) NOT NULL DEFAULT '30'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'notification_interval', "int(4) NOT NULL DEFAULT '30'"); $migration->addKey($newTable, "name"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_components */ $newTable = "glpi_plugin_monitoring_components"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_commands_id', 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'arguments', 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'plugin_monitoring_checks_id', 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'active_checks_enabled', 'active_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'passive_checks_enabled', 'passive_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'calendars_id', 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'remotesystem', 'remotesystem', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'is_arguments', 'is_arguments', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'alias_command', 'alias_command', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'graph_template', 'graph_template', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'link', 'link', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'is_weathermap', 'is_weathermap', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'weathermap_regex', 'weathermap_regex_in', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'perfname', 'perfname', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'perfnameinvert', 'perfnameinvert', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'perfnamecolor', 'perfnamecolor', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'active_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'passive_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'remotesystem', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'is_arguments', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'alias_command', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'graph_template', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'link', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'is_weathermap', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'weathermap_regex_in', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'weathermap_regex_out', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'perfname', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'perfnameinvert', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'perfnamecolor', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'plugin_monitoring_eventhandlers_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, "plugin_monitoring_commands_id"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_componentscatalogs_components */ $newTable = "glpi_plugin_monitoring_componentscatalogs_components"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_componentscalalog_id', 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_components_id', 'plugin_monitoring_components_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_components_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, array('plugin_monitoring_componentscalalog_id', 'plugin_monitoring_components_id'), "unicity", "UNIQUE"); $migration->addKey($newTable, "plugin_monitoring_componentscalalog_id"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_componentscatalogs_hosts */ $newTable = "glpi_plugin_monitoring_componentscatalogs_hosts"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_componentscalalog_id', 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'is_static', 'is_static', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_static', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addKey($newTable, array('itemtype', 'items_id'), 'itemtype'); $migration->addKey($newTable, 'plugin_monitoring_componentscalalog_id'); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_componentscatalogs_rules */ $newTable = "glpi_plugin_monitoring_componentscatalogs_rules"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_componentscalalog_id', 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'condition', 'condition', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->dropField($newTable, 'entities_id'); $migration->dropField($newTable, 'is_recursive'); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_componentscalalog_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'itemtype', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'condition', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addKey($newTable, 'plugin_monitoring_componentscalalog_id'); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_services */ $newTable = "glpi_plugin_monitoring_services"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_components_id', 'plugin_monitoring_components_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_componentscatalogs_hosts_id', 'plugin_monitoring_componentscatalogs_hosts_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'event', 'event', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'state', 'state', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'state_type', 'state_type', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'last_check', 'last_check', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'arguments', 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'networkports_id', 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->dropField($newTable, 'alias_command'); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_components_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_componentscatalogs_hosts_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'event', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state_type', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'last_check', "datetime DEFAULT NULL"); $migration->addField($newTable, 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_acknowledged', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_acknowledgeconfirmed', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'acknowledge_comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'acknowledge_users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, array('state', 'state_type'), 'state'); $migration->addKey($newTable, 'plugin_monitoring_componentscatalogs_hosts_id'); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_servicegraphs */ $newTable = "glpi_plugin_monitoring_servicegraphs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` bigint(30) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "bigint(30) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_services_id', 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'date', 'date', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'data', 'data', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'type', 'type', "varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'date', "datetime DEFAULT NULL"); $migration->addField($newTable, 'data', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'type', "varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addKey($newTable, array('plugin_monitoring_services_id', 'type'), 'plugin_monitoring_services_id'); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contacttemplates */ $newTable = "glpi_plugin_monitoring_contacttemplates"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'is_default', 'is_default', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notifications_enabled', 'host_notifications_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notifications_enabled', 'service_notifications_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notification_period', 'service_notification_period', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notification_period', 'host_notification_period', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'service_notification_options_w', 'service_notification_options_w', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notification_options_u', 'service_notification_options_u', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notification_options_c', 'service_notification_options_c', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notification_options_r', 'service_notification_options_r', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'service_notification_options_f', 'service_notification_options_f', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'service_notification_options_n', 'service_notification_options_n', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notification_options_d', 'host_notification_options_d', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'host_notification_options_u', 'host_notification_options_u', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'host_notification_options_r', 'host_notification_options_r', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'host_notification_options_f', 'host_notification_options_f', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notification_options_s', 'host_notification_options_s', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notification_options_n', 'host_notification_options_n', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'service_notification_commands', 'service_notification_commands', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'host_notification_commands', 'host_notification_commands', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'is_default', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notifications_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notifications_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notification_period', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notification_period', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'service_notification_options_w', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notification_options_u', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notification_options_c', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notification_options_r', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'service_notification_options_f', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'service_notification_options_n', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notification_options_d', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'host_notification_options_u', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'host_notification_options_r', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'host_notification_options_f', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notification_options_s', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notification_options_n', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'service_notification_commands', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'host_notification_commands', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contacts */ $newTable = "glpi_plugin_monitoring_contacts"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'users_id', 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_contacttemplates_id', 'plugin_monitoring_contacttemplates_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_contacttemplates_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contacts_items */ $newTable = "glpi_plugin_monitoring_contacts_items"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'users_id', 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'groups_id', 'groups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'groups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_commandtemplates */ $newTable = "glpi_plugin_monitoring_commandtemplates"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_commands_id', 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'key', 'key', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'key', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_rrdtooltemplates */ $newTable = "glpi_plugin_monitoring_rrdtooltemplates"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_commands_id', 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'key', 'key', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'key', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_configs */ $newTable = "glpi_plugin_monitoring_configs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'timezones', 'timezones', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '[\"0\"]'"); $migration->changeField($newTable, 'version', 'version', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'logretention', 'logretention', "int(5) NOT NULL DEFAULT '30'"); $migration->dropField($newTable, 'phppath'); $migration->dropField($newTable, 'rrdtoolpath'); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'timezones', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '[\"0\"]'"); $migration->addField($newTable, 'version', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'logretention', "int(5) NOT NULL DEFAULT '30'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_displayviews */ $newTable = "glpi_plugin_monitoring_displayviews"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'is_recursive', 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'is_active', 'is_active', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'users_id', 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'counter', 'counter', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'in_central', 'in_central', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'width', 'width', "int(5) NOT NULL DEFAULT '950'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_active', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'counter', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'in_central', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'width', "int(5) NOT NULL DEFAULT '950'"); $migration->addField($newTable, 'is_frontview', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_displayviews_groups */ $newTable = "glpi_plugin_monitoring_displayviews_groups"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->addField($newTable, 'pluginmonitoringdisplayviews_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'groups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'is_recursive', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, "pluginmonitoringdisplayviews_id"); $migration->addKey($newTable, "groups_id"); $migration->addKey($newTable, "entities_id"); $migration->addKey($newTable, "is_recursive"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_displayviews_users */ $newTable = "glpi_plugin_monitoring_displayviews_users"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->addField($newTable, 'pluginmonitoringdisplayviews_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'users_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, "pluginmonitoringdisplayviews_id"); $migration->addKey($newTable, "users_id"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_displayviews_items */ $newTable = "glpi_plugin_monitoring_displayviews_items"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_displayviews_id', 'plugin_monitoring_displayviews_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'x', 'x', "int(5) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'y', 'y', "int(5) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'extra_infos', 'extra_infos', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_displayviews_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'x', "int(5) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'y', "int(5) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'extra_infos', "varchar(255) DEFAULT NULL"); $migration->addKey($newTable, "plugin_monitoring_displayviews_id"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_displayviews_rules */ $newTable = "glpi_plugin_monitoring_displayviews_rules"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_displayviews_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'itemtype', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'type', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'condition', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addKey($newTable, 'plugin_monitoring_displayviews_id'); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_entities */ $newTable = "glpi_plugin_monitoring_entities"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'entities_id', 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'tag', 'tag', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'entities_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'tag', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addKey($newTable, "entities_id"); $migration->addKey($newTable, "tag"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_hostaddresses */ $newTable = "glpi_plugin_monitoring_hostaddresses"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'networkports_id', 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'ipaddresses_id', 'ipaddresses_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'ipaddresses_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_hostconfigs */ $newTable = "glpi_plugin_monitoring_hostconfigs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_commands_id', 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_checks_id', 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'calendars_id', 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_realms_id', 'plugin_monitoring_realms_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'computers_id', 'computers_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_realms_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'computers_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_hosts */ $newTable = "glpi_plugin_monitoring_hosts"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'event', 'event', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'state', 'state', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'state_type', 'state_type', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'last_check', 'last_check', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'dependencies', 'dependencies', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'event', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state_type', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'last_check', "datetime DEFAULT NULL"); $migration->addField($newTable, 'dependencies', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_logs */ $newTable = "glpi_plugin_monitoring_logs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` bigint(30) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "bigint(30) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'date_mod', 'date_mod', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'user_name', 'user_name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'action', 'action', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'value', 'value', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'date_mod', "datetime DEFAULT NULL"); $migration->addField($newTable, 'user_name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'action', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'value', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_networkports */ $newTable = "glpi_plugin_monitoring_networkports"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'networkports_id', 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'networkports_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_realms */ $newTable = "glpi_plugin_monitoring_realms"; $insertrealm = 0; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); $insertrealm = 1; } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'comment', 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'date_mod', 'date_mod', "datetime DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'comment', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'date_mod', "datetime DEFAULT NULL"); $migration->migrationOneTable($newTable); if ($insertrealm == '1') { $query = "INSERT INTO `glpi_plugin_monitoring_realms` \n (`id` ,`name` ,`comment` ,`date_mod`) VALUES (NULL , 'All', NULL , NULL)"; $DB->query($query); } /* * Table glpi_plugin_monitoring_serviceevents */ $newTable = "glpi_plugin_monitoring_serviceevents"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` bigint(30) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "bigint(30) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_services_id', 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'date', 'date', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'event', 'event', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'perf_data', 'perf_data', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'output', 'output', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'state', 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'state_type', 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'latency', 'latency', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'execution_time', 'execution_time', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'unavailability', 'unavailability', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'date', "datetime DEFAULT NULL"); $migration->addField($newTable, 'event', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'perf_data', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'output', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'state', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'state_type', "varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'latency', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'execution_time', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'unavailability', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, "plugin_monitoring_services_id"); $migration->addKey($newTable, array('plugin_monitoring_services_id', 'date'), "plugin_monitoring_services_id_2"); $migration->addKey($newTable, array('unavailability', 'state_type', 'plugin_monitoring_services_id'), "unavailability"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_commands */ $newTable = "glpi_plugin_monitoring_commands"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'is_active', 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_name', 'command_name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_line', 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'poller_tag', 'poller_tag', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'module_type', 'module_type', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'arguments', 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->dropField($newTable, 'regex'); $migration->dropField($newTable, 'legend'); $migration->dropField($newTable, 'unit'); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'poller_tag', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'module_type', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addKey($newTable, "name"); $migration->addKey($newTable, "command_name"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_checks */ $newTable = "glpi_plugin_monitoring_checks"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'max_check_attempts', 'max_check_attempts', "int(2) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'check_interval', 'check_interval', "int(5) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'retry_interval', 'retry_interval', "int(5) NOT NULL DEFAULT '1'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'max_check_attempts', "int(2) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'check_interval', "int(5) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'retry_interval', "int(5) NOT NULL DEFAULT '1'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_businessrules */ $newTable = "glpi_plugin_monitoring_businessrules"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_businessrulegroups_id', 'plugin_monitoring_businessrulegroups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_services_id', 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_businessrulegroups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_businessrulegroups */ $newTable = "glpi_plugin_monitoring_businessrulegroups"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_servicescatalogs_id', 'plugin_monitoring_servicescatalogs_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'operator', 'operator', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_servicescatalogs_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'operator', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_eventhandlers */ $newTable = "glpi_plugin_monitoring_eventhandlers"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'is_active', 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_name', 'command_name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_line', 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addKey($newTable, "name"); $migration->addKey($newTable, "command_name"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_notificationcommands */ $newTable = "glpi_plugin_monitoring_notificationcommands"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'is_active', 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_name', 'command_name', "varchar(255) DEFAULT NULL"); $migration->changeField($newTable, 'command_line', 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'is_active', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_name', "varchar(255) DEFAULT NULL"); $migration->addField($newTable, 'command_line', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addKey($newTable, "name"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contactgroups */ $newTable = "glpi_plugin_monitoring_contactgroups"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contacts_contactgroups */ $newTable = "glpi_plugin_monitoring_contacts_contactgroups"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_contacts_id', 'plugin_monitoring_contacts_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_contactgroups_id', 'plugin_monitoring_contactgroups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_contacts_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_contactgroups_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, array('plugin_monitoring_contacts_id', 'plugin_monitoring_contactgroups_id'), "unicity", "UNIQUE"); $migration->addKey($newTable, "plugin_monitoring_contactgroups_id"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_contactgroups_contactgroups */ $newTable = "glpi_plugin_monitoring_contactgroups_contactgroups"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_contactgroups_id_1', 'plugin_monitoring_contactgroups_id_1', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_contactgroups_id_2', 'plugin_monitoring_contactgroups_id_2', "int(11) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_contactgroups_id_1', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_contactgroups_id_2', "int(11) NOT NULL DEFAULT '0'"); $migration->addKey($newTable, array('plugin_monitoring_contactgroups_id_1', 'plugin_monitoring_contactgroups_id_2'), "unicity", "UNIQUE"); $migration->addKey($newTable, "plugin_monitoring_contactgroups_id_2"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_profiles */ $newTable = "glpi_plugin_monitoring_profiles"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `profiles_id` int(11) NOT NULL DEFAULT '0'\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'profiles_id', 'profiles_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'dashboard', 'dashboard', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'servicescatalog', 'servicescatalog', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'view', 'view', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'componentscatalog', 'componentscatalog', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'viewshomepage', 'viewshomepage', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'weathermap', 'weathermap', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'component', 'component', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'command', 'command', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'config', 'config', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'check', 'check', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'profiles_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'dashboard', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'servicescatalog', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'view', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'componentscatalog', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'viewshomepage', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'weathermap', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'component', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'command', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'config', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'check', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'allressources', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'restartshinken', "char(1) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_servicedefs */ $newTable = "glpi_plugin_monitoring_servicedefs"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_commands_id', 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'arguments', 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'plugin_monitoring_checks_id', 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'active_checks_enabled', 'active_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'passive_checks_enabled', 'passive_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->changeField($newTable, 'calendars_id', 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'remotesystem', 'remotesystem', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'is_arguments', 'is_arguments', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'alias_command', 'alias_command', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->changeField($newTable, 'aliasperfdata_commands_id', 'aliasperfdata_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'link', 'link', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'arguments', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'plugin_monitoring_checks_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'active_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'passive_checks_enabled', "tinyint(1) NOT NULL DEFAULT '1'"); $migration->addField($newTable, 'calendars_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'remotesystem', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'is_arguments', "tinyint(1) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'alias_command', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->addField($newTable, 'aliasperfdata_commands_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'link', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_unavaibilities */ $newTable = "glpi_plugin_monitoring_unavaibilities"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); if (!FieldExists($newTable, "plugin_monitoring_services_id")) { $migration->changeField($newTable, 'items_id', 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); } $migration->migrationOneTable($newTable); $migration->changeField($newTable, 'plugin_monitoring_services_id', 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'begin_date', 'begin_date', "datetime DEFAULT NULL"); $migration->changeField($newTable, 'end_date', 'end_date', "datetime DEFAULT NULL"); $migration->dropField($newTable, 'itemtype'); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'begin_date', "datetime DEFAULT NULL"); $migration->addField($newTable, 'end_date', "datetime DEFAULT NULL"); $migration->addField($newTable, 'duration', "int(15) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_weathermaps */ $newTable = "glpi_plugin_monitoring_weathermaps"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'width', 'width', "smallint(6) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'height', 'height', "smallint(6) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'background', 'background', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'width', "smallint(6) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'height', "smallint(6) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'background', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_weathermapnodes */ $newTable = "glpi_plugin_monitoring_weathermapnodes"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'name', 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'plugin_monitoring_weathermaps_id', 'plugin_monitoring_weathermaps_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'items_id', 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'itemtype', 'itemtype', "varchar(100) DEFAULT NULL"); $migration->changeField($newTable, 'x', 'x', "smallint(6) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'y', 'y', "smallint(6) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'name', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'plugin_monitoring_weathermaps_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'items_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'itemtype', "varchar(100) DEFAULT NULL"); $migration->addField($newTable, 'x', "smallint(6) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'y', "smallint(6) NOT NULL DEFAULT '0'"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_weathermaplinks */ $newTable = "glpi_plugin_monitoring_weathermaplinks"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->changeField($newTable, 'id', 'id', "int(11) NOT NULL AUTO_INCREMENT"); $migration->changeField($newTable, 'plugin_monitoring_weathermapnodes_id_1', 'plugin_monitoring_weathermapnodes_id_1', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_weathermapnodes_id_2', 'plugin_monitoring_weathermapnodes_id_2', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'plugin_monitoring_services_id', 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->changeField($newTable, 'bandwidth_in', 'bandwidth_in', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->changeField($newTable, 'bandwidth_out', 'bandwidth_out', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); $migration->addField($newTable, 'plugin_monitoring_weathermapnodes_id_1', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_weathermapnodes_id_2', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'plugin_monitoring_services_id', "int(11) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'bandwidth_in', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'bandwidth_out', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_shinkenwebservices */ $newTable = "glpi_plugin_monitoring_shinkenwebservices"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->addField($newTable, 'url', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'action', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'cnt', "tinyint(2) NOT NULL DEFAULT '0'"); $migration->addField($newTable, 'fields_string', "text DEFAULT NULL COLLATE utf8_unicode_ci"); $migration->migrationOneTable($newTable); /* * Table glpi_plugin_monitoring_tags */ $newTable = "glpi_plugin_monitoring_tags"; if (!TableExists($newTable)) { $query = "CREATE TABLE `" . $newTable . "` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $DB->query($query); } $migration->addField($newTable, 'tag', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'ip', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'username', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->addField($newTable, 'password', "varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL"); $migration->migrationOneTable($newTable); /* * Table Delete old table not used */ if (TableExists("glpi_plugin_monitoring_servicesuggests")) { $DB->query("DROP TABLE `glpi_plugin_monitoring_servicesuggests`"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring"); } if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) { mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates"); } $query = "SELECT * FROM `glpi_calendars`\n WHERE `name`='24x7'\n LIMIT 1"; $result = $DB->query($query); if ($DB->numrows($result) == 0) { $calendar = new Calendar(); $input = array(); $input['name'] = '24x7'; $input['is_recursive'] = 1; $calendars_id = $calendar->add($input); $calendarSegment = new CalendarSegment(); $input = array(); $input['calendars_id'] = $calendars_id; $input['is_recursive'] = 1; $input['begin'] = '00:00:00'; $input['end'] = '24:00:00'; $input['day'] = '0'; $calendarSegment->add($input); $input['day'] = '1'; $calendarSegment->add($input); $input['day'] = '2'; $calendarSegment->add($input); $input['day'] = '3'; $calendarSegment->add($input); $input['day'] = '4'; $calendarSegment->add($input); $input['day'] = '5'; $calendarSegment->add($input); $input['day'] = '6'; $calendarSegment->add($input); } $crontask = new CronTask(); if (!$crontask->getFromDBbyName('PluginMonitoringServiceevent', 'updaterrd')) { CronTask::Register('PluginMonitoringServiceevent', 'updaterrd', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); } if (!$crontask->getFromDBbyName('PluginMonitoringLog', 'cleanlogs')) { CronTask::Register('PluginMonitoringLog', 'cleanlogs', '96400', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); } if (!$crontask->getFromDBbyName('PluginMonitoringUnavaibility', 'unavaibility')) { CronTask::Register('PluginMonitoringUnavaibility', 'unavaibility', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); } if (!$crontask->getFromDBbyName('PluginMonitoringDisplayview_rule', 'replayallviewrules')) { CronTask::Register('PluginMonitoringDisplayview_rule', 'replayallviewrules', '1200', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30)); } /* * Clean services not have host */ $query = "SELECT `glpi_plugin_monitoring_services`.* FROM `glpi_plugin_monitoring_services`\n LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`\n ON `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` = `plugin_monitoring_componentscatalogs_hosts_id`\n WHERE `is_static` IS NULL"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $queryd = "DELETE FROM `glpi_plugin_monitoring_services`\n WHERE `id`='" . $data['id'] . "'"; $DB->query($queryd); } include GLPI_ROOT . "/plugins/monitoring/inc/hostconfig.class.php"; $pmHostconfig = new PluginMonitoringHostconfig(); $pmHostconfig->initConfig(); include GLPI_ROOT . "/plugins/monitoring/inc/host.class.php"; $pmHost = new PluginMonitoringHost(); $pmHost->verifyHosts(); if ($insertrealm == '1') { // Insert into hostconfigs $query = "UPDATE `glpi_plugin_monitoring_hostconfigs` \n SET `plugin_monitoring_realms_id` = '1'\n WHERE `items_id` = '0'\n AND `itemtype` = 'Entity'"; $DB->query($query); } include GLPI_ROOT . "/plugins/monitoring/inc/config.class.php"; $pmConfig = new PluginMonitoringConfig(); $pmConfig->initConfig(); // * Recalculate unavaibility if ($unavaibility_recalculate == 1) { $query = "SELECT * FROM `glpi_plugin_monitoring_unavaibilities`\n WHERE `end_date` IS NOT NULL"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $time = strtotime($data['end_date']) - strtotime($data['begin_date']); $queryd = "UPDATE `glpi_plugin_monitoring_unavaibilities`\n SET `duration`='" . $time . "'\n WHERE `id`='" . $data['id'] . "'"; $DB->query($queryd); } } $query = "UPDATE `glpi_plugin_monitoring_configs`\n SET `version`='" . PLUGIN_MONITORING_VERSION . "'\n WHERE `id`='1'"; $DB->query($query); }
function plugin_monitoring_MassiveActionsProcess($data) { switch ($data['action']) { case "plugin_monitoring_activatehosts": if ($data['itemtype'] == "Computer") { $pmHost = new PluginMonitoringHost(); foreach ($data['item'] as $key => $val) { if ($val == '1') { $pmHost->massiveactionAddHost($data['itemtype'], $key, $data['template_id']); } } } break; } }
@package Plugin Monitoring for GLPI @author David Durieux @co-author @comment @copyright Copyright (c) 2011-2013 Plugin Monitoring for GLPI team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link https://forge.indepnet.net/projects/monitoring/ @since 2011 ------------------------------------------------------------------------ */ include "../../../inc/includes.php"; Session::checkCentralAccess(); Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "host"); $pmHost = new PluginMonitoringHost(); if (isset($_POST["add"])) { if (isset($_POST['items_id']) and $_POST['items_id'] != "0" and $_POST['items_id'] != "" or isset($_POST['is_template']) and $_POST['is_template'] == "1") { if (isset($_POST['template_id']) and $_POST['template_id'] > 0) { $pmHost->getFromDB($_POST['template_id']); $_POST['parenttype'] = $pmHost->fields['parenttype']; $_POST['plugin_monitoring_commands_id'] = $pmHost->fields['plugin_monitoring_commands_id']; $_POST['plugin_monitoring_checks_id'] = $pmHost->fields['plugin_monitoring_checks_id']; $_POST['active_checks_enabled'] = $pmHost->fields['active_checks_enabled']; $_POST['passive_checks_enabled'] = $pmHost->fields['passive_checks_enabled']; $_POST['calendars_id'] = $pmHost->fields['calendars_id']; } $hosts_id = $pmHost->add($_POST); if (isset($_POST['template_id']) and $_POST['template_id'] > 0) { // Add parents $pmHost_Host = new PluginMonitoringHost_Host();
function generateHostsCfg($file=0, $tag='') { global $DB; // Log Shinken restart event with Tag information ... $pmLog = new PluginMonitoringLog(); if (isset($_SERVER['HTTP_USER_AGENT']) AND strstr($_SERVER['HTTP_USER_AGENT'], 'xmlrpclib.py')) { if (!isset($_SESSION['glpi_currenttime'])) { $_SESSION['glpi_currenttime'] = date("Y-m-d H:i:s"); } $input = array(); $input['user_name'] = "Shinken"; $input['action'] = "restart"; $input['date_mod'] = date("Y-m-d H:i:s"); $input['value'] = $tag; $pmLog->add($input); } PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "Starting generateHostsCfg ($tag) ...\n" ); $pmCommand = new PluginMonitoringCommand(); $pmCheck = new PluginMonitoringCheck(); $pmComponent = new PluginMonitoringComponent(); $pmEntity = new PluginMonitoringEntity(); $pmHostconfig = new PluginMonitoringHostconfig(); $pmHost = new PluginMonitoringHost(); $calendar = new Calendar(); $pmRealm = new PluginMonitoringRealm(); $networkEquipment = new NetworkEquipment(); $pmContact_Item = new PluginMonitoringContact_Item(); $profile_User = new Profile_User(); $pmEventhandler = new PluginMonitoringEventhandler(); $user = new User(); $a_hosts = array(); $i=0; $a_parents_found = array(); $a_hosts_found = array(); $a_entities_allowed = $pmEntity->getEntitiesByTag($tag); $a_entities_list = array(); foreach ($a_entities_allowed as $entity) { $a_entities_list = getSonsOf("glpi_entities", $entity); } $where = ''; if (! isset($a_entities_allowed['-1'])) { $where = getEntitiesRestrictRequest("WHERE", "glpi_entities", '', $a_entities_list); } // * Prepare contacts $a_contacts_entities = array(); $a_list_contact = $pmContact_Item->find("`itemtype`='PluginMonitoringComponentscatalog' AND `users_id`>0"); foreach ($a_list_contact as $data) { $contactentities = getSonsOf('glpi_entities', $data['entities_id']); if (isset($a_contacts_entities[$data['items_id']][$data['users_id']])) { $contactentities = array_merge($contactentities, $a_contacts_entities[$data['items_id']][$data['users_id']]); } $a_contacts_entities[$data['items_id']][$data['users_id']] = $contactentities; } // $query = "SELECT * // FROM `glpi_plugin_monitoring_componentscatalogs_hosts` // GROUP BY `itemtype`, `items_id`"; $query = "SELECT `glpi_plugin_monitoring_componentscatalogs_hosts`.*, `glpi_computers`.`id`, `glpi_entities`.`id` AS entityId, `glpi_entities`.`name` AS entityName, `glpi_entities`.`completename` AS entityFullName, `glpi_locations`.`id`, `glpi_locations`.`completename` AS locationName, `glpi_locations`.`comment` AS locationComment, `glpi_locations`.`building` AS locationGPS, `glpi_plugin_monitoring_services`.`networkports_id` FROM `glpi_plugin_monitoring_componentscatalogs_hosts` LEFT JOIN `glpi_computers` ON `glpi_computers`.`id` = `glpi_plugin_monitoring_componentscatalogs_hosts`.`items_id` LEFT JOIN `glpi_entities` ON `glpi_computers`.`entities_id` = `glpi_entities`.`id` LEFT JOIN `glpi_locations` ON `glpi_locations`.`id` = `glpi_computers`.`locations_id` LEFT JOIN `glpi_plugin_monitoring_services` ON `glpi_plugin_monitoring_services`.`plugin_monitoring_componentscatalogs_hosts_id` = `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` $where GROUP BY `itemtype`, `items_id`"; PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "Hosts: $query\n" ); $result = $DB->query($query); while ($data=$DB->fetch_array($result)) { // Toolbox::logInFile("pm-shinken", " - fetch host ".$data['itemtype']." / ".$data['items_id']."\n"); $classname = $data['itemtype']; $class = new $classname; if ($class->getFromDB($data['items_id'])) { // if (isset($a_entities_allowed['-1']) // OR isset($a_entities_allowed[$class->fields['entities_id']])) { $pmHost->getFromDBByQuery("WHERE `glpi_plugin_monitoring_hosts`.`itemtype` = '" . $data['itemtype'] . "' AND `glpi_plugin_monitoring_hosts`.`items_id` = '" . $data['items_id'] . "' LIMIT 1"); $a_hosts[$i]['host_name'] = preg_replace("/[^A-Za-z0-9\-_]/","",$class->fields['name']); // Fix if hostname is not defined ... if (empty($a_hosts[$i]['host_name'])) { continue; } $a_hosts_found[$a_hosts[$i]['host_name']] = 1; PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', " - add host ".$a_hosts[$i]['host_name']."\n" ); $a_hosts[$i]['_HOSTID'] = $pmHost->getField('id'); if (isset(self::$shinkenParameters['glpi']['entityId'])) { $a_hosts[$i][self::$shinkenParameters['glpi']['entityId']] = $data['entityId']; } if (isset(self::$shinkenParameters['glpi']['itemType'])) { $a_hosts[$i][self::$shinkenParameters['glpi']['itemType']] = $classname; } if (isset(self::$shinkenParameters['glpi']['itemId'])) { $a_hosts[$i][self::$shinkenParameters['glpi']['itemId']] = $data['items_id']; } if (isset(self::$shinkenParameters['glpi']['entityName'])) { $a_hosts[$i][self::$shinkenParameters['glpi']['entityName']] = strtolower(preg_replace("/[^A-Za-z0-9\-_]/","",$data['entityName'])); } $data['entityFullName'] = preg_replace("/ > /","#",$data['entityFullName']); $data['entityFullName'] = preg_replace("/". self::$shinkenParameters['glpi']['rootEntity'] ."#/","",$data['entityFullName']); $data['entityFullName'] = preg_replace("/#/","_",$data['entityFullName']); if (isset(self::$shinkenParameters['glpi']['entityComplete'])) { $a_hosts[$i][self::$shinkenParameters['glpi']['entityComplete']] = strtolower(preg_replace("/[^A-Za-z0-9\-_]/","",$data['entityFullName'])); } $data['entityFullName'] = preg_replace("/_/",".",$data['entityFullName']); if (isset(self::$shinkenParameters['glpi']['location'])) { if (! empty($data['locationName'])) { // Toolbox::logInFile("pm-shinken", " - location: ".$data['locationName']."\n"); $string = utf8_decode(strip_tags(trim($data['locationName']))); // $string = Toolbox::decodeFromUtf8($data['locationName']); $string = preg_replace("/[\r\n]/",".",$data['locationName']); $string = preg_replace("/[^A-Za-z0-9\-_ <>\',;.:!?%*()éèàù]/",'',$string); // Toolbox::logInFile("pm-shinken", " - location: ".$string."\n"); $a_hosts[$i][self::$shinkenParameters['glpi']['location']] = $string; } } if (isset(self::$shinkenParameters['graphite']['prefix']['name'])) { $a_hosts[$i][self::$shinkenParameters['graphite']['prefix']['name']] = strtolower(self::$shinkenParameters['graphite']['prefix']['value'] . preg_replace("/[^A-Za-z0-9\-_.]/","",$data['entityFullName'])); } if (isset(self::$shinkenParameters['glpi']['lat'])) { if (! empty($data['locationGPS'])) { $split = explode(',', $data['locationGPS']); if (count($split) > 2) { // At least 3 elements, let us consider as GPS coordinates with altitude ... $a_hosts[$i][self::$shinkenParameters['glpi']['lat']] = $split[0]; $a_hosts[$i][self::$shinkenParameters['glpi']['lng']] = $split[1]; $a_hosts[$i][self::$shinkenParameters['glpi']['alt']] = $split[2]; } else if (count($split) > 1) { // At least 2 elements, let us consider as GPS coordinates ... $a_hosts[$i][self::$shinkenParameters['glpi']['lat']] = $split[0]; $a_hosts[$i][self::$shinkenParameters['glpi']['lng']] = $split[1]; // } else { // $a_hosts[$i]['_LOC_BUILDING'] = preg_replace("/[\r\n]/",".",$data['locationGPS']); // $a_hosts[$i]['_LOC_BUILDING'] = preg_replace("/[^A-Za-z0-9\-_]/"," / ",$a_hosts[$i]['_LOC_BUILDING']); } } } // Hostgroup name $a_hosts[$i]['hostgroups'] = strtolower(preg_replace("/[^A-Za-z0-9\-_ ]/","",$data['entityName'])); $a_hosts[$i]['hostgroups'] = preg_replace("/[ ]/","_",$a_hosts[$i]['hostgroups']); // Alias $a_hosts[$i]['alias'] = $data['entityName']." / ". $a_hosts[$i]['host_name']; if (isset($class->fields['networkequipmenttypes_id'])) { if ($class->fields['networkequipmenttypes_id'] > 0) { $a_hosts[$i]['alias'] .= " (".Dropdown::getDropdownName("glpi_networkequipmenttypes", $class->fields['networkequipmenttypes_id']).")"; } } else if (isset($class->fields['computertypes_id'])) { if ($class->fields['computertypes_id'] > 0) { $a_hosts[$i]['alias'] .= " (".Dropdown::getDropdownName("glpi_computertypes", $class->fields['computertypes_id']).")"; } } else if (isset($class->fields['printertypes_id'])) { if ($class->fields['printertypes_id'] > 0) { $a_hosts[$i]['alias'] .= " (".Dropdown::getDropdownName("glpi_printertypes", $class->fields['printertypes_id']).")"; } } // WebUI user interface ... if (isset(self::$shinkenParameters['webui']['hostIcons']['name'])) { $a_hosts[$i][self::$shinkenParameters['webui']['hostIcons']['name']] = self::$shinkenParameters['webui']['hostIcons']['value']; } if (isset(self::$shinkenParameters['webui']['hostView']['name'])) { $a_hosts[$i][self::$shinkenParameters['webui']['hostView']['name']] = self::$shinkenParameters['webui']['hostView']['value']; } // IP address $ip = PluginMonitoringHostaddress::getIp($data['items_id'], $data['itemtype'], $class->fields['name']); $a_hosts[$i]['address'] = $ip; // Manage dependencies $parent = ''; if ($data['itemtype'] != 'NetworkEquipment') { $networkPort = new NetworkPort(); $a_networkports = $networkPort->find("`itemtype`='".$data['itemtype']."' AND `items_id`='".$data['items_id']."'"); foreach ($a_networkports as $data_n) { $networkports_id = $networkPort->getContact($data_n['id']); if ($networkports_id) { $networkPort->getFromDB($networkports_id); if ($networkPort->fields['itemtype'] == 'NetworkEquipment') { $networkEquipment->getFromDB($networkPort->fields['items_id']); $parent = preg_replace("/[^A-Za-z0-9\-_]/","",$networkEquipment->fields['name']); $a_parents_found[$parent] = 1; $pmHost->updateDependencies($classname, $data['items_id'], 'NetworkEquipment-'.$networkPort->fields['items_id']); } } } if (empty($parent)) { if (self::$shinkenParameters['shinken']['hosts']['parents'] == 'entity') { $parent = self::$shinkenParameters['shinken']['fake_hosts']['name_prefix'] . $a_hosts[$i]['hostgroups']; } else { $parent = self::$shinkenParameters['shinken']['hosts']['parents']; } } } $a_hosts[$i]['parents'] = $parent; $a_fields = array(); $pmComponent->getFromDB($pmHostconfig->getValueAncestor('plugin_monitoring_components_id', $class->fields['entities_id'], $classname, $class->getID())); $pmCommand->getFromDB($pmComponent->fields['plugin_monitoring_commands_id']); $a_fields = $pmComponent->fields; // Manage host check_command arguments // Toolbox::logInFile("pm-shinken", "Command line : ".$pmCommand->fields['command_line']."\n"); // Toolbox::logInFile("pm-shinken", "Arguments : ".$a_fields['arguments']."\n"); // Toolbox::logInFile("pm-shinken", "Arguments : ".$pmCommand->fields['arguments']."\n"); $array = array(); preg_match_all("/\\$(ARG\d+)\\$/", $pmCommand->fields['command_line'], $array); sort($array[0]); $a_arguments = importArrayFromDB($pmCommand->fields['arguments']); $a_argumentscustom = importArrayFromDB($pmComponent->fields['arguments']); foreach ($a_argumentscustom as $key=>$value) { $a_arguments[$key] = $value; } foreach ($a_arguments as $key=>$value) { $a_arguments[$key] = str_replace('!', '\!', html_entity_decode($value)); } $args = ''; foreach ($array[0] as $arg) { if ($arg != '$PLUGINSDIR$' AND $arg != '$NAGIOSPLUGINSDIR$' AND $arg != '$HOSTADDRESS$' AND $arg != '$MYSQLUSER$' AND $arg != '$MYSQLPASSWORD$') { $arg = str_replace('$', '', $arg); if (!isset($a_arguments[$arg])) { $args .= '!'; } else { if (strstr($a_arguments[$arg], "[[HOSTNAME]]")) { $a_arguments[$arg] = str_replace("[[HOSTNAME]]", $hostname, $a_arguments[$arg]); } elseif (strstr($a_arguments[$arg], "[[NETWORKPORTDESCR]]")){ if (class_exists("PluginFusioninventoryNetworkPort")) { $pfNetworkPort = new PluginFusioninventoryNetworkPort(); $pfNetworkPort->loadNetworkport($data['networkports_id']); $descr = $pfNetworkPort->getValue("ifdescr"); $a_arguments[$arg] = str_replace("[[NETWORKPORTDESCR]]", $descr, $a_arguments[$arg]); } } elseif (strstr($a_arguments[$arg], "[[NETWORKPORTNUM]]")){ $networkPort = new NetworkPort(); $networkPort->getFromDB($data['networkports_id']); $logicalnum = $pfNetworkPort->fields['logical_number']; $a_arguments[$arg] = str_replace("[[NETWORKPORTNUM]]", $logicalnum, $a_arguments[$arg]); } elseif (strstr($a_arguments[$arg], "[[NETWORKPORTNAME]]")) { if (isset($data['networkports_id']) && $data['networkports_id'] > 0) { $networkPort = new NetworkPort(); $networkPort->getFromDB($data['networkports_id']); $portname = $pfNetworkPort->fields['name']; $a_arguments[$arg] = str_replace("[[NETWORKPORTNAME]]", $portname, $a_arguments[$arg]); } else if ($classname == 'Computer') { // Get networkportname of networkcard defined $pmHostaddress = new PluginMonitoringHostaddress(); $a_hostaddresses = $pmHostaddress->find("`itemtype`='Computer'" . " AND `items_id`='".$class->fields['id']."'", '', 1); if (count($a_hostaddresses) == 1) { $a_hostaddress = current($a_hostaddresses); if ($a_hostaddress['networkports_id'] > 0) { $networkPort = new NetworkPort(); $networkPort->getFromDB($a_hostaddress['networkports_id']); $a_arguments[$arg] = str_replace("[[NETWORKPORTNAME]]", $networkPort->fields['name'], $a_arguments[$arg]); } } } } else if (strstr($a_arguments[$arg], "[")) { $a_arguments[$arg] = PluginMonitoringService::convertArgument($data['id'], $a_arguments[$arg]); } if ($a_arguments == '') { $notadd = 1; if ($notadddescription != '') { $notadddescription .= ", "; } $notadddescription .= "Argument ".$a_arguments[$arg]." Not have value"; } $args .= '!'.$a_arguments[$arg]; if ($a_arguments[$arg] == '' AND $a_component['alias_command'] != '') { $args .= $a_component['alias_command']; } } } } $a_hosts[$i]['check_command'] = PluginMonitoringCommand::$command_prefix . $pmCommand->fields['command_name'].$args; // Toolbox::logInFile("pm", "check_command : ".$a_hosts[$i]['check_command']."\n"); $pmCheck->getFromDB($pmComponent->fields['plugin_monitoring_checks_id']); $a_hosts[$i]['check_interval'] = $pmCheck->fields['check_interval']; $a_hosts[$i]['retry_interval'] = $pmCheck->fields['retry_interval']; $a_hosts[$i]['max_check_attempts'] = $pmCheck->fields['max_check_attempts']; if ($calendar->getFromDB($pmComponent->fields['calendars_id'])) { $a_hosts[$i]['check_period'] = $calendar->fields['name']; } else { $a_hosts[$i]['check_period'] = self::$shinkenParameters['shinken']['hosts']['check_period']; } $a_hosts[$i]['active_checks_enabled'] = $a_fields['active_checks_enabled']; $a_hosts[$i]['passive_checks_enabled'] = $a_fields['passive_checks_enabled']; // Manage freshness if ($a_fields['freshness_count'] == 0) { $a_hosts[$i]['check_freshness'] = '0'; $a_hosts[$i]['freshness_threshold'] = '0'; } else { $multiple = 1; if ($a_fields['freshness_type'] == 'seconds') { $multiple = 1; } else if ($a_fields['freshness_type'] == 'minutes') { $multiple = 60; } else if ($a_fields['freshness_type'] == 'hours') { $multiple = 3600; } else if ($a_fields['freshness_type'] == 'days') { $multiple = 86400; } $a_hosts[$i]['check_freshness'] = '1'; $a_hosts[$i]['freshness_threshold'] = (string)($a_fields['freshness_count'] * $multiple); } // Manage event handler if ($a_fields['plugin_monitoring_eventhandlers_id'] > 0) { if ($a_fields->getFromDB($a_fields['plugin_monitoring_eventhandlers_id'])) { $a_hosts[$i]['event_handler'] = $pmEventhandler->fields['command_name']; } } // Realm $pmRealm->getFromDB($pmHostconfig->getValueAncestor('plugin_monitoring_realms_id', $class->fields['entities_id'], $classname, $class->getID())); $a_hosts[$i]['realm'] = $pmRealm->fields['name']; if (! empty(self::$shinkenParameters['shinken']['hosts']['use'])) $a_hosts[$i]['use'] = self::$shinkenParameters['shinken']['hosts']['use']; if (! empty(self::$shinkenParameters['shinken']['hosts']['process_perf_data'])) $a_hosts[$i]['process_perf_data'] = self::$shinkenParameters['shinken']['hosts']['process_perf_data']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_period'])) $a_hosts[$i]['notification_period'] = self::$shinkenParameters['shinken']['hosts']['notification_period']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_options'])) $a_hosts[$i]['notification_options'] = self::$shinkenParameters['shinken']['hosts']['notification_options']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_interval'])) $a_hosts[$i]['notification_interval'] = self::$shinkenParameters['shinken']['hosts']['notification_interval']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notes'])) $a_hosts[$i]['notes'] = self::$shinkenParameters['shinken']['hosts']['notes']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notes_url'])) $a_hosts[$i]['notes_url'] = self::$shinkenParameters['shinken']['hosts']['notes_url']; if (! empty(self::$shinkenParameters['shinken']['hosts']['action_url'])) $a_hosts[$i]['action_url'] = self::$shinkenParameters['shinken']['hosts']['action_url']; if (! empty(self::$shinkenParameters['shinken']['hosts']['icon_image'])) $a_hosts[$i]['icon_image'] = self::$shinkenParameters['shinken']['hosts']['icon_image']; if (! empty(self::$shinkenParameters['shinken']['hosts']['icon_image_alt'])) $a_hosts[$i]['icon_image_alt'] = self::$shinkenParameters['shinken']['hosts']['icon_image_alt']; if (! empty(self::$shinkenParameters['shinken']['hosts']['vrml_image'])) $a_hosts[$i]['vrml_image'] = self::$shinkenParameters['shinken']['hosts']['vrml_image']; if (! empty(self::$shinkenParameters['shinken']['hosts']['statusmap_image'])) $a_hosts[$i]['statusmap_image'] = self::$shinkenParameters['shinken']['hosts']['statusmap_image']; // For contacts, check if a component catalog contains the host associated component ... $a_hosts[$i]['contacts'] = ''; if (($a_fields['passive_checks_enabled'] == '1') and ($a_fields['active_checks_enabled'] == '0')) { // Specific query if host is only passively checked ... // Find the first component catalog in which the host is used ... $querycont = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts` LEFT JOIN `glpi_plugin_monitoring_services` ON `plugin_monitoring_componentscatalogs_hosts_id` = `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` WHERE `items_id`='".$data['items_id']."' AND `itemtype`='".$data['itemtype']."' LIMIT 1"; } else { // Find component catalog which contains the host associated component ... $querycont = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts` LEFT JOIN `glpi_plugin_monitoring_services` ON `plugin_monitoring_componentscatalogs_hosts_id` = `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` WHERE `plugin_monitoring_components_id`='".$pmComponent->fields['id']."' AND `items_id`='".$data['items_id']."' AND `itemtype`='".$data['itemtype']."' LIMIT 1"; } $resultcont = $DB->query($querycont); if ($DB->numrows($resultcont) != 0) { $a_componentscatalogs_hosts = $DB->fetch_assoc($resultcont); // Notification interval $pmComponentscatalog = new PluginMonitoringComponentscatalog(); $pmComponentscatalog->getFromDB($a_componentscatalogs_hosts['plugin_monitoring_componentscalalog_id']); $a_hosts[$i]['notification_interval'] = $pmComponentscatalog->fields['notification_interval']; $a_contacts = array(); $a_list_contact = $pmContact_Item->find("`itemtype`='PluginMonitoringComponentscatalog' AND `items_id`='".$a_componentscatalogs_hosts['plugin_monitoring_componentscalalog_id']."'"); foreach ($a_list_contact as $data_contact) { if (isset($a_contacts_entities[$a_componentscatalogs_hosts['plugin_monitoring_componentscalalog_id']][$data_contact['users_id']])) { if (in_array($class->fields['entities_id'], $a_contacts_entities[$a_componentscatalogs_hosts['plugin_monitoring_componentscalalog_id']][$data_contact['users_id']])) { $user->getFromDB($data_contact['users_id']); $a_contacts[] = $user->fields['name']; } } } if (count($a_contacts) > 0) { $a_contacts_unique = array_unique($a_contacts); $a_hosts[$i]['contacts'] = implode(',', $a_contacts_unique); } } $i++; // } } } // Fake host for business rules PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', " - add host_for_bp\n" ); $a_hosts[$i]['host_name'] = self::$shinkenParameters['shinken']['fake_hosts']['name_prefix'] . self::$shinkenParameters['shinken']['fake_hosts']['bp_host']; $a_hosts[$i]['check_command'] = PluginMonitoringCommand::$command_prefix . 'check_dummy!0'; $a_hosts[$i]['alias'] = 'Fake host for business rules'; $a_hosts[$i]['_HOSTID'] = '0'; $a_hosts[$i]['_ITEMSID'] = '0'; $a_hosts[$i]['_ITEMTYPE'] = 'Computer'; $a_hosts[$i]['address'] = '127.0.0.1'; $a_hosts[$i]['parents'] = self::$shinkenParameters['shinken']['fake_hosts']['name_prefix'] . self::$shinkenParameters['shinken']['fake_hosts']['root_parent']; $a_hosts[$i]['hostgroups'] = self::$shinkenParameters['shinken']['fake_hosts']['hostgroup_name']; $a_hosts[$i]['check_interval'] = '60'; $a_hosts[$i]['retry_interval'] = '1'; $a_hosts[$i]['max_check_attempts'] = '1'; $a_hosts[$i]['check_period'] = '24x7'; if (self::$shinkenParameters['shinken']['fake_contacts']['build']) { $a_hosts[$i]['contacts'] = self::$shinkenParameters['shinken']['fake_contacts']['contact_name']; } else { $a_hosts[$i]['contacts'] = ''; } if (! empty(self::$shinkenParameters['shinken']['fake_hosts']['use'])) $a_hosts[$i]['use'] = self::$shinkenParameters['shinken']['fake_hosts']['use']; if (! empty(self::$shinkenParameters['shinken']['hosts']['process_perf_data'])) $a_hosts[$i]['process_perf_data'] = self::$shinkenParameters['shinken']['hosts']['process_perf_data']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_period'])) $a_hosts[$i]['notification_period'] = self::$shinkenParameters['shinken']['hosts']['notification_period']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_options'])) $a_hosts[$i]['notification_options'] = self::$shinkenParameters['shinken']['hosts']['notification_options']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_interval'])) $a_hosts[$i]['notification_interval'] = self::$shinkenParameters['shinken']['hosts']['notification_interval']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notes'])) $a_hosts[$i]['notes'] = self::$shinkenParameters['shinken']['hosts']['notes']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notes_url'])) $a_hosts[$i]['notes_url'] = self::$shinkenParameters['shinken']['hosts']['notes_url']; if (! empty(self::$shinkenParameters['shinken']['hosts']['action_url'])) $a_hosts[$i]['action_url'] = self::$shinkenParameters['shinken']['hosts']['action_url']; if (! empty(self::$shinkenParameters['shinken']['hosts']['icon_image'])) $a_hosts[$i]['icon_image'] = self::$shinkenParameters['shinken']['hosts']['icon_image']; if (! empty(self::$shinkenParameters['shinken']['hosts']['icon_image_alt'])) $a_hosts[$i]['icon_image_alt'] = self::$shinkenParameters['shinken']['hosts']['icon_image_alt']; if (! empty(self::$shinkenParameters['shinken']['hosts']['vrml_image'])) $a_hosts[$i]['vrml_image'] = self::$shinkenParameters['shinken']['hosts']['vrml_image']; if (! empty(self::$shinkenParameters['shinken']['hosts']['statusmap_image'])) $a_hosts[$i]['statusmap_image'] = self::$shinkenParameters['shinken']['hosts']['statusmap_image']; $i++; // Add one fake host for each entity if (self::$shinkenParameters['shinken']['fake_hosts']['build']) { PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', " - add fake hosts for parents relationship\n" ); // Main root parent $a_hosts[$i]['host_name'] = self::$shinkenParameters['shinken']['fake_hosts']['name_prefix'] . self::$shinkenParameters['shinken']['fake_hosts']['root_parent']; $a_hosts[$i]['check_command'] = PluginMonitoringCommand::$command_prefix . 'check_dummy!0'; $a_hosts[$i]['alias'] = 'Main root parent'; $a_hosts[$i]['_HOSTID'] = '0'; $a_hosts[$i]['_ITEMSID'] = '0'; $a_hosts[$i]['_ITEMTYPE'] = 'Computer'; $a_hosts[$i]['address'] = '127.0.0.1'; $a_hosts[$i]['parents'] = ''; $a_hosts[$i]['hostgroups'] = self::$shinkenParameters['shinken']['fake_hosts']['hostgroup_name']; $a_hosts[$i]['check_interval'] = '60'; $a_hosts[$i]['retry_interval'] = '1'; $a_hosts[$i]['max_check_attempts'] = '1'; $a_hosts[$i]['check_period'] = '24x7'; if (self::$shinkenParameters['shinken']['fake_contacts']['build']) { $a_hosts[$i]['contacts'] = self::$shinkenParameters['shinken']['fake_contacts']['contact_name']; } else { $a_hosts[$i]['contacts'] = ''; } if (! empty(self::$shinkenParameters['shinken']['fake_hosts']['use'])) $a_hosts[$i]['use'] = self::$shinkenParameters['shinken']['fake_hosts']['use']; if (! empty(self::$shinkenParameters['shinken']['hosts']['process_perf_data'])) $a_hosts[$i]['process_perf_data'] = self::$shinkenParameters['shinken']['hosts']['process_perf_data']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_period'])) $a_hosts[$i]['notification_period'] = self::$shinkenParameters['shinken']['hosts']['notification_period']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_options'])) $a_hosts[$i]['notification_options'] = self::$shinkenParameters['shinken']['hosts']['notification_options']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_interval'])) $a_hosts[$i]['notification_interval'] = self::$shinkenParameters['shinken']['hosts']['notification_interval']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notes'])) $a_hosts[$i]['notes'] = self::$shinkenParameters['shinken']['hosts']['notes']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notes_url'])) $a_hosts[$i]['notes_url'] = self::$shinkenParameters['shinken']['hosts']['notes_url']; if (! empty(self::$shinkenParameters['shinken']['hosts']['action_url'])) $a_hosts[$i]['action_url'] = self::$shinkenParameters['shinken']['hosts']['action_url']; if (! empty(self::$shinkenParameters['shinken']['hosts']['icon_image'])) $a_hosts[$i]['icon_image'] = self::$shinkenParameters['shinken']['hosts']['icon_image']; if (! empty(self::$shinkenParameters['shinken']['hosts']['icon_image_alt'])) $a_hosts[$i]['icon_image_alt'] = self::$shinkenParameters['shinken']['hosts']['icon_image_alt']; if (! empty(self::$shinkenParameters['shinken']['hosts']['vrml_image'])) $a_hosts[$i]['vrml_image'] = self::$shinkenParameters['shinken']['hosts']['vrml_image']; if (! empty(self::$shinkenParameters['shinken']['hosts']['statusmap_image'])) $a_hosts[$i]['statusmap_image'] = self::$shinkenParameters['shinken']['hosts']['statusmap_image']; $i++; $a_entities_allowed = $pmEntity->getEntitiesByTag($tag); $a_entities_list = array(); foreach ($a_entities_allowed as $entity) { $a_entities_list = getSonsOf("glpi_entities", $entity); } $where = ''; if (! isset($a_entities_allowed['-1'])) { $where = getEntitiesRestrictRequest("WHERE", "glpi_entities", '', $a_entities_list); } $query = "SELECT `glpi_entities`.`id` AS entityId, `glpi_entities`.`name` AS entityName FROM `glpi_entities` $where"; $result = $DB->query($query); while ($dataEntity=$DB->fetch_array($result)) { // Hostgroup name : used as host name for parents ... $fake_host_name = strtolower(preg_replace("/[^A-Za-z0-9\-_ ]/","",$dataEntity['entityName'])); $fake_host_name = preg_replace("/[ ]/","_",$fake_host_name); $a_hosts[$i]['host_name'] = self::$shinkenParameters['shinken']['fake_hosts']['name_prefix'] . $fake_host_name; $a_hosts[$i]['check_command'] = PluginMonitoringCommand::$command_prefix . 'check_dummy!0'; $a_hosts[$i]['alias'] = $dataEntity['entityName']; $a_hosts[$i]['_HOSTID'] = '0'; $a_hosts[$i]['_ITEMSID'] = '0'; $a_hosts[$i]['_ITEMTYPE'] = 'Computer'; $a_hosts[$i]['address'] = '127.0.0.1'; $a_hosts[$i]['parents'] = self::$shinkenParameters['shinken']['fake_hosts']['name_prefix'] . self::$shinkenParameters['shinken']['fake_hosts']['root_parent']; $a_hosts[$i]['hostgroups'] = self::$shinkenParameters['shinken']['fake_hosts']['hostgroup_name']; $a_hosts[$i]['check_interval'] = '60'; $a_hosts[$i]['retry_interval'] = '1'; $a_hosts[$i]['max_check_attempts'] = '1'; $a_hosts[$i]['check_period'] = '24x7'; if (self::$shinkenParameters['shinken']['fake_contacts']['build']) { $a_hosts[$i]['contacts'] = self::$shinkenParameters['shinken']['fake_contacts']['contact_name']; } else { $a_hosts[$i]['contacts'] = ''; } if (! empty(self::$shinkenParameters['shinken']['fake_hosts']['use'])) $a_hosts[$i]['use'] = self::$shinkenParameters['shinken']['fake_hosts']['use']; if (! empty(self::$shinkenParameters['shinken']['hosts']['process_perf_data'])) $a_hosts[$i]['process_perf_data'] = self::$shinkenParameters['shinken']['hosts']['process_perf_data']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_period'])) $a_hosts[$i]['notification_period'] = self::$shinkenParameters['shinken']['hosts']['notification_period']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_options'])) $a_hosts[$i]['notification_options'] = self::$shinkenParameters['shinken']['hosts']['notification_options']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notification_interval'])) $a_hosts[$i]['notification_interval'] = self::$shinkenParameters['shinken']['hosts']['notification_interval']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notes'])) $a_hosts[$i]['notes'] = self::$shinkenParameters['shinken']['hosts']['notes']; if (! empty(self::$shinkenParameters['shinken']['hosts']['notes_url'])) $a_hosts[$i]['notes_url'] = self::$shinkenParameters['shinken']['hosts']['notes_url']; if (! empty(self::$shinkenParameters['shinken']['hosts']['action_url'])) $a_hosts[$i]['action_url'] = self::$shinkenParameters['shinken']['hosts']['action_url']; if (! empty(self::$shinkenParameters['shinken']['hosts']['icon_image'])) $a_hosts[$i]['icon_image'] = self::$shinkenParameters['shinken']['hosts']['icon_image']; if (! empty(self::$shinkenParameters['shinken']['hosts']['icon_image_alt'])) $a_hosts[$i]['icon_image_alt'] = self::$shinkenParameters['shinken']['hosts']['icon_image_alt']; if (! empty(self::$shinkenParameters['shinken']['hosts']['vrml_image'])) $a_hosts[$i]['vrml_image'] = self::$shinkenParameters['shinken']['hosts']['vrml_image']; if (! empty(self::$shinkenParameters['shinken']['hosts']['statusmap_image'])) $a_hosts[$i]['statusmap_image'] = self::$shinkenParameters['shinken']['hosts']['statusmap_image']; $i++; } PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "End generateHostgroupsCfg\n" ); } // Check if parents all exist in hosts config foreach ($a_parents_found as $host => $num) { if (!isset($a_hosts_found[$host])) { // Delete parents not added in hosts config foreach ($a_hosts as $id=>$data) { if ($data['parents'] == $host) { $a_hosts[$id]['parents'] = ''; } } } } PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "End generateHostsCfg\n" ); if ($file == "1") { $config = "# Generated by plugin monitoring for GLPI\n# on ".date("Y-m-d H:i:s")."\n\n"; foreach ($a_hosts as $data) { $config .= $this->writeFile("host", $data); } return array('hosts.cfg', $config); } else { return $a_hosts; } }
/** * * * @param $items_id integer ID * * @param $host_id integer associated host ID * @param $options array * *@return bool true if form is ok * **/ function showForm($items_id = -1, $options = array()) { global $DB, $CFG_GLPI; $host_id = -1; if (isset($_GET['host_id'])) { $host_id = $_GET['host_id']; } if ($host_id == -1 && $items_id == -1) { return false; } $createDowntime = false; $pmHost = new PluginMonitoringHost(); if ($host_id != -1) { $pmHost->getFromDB($host_id); if ($pmHost->isInScheduledDowntime()) { // If host already in scheduled downtime, show current downtime ... $pmDowntime = new PluginMonitoringDowntime(); $pmDowntime->getFromDBByQuery("WHERE `" . $pmDowntime->getTable() . "`.`plugin_monitoring_hosts_id` = '" . $host_id . "' LIMIT 1"); $items_id = $pmDowntime->getID(); $this->getFromDB($items_id); } else { // .. else create new downtime $createDowntime = true; $this->getEmpty(); $this->setDefaultContent($host_id); } } else { $this->getFromDB($items_id); } // Now ... $nowDate = date('Y-m-d'); $nowTime = date('H:i:s'); $this->showFormHeader(array('colspan' => '4')); $this->isExpired(); $pmHost = new PluginMonitoringHost(); $pmHost->getFromDB($this->fields["plugin_monitoring_hosts_id"]); $itemtype = $pmHost->getField("itemtype"); $item = new $itemtype(); $item->getFromDB($pmHost->getField("items_id")); echo "<tr class='tab_bg_1'>"; echo "<td>" . $item->getTypeName() . "</td>"; echo "<td>"; echo "<input type='hidden' name='plugin_monitoring_hosts_id' value='" . $this->fields['plugin_monitoring_hosts_id'] . "' />"; echo $item->getLink() . " " . $pmHost->getComments(); echo "</td>"; echo "<td></td>"; echo "<td></td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Start time', 'monitoring') . "</td>"; echo "<td>"; $date = $this->fields["start_time"]; Html::showDateTimeField("start_time", array('value' => $date, 'timestep' => 10, 'maybeempty' => false, 'canedit' => $createDowntime, 'mindate' => $nowDate, 'mintime' => $nowTime)); echo "</td>"; echo "<td>" . __('Flexible ?', 'monitoring') . "</td>"; echo "<td>"; if ($createDowntime) { Dropdown::showYesNo('flexible', $this->fields['flexible']); } else { echo Dropdown::getYesNo($this->fields['flexible']); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('End time', 'monitoring') . "</td>"; echo "<td>"; $date = $this->fields["end_time"]; Html::showDateTimeField("end_time", array('value' => $date, 'timestep' => 10, 'maybeempty' => false, 'canedit' => $createDowntime, 'mindate' => $nowDate, 'mintime' => $nowTime)); echo "</td>"; echo "<td>" . __('Duration', 'monitoring') . "</td>"; echo "<td>"; if ($createDowntime) { Dropdown::showNumber("duration", array('value' => $this->fields['duration'], 'min' => 1, 'max' => 300)); } else { echo $this->fields['duration']; } $a_duration_type = array(); $a_duration_type['seconds'] = __('Second(s)', 'monitoring'); $a_duration_type['minutes'] = __('Minute(s)', 'monitoring'); $a_duration_type['hours'] = __('Hour(s)', 'monitoring'); $a_duration_type['days'] = __('Day(s)', 'monitoring'); if ($createDowntime) { Dropdown::showFromArray("duration_type", $a_duration_type, array('value' => $this->fields['duration_type'])); } else { echo " " . $this->fields['duration_type']; } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Comment', 'monitoring') . "</td>"; echo "<td >"; if ($createDowntime) { echo "<textarea cols='80' rows='4' name='comment' >" . $this->fields['comment'] . "</textarea>"; } else { echo "<textarea cols='80' rows='4' name='comment' readonly='1' disabled='1' >" . $this->fields['comment'] . "</textarea>"; } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('User', 'monitoring') . "</td>"; echo "<td>"; echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "' />"; echo $this->getUsername(); echo "</td>"; echo "<td>" . __('Expired ?', 'monitoring') . "</td>"; echo "<td>"; echo Dropdown::getYesNo($this->fields['expired']); echo "</td>"; echo "</tr>"; if (Ticket::canView()) { echo "<tr class='tab_bg_1'>"; echo "<td colspan='4'> </td>"; echo "</tr>"; if ($this->isAssociatedTicket()) { echo "<tr class='tab_bg_3'>"; echo "<td colspan='4'>" . __('Downtime associated ticket', 'monitoring') . "</td>"; echo "</tr>"; // Find ticket in DB ... $track = new Ticket(); $track->getFromDB($this->getField("tickets_id")); // Display ticket id, name and tracking ... $bgcolor = $_SESSION["glpipriority_" . $track->fields["priority"]]; echo "<tr class='tab_bg_2'>"; echo "<td class='center' bgcolor='{$bgcolor}'>" . sprintf(__('%1$s: %2$s'), __('ID'), $track->fields["id"]) . "</td>"; echo "<td class='center'>"; $showprivate = Session::haveRight("show_full_ticket", 1); $link = "<a id='ticket" . $track->fields["id"] . "' href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $track->fields["id"]; $link .= "'>"; $link .= "<span class='b'>" . $track->getNameID() . "</span></a>"; $link = sprintf(__('%1$s (%2$s)'), $link, sprintf(__('%1$s - %2$s'), $track->numberOfFollowups($showprivate), $track->numberOfTasks($showprivate))); $link = printf(__('%1$s %2$s'), $link, Html::showToolTip($track->fields['content'], array('applyto' => 'ticket' . $track->fields["id"], 'display' => false))); echo "</td>"; echo "</tr>"; } else { if ($createDowntime && Ticket::canCreate()) { echo "<tr class='tab_bg_3'>"; echo "<td colspan='4'>" . __('Associated ticket (no declared category implies no ticket created):', 'monitoring') . "</td>"; echo "</tr>"; echo "<input type='hidden' name='redirect' value='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php' />"; echo "<input type='hidden' name='itemtype' value='" . $pmHost->getField("itemtype") . "' />"; echo "<input type='hidden' name='items_id' value='" . $pmHost->getField("items_id") . "' />"; echo '<input type="hidden" name="entities_id" value="' . $item->fields['entities_id'] . '" />'; $item = new $itemtype(); $item->getFromDB($pmHost->getField("items_id")); echo "<input type='hidden' name='locations_id' value='" . $item->getField("locations_id") . "' />"; /* // Find SLA ... $sla = new Sla(); $slas = current($sla->find("`name` LIKE '%proactive%' LIMIT 1")); $sla_id = isset($slas['id']) ? $slas['id'] : 0; echo "<tr class='tab_bg_3'>"; echo "<td>".__('Ticket SLA:', 'monitoring')."</td>"; echo "<td colspan='3'>"; Sla::dropdown(array('value' => $sla_id)); echo "</td>"; echo "</tr>"; */ // Ticket type ... echo "<tr class='tab_bg_3'>"; echo "<td>" . __('Ticket type:', 'monitoring') . "</td>"; echo "<td colspan='3'>"; Ticket::dropdownType("type", array('value' => Ticket::INCIDENT_TYPE)); echo "</td>"; echo "</tr>"; // Find category ... $category = new ITILCategory(); $categories = current($category->find("`name` LIKE '%incident%' LIMIT 1")); $category_id = isset($categories['id']) ? $categories['id'] : 0; /* echo " <script> function changeCategory() { alert(document.getElementById('dropdown_itilcategories_idcategory')); alert($('#dropdown_itilcategories_idcategory').val()); } </script> "; */ echo "<tr class='tab_bg_3'>"; echo "<td>" . __('Ticket category:', 'monitoring') . "</td>"; echo "<td colspan='3'>"; ITILCategory::dropdown(array('value' => $category_id)); /* ITILCategory::dropdown(array( 'value' => $category_id, 'rand' => 'category', 'on_change' => 'changeCategory();' )); */ echo "</td>"; echo "</tr>"; } else { echo "<tr class='tab_bg_3'>"; echo "<td colspan='4'>" . __('No associated ticket for this downtime', 'monitoring') . "</td>"; echo "</tr>"; } } } $this->showFormButtons(array('canedit' => $createDowntime)); return true; }