PageRenderTime 36ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/html/pages/front/demo.php

https://bitbucket.org/MelFlynn/observium
PHP | 179 lines | 148 code | 30 blank | 1 comment | 23 complexity | e388760c1d3d3195b50e1404e319881a MD5 | raw file
Possible License(s): GPL-3.0, MIT
  1. <table border=0 cellpadding=10 cellspacing=10 width=100%>
  2. <tr>
  3. <td colspan=2>
  4. <?php
  5. echo("<table><tr>");
  6. $dev_list = array('6' => 'Central Fileserver',
  7. '7' => 'NE61 Fileserver',
  8. '34' => 'DE56 Fileserver');
  9. foreach ($dev_list as $device_id => $descr)
  10. {
  11. echo("<td>");
  12. echo("<div style='font-size: 16px; font-weight: bold; color: #555555;'>".$descr."</div>");
  13. $graph_array['height'] = "100";
  14. $graph_array['width'] = "310";
  15. $graph_array['to'] = $now;
  16. $graph_array['id'] = $device_id;
  17. $graph_array['type'] = "device_bits";
  18. $graph_array['from'] = $day;
  19. $graph_array['legend'] = "no";
  20. $graph_array['popup_title'] = $descr;
  21. # $graph_array['link'] = generate_device_link($device_id);
  22. print_graph_popup($graph_array);
  23. $graph_array['height'] = "50";
  24. $graph_array['width'] = "180";
  25. echo("<div style='margin: 1px; float: left; padding: 5px; background-color: #e5e5e5;'>");
  26. $graph_array['type'] = "device_ucd_memory";
  27. print_graph_popup($graph_array);
  28. echo("</div>");
  29. echo("<div style='margin: 1px; float: left; padding: 5px; background-color: #e5e5e5;'>");
  30. $graph_array['type'] = "device_processor";
  31. print_graph_popup($graph_array);
  32. echo("</div>");
  33. echo("<div style='margin: 1px; float: left; padding: 5px; background-color: #e5e5e5;'>");
  34. $graph_array['type'] = "device_storage";
  35. print_graph_popup($graph_array);
  36. echo("</div>");
  37. echo("<div style='margin: 1px; float: left; padding: 5px; background-color: #e5e5e5;'>");
  38. $graph_array['type'] = "device_diskio";
  39. print_graph_popup($graph_array);
  40. echo("</div>");
  41. echo("</td>");
  42. }
  43. echo("</tr></table>");
  44. ?>
  45. </td>
  46. </tr>
  47. <tr>
  48. <td bgcolor=#e5e5e5 valign=top>
  49. <?php
  50. $nodes = array();
  51. $sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'");
  52. while ($device = mysql_fetch_array($sql)) {
  53. unset($already);
  54. $i = 0;
  55. while ($i <= count($nodes)) {
  56. $thisnode = $device['device_id'];
  57. if ($nodes[$i] == $thisnode) {
  58. $already = "yes";
  59. }
  60. $i++;
  61. }
  62. if (!$already) { $nodes[] = $device['device_id']; }
  63. }
  64. $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
  65. while ($device = mysql_fetch_array($sql)) {
  66. if (device_permitted($device['device_id'])) {
  67. echo("<div style='text-align: center; margin: 2px; border: solid 2px #d0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffbbbb;'>
  68. <strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
  69. <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span><br />
  70. <span class=body-date-1>".truncate($device['location'], 35)."</span>
  71. </div>");
  72. }
  73. }
  74. if ($config['warn']['ifdown'])
  75. {
  76. $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
  77. while ($interface = mysql_fetch_array($sql))
  78. {
  79. if (port_permitted($interface['interface_id']))
  80. {
  81. echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
  82. <strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
  83. <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />
  84. <strong>".generate_port_link($interface, makeshortif($interface['ifDescr']))."</strong><br />
  85. <span class=body-date-1>".truncate($interface['ifAlias'], 15)."</span>
  86. </div>");
  87. }
  88. }
  89. }
  90. $sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
  91. while ($service = mysql_fetch_array($sql))
  92. {
  93. if (device_permitted($service['device_id']))
  94. {
  95. echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
  96. <strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
  97. <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span><br />
  98. <strong>".$service['service_type']."</strong><br />
  99. <span class=body-date-1>".truncate($interface['ifAlias'], 15)."</span>
  100. </center></div>");
  101. }
  102. }
  103. $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id");
  104. while ($peer = mysql_fetch_array($sql))
  105. {
  106. if (device_permitted($peer['device_id']))
  107. {
  108. echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
  109. <strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
  110. <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span><br />
  111. <strong>".$peer['bgpPeerIdentifier']."</strong><br />
  112. <span class=body-date-1>AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)."</span>
  113. </div>");
  114. }
  115. }
  116. if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
  117. {
  118. $sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE
  119. A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'");
  120. while ($device = mysql_fetch_array($sql))
  121. {
  122. if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime")
  123. {
  124. echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'>
  125. <strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
  126. <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />
  127. <span class=body-date-1>".formatUptime($device['attrib_value'])."</span>
  128. </div>");
  129. }
  130. }
  131. }
  132. echo("
  133. <div style='clear: both;'>$errorboxes</div> <div style='margin: 0px; clear: both;'>
  134. <h3>Recent Syslog Messages</h3>
  135. ");
  136. $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from `syslog` ORDER BY seq DESC LIMIT 20";
  137. $query = mysql_query($sql);
  138. echo("<table cellspacing=0 cellpadding=2 width=100%>");
  139. while ($entry = mysql_fetch_array($query))
  140. {
  141. $entry = array_merge($entry, device_by_id_cache($entry['device_id']));
  142. include("includes/print-syslog.inc.php");
  143. }
  144. echo("</table>");
  145. ?>
  146. </td>
  147. </tr>
  148. <tr>
  149. </tr></table>