derdanilo / snmp Goto Github PK
View Code? Open in Web Editor NEWSNMPV3 Setup Scripts
License: MIT License
SNMPV3 Setup Scripts
License: MIT License
"help wanted"
I have this, which I took advantage of parts of your files to do, but I don't think it's quite correct, it's a college work, but I don't understand much about it, so if you could help me a little, giving it sometime.
My task is:
Develop a script "bash ” that allows protocol configuration
SNMP on a managed agent with the following options:
I don't know what to put in the options functions
#!/usr/bin/env bash
defaultsnmpuser=
monitoringhost="None"
hostnamevar=$(hostname -f)
myip=$(hostname -I)
# display usage if the script is not run as root user
if [[ $USER != "root" ]]; then
echo "This script must be run as root user!"
exit 1
else
echo "root user detected!!"
fi
x="first"
menu() {
while true $x != "first"; do
clear
echo "==================================================="
echo "Script"
echo "1) SNMPv1 Only"
echo "2) SNMPv1 e SNMPv2 Only"
echo "3) SNMPv3 Only"
echo "4) SNMPv1, v2, v3"
echo "5) Install snmp + snmpd + libsnmp-dev + libsnmp-perl + snmp-mibs-downloader"
echo "0) Exit"
echo "==================================================="
echo " "
echo "Choose Option: "
read x
echo "Option: ($x)"
echo "==================================================="
case "$x" in
1)
echo "SNMPv1"
#cod
#cod
sleep 2
echo "==================================================="
;;
2)
echo "SNMPv1 e SNMPv2"
#cod
#cod
sleep 2
echo "==================================================="
;;
3)
echo "SNMPv3"
#cod
echo Disable SNMP V1 and V2...
sed -i '/.*rocommunity.*/c\#rocommunity STRINGCLEARBYSCRIPT' /etc/snmp/snmpd.conf
sed -i '/.*trapsink.*/c\#trapsink STRINGCLEARBYSCRIPT' /etc/snmp/snmpd.conf
echo -e
echo Enter SNMPv3 Username:
read defaultsnmpuser
if ! [ -z ${defaultsnmpuser+x} ]; then
echo SNMPv3 User set to $defaultsnmpuser
fi
echo Creating SNMP V3 user
echo "net-snmp-create-v3-user -ro -A <Passwort> -X <Encryption Key> -a SHA -x AES <Benutzer>"
passwortsnmp=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 21 | head -n 1)
keysnmp=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 26 | head -n 1)
if net-snmp-create-v3-user -ro -A $passwortsnmp -X $keysnmp -a SHA -x AES $defaultsnmpuser; then
echo "net-snmp-create-v3-user -ro -A $passwortsnmp -X $keysnmp -a SHA -x AES $defaultsnmpuser"
else
net-snmp-config --create-snmpv3-user -ro -A $passwortsnmp -X $keysnmp -a SHA -x AES $defaultsnmpuser
echo "net-snmp-config --create-snmpv3-user -ro -A $passwortsnmp -X $keysnmp -a SHA -x AES $defaultsnmpuser"
fi
echo -e
#cod
sleep 2
echo "==================================================="
;;
4)
echo "SNMPv1, v2, v3"
#cod
#cod
sleep2
echo "==================================================="
;;
5)
echo "Installing packages SNMP"
sudo apt update
sudo apt -y upgrade
sudo apt -y install snmp snmpd libsnmp-dev libsnmp-perl snmp-mibs-downloader
sleep 3
echo Starting snmpd service
/etc/init.d/snmp start
/etc/init.d/snmpd start
sleep 5
echo -e
sleep 5
echo "==================================================="
;;
0)
echo "Exiting..."
sleep 3
clear
exit
echo "==================================================="
;;
*)
echo "Not an Option!!"
;;
esac
done
}
menu
#used to example:
sudo sed -i 's/^mibs\ :/mibs\ +ALL/g' /etc/snmp/snmp.conf
sudo sed -i 's/^#mibs\ :/mibs\ +ALL/g' /etc/snmp/snmp.conf
sudo sed -i 's/^agentaddress/#agentaddress/g' /etc/snmp/snmpd.conf
sudo sed -i '/#agentaddress\ \ 127.0.0.1\,\[::1\]/a agentAddress\ udp:161\,udp6:\[::1\]:161' /etc/snmp/snmpd.conf
sudo sed -i 's/^rocommunity/#rocommunity/g' /etc/snmp/snmpd.conf
sudo sed -i '/^#rocommunity6/a rocommunity public \nrocommunity6 public \nrwcommunity private \nrwcommunity6 private' /etc/snmp/snmpd.conf
sudo service snmpd restart
#Must verify the ip address size
MYIP=$(ip a | grep "brd" | grep "inet " | cut -b 9-24)
snmpwalk -c public -v1 $MYIP system
sudo snmptranslate -Tp
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.