started to build script
This commit is contained in:
parent
0b71b95a74
commit
76aab575ce
12
howTo.txt
12
howTo.txt
|
@ -72,12 +72,12 @@ systemctl start snmpd
|
||||||
nano /etc/firewalld/services/snmp.xml
|
nano /etc/firewalld/services/snmp.xml
|
||||||
|
|
||||||
# Paste the below in the file
|
# Paste the below in the file
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<service>
|
||||||
SNMP
|
<short>SNMP</short>
|
||||||
SNMP protocol
|
<description>SNMP protocol</description>
|
||||||
|
<port protocol="udp" port="161"/>
|
||||||
|
</service>
|
||||||
|
|
||||||
firewall-cmd --reload
|
firewall-cmd --reload
|
||||||
|
|
||||||
|
|
53
install.sh
53
install.sh
|
@ -1,17 +1,29 @@
|
||||||
### SNMPWALK HELP ####
|
# SNMPD install script
|
||||||
snmpwalk -v2c -c rouser987 ip_hostname
|
|
||||||
snmpwalk -v3 -l authPriv -u rouser987 -a SHA -A "pass1" -x AES -X "pass2" ip_hostname
|
|
||||||
|
|
||||||
|
OSID=$(awk -F= '/^ID=/{print $2}' /etc/os-release | sed 's/"//g')
|
||||||
|
|
||||||
|
|
||||||
|
### SNMPWALK HELP ####
|
||||||
|
# Usefull for testing
|
||||||
|
#snmpwalk -v2c -c rouser987 ip_hostname
|
||||||
|
#snmpwalk -v3 -l authPriv -u rouser987 -a SHA -A "pass1" -x AES -X "pass2" ip_hostname
|
||||||
|
|
||||||
|
if [[ OSID == "centos" ]]; then
|
||||||
# IF USING CENTOS
|
# IF USING CENTOS
|
||||||
yum install -y net-snmp
|
yum install -y net-snmp
|
||||||
|
systemctl start snmpd
|
||||||
|
elif [[ OSID == "debian" ]]; then
|
||||||
# IF USING DEBIAN
|
# IF USING DEBIAN
|
||||||
apt install -y snmpd
|
apt install -y snmpd
|
||||||
|
fi
|
||||||
|
|
||||||
systemctl start snmpd
|
# Stop snmpd so we can do our config
|
||||||
systemctl stop snmpd
|
systemctl stop snmpd
|
||||||
|
|
||||||
|
# enable it so it will work on startup
|
||||||
systemctl enable snmpd
|
systemctl enable snmpd
|
||||||
|
|
||||||
|
# Make config changes
|
||||||
cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
|
cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
|
||||||
echo "" > /etc/snmp/snmpd.conf
|
echo "" > /etc/snmp/snmpd.conf
|
||||||
curl -o /etc/snmp/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
|
curl -o /etc/snmp/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
|
||||||
|
@ -19,6 +31,7 @@ chmod +x /etc/snmp/distro
|
||||||
nano /etc/snmp/snmpd.conf
|
nano /etc/snmp/snmpd.conf
|
||||||
|
|
||||||
|
|
||||||
|
cat <<EOF > /etc/snmp/snmpd.conf
|
||||||
# IF SERVER REMOTE #
|
# IF SERVER REMOTE #
|
||||||
agentaddress udp:16161
|
agentaddress udp:16161
|
||||||
|
|
||||||
|
@ -26,7 +39,7 @@ rouser rouser987
|
||||||
|
|
||||||
syslocation VMENV | LOCATION
|
syslocation VMENV | LOCATION
|
||||||
syscontact EMAIL
|
syscontact EMAIL
|
||||||
sysname CHANGENAMEHERE
|
#sysname CHANGENAMEHERE
|
||||||
|
|
||||||
#Distro Detection
|
#Distro Detection
|
||||||
extend .1.3.6.1.4.1.2021.7890.1 distro /etc/snmp/distro
|
extend .1.3.6.1.4.1.2021.7890.1 distro /etc/snmp/distro
|
||||||
|
@ -35,7 +48,9 @@ extend .1.3.6.1.4.1.2021.7890.2 hardware '/bin/cat /sys/devices/virtual/dmi/id/p
|
||||||
extend .1.3.6.1.4.1.2021.7890.3 manufacturer '/bin/cat /sys/devices/virtual/dmi/id/sys_vendor'
|
extend .1.3.6.1.4.1.2021.7890.3 manufacturer '/bin/cat /sys/devices/virtual/dmi/id/sys_vendor'
|
||||||
#extend .1.3.6.1.4.1.2021.7890.4 serial '/bin/cat /sys/devices/virtual/dmi/id/product_serial'
|
#extend .1.3.6.1.4.1.2021.7890.4 serial '/bin/cat /sys/devices/virtual/dmi/id/product_serial'
|
||||||
# END REMOTE
|
# END REMOTE
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF > /etc/snmp/snmpd.conf
|
||||||
# IF SERVER LOCAL #
|
# IF SERVER LOCAL #
|
||||||
agentaddress udp:161
|
agentaddress udp:161
|
||||||
|
|
||||||
|
@ -43,7 +58,7 @@ rouser rouser987
|
||||||
|
|
||||||
syslocation VMENV | LOCATION
|
syslocation VMENV | LOCATION
|
||||||
syscontact EMAIL
|
syscontact EMAIL
|
||||||
sysname CHANGENAMEHERE
|
#sysname CHANGENAMEHERE
|
||||||
|
|
||||||
#Distro Detection
|
#Distro Detection
|
||||||
extend .1.3.6.1.4.1.2021.7890.1 distro /etc/snmp/distro
|
extend .1.3.6.1.4.1.2021.7890.1 distro /etc/snmp/distro
|
||||||
|
@ -52,19 +67,16 @@ extend .1.3.6.1.4.1.2021.7890.2 hardware '/bin/cat /sys/devices/virtual/dmi/id/p
|
||||||
extend .1.3.6.1.4.1.2021.7890.3 manufacturer '/bin/cat /sys/devices/virtual/dmi/id/sys_vendor'
|
extend .1.3.6.1.4.1.2021.7890.3 manufacturer '/bin/cat /sys/devices/virtual/dmi/id/sys_vendor'
|
||||||
#extend .1.3.6.1.4.1.2021.7890.4 serial '/bin/cat /sys/devices/virtual/dmi/id/product_serial'
|
#extend .1.3.6.1.4.1.2021.7890.4 serial '/bin/cat /sys/devices/virtual/dmi/id/product_serial'
|
||||||
# END LOCAL
|
# END LOCAL
|
||||||
|
OEF
|
||||||
|
|
||||||
|
if [[ "${OSID}" == "centos" ]]; then
|
||||||
# no longer needed, replaced with the below
|
|
||||||
## nano /var/lib/net-snmp/snmpd.conf
|
|
||||||
|
|
||||||
# no longer needed, replaced with the below
|
|
||||||
## createUser rouser987 SHA "rd1" AES "password2"
|
|
||||||
|
|
||||||
# IF USING CENTOS This creates a random password1 and password 2. I like to log the output somewhere that way I have the info if I need it later #
|
# IF USING CENTOS This creates a random password1 and password 2. I like to log the output somewhere that way I have the info if I need it later #
|
||||||
echo "createUser rouser987 SHA \""$(tr -cd '[:alnum:]' < /dev/urandom | fold -w50 | head -n1)"\" AES \""$(tr -cd '[:alnum:]' < /dev/urandom | fold -w50 | head -n1)"\"" | tee -a /var/lib/net-snmp/snmpd.conf
|
echo "createUser rouser987 SHA \""$(tr -cd '[:alnum:]' < /dev/urandom | fold -w50 | head -n1)"\" AES \""$(tr -cd '[:alnum:]' < /dev/urandom | fold -w50 | head -n1)"\"" | tee -a /var/lib/net-snmp/snmpd.conf
|
||||||
|
elif [[ "${OSID}" == "debian" ]]; then
|
||||||
# IF USING DEBIAN This creates a random password1 and password 2. I like to log the output somewhere that way I have the info if I need it later #
|
# IF USING DEBIAN This creates a random password1 and password 2. I like to log the output somewhere that way I have the info if I need it later #
|
||||||
echo "createUser rouser987 SHA \""$(tr -cd '[:alnum:]' < /dev/urandom | fold -w50 | head -n1)"\" AES \""$(tr -cd '[:alnum:]' < /dev/urandom | fold -w50 | head -n1)"\"" | tee -a /var/lib/snmp/snmpd.conf
|
echo "createUser rouser987 SHA \""$(tr -cd '[:alnum:]' < /dev/urandom | fold -w50 | head -n1)"\" AES \""$(tr -cd '[:alnum:]' < /dev/urandom | fold -w50 | head -n1)"\"" | tee -a /var/lib/snmp/snmpd.conf
|
||||||
|
if
|
||||||
|
|
||||||
systemctl start snmpd
|
systemctl start snmpd
|
||||||
|
|
||||||
#### IF THERE'S FIREWALL-CMD ####
|
#### IF THERE'S FIREWALL-CMD ####
|
||||||
|
@ -72,11 +84,12 @@ systemctl start snmpd
|
||||||
nano /etc/firewalld/services/snmp.xml
|
nano /etc/firewalld/services/snmp.xml
|
||||||
|
|
||||||
# Paste the below in the file
|
# Paste the below in the file
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<service>
|
||||||
SNMP
|
<short>SNMP</short>
|
||||||
SNMP protocol
|
<description>SNMP protocol</description>
|
||||||
|
<port protocol="udp" port="161"/>
|
||||||
|
</service>
|
||||||
|
|
||||||
|
|
||||||
firewall-cmd --reload
|
firewall-cmd --reload
|
||||||
|
|
Loading…
Reference in New Issue