PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/html/pages/front/example2.php

https://bitbucket.org/MelFlynn/observium
PHP | 179 lines | 140 code | 36 blank | 3 comment | 21 complexity | c95286b7231823cf39b233d4bd66ba27 MD5 | raw file
Possible License(s): GPL-3.0, MIT
  1. <table border=0 cellpadding=10 cellspacing=10 width=100%>
  2. <tr>
  3. <td bgcolor=#e5e5e5 valign=top>
  4. <?php
  5. # <table width=100% border=0><tr><td><div style="margin-bottom: 5px; font-size: 18px; font-weight: bold;">Devices with Alerts</div></td><td width=35 align=center><div class=tablehead>Host</div></td><td align=center width=35><div class=tablehead>Int</div></td><td align=center width=35><div class=tablehead>Srv</div></tr>
  6. ?>
  7. <?php
  8. $nodes = array();
  9. $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'");
  10. while ($device = mysql_fetch_assoc($sql))
  11. {
  12. unset($already);
  13. $i = 0;
  14. while ($i <= count($nodes))
  15. {
  16. $thisnode = $device['device_id'];
  17. if ($nodes[$i] == $thisnode)
  18. {
  19. $already = "yes";
  20. }
  21. $i++;
  22. }
  23. if (!$already) { $nodes[] = $device['device_id']; }
  24. }
  25. $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
  26. while ($device = mysql_fetch_assoc($sql)) {
  27. echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffbbbb; margin: 4px;'>
  28. <center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
  29. <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span>
  30. <span class=body-date-1>".truncate($device['location'], 20)."</span>
  31. </center></div>");
  32. }
  33. $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'");
  34. while ($interface = mysql_fetch_assoc($sql)) {
  35. echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
  36. <center><strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
  37. <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span>
  38. <strong>".generate_port_link($interface, makeshortif($interface['ifDescr']))."</strong> <br />
  39. <span class=body-date-1>".truncate($interface['ifAlias'], 20)."</span>
  40. </center></div>");
  41. }
  42. $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'");
  43. while ($service = mysql_fetch_assoc($sql)) {
  44. echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
  45. <center><strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
  46. <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>
  47. <strong>".$service['service_type']."</strong><br />
  48. <span class=body-date-1>".truncate($interface['ifAlias'], 20)."</span>
  49. </center></div>");
  50. }
  51. $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id");
  52. while ($peer = mysql_fetch_assoc($sql)) {
  53. echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
  54. <center><strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
  55. <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span>
  56. <strong>".$peer['bgpPeerIdentifier']."</strong> <br />
  57. <span class=body-date-1>AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)."</span>
  58. </center></div>");
  59. }
  60. if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
  61. {
  62. $sql = mysql_query("SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'");
  63. while ($device = mysql_fetch_assoc($sql)) {
  64. echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ddffdd; margin: 4px;'>
  65. <center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
  66. <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />
  67. <span class=body-date-1>".formatUptime($device['attrib_value'])."</span>
  68. </center></div>");
  69. }
  70. }
  71. echo("
  72. <div style='clear: both;'>$errorboxes</div> <div style='margin: 4px; clear: both;'>
  73. <h3>Recent Syslog Messages</h3>
  74. ");
  75. $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
  76. $query = mysql_query($sql);
  77. echo("<table cellspacing=0 cellpadding=2 width=100%>");
  78. while ($entry = mysql_fetch_assoc($query)) { include("includes/print-syslog.inc.php"); }
  79. echo("</table>");
  80. echo("</div>
  81. </td>
  82. <td bgcolor=#e5e5e5 width=275 valign=top>");
  83. /// this stuff can be customised to show whatever you want....
  84. if ($_SESSION['userlevel'] >= '5')
  85. {
  86. $sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%";
  87. $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias";
  88. $query = mysql_query($sql);
  89. unset ($seperator);
  90. while ($interface = mysql_fetch_assoc($query))
  91. {
  92. $ports['l2tp'] .= $seperator . $interface['interface_id'];
  93. $seperator = ",";
  94. }
  95. $sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id AND D.hostname LIKE '%";
  96. $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias";
  97. $query = mysql_query($sql);
  98. unset ($seperator);
  99. while ($interface = mysql_fetch_assoc($query))
  100. {
  101. $ports['transit'] .= $seperator . $interface['interface_id'];
  102. $seperator = ",";
  103. }
  104. $sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Server: thlon-pbx%' AND I.device_id = D.device_id AND D.hostname LIKE '%";
  105. $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias";
  106. $query = mysql_query($sql);
  107. unset ($seperator);
  108. while ($interface = mysql_fetch_assoc($query))
  109. {
  110. $ports['voip'] .= $seperator . $interface['interface_id'];
  111. $seperator = ",";
  112. }
  113. if ($ports['transit'])
  114. {
  115. echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=multi_bits&amp;ports=".$ports['transit'].
  116. "&amp;from=".$day."&amp;to=".$now."&amp;width=400&amp;height=150\'>', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >".
  117. "<div style='font-size: 18px; font-weight: bold;'>Internet Transit</div>".
  118. "<img src='graph.php?type=multi_bits&amp;ports=".$ports['transit'].
  119. "&amp;from=".$day."&amp;to=".$now."&amp;width=200&amp;height=100'></a>");
  120. }
  121. if ($ports['l2tp'])
  122. {
  123. echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=multi_bits&amp;ports=".$ports['l2tp'].
  124. "&amp;from=".$day."&amp;to=".$now."&amp;width=400&amp;height=150\'>', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >".
  125. "<div style='font-size: 18px; font-weight: bold;'>L2TP ADSL</div>".
  126. "<img src='graph.php?type=multi_bits&amp;ports=".$ports['l2tp'].
  127. "&amp;from=".$day."&amp;to=".$now."&amp;width=200&amp;height=100'></a>");
  128. }
  129. if ($ports['voip'])
  130. {
  131. echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=multi_bits&amp;ports=".$ports['voip'].
  132. "&amp;from=".$day."&amp;to=".$now."&amp;width=400&amp;height=150\'>', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >".
  133. "<div style='font-size: 18px; font-weight: bold;'>VoIP to PSTN</div>".
  134. "<img src='graph.php?type=multi_bits&amp;ports=".$ports['voip'].
  135. "&amp;from=".$day."&amp;to=".$now."&amp;width=200&amp;height=100'></a>");
  136. }
  137. }
  138. /// END VOSTRON
  139. ?>
  140. </td>
  141. </tr>
  142. <tr>
  143. </tr></table>