How To Create Gui For Plugins in OCS-NG Inventory
This is the second part of the post “How to create i Plugin for OCSNG”
In the server, the ocs instalation find the file machine.php
1. vi machine.php
2. Around line 187 add ‘netstat’
$lblHdw = Array($l->g(54), $l->g(26), $l->g(63), $l->g(92), $l->g(61), $l->g(96), $l->g(82), $l->g(93), $l->g(271), $l->g(272),'Netstat');
3. Line 267 – add
print_netstat($systemid);
4. Line 267 – add
case 'Netstat' : print_netstat($systemid); break;
4. Line 333 – add
function print_Netstat($systemid){
global $l, $td1, $td2, $td3, $td4;
$queryDetails = "SELECT * FROM netstat WHERE (hardware_id = $systemid)";
$resultDetails = mysql_query($queryDetails, $_SESSION["readServer"]) or
die(mysql_error($_SESSION["readServer"]));
if( mysql_num_rows($resultDetails) == 0 ) return;
print_item_header($l->g(211));
echo "<table BORDER='0' WIDTH = '95%' ALIGN = 'Center' CELLPADDING='0' BGCOLOR='#C7D9F5' BORDERCOLOR='#9894B5'>";
echo "<tr> $td1 PROTO </td> $td1 LOCALADDRESS </td> $td1 STATE</td> $td1 USER</td> $td1 INODE</td> $td1 PID</td> </tr>";
while($item = mysql_fetch_object($resultDetails))
{
$ii++; $td3 = $ii%2==0?$td2:$td4;
echo "<tr>
$td3".textDecode($item->PROTO)." </td>
$td3".textDecode($item->LOCALADDRESS)." </td>
$td3".textDecode($item->STATE)." </td>
$td3".textDecode($item->USER)."</td>
$td3".textDecode($item->INODE)."</td>
$td3".textDecode($item->PID)."</td>
</tr>";
}
echo "</table><br>";
}
5. Line 1263 – add
case 'Netstat' : $tble = "netstat"; break;