function get_host_details($dets) { global $NagiosUser; $page = "\n\n\t<h3>" . gettext('Host Status Detail') . "</h3>\n\t<div class='detailWrapper'>\n\t<h4><em>" . gettext('Host') . ": </em>{$dets['Host']}</h4>\n\t<h5><em>IP Address: </em>" . get_host_ip($dets['Host']) . "</h5>\n\t<h5><em>" . gettext('Member of') . ": </em>{$dets['MemberOf']}</h5>\n\t<h5><a href='index.php?type=services&host_filter={$dets['Host']}' title='" . gettext('See All Services For This Host') . "'>" . gettext('See All Services For This Host') . "</a></h5>\n\t<div class='detailcontainer'>\n\t<fieldset class='hostdetails'>\n\t<legend>" . gettext('Advanced Details') . "</legend>\n\t<table>\n\t\t<tr><td>" . gettext('Current State') . "</td><td class='{$dets['State']}'>{$dets['State']}</td></tr>\n\t\t<tr><td>" . gettext('Status Information') . "</td><td><div class='td_maxwidth'>{$dets['StatusInformation']}</div></td></tr>\n\t\t<tr><td>" . gettext('Duration') . "</td><td>{$dets['Duration']}</td></tr>\n\t\t<tr><td>" . gettext('State Type') . "</td><td>{$dets['StateType']}</td></tr>\n\t\t<tr><td>" . gettext('Current Check') . "</td><td>{$dets['CurrentCheck']}</td></tr>\n\t\t<tr><td>" . gettext('Last Check') . "</td><td>{$dets['LastCheck']}</td></tr>\n\t\t<tr><td>" . gettext('Next Check') . "</td><td>{$dets['NextCheck']}</td></tr>\n\t\t<tr><td>" . gettext('Last State Change') . "</td><td>{$dets['LastStateChange']}</td></tr>\n\t\t<tr><td>" . gettext('Last Notification') . "</td><td>{$dets['LastNotification']}</td></tr>\n\t\t<tr><td>" . gettext('Check Type') . "</td><td>{$dets['CheckType']}</td></tr>\n\t\t<tr><td>" . gettext('Check Latency') . "</td><td>{$dets['CheckLatency']}</td></tr>\n\t\t<tr><td>" . gettext('Execution Time') . "</td><td>{$dets['ExecutionTime']}</td></tr>\n\t\t<tr><td>" . gettext('State Change') . "</td><td>{$dets['StateChange']}</td></tr>\n\t\t<tr><td>" . gettext('Performance Data') . "</td><td><div class='td_maxwidth'>{$dets['PerformanceData']}</div></td></tr>\n\t\t\n\t</table>\t\n\t\n\t</fieldset>\n\t</div><!-- end detailcontainer -->\n\t\n\t<div class='rightContainer'>\n\t\n\t"; if (!$NagiosUser->if_has_authKey('authorized_for_read_only')) { $page .= "\t\n\t\n\t\t<fieldset class='attributes'>\n\t\t<legend>" . gettext('Service Attributes') . "</legend>\t\n\t\t<table>\t\n\t\t<tr><td class='{$dets['ActiveChecks']}'>" . gettext('Active Checks') . ": {$dets['ActiveChecks']}</td>\n\t\t<td><a href='{$dets['CmdActiveChecks']}'><img src='views/images/action_small.gif' title='" . gettext('Toggle Active Checks') . "' class='iconLink' height='12' width='12' alt='Toggle' /></a></td></tr>\n\t\t<tr><td class='{$dets['PassiveChecks']}'>" . gettext('Passive Checks') . ": {$dets['PassiveChecks']}</td>\n\t\t<td><a href='{$dets['CmdPassiveChecks']}'><img src='views/images/action_small.gif' title='" . gettext('Toggle Passive Checks') . "' class='iconLink' height='12' width='12' alt='Toggle' /></a></td></tr>\n\t\t<tr><td class='{$dets['Obsession']}'>" . gettext('Obsession') . ": {$dets['Obsession']}</td>\n\t\t<td><a href='{$dets['CmdObsession']}'><img src='views/images/action_small.gif' title='" . gettext('Toggle Obsession') . "' class='iconLink' height='12' width='12' alt='Toggle' /></a></td></tr>\n\t\t<tr><td class='{$dets['Notifications']}'>" . gettext('Notifications') . ": {$dets['Notifications']}</td>\n\t\t<td><a href='{$dets['CmdNotifications']}'><img src='views/images/action_small.gif' title='" . gettext('Toggle Notifications') . "' class='iconLink' height='12' width='12' alt='Toggle' /></a></td></tr>\n\t\t<tr><td class='{$dets['FlapDetection']}'>" . gettext('Flap Detection') . ": {$dets['FlapDetection']}</td>\n\t\t<td><a href='{$dets['CmdFlapDetection']}'><img src='views/images/action_small.gif' title='" . gettext('Toggle Flap Detection') . "' class='iconLink' height='12' width='12' alt='Toggle' /></a></td></tr>\n\t\t</table>\n\t\t<p class='note'>" . gettext('Commands will not appear until after page reload') . "</p>\n\t\t</fieldset>\n\t\t\n\t\t\n\t\t<!-- Nagios Core Command Table -->\n\t\t<fieldset class='corecommands'>\n\t\t<legend>" . gettext('Core Commands') . "</legend>\n\t\t<table>\n\t\t<tr><td><a href='{$dets['MapHost']}' title='" . gettext('Map Host') . "'><img src='views/images/statusmapballoon.png' class='iconLink' height='12' width='12' alt='Map' /></a></td><td>" . gettext('Locate host on map') . "</td></tr>\n\t\t<tr><td><a href='{$dets['CmdCustomNotification']}' title='" . gettext('Send Custom Notification') . "'><img src='views/images/notification.gif' class='iconLink' height='12' width='12' alt='Notification' /></a></td><td>" . gettext('Send custom notification') . "</td></tr>\n\t\t<tr><td><a href='{$dets['CmdScheduleDowntime']}' title='" . gettext('Schedule Downtime') . "'><img src='views/images/downtime.png' class='iconLink' height='12' width='12' alt='Downtime' /></a></td><td>" . gettext('Schedule downtime') . "</td></tr>\n\t\t<tr><td><a href='{$dets['CmdScheduleDowntimeAll']}' title='" . gettext('Schedule Recursive Downtime') . "'><img src='views/images/downtime.png' class='iconLink' height='12' width='12' alt='Downtime' /></a></td><td>" . gettext('Schedule downtime for this host and all services') . "</td></tr>\n\t\t<tr><td><a href='{$dets['CmdScheduleChecks']}' title='" . gettext('Schedule Check') . "'><img src='views/images/schedulecheck.png' class='iconLink' height='12' width='12' alt='Schedule' /></a></td><td>" . gettext('Schedule a check for all services of this host') . "</td></tr>\n\t\t<tr><td><a href='{$dets['CmdAcknowledge']}' title='{$dets['AckTitle']}'><img src='views/images/ack.png' class='iconLink' height='12' width='12' alt='Acknowledge' /></a></td><td>{$dets['AckTitle']}</td></tr><!-- make into variable -->\n\t\t<tr><td colspan='2'><a class='label' href='{$dets['CoreLink']}' title='" . gettext('See This Host In Nagios Core') . "'>" . gettext('See This Host In Nagios Core') . "</a></td></tr>\t\n\t\t</table>\n\t\t</fieldset>\n\t\t"; } //end if authorized for object $page .= " \n\t</div><!-- end rightContainer -->\n\t</div><!-- end detailWrapper -->\n\t\n\n\t<!-- begin comment table -->\n\t<div class='commentTable'>\n\t"; if (!$NagiosUser->if_has_authKey('authorized_for_read_only')) { $page .= " \n\t\t<h5 class='commentTable'>" . gettext('Comments') . "</h5>\n\t\t<p class='commentTable'><a class='label' href='{$dets['AddComment']}' title='" . gettext('Add Comment') . "'>" . gettext('Add Comment') . "</a></p> \n\n\t\t<table class='commentTable'><tr><th>" . gettext('Author') . "</th><th>" . gettext('Entry Time') . "</th><th>" . gettext('Comment') . "</th><th>" . gettext('Actions') . "</th></tr>\n\t\t"; //host comments table from Nagios core //print host comments in table rows if any exist //see display_functions.php for function $page .= get_host_comments($dets['Host']); //close comment table $page .= '</table>'; } $page .= '</div><br />'; return $page; }
/** * delete_ip_host($hostDN,$auDN) * Löscht die IP Adresse eines Hosts, und passt die FreeIPBlocks der AU an. * * @param string hostDN Distinguished Name des LDAP Host-Objektes * @param string auDN Distinguished Name des LDAP AU-Objektes * * @return boolean 1 bei Erfolg bzw. 0 bei Misserfolg * * @author Tarik Gasmi */ function delete_ip_host($hostDN, $auDN) { global $ds, $suffix, $ldapError; $host_array = get_host_ip($hostDN); $old_ip = $host_array['ipaddress']; # oder IP aus dem Formular # print_r($host_array);printf("<br>"); # printf($old_ip); $delentry['ipaddress'] = $old_ip; // if ( $host_array['dhcpoptfixed-address'] != "" ){ // $delentry ['dhcpoptfixed-address'] = array(); // } # print_r($delentry);printf("<br>"); $results = ldap_mod_del($ds, $hostDN, $delentry); if ($results) { echo "IP Adresse erfolgreich geloescht!<br>"; $modentry['FreeIPBlock'] = $old_ip; $results = ldap_mod_add($ds, $auDN, $modentry); if ($results) { echo "geloeschte IP Adresse erfolgreich als neuer FIPB in die AU eingetragen!<br>"; merge_ipranges($auDN); return 1; } else { echo "Fehler beim eintragen der geloeschten IP Adresse als neuen FIPB!<br>"; return 0; } } else { echo "Fehler beim loeschen der IP Adresse!<br>"; return 0; } }
if (empty($differences)) { $message .= "<br>Files are identicals<br>\n"; } else { $message .= "<br>File comparison output :<br>\n"; $message .= "<br>Legende :<br>"; $message .= "<p class=add> Key(s) added<br><p class=delete> Key(s) deleted</p><br>"; $message .= $differences; } echo "{$message}<br></fieldset>"; return $message; } $id = $_GET['id']; $id_account = $_GET['id_account']; $hostgroup = $_GET['hostgroup']; $hostname = get_host_name($id); $ip = get_host_ip($id); // Getting account information $queryaccount = "SELECT * FROM `accounts` WHERE `id` = '{$id_account}' "; $resultaccount = mysql_query($queryaccount) or die(mysql_error() . "<br>Couldn't execute query: {$queryaccount}"); $rowaccount = mysql_fetch_array($resultaccount); $account_name = $rowaccount["name"]; $account_UID = $rowaccount["UID"]; $account_GID = $rowaccount["GID"]; $GIDname = $rowaccount["GIDname"]; $GECOS = $rowaccount["GECOS"]; $OStype = get_os_type($id); $account_homedir = $rowaccount["homedir"]; if (!empty(${$account_homedir})) { if ($OStype == "Solaris") { $account_homedir .= "/export" . $account_homedir; }
function deploy_globalfile($id_file, $id_host) { $hostname = get_host_name($id_host); $hostip = get_host_ip($id_host); $gfiles = mysql_query("SELECT * FROM `globalfiles` WHERE `id` = '{$id_file}'") or die(mysql_error() . "<br>Couldn't execute query: {$query}"); $nr_gbfiles = mysql_num_rows($gfiles); if (!empty($nr_gbfiles)) { // Preparing file,path, etc... $gfilerow = mysql_fetch_array($gfiles); $path = $gfilerow['path']; $name = $gfilerow['name']; //$filecontents=$gfilerow['text']; $localfile = $gfilerow['localfile']; $now = date("Ymd-His"); // Testing connectivity... if (test_connection($hostname) != "OK") { $message .= "<img src='images/error.gif'>Connection failed. Please see output below.<br>\n"; return $message; } else { $message .= "<img src='images/ok.gif'>SSH connection is OK.<br>\n"; } // Testing presence of file if (test_presence($hostname, $path / $name) == 1) { $message .= "<img src='images/warning.gif'>{$path}/{$name} was not found...<br>\n"; } else { // File is present, we try to back it up // Archiving current file $output = shell_exec("ssh " . $GLOBALS['sudousr'] . "@{$hostname} cp {$path}/{$name} {$path}/{$name}.{$now} 2>&1"); if (empty($output)) { // Archiving is OK $message .= "<img src='images/ok.gif'>{$path}/{$name} has been backup successfully.<br>\n"; } else { $message .= "<img src='images/error.gif'>{$path}/{$name} could not be backed up.<br>\n"; return $message; } } // Deploying $output = shell_exec("scp {$localfile} " . $GLOBALS['sudousr'] . "@{$hostname}:{$path}/{$name} 2>&1"); if (empty($output)) { // File was correctly transfered $message .= "<img src='images/ok.gif'>{$path}/{$name} was correctly updated.<br>\n"; $output = shell_exec("ssh " . $GLOBALS['sudousr'] . "@{$hostname} chmod 440 {$path}/{$name} 2>&1"); if (empty($output)) { $message .= "<img src='images/ok.gif'>Permission changed successfully to 440 for file {$path}/{$name}.<br>\n"; } else { $message .= "<img src='images/error.gif'>Could not change permission to 440 for file {$path}/{$name}.<br>\n"; } } else { $message .= "<img src='images/error.gif'>An error occured during the update.<br>\n"; } } else { $message .= "<img src='images/error.gif'>No global file found with id {$id}<br>\n"; } return $message; }