HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //lib/check_mk_agent/plugins/plesk_domains_2.py
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
# Do not test generated 2.x files
# fmt: off
# type: ignore

from __future__ import with_statement
from __future__ import absolute_import
from io import open
__version__ = "2.3.0p38"

# Lists all domains configured in plesk
#
# <<<plesk_domains>>>
# <domain>

import sys

try:
    import MySQLdb  # type: ignore[import] # pylint: disable=import-error
except ImportError, e:
    sys.stdout.write(
        "<<<plesk_domains>>>\n%s. Please install missing module via `pip install mysqlclient`.\n"
        % e
    )
    sys.exit(0)

with open("/etc/psa/.psa.shadow") as pwd_file:
    pwd = pwd_file.read().strip()
try:
    db = MySQLdb.connect(
        host="localhost",
        db="psa",
        user="admin",
        passwd=pwd,
        charset="utf8",
    )
except MySQLdb.Error, e:
    sys.stderr.write("MySQL-Error %d: %s\n" % (e.args[0], e.args[1]))
    sys.exit(1)

cursor = db.cursor()
cursor.execute("SELECT name FROM domains")
sys.stdout.write("<<<plesk_domains>>>\n")
sys.stdout.write("%s\n" % "\n".join([d[0] for d in cursor.fetchall()]))
cursor.close()