snmp--CentOS安裝Net-SNMP小計
首先net-snmp是個軟體
然後我的目標是先安裝net-snmp到CentOS,再匯入python使用的netsnmp模組
即:
為最終目標
---------------------------------------------
從官網下載net-snmp的源碼,然後
./congficure
make
make install
值得講的是在CentOS安裝的時候會有一個錯誤:
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5/usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5.) at Makefile.PL line 1.BEGIN failed--compilation aborted at Makefile.PL line 1.make: *** [perlmakefiles] ERROR 2
我的解決方案是:
yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
--------------------------------
在make install完成之後直接:
cd python
python setup.py build
python setup.py test
這裡python setup.py build的時候,我的系統預設是python3.4,在build的時候出錯,(python2.7就不會出錯,看來3.4對縮排更加嚴格哦)
TabError: inconsistent use of tabs and spaces in indentation
然後去看setup.py檔案的時候發現有一行(14行)的縮排是tab而不是4空格,哈哈,這算bug嗎
然後python setup.py test的時候又出錯:
ImportError: libnetsnmp.so.30: cannot open shared object file: No such file or directory
因為net-snmp是我編譯安裝的,還是預設的,所以它的檔案是分散的,其中/usr/local/lib裡有一部分
找不到這部分是錯誤的原因,解決方案如下:
echo "/usr/local/netsnmp/lib" >> /etc/ld.so.confldconfig
然後
python setup.py install
安裝python模組,至此就會出線文章開頭那麼美妙的東西了
DONE.