Never let your sense of morals prevent you from doing what is right.

20,479 点击次数

HP-UX安装配置net-snmp

由于工作原因,要开启HP-UX的SNMP,网上资料很少,东拼西凑的整理了以下最实用的,方便大家使用。

1.查看SNMP版本。

test#[/]swlist -l product | grep -i snmp
OVSNMPAgent           B.11.23        HP-UX_SNMP_Agent_Product

2.禁用并停止系统自带snmp。

test#[/etc/rc.config.d]ll
-rwxr-xr-x   1 bin        bin           2206 Apr  11 08:54 SnmpHpunix
-r--r--r--     1 bin        bin           2201 Mar 26  2008 SnmpIpv6
-rwxr-xr-x   1 bin        bin           1720 Apr  11 08:54 SnmpMaster
-r--r--r--     1 bin        bin           2272 Sep  3  2003 SnmpMib2
-r--r--r--     1 bin        bin           1441 Mar 26  2008 SnmpNaa
-r--r--r--     1 bin        bin           1485 Sep  3  2003 SnmpTrpDst

修改SnmpHpunix和SnmpMaster这两个文件,把其中的1分别改为0,并保存。

SNMP_HPUNIX_START=1
SNMP_MASTER_START=1

停掉snmp的所有子进程:

/sbin/rc2.d/S576SnmpFddi4 stop
/sbin/rc2.d/S566cmsnmpagt stop
/sbin/rc2.d/S565SnmpTrpDst stop
/sbin/rc2.d/S565SnmpNaa stop
/sbin/rc2.d/S565SnmpMib2 stop
/sbin/rc2.d/S565SnmpIpv6 stop
/sbin/rc2.d/S565SnmpHpunix stop
/sbin/rc2.d/S560SnmpMaster stop

3.确定HP-UX系统版本,然后下载相关net-snmp包。

test#[/]uname –a
HP-UX test B.11.23 U ia64 3446788558 unlimited-user license

在HP官网上找到操作系统版本对应的depot包,选择下载internet这个bundle(需要注册):

https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPUXIEXP1123

4.用ftp方式把depot包导入到/tmp文件夹下,开始安装:

test#[/]swinstall -s /tmp/internet_A.16.00-001_HP-UX_B.11.23_IA_PA.depot

回车出现图形界面

回车,向下找到net-snmp,空格选中

Shift+Tab键–Actions–Install–回车

logfile–回车–Shift+Tab–OK–回车–返回上–界面

Shift+Tab–OK–等待安装完成–Shift+tab–DONE

找到net-snmp的安装路径:

test#[/] swlist -l fileset | grep -i net-snmp

找到路径是在/opt/iexpress/net-snmp,于是修改/opt/iexpress/net-snmp/etc/下的EXAMPLE.conf,修改完后重命名为snmpd.conf,放到路径/opt/iexpress/net-snmp/etc/snmp下。

Test#cp EXAMPLE.conf /opt/iexpress/net-snmp/etc/snmp/snmpd.conf

或执行vi snmpd.conf,并将如下内容复制过来:

com2sec local    localhost      public
com2sec mynetwork        <Your SNMP Poller IP Address>        public
group    MyROGroup       v2c  local
group    MyROGroup       v2c  mynetwork
view       all   included      .1    80
access   MyROGroup       ""    any noauth  exact     all   none     none
syslocation  Right here, right now.
syscontact   Me  <me@somewhere.org>
proc mountd
proc ntalkd 4
proc sendmail 10 1
exec echotest /bin/echo hello world
disk /10000
load 12 14 14

启动net-snmp:

test#[/opt/iexpress/net-snmp/sbin]./snmpd

5.设置设置设置设置net-snmp开机自启动,建立net-snmp启动脚本:

test#[/] vi /tmp/snmpd
snmpd=1
test#[/] cp /tmp/snmpd /etc/rc.config.d/
test#[/] chmod 444 /etc/rc.config.d/snmpd

建立启动snmpd的Shell脚本文件:

test#[/] vi /tmp/snmpdsh

内容如下:

################################################
# more snmpd
#!/sbin/sh
case $1 in
'start_msg')
echo "Start snmpd"
;; 'stop_msg')
echo "Stop snmpd"
;; 'start')
        if [ -f /etc/rc.config.d/snmpd ] ; then
                . /etc/rc.config.d/snmpd
        else
                echo "ERROR: /etc/rc.config.d/snmpd defaults file MISSING"
        fi
/opt/iexpress/net-snmp/sbin/snmpd
;;
'stop')
pwd
;;
*)
echo "usage: $0 {start|stop}"
;;
esac
exit

进一步的关联操作:

test#[/] cp /tmp/snmpdsh /sbin/init.d
test#[/] chmod 555 /sbin/init.d/snmpdsh
test#[/] ln -s /sbin/init.d/snmpdsh /sbin/rc2.d/S790snmpd
test#[/] ln -s /sbin/init.d/snmpdsh /sbin/rc1.d/K210snmpd

以上。

 

如果觉得文章对您有帮助,欢迎打赏支持作者:

WeChat
微信扫一扫
Alipay
支付宝扫一扫

487 点击次数

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注