{"id":115,"date":"2008-12-15T08:58:00","date_gmt":"2008-12-15T15:58:00","guid":{"rendered":"http:\/\/www.jasemccarty.com\/blog\/2008\/12\/virtual-machine-heartbeat-state-band-aid.html"},"modified":"2008-12-15T08:58:00","modified_gmt":"2008-12-15T15:58:00","slug":"virtual-machine-heartbeat-state-band-aid","status":"publish","type":"post","link":"https:\/\/www.jasemccarty.com\/blog\/virtual-machine-heartbeat-state-band-aid\/","title":{"rendered":"Virtual Machine Heartbeat State &#8211; Band Aid"},"content":{"rendered":"<p>From time to time, I get one of these:<br \/>\n<span style=\"font-size:100%;\"><\/p>\n<blockquote><p><span style=\"font-family:courier new;\">Target: VirtualMachine1 <\/span><br \/>\n<span style=\"font-family:courier new;\">Old Status: Green <\/span><br \/>\n<span style=\"font-family:courier new;\">New Status: Red<\/span><\/p><\/blockquote>\n<p><\/span><\/p>\n<p><span style=\"font-family:courier new;\">Current value:<br \/>\n<\/span> <span style=\"font-family:courier new;\">Virtual Machine Heartbeat State &#8211; (State = Red)<\/span><\/p>\n<p><span style=\"font-family:courier new;\">Alarm: Virtual Machine Heartbeat State<br \/>\n<\/span><span style=\"font-family:courier new;\">([Yellow State Is Equal To yellow; Red State Is Equal To red]) <\/span> <span style=\"font-family:courier new;\"> <\/span><\/p>\n<p>Description:  <span style=\"font-family:courier new;\"><br \/>\nAlarm Virtual Machine Heartbeat State on VirtualMachine1 changed from Green to Red<\/span><br \/>\nJust one of those alarms from vCenter that tells me that a VM&#8217;s Heartbeat isn&#8217;t being heard.<\/p>\n<p>It is kind of a pain to look into these after hours, and when you aren&#8217;t paying attention to the alerts&#8230; So I figured I&#8217;d put a band-aid on the problem, until I get a chance to look deeper into the problem.<\/p>\n<p>So I wrote a .VBS that will stop and restart the VMTOOLS service through a WMI call, and saved it to C:SCRIPTS on the vCenter Server.<\/p>\n<p>Here&#8217;s the .VBS (restarttools.vbs):<\/p>\n<blockquote style=\"font-family:courier new;\"><p><span style=\"font-size:85%;\">&#8216;Get the Guest Name from {targetName}<br \/>\nTargetServer = Wscript.Arguments(0)<\/p>\n<p>&#8216;The Domain User used to connect to the target guest via WMI<br \/>\nUsername = &#8220;DOMAINUsername&#8221;<\/p>\n<p>&#8216;Get the Password from the 2nd Script Argument<br \/>\nPassword = Wscript.Arguments(1)<\/p>\n<p>Set objSWbemLocator = CreateObject(&#8220;WBemScripting.SWbemLocator&#8221;)<\/p>\n<p>&#8216;Connect using the Username and Password<br \/>\nSet objWMIService = objSWbemLocator.ConnectServer &amp; _<br \/>\n(TargetServer, &#8220;rootcimv2&#8221;, Username, Password)<\/p>\n<p>&#8216;Grab all of the services named vmtools<br \/>\nSet colServices = objWMIService.ExecQuery (&#8220;Select * &#8221; &amp; _<br \/>\nfrom Win32_Service Where Name = &#8216;vmtools'&#8221;)<\/p>\n<p>&#8216;Stop the vmtools service<br \/>\nFor Each objService in colServices<br \/>\nerrReturnCode = objService.StopService()<br \/>\nNext<\/p>\n<p>Wscript.Sleep 20000<\/p>\n<p>&#8216;Start the vmtools service<br \/>\nFor Each objService in colServices<br \/>\nerrReturnCode = objService.StartService()<br \/>\nNext<\/p>\n<p><\/span><\/p><\/blockquote>\n<p>I then created an alarm that runs the .VBS when the Heartbeat State changes:<\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/uploaded_images\/alarm1-793560.jpg\" onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\"><img decoding=\"async\" style=\"margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 156px;\" src=\"http:\/\/www.jasemccarty.com\/blog\/uploaded_images\/alarm1-793556.jpg\" border=\"0\" alt=\"\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/uploaded_images\/alarm2-791717.jpg\" onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\"><img decoding=\"async\" style=\"margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 156px;\" src=\"http:\/\/www.jasemccarty.com\/blog\/uploaded_images\/alarm2-791712.jpg\" border=\"0\" alt=\"\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.jasemccarty.com\/blog\/uploaded_images\/alarm3-773562.jpg\" onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\"><img decoding=\"async\" style=\"margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 157px;\" src=\"http:\/\/www.jasemccarty.com\/blog\/uploaded_images\/alarm3-773541.jpg\" border=\"0\" alt=\"\" \/><\/a><\/p>\n<p>Make sure the &#8220;Run A Script&#8221; option has the following syntax:<\/p>\n<p>cscript \/nologo c:scriptsrestarttools.vbs {targetName} Password<\/p>\n<p>I also have an e-mail alert to notify me when this happens.  Typically, when this occurs, I&#8217;ll get a a Green to Red or Yellow, followed by a Red or Yellow to Green about a minute later.<\/p>\n<p>It doesn&#8217;t happen often, but when it does, the little script does the trick.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>From time to time, I get one of these: Target: VirtualMachine1 Old Status: Green New Status: Red Current value: Virtual Machine Heartbeat State &#8211; (State &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-virtualization"],"_links":{"self":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/comments?post=115"}],"version-history":[{"count":0,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/115\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/media?parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/categories?post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/tags?post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}