Giter VIP home page Giter VIP logo

snmp's People

Contributors

derdanilo avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

snmp's Issues

I Want write a Script to change to v1, v1+v2, v3, or v1+v2+v3, it is possible?

"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:

  1. SNMPv 1 only
  2. SNMPv 1 and SNMPv2 only
  3. SNMPv3 only
  4. SNMPv1, v2 and v3 (all
    *The parameters to SNMPv3 username and password can be entered by
    “hardcoded” variables in the script.
    **THE name of the writing and reading communities is your choice

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.