Bulk change syslocation

I would like to bulk change the syslocation of devices based on theire group.

I use to do it directly in mysql database.
First you have to create a location with coordinates and later asign this location to devices.

This is an example of changing location of devices based of hostname, in mycase the location name is the first part of device name.

CREATE TABLE if not exists corcaroli.import_antenas(antena varchar(128) DEFAULT NULL,location varchar(128) DEFAULT NULL,lat double(10,6) DEFAULT NULL,lng double (10,6) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

TRUNCATE TABLE corcaroli.import_antenas;

LOAD DATA INFILE ‘/var/lib/mysql-files/antenas.txt’ INTO TABLE corcaroli.import_antenas;

INSERT INTO librenms.locations SELECT NULL, substring(antena,5), MIN(lat), MIN(lng),now() from corcaroli.import_antenas WHERE (select id from librenms.locations where location = substring(antena,5)) is null GROUP BY substring(antena,5);

UPDATE devices SET type =‘wireless’, poller_group = 1, location_id = (SELECT id from locations WHERE location =substring(LEFT(hostname,LOCATE(’.’,hostname)-1),5)) where hostname REGEXP ‘a[ruc].-.*’;

Thats the way how I already to it. But it would be very nice to have a function in the webui.

I guess it is such an obvious thing to do in a SQL than function in web interface is a waste of time of developers :slight_smile: