using saltstack how to write a custom beacon that will generate event if the state of service/agent in linux changes. that is from running to stopped
#!/bin/python
import psutil
def status(service):
for proc in psutil.process_iter():
if proc.name() == service:
result=True
return result
This piece of code will check if service/agent is running.if running it will return true else none.I want to make this code part of custom beacon and if result is none custom beacon should trigger event to event bus system.this is for linux environment.
You don't need to write your custom module, SaltStack already has a built-in service beacon. All you need to do is define the beacon.