phpipam-agent icon indicating copy to clipboard operation
phpipam-agent copied to clipboard

Discovery fails with "Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'hostname' in 'field list"

Open ack-martijng opened this issue 8 years ago • 1 comments

When calling the command

php index.php discover

It fails with the error: Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'hostname' in 'field list'

After some troubleshooting i found that the following line is causing a problem: functions/classes/class.phpipamAgent.php:1035: "hostname"=>$hostname['name'], I.e.: https://github.com/phpipam/phpipam-agent/blob/master/functions/classes/class.phpipamAgent.php#L1035

After commenting out this line newly discovered hosts are added to the phpIpam installation, however host resolving does not work and ofcourse the entry is added without the hostname.

MariaDB [phpipam]> describe ipaddresses;
+-----------------------+------------------+------+-----+---------------------+-----------------------------+
| Field                 | Type             | Null | Key | Default             | Extra                       |
+-----------------------+------------------+------+-----+---------------------+-----------------------------+
| id                    | int(11)          | NO   | PRI | NULL                | auto_increment              |
| subnetId              | int(11) unsigned | YES  | MUL | NULL                |                             |
| ip_addr               | varchar(100)     | NO   | MUL | NULL                |                             |
| is_gateway            | tinyint(1)       | YES  |     | 0                   |                             |
| description           | varchar(64)      | YES  |     | NULL                |                             |
| dns_name              | varchar(100)     | YES  |     | NULL                |                             |
| mac                   | varchar(20)      | YES  |     | NULL                |                             |
| owner                 | varchar(32)      | YES  |     | NULL                |                             |
| state                 | int(3)           | YES  |     | 2                   |                             |
| switch                | int(11) unsigned | YES  |     | NULL                |                             |
| location              | int(11) unsigned | YES  | MUL | NULL                |                             |
| port                  | varchar(32)      | YES  |     | NULL                |                             |
| note                  | text             | YES  |     | NULL                |                             |
| lastSeen              | datetime         | YES  |     | 1970-01-01 00:00:01 |                             |
| excludePing           | binary(1)        | YES  |     | 0                   |                             |
| PTRignore             | binary(1)        | YES  |     | 0                   |                             |
| PTR                   | int(11) unsigned | YES  |     | 0                   |                             |
| firewallAddressObject | varchar(100)     | YES  |     | NULL                |                             |
| editDate              | timestamp        | YES  |     | NULL                | on update CURRENT_TIMESTAMP |
+-----------------------+------------------+------+-----+---------------------+-----------------------------+
19 rows in set (0.00 sec)

MariaDB [phpipam]> 

The table ipaddresses does not have a column hostname, however it does hold the column/field dns_name.

I have not yet tried updating the field name in the update query.

ack-martijng avatar Jul 04 '18 08:07 ack-martijng

I had the same issue & I had to modify the class.phpipamAgent.php file to use the appropriate column name. Essentially revert this change in your file:

https://github.com/phpipam/phpipam-agent/commit/9264d1b5d29729d82be44f17fc8daf26800d1af9

nathan-bonner avatar Jul 08 '18 17:07 nathan-bonner