• 收集主机OS相关数据


    #!/usr/bin/ksh
    
    touch hostinfo$(date +%Y%m%d).csv
    filename=hostinfo$(date +%Y%m%d).csv
    
    >${filename}
    for ip in $(cat iplist);
    do
        SYSTEM=`ssh -q ${ip} uname -s`
        HOST_NAME=`ssh -q ${ip} hostname`
        SERNUM=""
        OS=""
    
        printf "${ip}," >> ${filename}
        if [ "${SYSTEM}"x = "HP-UX"x ]; 
        then
            SERNUM=`ssh -q ${ip} /usr/contrib/bin/machinfo | awk '/serial number/ {print $NF}'`
            OS=`ssh -q ${ip} /usr/contrib/bin/machinfo | grep 'Release' | awk -F':' '{print $2}'`
        elif [ "${SYSTEM}"x = "AIX"x ];
        then
            SERNUM=`ssh -q ${ip} prtconf | awk '/Machine Serial Number/ {print $NF}'`
            OS=${SYSTEM}
        elif [ "${SYSTEM}"x = "Linux"x ];
        then
            SERNUM=`ssh -q ${ip} dmidecode -t system | grep 'Serial Number' | awk -F':' '{print $2}'`
        ssh ${ip} "ls /etc/redhat-release" > /dev/null 2>&1
        if [ $? -eq 0 ];
        then
            OS=`ssh -q ${ip} cat /etc/redhat-release | awk '{printf("%s%s %s
    ", $1, $2, $(NF-1))}'`
            tmp=`echo ${OS} | grep "^CentOS"`
            if [ "$tmp" != "" ]; then
                OS=`echo ${tmp} | awk '{printf("CentOS %s
    ", $NF)}'`
            fi
            else
                OS=`ssh -q ${ip} cat /etc/issue | awk '{printf("%s %s %s", $3, $7, $8)}'`
            fi
        else
            echo "other system!"
        fi
    
        printf "${SERNUM}, ${HOST_NAME}, ${OS}
    " >> ${filename}
    done
  • 相关阅读:
    WPF 重新启动该程序
    Winform水印
    PS 切HTML (ps+div+css)
    VS服务器运行有问题 怎么办?
    ISDeleted 软删除!!
    项目初始框架
    MD5加密
    !!LoginWindow.cs
    !!!精简版三层架构
    !!C#交互操作SqlServer数据库 基本的增删改查
  • 原文地址:https://www.cnblogs.com/donggongdechen/p/10632706.html
Copyright © 2020-2023  润新知