++ notes
This commit is contained in:
parent
c533f9e02b
commit
84b0b58ed4
4 changed files with 224 additions and 3 deletions
140
Pipfile.lock
generated
Normal file
140
Pipfile.lock
generated
Normal file
|
@ -0,0 +1,140 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "7feeea3eb83feed49cc045bdd236bc50b3a190689a269134b97696eacf0b5b1b"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.7"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.python.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"aniso8601": {
|
||||
"hashes": [
|
||||
"sha256:b8a6a9b24611fc50cf2d9b45d371bfdc4fd0581d1cc52254f5502130a776d4af",
|
||||
"sha256:bb167645c79f7a438f9dfab6161af9bed75508c645b1f07d1158240841d22673"
|
||||
],
|
||||
"version": "==6.0.0"
|
||||
},
|
||||
"click": {
|
||||
"hashes": [
|
||||
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
|
||||
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
|
||||
],
|
||||
"version": "==7.0"
|
||||
},
|
||||
"flask": {
|
||||
"hashes": [
|
||||
"sha256:2271c0070dbcb5275fad4a82e29f23ab92682dc45f9dfbc22c02ba9b9322ce48",
|
||||
"sha256:a080b744b7e345ccfcbc77954861cb05b3c63786e93f2b3875e0913d44b43f05"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.0.2"
|
||||
},
|
||||
"flask-jsonpify": {
|
||||
"hashes": [
|
||||
"sha256:8ac4c732aa5b11d9f6c2de58065d3b669f139518ca8f529bce943817e2fedbfb"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.5.0"
|
||||
},
|
||||
"flask-restful": {
|
||||
"hashes": [
|
||||
"sha256:ecd620c5cc29f663627f99e04f17d1f16d095c83dc1d618426e2ad68b03092f8",
|
||||
"sha256:f8240ec12349afe8df1db168ea7c336c4e5b0271a36982bff7394f93275f2ca9"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.3.7"
|
||||
},
|
||||
"flask-sqlalchemy": {
|
||||
"hashes": [
|
||||
"sha256:3bc0fac969dd8c0ace01b32060f0c729565293302f0c4269beed154b46bec50b",
|
||||
"sha256:5971b9852b5888655f11db634e87725a9031e170f37c0ce7851cf83497f56e53"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.3.2"
|
||||
},
|
||||
"itsdangerous": {
|
||||
"hashes": [
|
||||
"sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19",
|
||||
"sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749"
|
||||
],
|
||||
"version": "==1.1.0"
|
||||
},
|
||||
"jinja2": {
|
||||
"hashes": [
|
||||
"sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013",
|
||||
"sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b"
|
||||
],
|
||||
"version": "==2.10.1"
|
||||
},
|
||||
"markupsafe": {
|
||||
"hashes": [
|
||||
"sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
|
||||
"sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161",
|
||||
"sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235",
|
||||
"sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5",
|
||||
"sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff",
|
||||
"sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b",
|
||||
"sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1",
|
||||
"sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e",
|
||||
"sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183",
|
||||
"sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66",
|
||||
"sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1",
|
||||
"sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1",
|
||||
"sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e",
|
||||
"sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b",
|
||||
"sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905",
|
||||
"sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735",
|
||||
"sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d",
|
||||
"sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e",
|
||||
"sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d",
|
||||
"sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c",
|
||||
"sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21",
|
||||
"sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2",
|
||||
"sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5",
|
||||
"sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b",
|
||||
"sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6",
|
||||
"sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f",
|
||||
"sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f",
|
||||
"sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"
|
||||
],
|
||||
"version": "==1.1.1"
|
||||
},
|
||||
"pytz": {
|
||||
"hashes": [
|
||||
"sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda",
|
||||
"sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141"
|
||||
],
|
||||
"version": "==2019.1"
|
||||
},
|
||||
"six": {
|
||||
"hashes": [
|
||||
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
|
||||
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
|
||||
],
|
||||
"version": "==1.12.0"
|
||||
},
|
||||
"sqlalchemy": {
|
||||
"hashes": [
|
||||
"sha256:d5432832f91d200c3d8b473a266d59442d825f9ea744c467e68c5d9a9479fbce"
|
||||
],
|
||||
"version": "==1.3.2"
|
||||
},
|
||||
"werkzeug": {
|
||||
"hashes": [
|
||||
"sha256:0a73e8bb2ff2feecfc5d56e6f458f5b99290ef34f565ffb2665801ff7de6af7a",
|
||||
"sha256:7fad9770a8778f9576693f0cc29c7dcc36964df916b83734f4431c0e612a7fbc"
|
||||
],
|
||||
"version": "==0.15.2"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
25
README.md
25
README.md
|
@ -1,3 +1,26 @@
|
|||
## Objective
|
||||
|
||||
This codebase is for preparing the ungleich game, which heavily relies
|
||||
on checking other people's VMs.
|
||||
|
||||
The (not so) hidden objective is to create the base for "cmon",
|
||||
our new monitoring system that does not suck.
|
||||
|
||||
### Planned features (monitoring)
|
||||
|
||||
- full parallel execution
|
||||
- history support -> possible grafana interface
|
||||
- easy to create and extend checks
|
||||
- Requirements: python3 + binaries for certain checks
|
||||
|
||||
### Planned features (game)
|
||||
|
||||
- Allow registration
|
||||
- Allow deep (i.e. functionality based) checks of services
|
||||
- Define points (or monitoring severity)
|
||||
|
||||
|
||||
|
||||
## How to play
|
||||
|
||||
ungleich register --name your-user-name --email your@email
|
||||
|
@ -8,7 +31,7 @@ ungleich play-game --game dns-forward --ip
|
|||
|
||||
## Documentation
|
||||
|
||||
- Rais CheckExc
|
||||
- Rais CheckException on parameter wrong
|
||||
|
||||
## TODOs
|
||||
|
||||
|
|
19
check-cli.py
Normal file
19
check-cli.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import check
|
||||
|
||||
|
||||
checks = []
|
||||
|
||||
checks.append(check.DNSCheck("www.ungleich.ch"))
|
||||
checks.append(check.DNSCheck("www.ungleich.ch", expected_result="2a0a:e5c0:0:2:400:b3ff:fe39:795c"))
|
||||
checks.append(check.DNSCheck("www.ungleich.ch", rr_type="A", expected_result="185.203.112.17"))
|
||||
|
||||
for num_server in range(1,6):
|
||||
server="d{}.ungleich.ch".format(num_server)
|
||||
|
||||
checks.append(check.DNSCheck("www.ungleich.ch", server=server))
|
||||
|
||||
|
||||
for c in checks:
|
||||
print("{} {}".format(c, c.check()))
|
43
check.py
43
check.py
|
@ -1,3 +1,4 @@
|
|||
import subprocess
|
||||
|
||||
class CheckException(Exception):
|
||||
pass
|
||||
|
@ -16,17 +17,21 @@ class BaseCheck(object):
|
|||
pass
|
||||
|
||||
|
||||
|
||||
class DNSCheck(BaseCheck):
|
||||
def __init__(self, name, rr_type="AAAA", server=None):
|
||||
def __init__(self, name, rr_type="AAAA", expected_result=None, server=None):
|
||||
|
||||
self.rr_types = [ "AAAA", "A", "PTR", "TXT" ]
|
||||
self.name = name
|
||||
self.rr_type = rr_type
|
||||
self.server = server
|
||||
|
||||
self.expected_result = expected_result
|
||||
|
||||
if not self.rr_type in self.rr_types:
|
||||
raise WrongParameterException("Unsupported rr_type: {}".format(self.rr_type))
|
||||
|
||||
self.command = self.rr_type_to_command()
|
||||
|
||||
def rr_type_to_command(self):
|
||||
base_cmd="dig +short"
|
||||
|
@ -38,8 +43,42 @@ class DNSCheck(BaseCheck):
|
|||
elif self.rr_type == "PTR":
|
||||
command = "-x {}".format(base_cmd, self.name)
|
||||
elif self.rr_type == "TXT":
|
||||
command = "{} {} aaaa".format(base_cmd, self.name)
|
||||
command = "{} {} txt".format(base_cmd, self.name)
|
||||
|
||||
if self.server:
|
||||
command = "{} @{}".format(command, self.server)
|
||||
|
||||
return command.split()
|
||||
|
||||
|
||||
def check(self):
|
||||
res = subprocess.run(self.command,
|
||||
capture_output=True,
|
||||
encoding="utf-8")
|
||||
|
||||
if not res.returncode == 0:
|
||||
return (False, "")
|
||||
|
||||
|
||||
if self.expected_result:
|
||||
if not self.expected_result == res.stdout:
|
||||
return (False, res.stdout)
|
||||
|
||||
else:
|
||||
if res.stdout == "":
|
||||
return (False, res.stdout)
|
||||
|
||||
# Has (correct) data
|
||||
|
||||
return (True, res.stdout)
|
||||
|
||||
def __repr__(self):
|
||||
return "<Check {}>".format(self.__str__())
|
||||
|
||||
def __str__(self):
|
||||
name = "{}/{}".format(self.name, self.rr_type)
|
||||
|
||||
if self.server:
|
||||
name = "{}@{}".format(name, self.server)
|
||||
|
||||
return name
|
||||
|
|
Loading…
Reference in a new issue