Создаем такого содержания файл /usr/local/scripts/apcupsd-stats :
#!/usr/local/bin/perl -w # Copyright (C) 2009 Glen Pitt-Pladdy # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # # # See: http://www.pitt-pladdy.com/blog/_20100320-215243_0000_apcupsd_stats_on_Cacti_via_SNMP_/ # open AC, "/usr/local/sbin/apcaccess status localhost |" or die "FATAL: can't run \"/usr/local/sbin/apcaccess\": $!\n"; while ( defined ( $line = <AC> ) ) { chomp $line; if ( $line !~ /^(\w+)\s*:\s*([^\s]+)/ ) { next; } $field{$1} = $2; } close AC; print "$field{LINEV}\n"; print "$field{OUTPUTV}\n"; print "$field{LOTRANS}\n"; print "$field{HITRANS}\n"; print "$field{BATTV}\n"; print "$field{NOMBATTV}\n"; print "$field{BCHARGE}\n"; print "$field{TIMELEFT}\n"; print "$field{LOADPCT}\n"; print "$field{LINEFREQ}\n"; #print "$field{ITEMP}\n"; #print ''.($field{'NOMPOWER'}*$field{'LOADPCT'}/100)."\n"; #print "$field{NOMPOWER}\n"; #if ( $field{'STATUS'} eq 'ONLINE' ) { # print "100\n0\n"; #} else { # print "0\n100\n"; #}
Некоторые модели не показывают температуру, как, например 420, поӕтому строку с температурой комментируем :-)
#print "$field{ITEMP}\n";
Делаем скрипт исполняемым
chmod +x /usr/local/scripts/apcupsd-stats
В /usr/local/etc/snmp/snmpd.conf добавляем:
extend apcupsd /usr/local/scripts/apcupsd-stats
Перезапускаем snmpd
/usr/local/etc/rc.d/snmpd restart
В zabbix создаэм шаблон иои добавляем итемы напрямую хосту:
Имя: APC_BattCharge
Тип: SNMP agent
Ключ: nsExtendOutLine.apcupsd.7
SNMP OID: NET-SNMP-EXTEND-MIB::nsExtendOutLine."apcupsd".7
и т.д.