Merge branch 'issue28' into development
This commit is contained in:
commit
5a644b6910
2 changed files with 51 additions and 21 deletions
68
main.py
68
main.py
|
@ -22,30 +22,20 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
import config
|
def get_pip_command():
|
||||||
import psutil
|
|
||||||
import os
|
if sys.version_info >= (3, 0):
|
||||||
import time
|
|
||||||
import log
|
|
||||||
import requests
|
|
||||||
import threading
|
|
||||||
import signal
|
|
||||||
import socket
|
|
||||||
import sys
|
|
||||||
from functools import partial
|
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
from log import logsManager
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
if config.loggingMode == 'rabbitmq':
|
return 'pip3'
|
||||||
|
|
||||||
import rabbitmq
|
else:
|
||||||
rabbitmq = rabbitmq.rabbitMQClient(config.rabbitmqca,config.rabbitmqcacert,config.rabbitmqcakey,config.rabbitmqHost,config.rabbitmqPort,config.rabbitmqRoutingKey)
|
|
||||||
|
|
||||||
stop_event = threading.Event()
|
return 'pip'
|
||||||
nonPOSIXCPULoads = []
|
|
||||||
lock = threading.Lock()
|
def install_dependencies():
|
||||||
|
|
||||||
|
pip_command = get_pip_command()
|
||||||
|
subprocess.check_call([pip_command, 'install', '-r', 'requirements.txt', '--user'])
|
||||||
|
|
||||||
def signal_handler(sig, frame):
|
def signal_handler(sig, frame):
|
||||||
print('SIGINT/SIGTERM aknowledged. Stopping script gracefully, please wait...')
|
print('SIGINT/SIGTERM aknowledged. Stopping script gracefully, please wait...')
|
||||||
|
@ -207,11 +197,17 @@ def main():
|
||||||
win32api.SetConsoleCtrlHandler(lambda sig, frame:
|
win32api.SetConsoleCtrlHandler(lambda sig, frame:
|
||||||
|
|
||||||
signal_handler(signal.CTRL_C_EVENT, frame), True)
|
signal_handler(signal.CTRL_C_EVENT, frame), True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
signal.signal(signal.SIGTERM, signal_handler)
|
signal.signal(signal.SIGTERM, signal_handler)
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
|
install_dependencies()
|
||||||
|
|
||||||
|
signal.signal(signal.SIGTERM, signal_handler)
|
||||||
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
hostMonitorThread = threading.Thread(target=monitorHost, args=(stop_event,))
|
hostMonitorThread = threading.Thread(target=monitorHost, args=(stop_event,))
|
||||||
urlMonitorThread = threading.Thread(target=monitorUrls, args=(stop_event,))
|
urlMonitorThread = threading.Thread(target=monitorUrls, args=(stop_event,))
|
||||||
|
|
||||||
|
@ -222,4 +218,34 @@ def main():
|
||||||
urlMonitorThread.join()
|
urlMonitorThread.join()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
install_dependencies()
|
||||||
|
|
||||||
|
import config
|
||||||
|
import psutil
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import log
|
||||||
|
import requests
|
||||||
|
import threading
|
||||||
|
import signal
|
||||||
|
import socket
|
||||||
|
from functools import partial
|
||||||
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from log import logsManager
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
if config.loggingMode == 'rabbitmq':
|
||||||
|
|
||||||
|
import rabbitmq
|
||||||
|
rabbitmq = rabbitmq.rabbitMQClient(config.rabbitmqca,config.rabbitmqcacert,config.rabbitmqcakey,config.rabbitmqHost,config.rabbitmqPort,config.rabbitmqRoutingKey)
|
||||||
|
|
||||||
|
stop_event = threading.Event()
|
||||||
|
nonPOSIXCPULoads = []
|
||||||
|
lock = threading.Lock()
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
psutil
|
||||||
|
requests
|
||||||
|
bs4
|
||||||
|
datetime
|
Loading…
Reference in a new issue