Skip to content

Commit

Permalink
feat: add support for uptime kuma 1.23.0 and 1.23.1
Browse files Browse the repository at this point in the history
lucasheld committed Aug 29, 2023
1 parent 20d08c1 commit c74804e
Showing 9 changed files with 251 additions and 5 deletions.
70 changes: 67 additions & 3 deletions plugins/modules/monitor.py
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@
type:
description: The type of the monitor.
type: str
choices: ["http", "port", "ping", "keyword", "grpc-keyword", "dns", "docker", "push", "steam", "gamedig", "mqtt", "sqlserver", "postgres", "mysql", "mongodb", "radius", "redis", "group"]
choices: ["group", "http", "port", "ping", "keyword", "json-query", "grpc-keyword", "dns", "docker", "real-browser", "push", "steam", "gamedig", "mqtt", "kafka-producer", "sqlserver", "postgres", "mysql", "mongodb", "radius", "redis", "tailscale-ping"]
interval:
description: The heartbeat interval of the monitor.
type: int
@@ -126,7 +126,7 @@
authMethod:
description: The auth method of the monitor.
type: str
choices: ["", "basic", "ntlm", "mtls"]
choices: ["", "basic", "ntlm", "mtls", "oauth2-cc"]
tlsCert:
description: The tls cert of the monitor.
type: str
@@ -148,9 +148,30 @@
authWorkstation:
description: The auth workstation of the monitor.
type: str
oauth_auth_method:
description: Authentication Method
type: str
oauth_token_url:
description: OAuth Token URL
type: str
oauth_client_id:
description: Client ID
type: str
oauth_client_secret:
description: Client Secret
type: str
oauth_scopes:
description: OAuth Scope
type: str
timeout:
description: Request Timeout
type: int
keyword:
description: The keyword of the monitor.
type: str
invertKeyword:
description: Invert Keyword. Look for the keyword to be absent rather than present.
type: bool
grpcUrl:
description: The grpc url of the monitor.
type: str
@@ -236,6 +257,33 @@
game:
description: The game of the monitor.
type: str
gamedigGivenPortOnly:
description: Guess Gamedig Port. The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server.
type: bool
jsonPath:
description: Json Query
type: str
expectedValue:
description: Expected Value
type: str
kafkaProducerBrokers:
description: Kafka Broker list
type: str
kafkaProducerTopic:
description: Kafka Topic Name
type: str
kafkaProducerMessage:
description: Kafka Producer Message
type: str
kafkaProducerSsl:
description: Enable Kafka SSL
type: bool
kafkaProducerAllowAutoTopicCreation:
description: Enable Kafka Producer Auto Topic Creation
type: bool
kafkaProducerSaslOptions:
description: Kafka SASL Options
type: dict
state:
description:
- Set to C(present) to create/update a monitor.
@@ -423,17 +471,24 @@ def main():
method=dict(type="str"),
body=dict(type="str"),
headers=dict(type="str"),
authMethod=dict(type="str", choices=["", "basic", "ntlm", "mtls"]),
authMethod=dict(type="str", choices=["", "basic", "ntlm", "mtls", "oauth2-cc"]),
tlsCert=dict(type="str"),
tlsKey=dict(type="str"),
tlsCa=dict(type="str"),
basic_auth_user=dict(type="str"),
basic_auth_pass=dict(type="str", no_log=True),
authDomain=dict(type="str"),
authWorkstation=dict(type="str"),
oauth_auth_method=dict(type="str"),
oauth_token_url=dict(type="str"),
oauth_client_id=dict(type="str"),
oauth_client_secret=dict(type="str"),
oauth_scopes=dict(type="str"),
timeout=dict(type="int"),

# KEYWORD
keyword=dict(type="str"),
invertKeyword=dict(type="bool"),

# GRPC_KEYWORD
grpcUrl=dict(type="str"),
@@ -483,6 +538,15 @@ def main():

# GAMEDIG
game=dict(type="str"),
gamedigGivenPortOnly=dict(type="bool"),
jsonPath=dict(type="str"),
expectedValue=dict(type="str"),
kafkaProducerBrokers=dict(type="str"),
kafkaProducerTopic=dict(type="str"),
kafkaProducerMessage=dict(type="str"),
kafkaProducerSsl=dict(type="bool"),
kafkaProducerAllowAutoTopicCreation=dict(type="bool"),
kafkaProducerSaslOptions=dict(type="dict"),

state=dict(type="str", default="present", choices=["present", "absent", "paused", "resumed"])
)
85 changes: 85 additions & 0 deletions plugins/modules/monitor_info.py
Original file line number Diff line number Diff line change
@@ -377,6 +377,91 @@
returned: always
type: str
sample: None
expectedValue:
description: Expected Value
returned: always
type: str
sample: None
gamedigGivenPortOnly:
description: Guess Gamedig Port. The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server.
returned: always
type: bool
sample: True
invertKeyword:
description: Invert Keyword
returned: always
type: bool
sample: False
jsonPath:
description: Json Query
returned: always
type: str
sample: None
kafkaProducerAllowAutoTopicCreation:
description: Enable Kafka Producer Auto Topic Creation
returned: always
type: bool
sample: False
kafkaProducerBrokers:
description: Kafka Broker list
returned: always
type: list
sample: None
kafkaProducerMessage:
description: Kafka Producer Message
returned: always
type: str
sample: None
kafkaProducerSaslOptions:
description: Kafka SASL Options
returned: always
type: dict
sample: None
kafkaProducerSsl:
description: Enable Kafka SSL
returned: always
type: bool
sample: False
kafkaProducerTopic:
description: Kafka Topic Name
returned: always
type: str
sample: None
oauth_auth_method:
description: Authentication Method
returned: always
type: str
sample: None
oauth_client_id:
description: Client ID
returned: always
type: str
sample: None
oauth_client_secret:
description: Client Secret
returned: always
type: str
sample: None
oauth_scopes:
description: OAuth Scope
returned: always
type: str
sample: None
oauth_token_url:
description: OAuth Token URL
returned: always
type: str
sample: None
screenshot:
description: Path to the screenshot
returned: always
type: str
sample: None
timeout:
description: Request Timeout
returned: always
type: int
sample: 48
'''

import traceback
56 changes: 56 additions & 0 deletions plugins/modules/notification_info.py
Original file line number Diff line number Diff line change
@@ -184,6 +184,14 @@
description: Feishu provider option.
returned: if type is Feishu
type: str
flashdutySeverity:
description: FlashDuty provider option.
returned: if type is FlashDuty
type: str
flashdutyIntegrationKey:
description: FlashDuty provider option.
returned: if type is FlashDuty
type: str
freemobileUser:
description: FreeMobile provider option.
returned: if type is FreeMobile
@@ -320,6 +328,18 @@
description: mattermost provider option.
returned: if type is mattermost
type: str
sender:
description: nostr provider option.
returned: if type is nostr
type: str
recipients:
description: nostr provider option.
returned: if type is nostr
type: str
relays:
description: nostr provider option.
returned: if type is nostr
type: str
ntfyAuthenticationMethod:
description: ntfy provider option.
returned: if type is ntfy
@@ -460,6 +480,10 @@
description: pushbullet provider option.
returned: if type is pushbullet
type: str
pushdeerServer:
description: PushDeer provider option.
returned: if type is PushDeer
type: str
pushdeerKey:
description: PushDeer provider option.
returned: if type is PushDeer
@@ -548,6 +572,10 @@
description: signal provider option.
returned: if type is signal
type: str
slackchannelnotify:
description: slack provider option.
returned: if type is slack
type: bool
slackchannel:
description: slack provider option.
returned: if type is slack
@@ -564,6 +592,26 @@
description: slack provider option.
returned: if type is slack
type: str
smscTranslit:
description: smsc provider option.
returned: if type is smsc
type: str
smscLogin:
description: smsc provider option.
returned: if type is smsc
type: str
smscPassword:
description: smsc provider option.
returned: if type is smsc
type: str
smscToNumber:
description: smsc provider option.
returned: if type is smsc
type: str
smscSenderName:
description: smsc provider option.
returned: if type is smsc
type: str
smseagleEncoding:
description: SMSEagle provider option.
returned: if type is SMSEagle
@@ -720,6 +768,10 @@
description: twilio provider option.
returned: if type is twilio
type: str
twilioApiKey:
description: twilio provider option.
returned: if type is twilio
type: str
twilioAuthToken:
description: twilio provider option.
returned: if type is twilio
@@ -736,6 +788,10 @@
description: webhook provider option.
returned: if type is webhook
type: str
webhookCustomBody:
description: webhook provider option.
returned: if type is webhook
type: str
webhookAdditionalHeaders:
description: webhook provider option.
returned: if type is webhook
8 changes: 8 additions & 0 deletions plugins/modules/settings.py
Original file line number Diff line number Diff line change
@@ -49,9 +49,15 @@
steamAPIKey:
description: The Steam API key for monitoring a Steam game server.
type: str
nscd:
description: Enable NSCD (Name Service Cache Daemon) for caching all DNS requests
type: bool
dnsCache:
description: True if dns cache should be enabled.
type: bool
chromeExecutable:
description: Chrome/Chromium Executable
type: str
tlsExpiryNotifyDays:
description: HTTPS monitors trigger notification when the TLS certificate expires in the specified days.
type: list
@@ -117,7 +123,9 @@ def main():
searchEngineIndex=dict(type="bool"),
primaryBaseURL=dict(type="str"),
steamAPIKey=dict(type="str"),
nscd=dict(type="bool"),
dnsCache=dict(type="bool"),
chromeExecutable=dict(type="str"),
# notifications
tlsExpiryNotifyDays=dict(type="list", elements="int"),
# security
10 changes: 10 additions & 0 deletions plugins/modules/settings_info.py
Original file line number Diff line number Diff line change
@@ -95,6 +95,16 @@
returned: always
type: bool
sample: false
chromeExecutable:
description: Value of the chromeExecutable setting.
returned: always
type: str
sample: ''
nscd:
description: Value of the nscd setting.
returned: always
type: bool
sample: false
'''

import traceback
7 changes: 6 additions & 1 deletion plugins/modules/status_page_info.py
Original file line number Diff line number Diff line change
@@ -75,6 +75,11 @@
returned: always
type: bool
sample: True
showCertificateExpiry:
description: Show Certificate Expiry.
returned: always
type: bool
sample: False
showTags:
description: True if the show tags is enabled.
returned: always
@@ -119,7 +124,7 @@
description: The public group list of the status page.
returned: always
type: list
sample: [{'id': 5, 'name': 'Services', 'weight': 1, 'monitorList': [{'id': 18, 'name': 'sample monitor'}]}]
sample: [{'id': 5, 'name': 'Services', 'weight': 1, 'monitorList': [{'id': 18, 'name': 'sample monitor', 'type': 'http'}]}]
'''

import traceback
3 changes: 2 additions & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ if [ $version ] && [ "$version" != "all" ]
then
versions=("$version")
else
versions=(1.22.1 1.22.0 1.21.3)
versions=(1.23.1 1.23.0 1.22.1 1.22.0 1.21.3)
fi

unit_targets=""
@@ -61,6 +61,7 @@ do

echo "Stopping uptime kuma..."
docker stop uptimekuma > /dev/null
sleep 1

echo ""
done
16 changes: 16 additions & 0 deletions tests/unit/plugins/module_utils/test_monitor.py
Original file line number Diff line number Diff line change
@@ -46,7 +46,14 @@ def setUp(self):
"basic_auth_pass": None,
"authDomain": None,
"authWorkstation": None,
"oauth_auth_method": None,
"oauth_token_url": None,
"oauth_client_id": None,
"oauth_client_secret": None,
"oauth_scopes": None,
"timeout": None,
"keyword": None,
"invertKeyword": None,
"grpcUrl": None,
"grpcEnableTls": None,
"grpcServiceName": None,
@@ -74,6 +81,15 @@ def setUp(self):
"radiusCalledStationId": None,
"radiusCallingStationId": None,
"game": None,
"gamedigGivenPortOnly": None,
"jsonPath": None,
"expectedValue": None,
"kafkaProducerBrokers": None,
"kafkaProducerTopic": None,
"kafkaProducerMessage": None,
"kafkaProducerSsl": None,
"kafkaProducerAllowAutoTopicCreation": None,
"kafkaProducerSaslOptions": None,
"state": "present"
}

1 change: 1 addition & 0 deletions tests/unit/plugins/module_utils/test_status_page.py
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ def test_status_page(self):
for j in i.get("monitorList", []):
j.pop("sendUrl", None)
j["name"] = None
j.pop("type", None)
self.assertEqual(public_group_list, self.params["publicGroupList"])

result = self.run_module(module, self.params)

0 comments on commit c74804e

Please sign in to comment.