Net-SNMP是一个免费的、开放源码的SNMP实现,以前称为UCD-SNMP。SNMP 很多都用其安装之后,作为监控宝和阿里云的系统信息监控使用。下面就来分享linux下实现SNMP一键安装的shell脚本:
#!/usr/bin/env bash export LC_ALL=C if [ "$(id -u)" != "0" ] then echo "This script. must be run as root" 1>&2 exit 1 fi ####check if gcc perl perl-devel(centos) or libperl-dev(ubuntu) exists, APT_CMD=`whereis apt-get|awk '{print $2}'` YUM_CMD=`whereis yum|awk '{print $2}'` if [ "$APT_CMD"x != ""x ] then echo "$APT_CMD" cmd=`dpkg -l|grep gcc` if [ "$cmd"x = ""x ] then apt-get install -y gcc fi cmd=`dpkg -l|grep perl` if [ "$cmd"x = ""x ] then apt-get install -y perl fi cmd=`dpkg -l|grep "libperl-dev"` if [ "$cmd"x = ""x ] then apt-get install -y libperl-dev fi elif [ "$YUM_CMD"x != ""x ] then echo $YUM_CMD cmd=`rpm -q gcc|grep -v "not installed"` if [ "$cmd"x = ""x ] then yum install gcc -y 1>/dev/null 2>&1 fi cmd=`rpm -q perl|grep -v "not installed"` if [ "$cmd"x = ""x ] then yum install -y perl 1>/dev/null 2>&1 fi cmd=`rpm -q perl-devel|grep -v "not installed"` if [ "$cmd"x = ""x ] then yum install -y perl-devel 1>/devel/null 2>&1 fi else echo "your release have no yum or apt-get" fi function Usage() { echo "用法如下:(注意:2c版本密码必须大于6位,3版本密码必须大于8位)"; echo "" echo " $0 -v 版本号(2代表2C,3代表版本3) -u 用户名 -p 密码"; echo " $0 -v [2|3] -u username -p password"; echo ""; exit 0; } if [ $# -lt 1 ] then echo "请输入参数" Usage fi #####get parameters version=0 username="" password="" while getopts ":v:u:p:" opt; do case $opt in v) version=$OPTARG if [[ ${OPTARG:0:1} = "-" ]] then echo "" echo "-v need argument" echo "" Usage fi ;; u) username=$OPTARG if [[ ${OPTARG:0:1} = "-" ]] then echo "" echo "-u need argument" echo "" Usage fi ;; p) password=$OPTARG if [[ ${OPTARG:0:1} = "-" ]] then echo "" echo "-p need argument" echo "" Usage fi ;; :) Usage ;; "3" -a $version -ne "2" ] then Usage exit 3 fi if [ $version -eq "3" -a "$username"x = ""x ] then echo "版本3必须要输入用户名" Usage fi ###check password length, version 3 big then 8, version 2 big then 6 if [ "$version" -eq "3" ] then if [ ${#password} -lt "8" ] then echo "" echo "Your passwords must greater than 8 bytes" 1>&2 echo "" Usage fi else ########### version = 2 if [ ${#password} -lt "6" ] then echo "" echo "Your passwords must greater than 6 bytes" 1>&2 echo "" Usage fi fi wget http://download.cloud.360.cn/yjk/net-snmp.tar.gz tar zxvf net-snmp.tar.gz cd net-snmp-5.7.2 ./configure --prefix=/usr/local/snmp --with-mib-modules=ucd-snmp/diskio -enable-mfd-rewrites --with-default-snmp-version="$version" --with-sys-contact="@@no.where" --with-sys-location="Unknown" --with-logfile="/var/log/snmpd.log" --with-persistent-directory="/var/net-snmp" make make install case $version in 2) cat /usr/local/snmp/share/snmp/snmpd.conf << EOF rocommunity $password 101.199.100.150 rocommunity $password 220.181.150.98 rocommunity $password 180.153.229.230 rocommunity $password 220.181.150.125 rocommunity $password 103.28.10.223 EOF ;; 3) cat /usr/local/snmp/share/snmp/snmpd.conf << EOF rouser $username auth EOF # echo "createUser $2 MD5 $3" /var/net-snmp/snmpd.conf # cat /var/net-snmp/snmpd.conf << EOF #createUser $2 MD5 $3 #EOF ;; *) echo "Please check your input version" 1>&2 echo exit 1 ;; esac i=0 while [ $i -lt 5 ] do ret=`/usr/local/snmp/sbin/snmpd` ret=`ps aux | grep -v grep | grep snmp` if [ "$ret"x = ""x ] then ((i=i+1)) ret=`/usr/local/snmp/sbin/snmpd` else break fi done case $version in 3) echo "createUser $username MD5 $password" /var/net-snmp/snmpd.conf ;; esac pid=`ps -ef|grep snmpd|grep -v grep|awk '{print $2}'` echo "pid: $pid" if [ "$pid"x != ""x ] then kill -9 $pid /usr/local/snmp/sbin/snmpd else /usr/local/snmp/sbin/snmpd fi case $version in 3) cmd=`cat /var/net-snmp/snmpd.conf|grep "$username"` if [ "$cmd"x == ""x ] then pid=`ps -ef|grep snmpd|grep -v grep|awk '{print $2}'` if [ "$pid"x != ""x ] then kill -9 $pid echo "createUser $username MD5 $password" /var/net-snmp/snmpd.conf fi fi ;; esac ret=`ps -ef | grep -v grep | grep snmp` if [ "$ret"x != ""x ] then echo "snmp start success" echo else echo "snmp start failed" echo exit 4 fi echo "Finish..." echo exit 0
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年11月23日
2024年11月23日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]