when you’re using MMonit software with multiple VMs cloned from a template with monit installed, there are sometimes 2 VM get the same monit IDs. You’ll notice that there are errors on your MMonit dashboard which disappears after a while.
To view the monit id of your VMs, type the following command on your terminal
# monit -i
What do you do if you have hundreds or thousands of VMs? How will you know which ones have duplicate IDs?
I implemented a solution using SQL Triggers.
CREATE TABLE `duplicate_monitids` (
`ipaddrin` varchar(255) NOT NULL DEFAULT ”,
`monitid` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ipaddrin`)
CREATE TRIGGER duplicate_monitids AFTER UPDATE
FOR EACH ROW
INSERT INTO duplicate_monitids(ipaddrin,monitid) VALUES(NEW.ipaddrin,NEW.monitid);
Then to view the VMs which have duplicate IDs, run the following SQL Query
select ipaddrin from duplicate_monitids where monitid IN (select monitid from duplicate_monitids group by monitid having count(*) > 1);