-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall_snmp.sh
94 lines (80 loc) · 3.25 KB
/
install_snmp.sh
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
#!/bin/sh
# If you update this from Windows, using Notepad ++, do the following:
# sudo apt-get -y install dos2unix
# dos2unix <FILE>
# chmod u+x <FILE>
#
clear
echo "
_____ _ _ _ _
| |___ ___ ___| |_ ___ _| | | |_ _ _ |_|
| --| _| -_| .'| _| -_| . | | . | | | _
|_____|_| |___|__,|_| |___|___| |___|_ | |_|
|___|
_____ _ _ _ _ _____ __ _____
| | |_ ___|_|___| |_ ___ ___| |_ ___ ___ | |__| | | __|___ ___ _ _
| --| | _| |_ -| _| . | . | | -_| _| | | | | | | | | | _| .'| | |
|_____|_|_|_| |_|___|_| |___| _|_|_|___|_| |_|_|_|_____| |_____|_| |__,|_ |
|_| |___|
\r\n \r\n
Version: 1.3.7
Last Updated: 8/11/2021
\r\n \r\n
#Updating system first..."
#sudo -E apt-get update
#wait
#sudo -E apt-get upgrade -y
wait
echo "Downloading required dependencies...\r\n\r\n"
#--------------------------------------------------------------------------------------------
rm snmpd.conf
wget https://raw.githubusercontent.com/c2theg/srvBuilds/master/configs/snmpd.conf
wait
chmod u+x snmpd.conf
wait
# python-smbus
sudo apt-get install -y unzip zip
sudo apt-get install -y libperl-dev snmp snmpd
wait
sudo apt-get install -y snmp-mibs-downloader
sudo download-mibs
#--- Sensors ---
sudo apt-get install -y lm-sensors fancontrol read-edid i2c-tools
sudo apt-get install -y rrdtool libi2c-dev librrds-perl
#-- VISIT http://www.net-snmp.org/download.html for the latest version --
#curl -O "net-snmp-5.8.tar.gz" "https://downloads.sourceforge.net/project/net-snmp/net-snmp/5.8/net-snmp-5.8.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fnet-snmp%2Ffiles%2Fnet-snmp%2F5.8%2Fnet-snmp-5.8.tar.gz%2Fdownload%3Fuse_mirror%3Dgigenet&ts=1587743687&use_mirror=gigenet"
#- couldn't get a direct download link to work, so mirror to my github account
wget https://github.com/c2theg/srvBuilds/raw/master/net-snmp-5.9.1.tar.gz
wait
tar -xvzf net-snmp-5.9.1.tar.gz
wait
mv net-snmp-5.9.1 net-snmp
wait
cd net-snmp
wait
./configure --with-default-snmp-version="2c" --with-sys-contact="admin@companyxyz.com" --with-sys-location="DC_Server1" --with-logfile="/var/log/snmpd.log" --with-persistent-directory="/var/net-snmp"
wait
make
wait
sudo make install
wait
snmpget --version
# Move Sample snmp.conf to the correct location
cd ..
cp snmpd.conf /etc/snmp/snmpd.conf
#-- fix, by default, snmpd is set to log at the DEBUG level which seems too intensive. ---
sudo sed -i "s|-Lsd|-LS4d|" /lib/systemd/system/snmpd.service
# tells Ubuntu to load SNMP MIB files:
sudo sed -i 's/mibs :/# mibs :/g' /etc/snmp/snmp.conf
#---------- Start Service --------------
wait
/etc/init.d/snmpd start
sudo systemctl daemon-reload
sudo systemctl restart snmpd.service
wait
service snmpd status
sudo netstat -ntlp
echo "DONE! \r\n \r\n"
echo "To edit, enter the following: \r\n"
echo "nano /etc/snmp/snmpd.conf"
echo "\r\n \r\n"