Back to Geneos FAQ

How to automatically restart a process if it goes down

Yes, Geneos can be configured to restart a process which has gone down, review the instructions below on how to achieve this.

Firstly you should setup a Processes sampler on the same machine which has the process you want to try and restart. Once run up you will see a view like below:

Geneos - How to automatically restart a process if it goes down

We are interested in the instance count column. We need to define a rule which detects the process dropping and running a script:

<rule name="Restart Process">
 <targets>
 <target>/geneos/gateway[(@name=&quot;systemAlerts&quot;)]/directory/probe[(@name=&quot;iwhddb2&quot;)]/managedEntity[(@name=&quot;Helpdesk DB&quot;)]/sampler[(@name=&quot;processes&quot;)][(@type=&quot;process&quot;)]/dataview[(@name=&quot;processes&quot;)]/rows/row[(@name=&quot;mysqld&quot;)]/cell[(@column=&quot;instanceCount&quot;)]</target>
 </targets>
 <priority>1</priority>
 <pathAliases>
 <pathAlias name="num">../../rows/row/cell[(@column=&quot;City&quot;)]</pathAlias>
 </pathAliases>
 <evaluateOnDataviewSample>false</evaluateOnDataviewSample>
 <block>
 <if>
 <and>
 <equal>
 <dataItem>
 <property>@value</property>
 </dataItem>
 <integer>0</integer>
 </equal>
 <lt>
 <dataItem>
 <property>state/@severity</property>
 </dataItem>
 <integer>2</integer>
 </lt>
 </and>
 <transaction>
 <delay unit="samples">2</delay>
 <update>
 <property>state/@severity</property>
 <severity>warning</severity>
 </update>
 <action ref="Run Start Script"></action>
 </transaction>
 <if>
 <and>
 <equal>
 <dataItem>
 <property>state/@severity</property>
 </dataItem>
 <severity>warning</severity>
 </equal>
 <equal>
 <dataItem>
 <property>@value</property>
 </dataItem>
 <integer>0</integer>
 </equal>
 </and>
 <transaction>
 <delay unit="samples">2</delay>
 <update>
 <property>state/@severity</property>
 <severity>critical</severity>
 </update>
 </transaction>
 <transaction>
 <update>
 <property>state/@severity</property>
 <severity>ok</severity>
 </update>
 </transaction>
 </if>
 </if>
 </block>
</rule>

We have added the delay 2 samples to ensure the process is truly down, and a further escalation to critical in case the restart does not work.

The Action definition:

<action name="Run Start Script">
 <script>
 <exeFile>./startMyProcess.sh</exeFile>
 <arguments>
 <data></data>
 </arguments>
 <runLocation>netprobe</runLocation>
 <probe ref="Netprobe"></probe>
 </script>
</action>

There will need to be a script relative to the Netprobe which you invoke. The name and path of which should replace the ./startMyprocess.sh in the action definition above.

["Geneos"] ["FAQ"]

Was this topic helpful?