-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from mriedmann/probe-mysql
feat: add mysql probe
- Loading branch information
Showing
17 changed files
with
1,013 additions
and
699 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.4.1" | ||
__version__ = "0.4.2-2+2db1f87" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
from pipecheck.checks.dns import DnsProbe | ||
from pipecheck.checks.http import HttpProbe | ||
from pipecheck.checks.icmp import PingProbe | ||
from pipecheck.checks.mysql import MysqlProbe | ||
from pipecheck.checks.tcp import TcpProbe | ||
|
||
probes = {} | ||
|
||
for cls in [HttpProbe, DnsProbe, PingProbe, TcpProbe]: | ||
for cls in [HttpProbe, DnsProbe, PingProbe, TcpProbe, MysqlProbe]: | ||
probes[cls.get_type()] = cls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Optional | ||
|
||
import pymysql | ||
|
||
from pipecheck.api import CheckResult, Err, Ok, Probe | ||
|
||
|
||
class MysqlProbe(Probe): | ||
"""Try MySQL Connection to given host and port using given user and password""" | ||
|
||
host: str = "" | ||
port: int = 3306 | ||
database: Optional[str] = None | ||
user: str = "" | ||
password: str = "" | ||
timeout: int = 5 | ||
|
||
def __call__(self) -> CheckResult: | ||
connection = pymysql.connect( | ||
host=self.host, | ||
port=self.port, | ||
user=self.user, | ||
password=self.password, | ||
database=self.database, | ||
connect_timeout=self.timeout, | ||
defer_connect=True, | ||
) | ||
try: | ||
connection.connect() | ||
return Ok(f"MySQL connection successfully established to port {self.port} on {self.host}") | ||
except Exception as e: | ||
return Err(f"MySQL connection failed on port {self.port} for {self.host} ({e})") | ||
finally: | ||
connection.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.