I need to develop the performance review based python script , here is the scenario.
- I need to send the logs to ElK (Elasticsearch, logstash , Kibana) from yocto linux but only when system resources are free enough
- So what I need here a python script which continuously monitor the system performance and when system resources like CPU is less then 50% start sending the logs and if CPU again goes above 50% PAUSE the logging
- Now I am don’t have idea we can pause any process with python
or not? This is because I want this for logs so when its start
again send the logs from where it stops last time
Advertisement
Answer
Yes, all your requirements are possible in Python. In fact it’s possible in basically any language because you’re not asking for cutting edge stuff, this is basic scripting.
Sending logs to ES/Kibana
It’s possible, Kibana, ES and Splunk all have public API’s with good documentation on how to do it, so yes it’s possible.
Pausing a process in Linux
Yes, also possible. If it’s a external process simply find the PID
of your process and send kill -STOP <PID>
which would stop the process, to resume the process, do run kill -CONT <PID>
. If it’s your own process that you want to pause, simply enter a sleep cycle in your code (simple example while PAUSED: time.sleep(0.5)
.