OpenSolaris net-snmp install script
Posted by 4Aiur on 12/16/2010 in OpenSolaris | ∞
OpenSolaris net-snmp install script
#!/bin/bash
# OpenSolaris net-snmp installer
# Created by 4Aiur on 2010-12-14.
# define function
check_netsnmp_config () {
if [ ! -f /var/net-snmp/snmpd.local.conf ]; then
cat > /var/net-snmp/snmpd.local.conf
###############################################################################
# Process checks.
# Make sure sshd is running
proc sshd
###############################################################################
# disk checks
# disk PATH [MIN=DEFDISKMINIMUMSPACE]
# Check the / partition and make sure it contains at least 20 percent.
disk / 20%
###############################################################################
# load average checks
# load [1MAX=DEFMAXLOADAVE] [5MAX=DEFMAXLOADAVE] [15MAX=DEFMAXLOADAVE]
load 12 14 14
###############################################################################
# Executables/scripts
# exec NAME PROGRAM [ARGS ...]
exec echotest /bin/echo hello world
EOF
fi
chmod 600 /var/net-snmp/snmpd.local.conf
}
check_svc_netsnmp () {
if [ ! -f /var/svc/manifest/application/management/net-snmp.xml ]; then
cat > /var/svc/manifest/application/management/net-snmp.xml
net-snmp SNMP daemon
EOF
fi
}
# Check net-snmp package
if ! pkgin list | grep net-snmp >/dev/null; then
pkgin -y in net-snmp
fi
# Check directory
if [ ! -d /var/net-snmp/ ]; then
mkdir -p /var/net-snmp/
fi
# Check net-snmp config file.
check_netsnmp_config
# Check net-snmp service config
check_svc_netsnmp
# Import net-snmp.xml
if ! svcs -a | grep net-snmp >/dev/null; then
svccfg import /var/svc/manifest/application/management/net-snmp.xml
fi
svcadm enable net-snmp
sleep 3
echo "Install net-snmp done."
echo "check net-snmp log."
tail /var/svc/log/application-management-net-snmp:default.log
echo "lookup net-snmp listen port"
netstat -an -P udp | grep 161