Install zabbix server
Install software
portmaster -d net-mgmt/zabbix6-server net-mgmt/zabbix6-agent
Config
cp /usr/local/etc/zabbix6/zabbix_server.conf.sample /usr/local/etc/zabbix6/zabbix_server.conf
cp /usr/local/etc/zabbix6/zabbix_agentd.conf.sample /usr/local/etc/zabbix6/zabbix_agentd.conf
vi /usr/local/etc/zabbix6/zabbix_server.conf
DBHost=192.168.222.32
DBName=zabbix
DBUser=zabbix
DBPassword=39zabbix
DBPort=5432
#for localhost
#DBSocket=/tmp
StartProxyPollers=3
ProxyConfigFrequency=300
CacheSize=512M
HistoryCacheSize=512M
TrendCacheSize=256M
ValueCacheSize=512M
Adjust sysctl
vi /etc/sysctl.conf
#All shared memory no more than 8G
kern.ipc.shmall=2097152
#Shared memory no more that 512M
kern.ipc.shmmax=536870912
Start zabbix server
vi /etc/rc.conf
zabbix_server_enable="YES"
zabbix_agentd_enable="YES"
service zabbix_server start
service zabbix_agentd start
Set up SNMP trap
Perl trap convertor
vi /usr/local/etc/zabbix6/zabbix_server.conf
StartSNMPTrapper=1
SNMPTrapperFile=/tmp/zabbix_traps.tmp
Downlaod trap convertor
curl "https://git.zabbix.com/projects/ZBX/repos/zabbix/raw/misc/snmptrap/zabbix_trap_receiver.pl" > /tmp/zabbix_trap_receiver.pl
chmod +x /tmp/zabbix_trap_receiver.pl
Fix some script
# print the PDU info
print OUTPUT_FILE "PDU INFO:\n";
foreach my $key ( reverse sort keys(%pdu_info) ) {
next if ( $key eq "community" );
next if ( $key eq "receivedfrom" );
if ( $pdu_info{$key} !~ /^[[:print:]]*$/ ) {
my $OctetAsHex =
unpack( 'H*', $pdu_info{$key} ); # convert octet string to hex
$pdu_info{$key} = "0x$OctetAsHex"; # apply 0x prefix for consistency
}
printf OUTPUT_FILE " %-20s %s\n", $key, $pdu_info{$key};
}
foreach my $x (@varbinds) {
printf OUTPUT_FILE " %s type=%d value=%s\n", $x->[0], $x->[2], $x->[1];
}
Config trapd
mkdir /usr/local/etc/snmp/
vi /usr/local/etc/snmp/snmptrapd.conf
authCommunity execute public
perl do "/tmp/zabbix_trap_receiver.pl";
Edit new syslogd vi /usr/local/etc/newsyslog.conf.d/zbx_trap.conf
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/tmp/zabbix_traps.tmp 644 0 100 * J /var/run/snmptrapd.pid
vi /etc/rc.conf
snmptrapd_enable="YES"
service snmptrapd start
Test send trap
snmptrap -v 1 -c kryptr0x 127.0.0.1 '.1.3.6.1.6.3.1.1.5.4' '0.0.0.0' 6 33 '55' .1.3.6.1.6.3.1.1.5.4 s "eth0"