Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style type="text/css">
- table.imagetable {
- font-family: verdana,arial,sans-serif;
- font-size:11px;
- color:#333333;
- border-width: 1px;
- border-color: #999999;
- border-collapse: collapse;
- }
- table.imagetable th {
- background:#b5cfd2 url('cell-blue.jpg');
- border-width: 1px;
- padding: 8px;
- border-style: solid;
- border-color: #999999;
- }
- table.imaetable td {
- background:#dcddc0 url('cell-grey.jpg');
- border-width: 1px;
- padding: 8px;
- border-style: solid;
- border-color: #999999;
- }
- </style>
- <?php
- // 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
- // 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
- // CONFIGURATION
- $user = "user";
- $pass = "pass";
- $dbserver = "localhost";
- // get parent URL
- function getAddress()
- {
- return $_SERVER['HTTP_REFERER'];
- }
- $url = getAddress();
- // find elementid
- $url_array = explode("&",$url);
- $pattern = "/elementid/";
- if (preg_match($pattern, $url_array[1]))
- $elementid = substr($url_array[1], -1, 1);
- elseif (preg_match($pattern, $url_array[2]))
- $elementid = substr($url_array[2], -1, 1);
- elseif (preg_match($pattern, $url_array[3]))
- $elementid = substr($url_array[3], -1, 1);
- else
- $elementid = substr($url_array[0], -1, 1);
- // database lookups / match elementid with device_alias from extended hosts profile
- $con = mysql_connect($dbserver,$user,$pass);
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db("zabbix", $con);
- // Formulate Query and store in variable
- $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' ");
- // Perform Query
- $result = mysql_query($query);
- // Check For Results
- if (!$result) {
- $message = 'Invalid query: ' . mysql_error() . "\n";
- $message .= 'Whole query: ' . $query;
- die($message);
- }
- // Display results table
- echo "<center><table class='imagetable'>
- <tr>
- <th>Site Code</th><th>Site Tech</th><th>Site Number</th><th>Tech e-Mail</th></tr>";
- while($row = mysql_fetch_assoc($result))
- {
- echo "<tr>";
- 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>";
- echo "</tr>";
- echo "<tr><th>Brand</th><th>Model</th><th>VM IP</th><th>PBX IP</th></tr>";
- echo "<tr>";
- 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>";
- echo "</tr>";
- }
- echo "</table></center>";
- mysql_free_result($result);
- ?>
Add Comment
Please, Sign In to add comment