设为首页 收藏本站
查看: 589|回复: 0

[经验分享] linux OCSNG agent安装说明

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-8-21 08:48:23 | 显示全部楼层 |阅读模式
基于https通信,可以使用OCS的IPdiscover功能。

-rw-r--r--.  1 root root  59M 8月  20 16:57 linux-ocs-agent.tar.gz

链接:http://pan.baidu.com/s/1pJKK4w7 密码:a0re



Ready Go!

===================================================
tar xf OCS_Agent0812.1028.tar.gz

2,【执行安装】【没有root权限会报错,提示用 sudo su】
root@debian:/home# cd linux/
root@debian:/home/linux/# ./install.sh
3,【输入机器的资产编号,不要输错!】
Vobile: Enter TAG  on this machine :

【显示Successful! 说明客户端安装成功,下面会显示这个机器的当前分钟是多少】
Successful!
57


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
# cacert.pem
# deb.txt
# yum packages
# Ocsinventory-agent
# fix cron time
# fix sync time
# if test ok,modify debug=0
# 2015.08.14 fix redhat linux yum depend problems
# 2015.08.14 fix seting cron time
# 2015.08.17 grep Successful or break
#
export PATH=$PATH:.

clear
setterm -blank 0

root_id=`id -u`
if [ $root_id -ne 0 ] ; then
{
   clear
   echo -e "\033[40;37mWarning: you are not root user ! \n\n[Please use Command line ]$ sudo su \n\n \033[0m"
   exit 10
}
fi

#judenment operation OS ************************************

rm -rf /etc/ocsinventory*     #rm old agent conf
if [ -f /etc/redhat-release ]
then
    OS=1
elif [ -f /etc/debian_version ]
then
    OS=2
else
   clear
   echo "No support Operating system !"
fi



# Debian ********************************
if [ $OS -eq 2 ] ;then

echo "Debian Linux"
sleep 1
cp /etc/apt/sources.list /etc/apt/sources.listbak
sed -i '1r deb.txt' /etc/apt/sources.list
mkdir /etc/ocsinventory-agent
cp -f ./cacert.pem /etc/ocsinventory-agent/
apt-get -y install ntpdate  dmidecode libxml-simple-perl libnet-ip-perl libwww-perl perl libnet-ssleay-perl libcrypt-ssleay-perl libnet-snmp-perl libproc-pid-file-perl  libproc-daemon-perl net-tools libsys-syslog-perl pciutils smartmontools read-edid nmap make
stat=`echo $?`
clear
cp -f /etc/apt/sources.listbak /etc/apt/sources.list
fi


# RedHat OS ********************************
if [ $OS -eq 1 ] ;then
echo "Redhat Linux "
sleep 1
mkdir -p /etc/ocsinventory-agent
cp -f ./cacert.pem /etc/ocsinventory-agent/
yum -y --nogpgcheck localinstall ./packages/*.rpm
stat=`echo $?`
fi

# sync time ****************************************
echo "sync time......"
ntpdate 210.72.145.44
ntpdate cn.pool.ntp.org

# make && make install *******************************
if [ $stat -eq 0 ] ;then

# read input Parameter
clear
while [ 1 ]
do
echo -en "\033[47;34;7mWarning: Enter TAG  on this machine :\033[0m"
read tag
leng1=`echo ${tag} | wc -L|bc`
         if [ $leng1 -lt 5 ]
         then
             clear
              echo -e "\033[40;36;7mWarning:TAG more than 5 length.:\033[0m"
         else
             break
        fi
done

# read input time for cron
while [ 1 ]
do
    echo -en "\033[47;34;7mHello: How many hours do you want executive OCS Agent ?\033[0m [1-23]/ [2]?:"
    read time1
       if [ -z "$time1" ];then
       time1=2
       fi
     
    time2=`echo ${time1} |bc`
       if [ $time2 -ge 1 -a $time2 -le 23 ]
       then
           time3=$time2
           break
             else
                  echo "Warning: input error ,please try again."
            fi
done


cd Ocsinventory-Unix-Agent-2.1.1
make clean
env PERL_AUTOINSTALL=1 perl Makefile.PL && make && make install && perl postinst.pl --nowizard --remove-old-linux-agent --server=https://your_OCSNG-Server_IP/ocsinventory --crontab --tag=$tag --debug --logfile=/etc/ocsinventory-agent/ocs.log --ca=/etc/ocsinventory-agent/cacert.pem --snmp --now
grep Cannot  /etc/ocsinventory-agent/ocs.log > /dev/null 2>&1
stat2=`echo $?`
else
    clear
    echo "warning:Dependency relationship No solution ."
    exit 2
fi


# set for cron *********************************************************
if [ $stat2 -ne 0 ] ;then
clear
echo  "install ocsinventory-agent  Successful !"
sleep 2
# modify ocsNG agent conf.file debug=0
sed -i "s#debug=1#debug=0#g" /etc/ocsinventory-agent/ocsinventory-agent.cfg


a=`date +%M`
b=`echo "$a"|bc`
sed -i '2d' /etc/cron.d/ocsinventory-agent
echo "$b */$time3 * * * root /usr/local/bin/ocsinventory-agent --lazy > /dev/null 2>&1" >> /etc/cron.d/ocsinventory-agent
stat3=`echo $?`
  if [ $stat3 -eq 0 ] ;then
    if [ $OS -eq 2 ] ;then #debian
    /etc/init.d/cron restart
    stat4=`echo $?`
    fi

    if [ $OS -eq 1 ] ;then #redHat
    service crond reload
    stat4=`echo $?`
    fi
  fi
else
    clear
    date
    echo "Warning:install error ,please try again  [ ./install.sh ]"
    exit 2
fi

if [ $stat4 -eq 0 ] ;then
clear
echo "your machine TAG :$tag"
grep debug=0 /etc/ocsinventory-agent/ocsinventory-agent.cfg
echo -en "install ocsinventory-agent Successful!\n\nThe current time: "
tail -n 1 /etc/cron.d/ocsinventory-agent | cut -d " "  -f1
else
    clear
    echo "Warning:cron error "
    exit 2
   
fi



=======一键自动化安装脚本结束==============================================




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-101866-1-1.html 上篇帖子: linux 下/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 干啥的 下篇帖子: centOS建立bind服务,做为内网DNS解析服务安装记录 linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表