question

lala-4085 avatar image
0 Votes"
lala-4085 asked CyrAz edited

alert if both services down (unix)

Hello

I have task to monitor 2 time services on unix machines - ntpd, chronyd but alert if both down

So i dont what to use script monitor - its too easy

So its 2 standard classes


 <ClassType ID="ntpd.class" Accessibility="Public" Abstract="false" Base="MUSL!Microsoft.SystemCenter.OwnProcessUnixService" Hosted="true" Singleton="false" Extension="false" />
 
 <ClassType ID="chronyd.class" Accessibility="Public" Abstract="false" Base="MUSL!Microsoft.SystemCenter.OwnProcessUnixService" Hosted="true" Singleton="false" Extension="false" />


And very standard monitors. Example

<UnitMonitor ID="chronyd.unit.monitor" Accessibility="Internal" Enabled="true" Target="chronyd.class" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="MUL!Microsoft.Unix.WSMan.Process.Status.MonitorType" ConfirmDelivery="false">

 <Category>AvailabilityHealth</Category>

 <OperationalStates>

   <OperationalState ID="Running" MonitorTypeStateID="Running" HealthState="Success" />

   <OperationalState ID="NotRunning" MonitorTypeStateID="NotRunning" HealthState="Error" />

 </OperationalStates>

 <Configuration>

   <TargetSystem>$Target/Host/Property[Type="MUL!Microsoft.Unix.Computer"]/NetworkName$</TargetSystem>

   <ProcessName>$Target/Property[Type="MUSL!Microsoft.SystemCenter.UnixService"]/ServiceName$</ProcessName>

   <Interval>300</Interval>

 </Configuration>

</UnitMonitor>


Story is that i want alert when if both services down on unix computer
What is best way to do it ?

msc-operations-manager
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CyrAz avatar image
0 Votes"
CyrAz answered CyrAz edited

Let's get creative!
I would not create additional classes but instead create a single monitor based on a custom monitor type, based on the native Microsoft.Unix.WSMan.Process.Status.MonitorType but with modified ConditionDetection expressions :


   <ConditionDetection ID="ProcessRunning" TypeID="System!System.ExpressionFilter">
       <Expression>
             <Or>
                 <Expression>
                   <Exists>
                     <ValueExpression>
                       <XPathQuery Type="String">//*[local-name()="Name" and text()="ntpd"]</XPathQuery>
                     </ValueExpression>
                   </Exists>
                 </Expression>
                 <Expression>
                   <Exists>
                     <ValueExpression>
                       <XPathQuery Type="String">//*[local-name()="Name" and text()="chronyd"]</XPathQuery>
                     </ValueExpression>
                   </Exists>
                 </Expression>
             </Or>
         </Expression>
   </ConditionDetection>
   <ConditionDetection ID="ProcessNotRunning" TypeID="System!System.ExpressionFilter">
   <Expression>
       <And>
         <Expression>
           <Not>
             <Expression>
               <Exists>
                 <ValueExpression>
                   <XPathQuery Type="String">//*[local-name()="Name" and text()="ntpd"]</XPathQuery>
                 </ValueExpression>
               </Exists>
             </Expression>
           </Not>
         </Expression>
         <Expression>
           <Not>
             <Expression>
               <Exists>
                 <ValueExpression>
                   <XPathQuery Type="String">//*[local-name()="Name" and text()="chronyd"]</XPathQuery>
                 </ValueExpression>
               </Exists>
             </Expression>
           </Not>
         </Expression>
         </And>
     </Expression>
   </ConditionDetection>  



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AliBurakGenc avatar image
0 Votes"
AliBurakGenc answered AliBurakGenc edited

I use a UNIX/Linux Shell command two-state monitor to achieve this and run ;

ps -ef | grep -e ntpd -e chronyd | grep -v grep

where alarm condition is ;

//*[local-name()=”ReturnCode”] = 1

and health condition is;

//[local-name()=”ReturnCode”] = 0 AND ( //[local-name()=”StdOut”] CONTAINS chronyd OR //*[local-name()=”StdOut”] CONTAINS ntpd )

Regards
Ali

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.