Python access sysctl variable or alternative

1.1k views Asked by At

I've network sniffer process which runs indefinitely capturing the live traffic and doing some other analysis as well. I want a variable which can turn on and off this analysis at the run-time which I should be able to change from outside the program (from a separate terminal).

sysctl is kind of the best way to do it, but the sysctl package for python is returning gcc error while installing. I don't want to do a complex coding with ctype as my program is already large and complex. Just like in a terminal I give the sysctl command and see the value of a parameter, I want to do that in python too.

One option I do have is make a subprocess.call() with the sysctl variable as parameter and process the stdout. But I'm concerned with the performance impact of this command being called again and again.

But is there any other better approach to achieve this?

0

There are 0 answers