Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

feat: notify scheduler when MIB starts #73

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ PyYAML = "^5.4.1"
Flask = "^1.1.2"
Flask-AutoIndex = "^0.6.6"
types-PyYAML = "^5.4.3"
checksumdir = "^1.2.0"

[tool.poetry.dev-dependencies]
mongomock = "^3.22.1"
Expand Down
8 changes: 8 additions & 0 deletions splunk_connect_for_snmp_mib_server/mib_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
# limitations under the License.
# ########################################################################
import logging
import os

import requests
from checksumdir import dirhash
from flask import Flask, request
from flask_autoindex import AutoIndex

Expand Down Expand Up @@ -80,3 +83,8 @@ def get_profiles():
def run_mib_server(self):
# poetry run fails when debug=True
self._flask_app.run(host="0.0.0.0", port=self._args.port)

def notify_startup(self):
profiles_hash = dirhash("profiles")
params = {"profiles_hash": profiles_hash}
requests.get(os.environ["SCHEDULER_REFRESH_URI"], params=params, timeout=3)
5 changes: 4 additions & 1 deletion splunk_connect_for_snmp_mib_server/snmp_mib_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# ########################################################################
import argparse
import logging
import threading
import time

import yaml
Expand Down Expand Up @@ -77,7 +78,9 @@ def main():

upload_mibs(server_config)
mib_server = MibServer(args, server_config)
mib_server.run_mib_server()
threading.Thread(target=mib_server.run_mib_server).start()
time.sleep(5)
mib_server.notify_startup()


if __name__ == "__main__":
Expand Down