The steps involved are:
- Identify the Data Aggregator Data Source ID.
- Create the list of IDs for the Retired Devices.
- Run the script to delete the IDs in the resulting list.
To execute the steps complete the following:
1: Enter the CLI on the PC server and go to the (default path) /opt/CA/MySql/bin directory. Run the following command as the root, or sudo root user, that owns the installation:
./mysql -unetqos -pnetqos netqosportal -e "select sourceid from data_sources2 where sourcetype='262144';"
For example:
./mysql -unetqos -pnetqos netqosportal -e "select sourceid from data_sources2 where sourcetype='262144';"
mysql: [Warning] Using a password on the command line interface can be insecure.
+----------+
| sourceid |
+----------+
| 3 |
+----------+
2: Take the SourceID value from step 1 and run the following command. Change the directory, and filename the ID's are written to, as desired.
./mysql -unetqos -pnetqos netqosportal -e "select localid from dst_device where sourceid = '<ID>' and itemid in (select itemid from t_device where lifecyclestate='RETIRED');" > /tmp/retiredLocalIdsToDelete.out
HINT: To determine the number of ID values in the resulting file run "wc -l <filename>".
For example using the sample output from step 1 it might look like:
./mysql -unetqos -pnetqos netqosportal -e "select localid from dst_device where sourceid = '3' and itemid in (select itemid from t_device where lifecyclestate='RETIRED');" > /tmp/retiredLocalIdsToDelete.out
After create the retiredLocalIdsToDelete.out
Edit the File and remove the first line:
localid
Just need to have the numbers
3: Place the script attached to this article, deleteAllDevicesInFile.pl, on the PC server where the ID list file was created in step 2. Make the script executable (chmod +x <fileName>). Run it as follows:
deleteAllDevicesInFile.pl [-da server] [-p httpsport] [-b batchsize] [-sl sleepSeconds] -f file
For example for DA named myda.company.com, using default non-https configs it might be:
deleteAllDevicesInFile.pl -da myda.company.com -f /tmp/retiredLocalIdsToDelete.out
Using SSL enabled DA it might be (example port):
deleteAllDevicesInFile.pl -da myda.company.com -p 8443 -f /tmp/retiredLocalIdsToDelete.out
If you got the message:
-bash: ./deleteAllDevicesInFile.pl: /usr/bin/perl^M: bad interpreter: No such file or directory
Just use the dos2unix to convert the file
By default the script will delete the items in batches of 500.