Comments (6)
I'm not sure how this error occurred. It looks like the login was successful, but when the monitor was created uptime kuma was no longer reachable.
This is an example code that works with a fresh uptime kuma instance.
from uptime_kuma_api import UptimeKumaApi, MonitorType
username = "admin"
password = "secret123"
api = UptimeKumaApi("http://127.0.0.1:3001/")
if api.need_setup():
api.setup(username, password)
api.login(username, password)
r = api.add_monitor(type=MonitorType.HTTP, name="Test API", url="https://gm.com")
print(r)
# {'msg': 'Added Successfully.', 'monitorID': 1}
monitors = api.get_monitors()
print(monitors)
# [{'id': 1, 'name': 'Test API', 'url': 'https://gm.com', 'method': 'GET', 'hostname': None, 'port': 53, 'maxretries': 0, 'weight': 2000, 'active': True, 'type': 'http', 'interval': 60, 'retryInterval': 60, 'resendInterval': 0, 'keyword': None, 'expiryNotification': False, 'ignoreTls': False, 'upsideDown': False, 'maxredirects': 10, 'accepted_statuscodes': ['200-299'], 'dns_resolve_type': 'A', 'dns_resolve_server': '1.1.1.1', 'dns_last_result': None, 'pushToken': None, 'docker_container': None, 'docker_host': None, 'proxyId': None, 'notificationIDList': [], 'tags': [], 'mqttUsername': None, 'mqttPassword': None, 'mqttTopic': None, 'mqttSuccessMessage': None, 'databaseConnectionString': None, 'databaseQuery': None, 'authMethod': '', 'authWorkstation': None, 'authDomain': None, 'radiusUsername': None, 'radiusPassword': None, 'radiusCalledStationId': None, 'radiusCallingStationId': None, 'radiusSecret': None, 'headers': None, 'body': None, 'basic_auth_user': None, 'basic_auth_pass': None}]
api.disconnect()
from uptime-kuma-api.
Supported parameters for add_monitor
and edit_monitor
:
uptime-kuma-api/uptime_kuma_api/api.py
Lines 445 to 502 in dac368e
An existing monitor can be edited by passing the id of the monitor and the key-value pairs of monitor parameters that should be edited.
uptime-kuma-api/uptime_kuma_api/api.py
Line 639 in dac368e
Example:
# add a new monitor
r = api.add_monitor(type=MonitorType.HTTP, name="Test API", url="https://gm.com")
print(r)
# {'msg': 'Added Successfully.', 'monitorID': 1}
# save the id of the new monitor
monitor_id = r["monitorID"]
# get and print the monitor
monitor = api.get_monitor(monitor_id)
print(monitor)
# {'id': 1, 'name': 'Test API', 'url': 'https://gm.com', 'method': 'GET', 'hostname': None, 'port': 53, 'maxretries': 0, 'weight': 2000, 'active': True, 'type': 'http', 'interval': 60, 'retryInterval': 60, 'resendInterval': 0, 'keyword': None, 'expiryNotification': False, 'ignoreTls': False, 'upsideDown': False, 'maxredirects': 10, 'accepted_statuscodes': ['200-299'], 'dns_resolve_type': 'A', 'dns_resolve_server': '1.1.1.1', 'dns_last_result': None, 'pushToken': None, 'docker_container': None, 'docker_host': None, 'proxyId': None, 'notificationIDList': [], 'tags': [], 'mqttUsername': None, 'mqttPassword': None, 'mqttTopic': None, 'mqttSuccessMessage': None, 'databaseConnectionString': None, 'databaseQuery': None, 'authMethod': '', 'authWorkstation': None, 'authDomain': None, 'radiusUsername': None, 'radiusPassword': None, 'radiusCalledStationId': None, 'radiusCallingStationId': None, 'radiusSecret': None, 'headers': None, 'body': None, 'basic_auth_user': None, 'basic_auth_pass': None}
# edit the monitor, change the url and the heartbeat interval
r = api.edit_monitor(monitor_id, url="https://google.com", interval=20)
print(r)
# {'msg': 'Saved.', 'monitorID': 1}
# get and print the monitor again
monitor = api.get_monitor(monitor_id)
print(monitor)
# {'id': 1, 'name': 'Test API', 'url': 'https://google.com', 'method': 'GET', 'hostname': None, 'port': 53, 'maxretries': 0, 'weight': 2000, 'active': True, 'type': 'http', 'interval': 20, 'retryInterval': 60, 'resendInterval': 0, 'keyword': None, 'expiryNotification': False, 'ignoreTls': False, 'upsideDown': False, 'maxredirects': 10, 'accepted_statuscodes': ['200-299'], 'dns_resolve_type': 'A', 'dns_resolve_server': '1.1.1.1', 'dns_last_result': None, 'pushToken': None, 'docker_container': None, 'docker_host': None, 'proxyId': None, 'notificationIDList': [], 'tags': [], 'mqttUsername': None, 'mqttPassword': None, 'mqttTopic': None, 'mqttSuccessMessage': None, 'databaseConnectionString': None, 'databaseQuery': None, 'authMethod': '', 'authWorkstation': None, 'authDomain': None, 'radiusUsername': None, 'radiusPassword': None, 'radiusCalledStationId': None, 'radiusCallingStationId': None, 'radiusSecret': None, 'headers': None, 'body': None, 'basic_auth_user': None, 'basic_auth_pass': None}
from uptime-kuma-api.
looks like its related to the python version I used (3.6.9)
once I switch to 3.7.5 it worked as expected.
any chance to get more examples of the api? how to edit existing monitors, which inputs are supported while creating a monitor, e.g. retry count before notificiation, etc.
from uptime-kuma-api.
I have started writing documentation for this module, with examples for all methods. I will publish it the next days.
from uptime-kuma-api.
thank you!!
from uptime-kuma-api.
The documentation is now available here: https://uptime-kuma-api.readthedocs.io/
from uptime-kuma-api.
Related Issues (20)
- api.delete_monitor() does nothing HOT 2
- "None is not a valid AuthMethod" error HOT 1
- Use Uptime Kuma API key for authentication HOT 2
- New type 'group' is not a valid MonitorType HOT 3
- Missing sanitisation of `accepted_statuscodes` HOT 1
- Interval modification does not take effect HOT 2
- Bug: api do not return correct timeout error TimeoutError -> Timeout HOT 1
- Proxy: Rate Limiting / Timeout HOT 9
- need to modify the value of interval and retryInterval to make it lower than 20 HOT 2
- support uptime kuma v1.23.0 HOT 3
- Support for Quick Stats
- Retrieve monitor status inside get_monitors()
- Inconsistant Status calls using get_monitor_status HOT 1
- Missing return element in `api.delete_status_page` HOT 1
- set pathName or parent HOT 1
- Default info event does not fetch version under uptime-kuma with version 1.23.1 HOT 1
- save_status_page() failing because of unexpected keyword. HOT 3
- Bug: `api.add_tag()` takes 1 positional HOT 1
- Timeout on get_monitors()
- get_monitor_status for all monitors HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uptime-kuma-api.