Guest User

Untitled

a guest
Aug 21st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. <style type="text/css">
  2. table.imagetable {
  3. font-family: verdana,arial,sans-serif;
  4. font-size:11px;
  5. color:#333333;
  6. border-width: 1px;
  7. border-color: #999999;
  8. border-collapse: collapse;
  9. }
  10. table.imagetable th {
  11. background:#b5cfd2 url('cell-blue.jpg');
  12. border-width: 1px;
  13. padding: 8px;
  14. border-style: solid;
  15. border-color: #999999;
  16. }
  17. table.imaetable td {
  18. background:#dcddc0 url('cell-grey.jpg');
  19. border-width: 1px;
  20. padding: 8px;
  21. border-style: solid;
  22. border-color: #999999;
  23. }
  24. </style>
  25.  
  26. <?php
  27. // Use: Set Alias in hosts extended profile to match the elementid of the screen you would like to do a dynamic lookup of data for. You can do this by looking in the URL on monitoring > screens for elmentid=N
  28. // site_street_1 = site code | poc_1_name = site tech | poc_1_phone_1 = site number | poc_1_email = tech email | device_chassis = brand | device_type = model | device_url_1 = pbx ip | device_url_2 = vm ip
  29.  
  30. // CONFIGURATION
  31.  
  32. $user = "user";
  33. $pass = "pass";
  34. $dbserver = "localhost";
  35.  
  36. // get parent URL
  37. function getAddress()
  38. {
  39. return $_SERVER['HTTP_REFERER'];
  40. }
  41. $url = getAddress();
  42.  
  43. // find elementid
  44. $url_array = explode("&",$url);
  45. $pattern = "/elementid/";
  46.  
  47. if (preg_match($pattern, $url_array[1]))
  48. $elementid = substr($url_array[1], -1, 1);
  49. elseif (preg_match($pattern, $url_array[2]))
  50. $elementid = substr($url_array[2], -1, 1);
  51. elseif (preg_match($pattern, $url_array[3]))
  52. $elementid = substr($url_array[3], -1, 1);
  53. else
  54. $elementid = substr($url_array[0], -1, 1);
  55.  
  56. // database lookups / match elementid with device_alias from extended hosts profile
  57. $con = mysql_connect($dbserver,$user,$pass);
  58. if (!$con)
  59. {
  60. die('Could not connect: ' . mysql_error());
  61. }
  62.  
  63. mysql_select_db("zabbix", $con);
  64.  
  65. // Formulate Query and store in variable
  66.  
  67. $query = sprintf("SELECT device_chassis, device_type, device_url_1, device_url_2, poc_1_name, poc_1_email, poc_1_phone_1, site_street_1 FROM hosts_profiles_ext WHERE device_alias = '$elementid' ");
  68.  
  69. // Perform Query
  70. $result = mysql_query($query);
  71.  
  72. // Check For Results
  73. if (!$result) {
  74. $message = 'Invalid query: ' . mysql_error() . "\n";
  75. $message .= 'Whole query: ' . $query;
  76. die($message);
  77. }
  78.  
  79. // Display results table
  80. echo "<center><table class='imagetable'>
  81. <tr>
  82. <th>Site Code</th><th>Site Tech</th><th>Site Number</th><th>Tech e-Mail</th></tr>";
  83. while($row = mysql_fetch_assoc($result))
  84. {
  85. echo "<tr>";
  86. echo "<td><center>" . $row['site_street_1'] . "</center></td>" . "<td><center>" . $row['poc_1_name'] . "</center></td>" . "<td><center>" . $row['poc_1_phone_1'] . "</center></td>" . "<td><center>" . $row['poc_1_email'] . "</center></td>";
  87. echo "</tr>";
  88. echo "<tr><th>Brand</th><th>Model</th><th>VM IP</th><th>PBX IP</th></tr>";
  89. echo "<tr>";
  90. echo "<br /><td><center>" . $row['device_chassis'] . "</center></td>" . "<td><center>" . $row['device_type'] . "</center></td>" . "<td><center>" . $row['device_url_2'] . "</center></td>" . "<td><center>" . $row['device_url_1'] . "</center></td>";
  91. echo "</tr>";
  92. }
  93. echo "</table></center>";
  94.  
  95. mysql_free_result($result);
  96. ?>
Add Comment
Please, Sign In to add comment