Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // fix no interface in icmp item. Zabbix 6.4. (c) fg
- $mysqli = new mysqli('127.0.0.1', 'dbuser', 'dbpass', 'zabbix');
- if ($mysqli->connect_errno) {
- echo "Errno: " . $mysqli->connect_errno . "\n";
- echo "Error: " . $mysqli->connect_error . "\n";
- die;
- }
- echo "<pre>";
- $sql="select * from items where key_ like \"icmp%\" ";
- echo "$sql \n";
- $rs = $mysqli->query($sql);
- echo mysqli_error($mysqli);
- foreach($rs as $row) {
- // print_r($row);
- $itemid=$row['itemid'];
- $hostid=$row['hostid'];
- $interfaceid=$row['interfaceid'];
- echo "$hostid - $interfaceid ";
- if ($interfaceid=='') {
- echo "error";
- // busca tabla interface
- $sql="select interfaceid,ip from interface where hostid='$hostid' limit 1";
- echo "\n$sql \n";
- $rs1 = $mysqli->query($sql);
- echo mysqli_error($mysqli);
- $row1=mysqli_fetch_assoc($rs1);
- print_r($row1);
- $interfaceid=$row1['interfaceid'];
- if ($interfaceid>0) {
- $sql="update items set interfaceid='$interfaceid' where itemid='$itemid' limit 1";
- echo "$sql\n";
- $rs2 = $mysqli->query($sql);
- echo mysqli_error($mysqli);
- echo mysqli_affected_rows($mysqli);
- }
- }
- echo "<hr>";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement