I have couple servers with services on Ubuntu 22.04
- Local server addresses = [
*.*.*.*
,*.*.*.*
,*.*.*.*
] - Services name = [
my_service1.service
,my_service2.service
,my_service3.service
]
How to check services status from python on one of servers? All servers are connected to a local network with each other.
2
Answers
I was able to connect to a remote server and get the service status value. Next, you need to find the line Active: and find out what the status of the service is.
From what I understand, you’re trying to connect to a database on a server from other servers in your local network. In Python, you can use libraries like
psycopg2
for PostgreSQL,mysql-connector-python
for MySQL, orpyodbc
for SQL Server to connect to your database.If you’re using MySQL, here’s a basic example of mysql-connector-python library:
I’m assuming that your database server allows connections from your client servers and that the username and password provided have the necessary permissions to execute queries.