コード例 #1
0
ファイル: cmd.py プロジェクト: vcrhonek/openlmi-scripts
    def execute(self, ns, service):
        columns = (('Name', lambda i: srv.RE_SUFFIX.sub('', i.Name)),
                   'Caption', ('Enabled',
                               lambda i: srv.get_enabled_string(ns, i)),
                   ('Status', lambda i: srv.get_status_string(ns, i)))

        return columns, srv.get_service(ns, service)
コード例 #2
0
ファイル: cmd.py プロジェクト: balamurugana/openlmi-scripts
    def execute(self, ns, service):
        columns = (
                ('Name', lambda i: srv.RE_SUFFIX.sub('', i.Name)),
                'Caption',
                ('Enabled', lambda i: srv.get_enabled_string(ns, i)),
                ('Status', lambda i: srv.get_status_string(ns, i)))

        return columns, srv.get_service(ns, service)
コード例 #3
0
ファイル: __init__.py プロジェクト: openlmi/openlmi-doc
def get_servicesinfo(ns):
    """
    Prints tabular data of some system services.
    """
    tf = TableFormatter(stdout, 0, True, {0: FIRST_COLUMN_MIN_SIZE})

    # Firewall
    try:
        fw = ''
        firewalld = get_service(ns, 'firewalld')
        if firewalld and firewalld.Status == 'OK':
            fw = 'on (firewalld)'
        else:
            iptables = get_service(ns, 'iptables')
            if iptables and iptables.Status == 'OK':
                fw = 'on (iptables)'
        if not fw:
            fw = 'off'
    except Exception:
        fw = 'N/A'
    tf.produce_output([('Firewall:', fw)])

    # Logging
    try:
        logging = ''
        journald = get_service(ns, 'systemd-journald')
        if journald and journald.Status == 'OK':
            logging = 'on (journald)'
        else:
            rsyslog = get_service(ns, 'rsyslog')
            if rsyslog and rsyslog.Status == 'OK':
                logging = 'on (rsyslog)'
        if not logging:
            logging = 'off'
    except Exception:
        logging = 'N/A'
    tf.produce_output([('Logging:', logging)])

    return []
コード例 #4
0
def get_servicesinfo(ns):
    """
    Prints tabular data of some system services.
    """
    tf = TableFormatter(stdout, 0, True, {0: FIRST_COLUMN_MIN_SIZE})

    # Firewall
    try:
        fw = ''
        firewalld = get_service(ns, 'firewalld')
        if firewalld and firewalld.Status == 'OK':
            fw = 'on (firewalld)'
        else:
            iptables = get_service(ns, 'iptables')
            if iptables and iptables.Status == 'OK':
                fw = 'on (iptables)'
        if not fw:
            fw = 'off'
    except Exception:
        fw = 'N/A'
    tf.produce_output([('Firewall:', fw)])

    # Logging
    try:
        logging = ''
        journald = get_service(ns, 'systemd-journald')
        if journald and journald.Status == 'OK':
            logging = 'on (journald)'
        else:
            rsyslog = get_service(ns, 'rsyslog')
            if rsyslog and rsyslog.Status == 'OK':
                logging = 'on (rsyslog)'
        if not logging:
            logging = 'off'
    except Exception:
        logging = 'N/A'
    tf.produce_output([('Logging:', logging)])

    return []
コード例 #5
0
def get_servicesinfo(ns):
    """
    :returns: Tabular data of some system services.
    :rtype: List of tuples
    """
    # Firewall
    try:
        fw = ''
        firewalld = get_service(ns, 'firewalld.service')
        if firewalld and firewalld.Status == 'OK':
            fw = 'on (firewalld)'
        else:
            iptables = get_service(ns, 'iptables.service')
            if iptables and iptables.Status == 'OK':
                fw = 'on (iptables)'
        if not fw:
            fw = 'off'
    except LMIClassNotFound:
        fw = 'N/A'
    # Logging
    try:
        logging = ''
        journald = get_service(ns, 'systemd-journald.service')
        if journald and journald.Status == 'OK':
            logging = 'on (journald)'
        else:
            rsyslog = get_service(ns, 'rsyslog.service')
            if rsyslog and rsyslog.Status == 'OK':
                logging = 'on (rsyslog)'
        if not logging:
            logging = 'off'
    except LMIClassNotFound:
        logging = 'N/A'
    # Result
    result = [
        ('Firewall:', fw),
        ('Logging:', logging)]
    return result
コード例 #6
0
def get_servicesinfo(ns):
    """
    :returns: Tabular data of some system services.
    :rtype: List of tuples
    """
    # Firewall
    try:
        fw = ''
        firewalld = get_service(ns, 'firewalld.service')
        if firewalld and firewalld.Status == 'OK':
            fw = 'on (firewalld)'
        else:
            iptables = get_service(ns, 'iptables.service')
            if iptables and iptables.Status == 'OK':
                fw = 'on (iptables)'
        if not fw:
            fw = 'off'
    except LMIClassNotFound:
        fw = 'N/A'
    # Logging
    try:
        logging = ''
        journald = get_service(ns, 'systemd-journald.service')
        if journald and journald.Status == 'OK':
            logging = 'on (journald)'
        else:
            rsyslog = get_service(ns, 'rsyslog.service')
            if rsyslog and rsyslog.Status == 'OK':
                logging = 'on (rsyslog)'
        if not logging:
            logging = 'off'
    except LMIClassNotFound:
        logging = 'N/A'
    # Result
    result = [('Firewall:', fw), ('Logging:', logging)]
    return result