Beispiel #1
0
def monitorUninstallation(system, component, cpu=None, hostname=None):
    """
    Register the uninstallation of a component in the ComponentMonitoringDB
    """
    monitoringClient = ComponentMonitoringClient()

    # Retrieve user uninstalling the component
    user = None
    result = getProxyInfo()
    if result["OK"]:
        proxyInfo = result["Value"]
        if "username" in proxyInfo:
            user = proxyInfo["username"]
    else:
        return result
    if not user:
        user = "******"

    if not cpu:
        cpu = "Not available"
        for line in open("/proc/cpuinfo"):
            if line.startswith("model name"):
                cpu = line.split(":")[1][0:64]
                cpu = cpu.replace("\n", "").lstrip().rstrip()

    if not hostname:
        hostname = socket.getfqdn()
    instance = component[0:32]

    result = monitoringClient.updateInstallations(
        {
            "Instance": instance,
            "UnInstallationTime": None
        },
        {"DIRACSystem": system},
        {
            "HostName": hostname,
            "CPU": cpu
        },
        {
            "UnInstallationTime": datetime.datetime.utcnow(),
            "UnInstalledBy": user
        },
    )
    return result
Beispiel #2
0
def monitorUninstallation(system, component, cpu=None, hostname=None):
    """
  Register the uninstallation of a component in the ComponentMonitoringDB
  """
    monitoringClient = ComponentMonitoringClient()

    # Retrieve user uninstalling the component
    user = None
    result = getProxyInfo()
    if result['OK']:
        proxyInfo = result['Value']
        if 'username' in proxyInfo:
            user = proxyInfo['username']
    else:
        return result
    if not user:
        user = '******'

    if not cpu:
        cpu = 'Not available'
        for line in open('/proc/cpuinfo'):
            if line.startswith('model name'):
                cpu = line.split(':')[1][0:64]
                cpu = cpu.replace('\n', '').lstrip().rstrip()

    if not hostname:
        hostname = socket.getfqdn()
    instance = component[0:32]

    result = monitoringClient.updateInstallations(
        {
            'Instance': instance,
            'UnInstallationTime': None
        }, {'System': system}, {
            'HostName': hostname,
            'CPU': cpu
        }, {
            'UnInstallationTime': datetime.datetime.utcnow(),
            'UnInstalledBy': user
        })
    return result