You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 KiB
35 KiB
<html>
<head>
</head>
</html>
In [1]:
print("hello world")
hello world
In [17]:
!apt install nettools
!ping tcp://mongo -p 27017
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root? /bin/bash: ping: command not found
In [22]:
from IPython.display import HTML
s = """<!DOCTYPE html>
<!-- Important: must specify -->
<html>
<head>
<meta charset="utf-8" />
<!-- Important: rapi-doc uses utf8 characters -->
<script
type="module"
src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"
></script>
</head>
<body>
<rapi-doc-mini
style="min-width: 600px; border: 1px solid #eee; border-top-width: 0"
spec-url="https://donavanaldrich.com/api/openapi.yaml"
theme="dark"
paths-expanded="false"
match-paths="get /bookstack/pages"
>
</rapi-doc-mini>
<!-- <rapi-doc spec-url = "https://petstore.swagger.io/v2/swagger.json"> </rapi-doc> -->
</body>
</html>
<!-- match-paths="^get /bookstack$|^post /bookstack$"
match-type="regex" -->"""
h = HTML(s)
display(h)
<html>
<head>
</head>
</html>
In [ ]:
In [23]:
from IPython.display import HTML
s = """<!DOCTYPE html>
<!-- Important: must specify -->
<html>
<head>
<meta charset="utf-8" />
<!-- Important: rapi-doc uses utf8 characters -->
<script
type="module"
src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"
></script>
</head>
<body>
<rapi-doc spec-url = "https://donavanaldrich.com/api/openapi.yaml"> </rapi-doc>
</body>
</html>"""
h = HTML(s)
display(h)
<html>
<head>
</head>
</html>
In [24]:
import requests
url = "https://donavanaldrich.com/api/metrics/netdata/charts"
response = requests.request("GET", url)
print(response.text)
IOPub data rate exceeded. The Jupyter server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable `--ServerApp.iopub_data_rate_limit`. Current values: ServerApp.iopub_data_rate_limit=1000000.0 (bytes/sec) ServerApp.rate_limit_window=3.0 (secs)
In [25]:
import requests
url = "https://donavanaldrich.com/api/metrics/netdata/chart"
querystring = {"chart":"system.cpu"}
response = requests.request("GET", url, params=querystring)
print(response.json())
mydict = response.json()
{'id': 'system.cpu', 'name': 'system.cpu', 'type': 'system', 'family': 'cpu', 'context': 'system.cpu', 'title': 'Total CPU utilization (system.cpu)', 'priority': 100, 'plugin': 'proc.plugin', 'module': '/proc/stat', 'units': 'percentage', 'data_url': '/api/v1/data?chart=system.cpu', 'chart_type': 'stacked', 'duration': 478780, 'first_entry': 1662087080, 'last_entry': 1662565840, 'update_every': 20, 'dimensions': {'guest_nice': {'name': 'guest_nice'}, 'guest': {'name': 'guest'}, 'steal': {'name': 'steal'}, 'softirq': {'name': 'softirq'}, 'irq': {'name': 'irq'}, 'user': {'name': 'user'}, 'system': {'name': 'system'}, 'nice': {'name': 'nice'}, 'iowait': {'name': 'iowait'}}, 'chart_variables': {}, 'green': None, 'red': None, 'alarms': {'20min_steal_cpu': {'id': 1662512394, 'status': 'CLEAR', 'units': '%', 'update_every': 300}, '10min_cpu_iowait': {'id': 1662512393, 'status': 'CLEAR', 'units': '%', 'update_every': 60}, '10min_cpu_usage': {'id': 1662512392, 'status': 'CLEAR', 'units': '%', 'update_every': 60}}, 'chart_labels': {'_collect_plugin': 'proc.plugin', '_collect_module': '/proc/stat', '_instance_family': 'cpu'}}
In [21]:
import pymongo
myclient = pymongo.MongoClient("mongodb://user:password@192.168.1.101:27017")
# DB
mydb = myclient["dev"]
# Collectino
mycol = mydb["netdata"]
mydict = { "name": "Peter", "address": "Lowstreet 27" }
x = mycol.insert_one(mydict)
print(x.inserted_id)
# print(mydb.list_collection_names())
--------------------------------------------------------------------------- OperationFailure Traceback (most recent call last) Input In [21], in <cell line: 14>() 10 mycol = mydb["netdata"] 12 mydict = { "name": "Peter", "address": "Lowstreet 27" } ---> 14 x = mycol.insert_one(mydict) 16 print(x.inserted_id) File /opt/conda/lib/python3.10/site-packages/pymongo/collection.py:621, in Collection.insert_one(self, document, bypass_document_validation, session, comment) 617 document["_id"] = ObjectId() 619 write_concern = self._write_concern_for(session) 620 return InsertOneResult( --> 621 self._insert_one( 622 document, 623 ordered=True, 624 write_concern=write_concern, 625 op_id=None, 626 bypass_doc_val=bypass_document_validation, 627 session=session, 628 comment=comment, 629 ), 630 write_concern.acknowledged, 631 ) File /opt/conda/lib/python3.10/site-packages/pymongo/collection.py:562, in Collection._insert_one(self, doc, ordered, write_concern, op_id, bypass_doc_val, session, comment) 550 result = sock_info.command( 551 self.__database.name, 552 command, (...) 557 retryable_write=retryable_write, 558 ) 560 _check_write_command_response(result) --> 562 self.__database.client._retryable_write(acknowledged, _insert_command, session) 564 if not isinstance(doc, RawBSONDocument): 565 return doc.get("_id") File /opt/conda/lib/python3.10/site-packages/pymongo/mongo_client.py:1448, in MongoClient._retryable_write(self, retryable, func, session) 1446 """Internal retryable write helper.""" 1447 with self._tmp_session(session) as s: -> 1448 return self._retry_with_session(retryable, func, s, None) File /opt/conda/lib/python3.10/site-packages/pymongo/mongo_client.py:1321, in MongoClient._retry_with_session(self, retryable, func, session, bulk) 1311 """Execute an operation with at most one consecutive retries 1312 1313 Returns func()'s return value on success. On error retries the same (...) 1316 Re-raises any exception thrown by func(). 1317 """ 1318 retryable = ( 1319 retryable and self.options.retry_writes and session and not session.in_transaction 1320 ) -> 1321 return self._retry_internal(retryable, func, session, bulk) File /opt/conda/lib/python3.10/site-packages/pymongo/_csot.py:105, in apply.<locals>.csot_wrapper(self, *args, **kwargs) 103 with _TimeoutContext(timeout): 104 return func(self, *args, **kwargs) --> 105 return func(self, *args, **kwargs) File /opt/conda/lib/python3.10/site-packages/pymongo/mongo_client.py:1353, in MongoClient._retry_internal(self, retryable, func, session, bulk) 1349 server = self._select_server(writable_server_selector, session) 1350 supports_session = ( 1351 session is not None and server.description.retryable_writes_supported 1352 ) -> 1353 with self._get_socket(server, session) as sock_info: 1354 max_wire_version = sock_info.max_wire_version 1355 if retryable and not supports_session: File /opt/conda/lib/python3.10/contextlib.py:135, in _GeneratorContextManager.__enter__(self) 133 del self.args, self.kwds, self.func 134 try: --> 135 return next(self.gen) 136 except StopIteration: 137 raise RuntimeError("generator didn't yield") from None File /opt/conda/lib/python3.10/site-packages/pymongo/mongo_client.py:1189, in MongoClient._get_socket(self, server, session) 1187 yield session._pinned_connection 1188 return -> 1189 with server.get_socket(handler=err_handler) as sock_info: 1190 # Pin this session to the selected server or connection. 1191 if in_txn and server.description.server_type in ( 1192 SERVER_TYPE.Mongos, 1193 SERVER_TYPE.LoadBalancer, 1194 ): 1195 session._pin(server, sock_info) File /opt/conda/lib/python3.10/contextlib.py:135, in _GeneratorContextManager.__enter__(self) 133 del self.args, self.kwds, self.func 134 try: --> 135 return next(self.gen) 136 except StopIteration: 137 raise RuntimeError("generator didn't yield") from None File /opt/conda/lib/python3.10/site-packages/pymongo/pool.py:1406, in Pool.get_socket(self, handler) 1403 if self.enabled_for_cmap: 1404 listeners.publish_connection_check_out_started(self.address) -> 1406 sock_info = self._get_socket(handler=handler) 1408 if self.enabled_for_cmap: 1409 listeners.publish_connection_checked_out(self.address, sock_info.id) File /opt/conda/lib/python3.10/site-packages/pymongo/pool.py:1519, in Pool._get_socket(self, handler) 1517 else: # We need to create a new connection 1518 try: -> 1519 sock_info = self.connect(handler=handler) 1520 finally: 1521 with self._max_connecting_cond: File /opt/conda/lib/python3.10/site-packages/pymongo/pool.py:1377, in Pool.connect(self, handler) 1374 if handler: 1375 handler.contribute_socket(sock_info, completed_handshake=False) -> 1377 sock_info.authenticate() 1378 except BaseException: 1379 sock_info.close_socket(ConnectionClosedReason.ERROR) File /opt/conda/lib/python3.10/site-packages/pymongo/pool.py:869, in SocketInfo.authenticate(self) 867 creds = self.opts._credentials 868 if creds: --> 869 auth.authenticate(creds, self) 870 self.ready = True 871 if self.enabled_for_cmap: File /opt/conda/lib/python3.10/site-packages/pymongo/auth.py:549, in authenticate(credentials, sock_info) 547 mechanism = credentials.mechanism 548 auth_func = _AUTH_MAP[mechanism] --> 549 auth_func(credentials, sock_info) File /opt/conda/lib/python3.10/site-packages/pymongo/auth.py:475, in _authenticate_default(credentials, sock_info) 473 return _authenticate_scram(credentials, sock_info, "SCRAM-SHA-256") 474 else: --> 475 return _authenticate_scram(credentials, sock_info, "SCRAM-SHA-1") 476 else: 477 return _authenticate_scram(credentials, sock_info, "SCRAM-SHA-1") File /opt/conda/lib/python3.10/site-packages/pymongo/auth.py:201, in _authenticate_scram(credentials, sock_info, mechanism) 199 else: 200 nonce, first_bare, cmd = _authenticate_scram_start(credentials, mechanism) --> 201 res = sock_info.command(source, cmd) 203 server_first = res["payload"] 204 parsed = _parse_scram_response(server_first) File /opt/conda/lib/python3.10/site-packages/pymongo/pool.py:766, in SocketInfo.command(self, dbname, spec, read_preference, codec_options, check, allowable_errors, read_concern, write_concern, parse_write_concern_error, collation, session, client, retryable_write, publish_events, user_fields, exhaust_allowed) 764 self._raise_if_not_writable(unacknowledged) 765 try: --> 766 return command( 767 self, 768 dbname, 769 spec, 770 self.is_mongos, 771 read_preference, 772 codec_options, 773 session, 774 client, 775 check, 776 allowable_errors, 777 self.address, 778 listeners, 779 self.max_bson_size, 780 read_concern, 781 parse_write_concern_error=parse_write_concern_error, 782 collation=collation, 783 compression_ctx=self.compression_context, 784 use_op_msg=self.op_msg_enabled, 785 unacknowledged=unacknowledged, 786 user_fields=user_fields, 787 exhaust_allowed=exhaust_allowed, 788 write_concern=write_concern, 789 ) 790 except (OperationFailure, NotPrimaryError): 791 raise File /opt/conda/lib/python3.10/site-packages/pymongo/network.py:166, in command(sock_info, dbname, spec, is_mongos, read_preference, codec_options, session, client, check, allowable_errors, address, listeners, max_bson_size, read_concern, parse_write_concern_error, collation, compression_ctx, use_op_msg, unacknowledged, user_fields, exhaust_allowed, write_concern) 164 client._process_response(response_doc, session) 165 if check: --> 166 helpers._check_command_response( 167 response_doc, 168 sock_info.max_wire_version, 169 allowable_errors, 170 parse_write_concern_error=parse_write_concern_error, 171 ) 172 except Exception as exc: 173 if publish: File /opt/conda/lib/python3.10/site-packages/pymongo/helpers.py:181, in _check_command_response(response, max_wire_version, allowable_errors, parse_write_concern_error) 178 elif code == 43: 179 raise CursorNotFound(errmsg, code, response, max_wire_version) --> 181 raise OperationFailure(errmsg, code, response, max_wire_version) OperationFailure: Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'}
In [ ]: