Skip to content

Instantly share code, notes, and snippets.

@MrXermon
Last active February 15, 2021 12:32
Show Gist options
  • Save MrXermon/694c0382a13056a358239020803c26b6 to your computer and use it in GitHub Desktop.
Save MrXermon/694c0382a13056a358239020803c26b6 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Author: Jan Gilla
# Company: level66.network UG (haftungsbeschränkt)
# Description: BASH script to install snmpd daemon on Debian/Ubuntu based linux systems, generate the configuration and reload the service by using systemd.
#
# Define variables here.
SNMPD_COMMUNITY=public
SNMPD_LOCATION="Milki Way"
SNMPD_CONTACT=test@example.com
# Do not change anything below here!
echo "Installing snmpd service via apt-get ..."
/usr/bin/apt-get update
/usr/bin/apt-get install snmpd lm-sensors --yes
echo "Deploy configuration to /etc/snmp/snmpd.conf ..."
cat <<EOF > /etc/snmp/snmpd.conf
# Listen on all ips
agentAddress udp:161,udp6:[::]:161
# Device information
syslocation $SNMPD_LOCATION
syscontact $SNMPD_CONTACT
# SNMPv2
rocommunity $SNMPD_COMMUNITY
rocommunity6 $SNMPD_COMMUNITY
EOF
echo "Restart snmpd service via systemd ..."
/usr/bin/systemctl restart snmpd.service
/usr/bin/systemctl status snmpd.service --plain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment