Friday, June 28, 2013

Configuring SNMP on multiple Solaris 10 machines

There was a requirement to configure SNMP on dozens of Solaris 10 servers. I took one server, modified the /etc/sma/snmp/snmpd.conf file, tested it worked using snmpwalk, then wrote the following script to deploy that snmpd.conf as a template to every server in servers.list. Here's the script:

#!/bin/bash

for x in $(cat servers.list)
do
     echo "Server: $x"
     ssh root@${x} "mv /etc/sma/snmp/snmpd.conf /etc/sma/snmp/snmpd.orig"
     scp ./snmpd.conf root@${x}:/etc/sma/snmp/snmpd.conf
     ssh root@${x} "svcadm disable snmpdx; svcadm refresh snmpdx; svcadm enable sma; svcadm refresh sma; sleep 3; svcs -v sma"
done

No comments:

Post a Comment