{"id":3853,"date":"2018-02-28T15:04:29","date_gmt":"2018-02-28T11:04:29","guid":{"rendered":"https:\/\/nayarweb.com\/blog\/?p=3853"},"modified":"2018-02-28T15:29:55","modified_gmt":"2018-02-28T11:29:55","slug":"duplicate-monit-ids-in-mmonit","status":"publish","type":"post","link":"https:\/\/nayarweb.com\/blog\/2018\/duplicate-monit-ids-in-mmonit\/","title":{"rendered":"Duplicate Monit IDs in MMonit"},"content":{"rendered":"<p>when you&#8217;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&#8217;ll notice that there are errors on your MMonit dashboard which disappears after a while. <\/p>\n<p>To view the monit id of your VMs, type the following command on your terminal<\/p>\n<blockquote><p># monit -i<\/p><\/blockquote>\n<p>What do you do if you have hundreds or thousands of VMs? How will you know which ones have duplicate IDs?<\/p>\n<p>I implemented a solution using SQL Triggers. <\/p>\n<blockquote><p>CREATE TABLE `duplicate_monitids` (<br \/>\n  `ipaddrin` varchar(255) NOT NULL DEFAULT &#8221;,<br \/>\n  `monitid` varchar(255) DEFAULT NULL,<br \/>\n  PRIMARY KEY (`ipaddrin`)<br \/>\n) <\/p><\/blockquote>\n<blockquote><p>\ndelimiter \/\/<br \/>\nCREATE TRIGGER duplicate_monitids AFTER UPDATE<br \/>\n ON host<br \/>\n FOR EACH ROW<br \/>\n BEGIN<br \/>\n    INSERT INTO duplicate_monitids(ipaddrin,monitid) VALUES(NEW.ipaddrin,NEW.monitid);<br \/>\n END\/\/<br \/>\ndelimiter ;<\/p><\/blockquote>\n<p>Then to view the VMs which have duplicate IDs, run the following SQL Query<\/p>\n<blockquote><p>select ipaddrin from duplicate_monitids where monitid IN (select monitid from duplicate_monitids group by monitid having count(*) > 1);<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>when you&#8217;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&#8217;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 &hellip; <a href=\"https:\/\/nayarweb.com\/blog\/2018\/duplicate-monit-ids-in-mmonit\/\" class=\"continue-reading\">Continue reading <span class=\"screen-reader-text\">Duplicate Monit IDs in MMonit<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[210,1],"tags":[98],"class_list":["post-3853","post","type-post","status-publish","format-standard","hentry","category-technology","category-uncategorized","tag-sql"],"_links":{"self":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/comments?post=3853"}],"version-history":[{"count":3,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3853\/revisions"}],"predecessor-version":[{"id":3856,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3853\/revisions\/3856"}],"wp:attachment":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/media?parent=3853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/categories?post=3853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/tags?post=3853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}