, Ippon, Powercom Krauler. Zabbix.
, 1) 2) , SNMP . serial , Ippon APC. APC SNMP , 11-20 . .
:
- ,
- , RS-232 , — zabbix_trapper.
- , , .
, /.
:
. , , DB9. , . F M , , , .
- Ippon Smart Winner 2000 back power pro, 2-2, 3-3, 5-5. , .
- Krauler Memo RT 2000 krauler.ru, 2-2,3-3, 5-5.
- Powercom SXL-2000A www.pcm.ru/data/docs/cables.zip, forum.pcm.ru. 2-9, 3-6, 5-7. (-).
. Vmware ESXi, . 2 . , , , . Zabbix . Ubuntu ( ) - .
: COM- ESXi -> Com- -> , -> zabbix trap. , . .
, , ( , rj-45 DB9), , , .
, , . Zabbix .
, , .
array=( $(/home/appliance/uniups) )
, MMM.M NNN.N PPP.P QQQ RR.R S.SS TT.T
#include <stdio.h> /* / */
#include <string>
#include <iostream>
#include <cstring>
using namespace std;
#include <unistd.h> /* UNIX */
#include <fcntl.h> /* */
#include <errno.h> /* */
#include <termios.h> /* POSIX- */
#include <sys/types.h>
#include <sys/stat.h>
int fd;
char buf[512];
int main (int argc, char* argv[])
{
int iIn,iOut;
string UPSAnswer;
if (argc>=2)
{
fd = open(argv[1], O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) {
printf("error port\n");
perror("open_port: Unable to open port - "); }
else
{
struct termios options;
tcgetattr(fd, &options);
cfsetispeed(&options, B2400);
cfsetospeed(&options, B2400);
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
tcsetattr(fd, TCSANOW, &options);
}
char Params[64];
if(argc>=3)
{
if (!strcmp(argv[2],"status"))
{
iOut = write(fd, "Q1\r", 3);
usleep(800000);
if (iOut < 0) fputs("write() of 4 bytes failed!\n", stderr);
iIn=read(fd,buf,250);
strncpy(Params,&buf[38],11);
Params[46]=0;
}
else if (!strcmp(argv[2],"help"))
{
printf (" . !\r\n");
}
else if (!strcmp(argv[2],"name"))
{
iOut = write(fd, "I\r", 3);
usleep(800000);
if (iOut < 0) fputs("write() of 4 bytes failed!\n", stderr);
iIn=read(fd,buf,250);
strncpy(Params,&buf[0],60);
}
else if (!strcmp(argv[2],"stat2"))
{
iOut = write(fd, "F\r", 3);
usleep(800000);
if (iOut < 0) fputs("write() of 4 bytes failed!\n", stderr);
iIn=read(fd,buf,250);
strncpy(Params,&buf[1],60);
Params[20]=0;
}
else
{
printf ("? \r\n");
}
}
else
{
usleep(1800);
iIn=read(fd,buf,250);
usleep(1800);
iOut = write(fd, "Q1\r", 3);
usleep(800000);
if (iOut < 0) fputs("write() of 4 bytes failed!\n", stderr);
iIn=read(fd,buf,250);
strncpy(Params,&buf[1],36);
Params[36]=' ';
}
close(fd);
printf("%s\r\n",Params);
}
else
printf("Usage %s /dev/ttySx", argv[0]);
}
, , . linux — . Ippon, Powercom , , PowerCom Megatec, «I» «F», «Q1». "/dev/ttyS0" "/dev/ttyS1" , , .
/home/appliance/ , uniups.cpp.
g++ -o uniups uniups.cpp
.
(, , )
root@zabbix:~
204.4 204.4 204.4 035 49.9 54.8 54.5
root@zabbix:~
I
root@zabbix:~
root@zabbix:~
216.3 216.3 216.3 000 50.0 54.2 30.0
root@zabbix:~
220.0 009 048.0 50.0
root@zabbix:~
, , , . 2400, 8N1, off. , Powercom, Ippon «I» , Krauler "# R1.1.1".
, Krauler , — ,
SS.S or S.SS For on-line units battery voltage/cell is provided in the form S.SS. For standby units actual battery voltage is provided in the form SS.S
. .
. zabbix_sender .
zabbix_sender -z _ -p 10051 -s ___ -k -o
, , , , Vmware .
zabbix_sender ,
Base64.
echo "<req>\n<host>S3JhdWxlck1lbW9SVDIwMDA=</host>\n<key>RnJlcQ==</key>\n<data>NDkuNA==</data>\n</req>\n" | nc -q 0 192.168.53.23 10051
192.168.53.23 — Zabbix. .
zabbix_sender.pl , :
use IO::Socket;
use IO::Select;
use MIME::Base64;
my ($zabbixserver,$hostname,$item,$data) = @_;
$zabbixserver= @ARGV[0];
$hostname= @ARGV[1];
$item= @ARGV[2];
$data= @ARGV[3];
my $timeout=10;
my $request=sprintf("<req>\n<host>%s</host>\n<key>%s</key>\n<data>%s</data>\n</req>\n",
encode_base64($hostname),encode_base64($item),encode_base64($data));
my $sock = new IO::Socket::INET ( PeerAddr => $zabbixserver, PeerPort => '10051', Proto => 'tcp', Timeout => $timeout);
die "Could not create socket: $!\n" unless $sock;
$sock->send($request);
my @handles=IO::Select->new($sock)->can_read($timeout);
if (scalar(@handles) > 0)
{
$sock->recv($result,1024);
print "answer from zabbix server $zabbixserver: $result\n";
}
else
{
print "no answer from zabbix server\n";
}
$sock->close();
Perl .
, Cron.
, . , 2 .
#!/bin/bash
array=( $(//uniups /dev/ttyS0) )
Names=( InVolt FaultVolt OutVolt Current Freq UBatt UTemp NA )
correct[5]="24.0"
j=0;
echo "Checking UPS on serial A - ${#array[@]}"
if [ ${#array[@]} -gt "7" ]
then
param=""
for i in "${array[@]}"
do
if [[ ${correct[$j]} ]]
then
param=$( echo "scale = 0; $i * ${correct[$j]}" | bc)
else.
param=$i
fi
//zabbix_sender.pl 192.168.53.23 KraulerMemoRT2000 ${Names[$j]} $param
j=$j+1;
done
else
echo "No data on A"
fi
:
- array — , , Names — Item, Zabbix . KraulerMemoRT2000 — , .
- , , Zabbix , , , NA, , , .
- ${#array[@]}, . , . : , , . , , . , , .
- correct[5]=«24.0» (5 ), (battery voltage/cell). 6 , 4 , 24. . , 48 . , , , .
cron . .
, . , - .