Ad Widget

Collapse

Allowing external profil view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • leo.leroy
    Junior Member
    • Apr 2008
    • 6

    #1

    Allowing external profil view

    Hello everyone,

    Happy new year !

    The simple php code below allow you to deliver profil information based on IP to an external, non-zabbix, user using the following URL :



    See the screenshot attached for example :-)


    profil.php page - to be placed on /usr/local/annuaire/ :
    <?php

    include 'include/db.php';

    ?>

    <HTML>
    <HEAD>
    <TITLE>Annuaire Zabbix</TITLE>
    <meta http-equiv="Content-Type" content="text/html; charset=latin1">
    </HEAD>
    <img src="http://zabbixserver/zabbix/images/general/zabbix.png">
    <BODY align="center" valign="center" bgcolor="#f6f6f6">
    <br><br><br>
    <table align="center" valign="center">
    <tr><td bgcolor="#e33432" align="center">
    <?php
    echo "<font size=\"5\" style=\"verdana\" color=\"white\">&nbsp;&nbsp;&nbsp;profil of</font>" ;

    $query_sql="select hostid,host from hosts where ip='".$_GET['host']."'";
    $result = mysql_query($query_sql,$connect);
    $reponse = mysql_fetch_array($result);

    echo "<font size=\"6\" color=\"white\"> <b>$reponse[1]&nbsp;&nbsp;&nbsp;</b></font>";
    $hostid=$reponse[0];

    ?>

    </td></tr><tr><td><br><br></td></tr><tr><td><table width="100%" cellspacing="0" cellspacing="0">
    <?php

    $query_sql="select * from hosts_profiles where hostid='".$hostid."'";

    $result = mysql_query($query_sql);
    $reponse = mysql_fetch_array($result);

    echo "<tr><td bgcolor=\"#eeeeee\"><b>Host type</b></td><td bgcolor=\"#eeeeee\" align=\"right\">".str_replace("\n","<br>",$reponse[1])."</td></tr>";
    echo "<tr><td bgcolor=\"#dddddd\"><b>Host name</b></td><td bgcolor=\"#dddddd\" align=\"right\">".str_replace("\n","<br>",$reponse[2])."</td></tr>";
    echo "<tr><td bgcolor=\"#eeeeee\"><b>Operating system</b></td><td bgcolor=\"#eeeeee\" align=\"right\">".str_replace("\n","<br>",$reponse[3])."</td></tr>";
    echo "<tr><td bgcolor=\"#dddddd\"><b>Serial number</b></td><td bgcolor=\"#dddddd\" align=\"right\">".str_replace("\n","<br>",$reponse[4])."</td></tr>";
    echo "<tr><td bgcolor=\"#eeeeee\"><b>Hardware</b></td><td bgcolor=\"#eeeeee\" align=\"right\" >".str_replace("\n","<br>",$reponse[7])."</td></tr>";
    echo "<tr><td bgcolor=\"#dddddd\"><b>Software</b></td><td bgcolor=\"#dddddd\" align=\"right\">".str_replace("\n","<br>",$reponse[8])."</td></tr>";
    echo "<tr><td bgcolor=\"#eeeeee\"><b>Contacts</b></td><td bgcolor=\"#eeeeee\" align=\"right\">".str_replace("\n","<br>",$reponse[9])."</td></tr>";
    echo "<tr><td bgcolor=\"#dddddd\"><b>Where</b></td><td bgcolor=\"#dddddd\" align=\"right\">".str_replace("\n","<br>",$reponse[10])."</td></tr>";
    echo "<tr><td bgcolor=\"#eeeeee\"><b>You need to know</b></td><td bgcolor=\"#eeeeee\" align=\"right\">".str_replace("\n","<br>",$reponse[11])."</td></tr>";

    ?>

    </td></tr></table>
    </BODY>
    </HTML>


    The db.php - to be placed on /usr/local/annuaire/include/ :
    <?php

    $connect=mysql_connect("127.0.0.1","zabbixlogin"," zabbixpwd");
    mysql_select_db("zabbix", $connect);
    ?>
    The /etc/httpd/conf.d/profil.conf :
    Alias /annuaire /usr/local/annuaire

    <Directory "/usr/local/annuaire">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>

    <Directory "/usr/local/annuaire/include">
    Order deny,allow
    Deny from all
    <files *.php>
    Order deny,allow
    Deny from all
    </files>
    </Directory>
    Attached Files
Working...