[Xymon] Perl ipc and bsq option

Olivier AUDRY leo at minas.fr
Wed Jul 2 15:06:54 CEST 2014


hello

I'm trying to use the new Posix MQ feature of the lastest Xymon version
with devmon. The first step is talking to xymon with ipc in perl ...

So the fisrt step will be to find the correct msqid. As I understand the
C xymon code I wrote this. What is not working :(

#!/usr/bin/perl -w

use strict;
use IPC::SysV qw(IPC_RMID ftok);

#
my $MAXMSG_STATUS       = $ENV{'MAXMSG_STATUS'};
my $XYMONHOME           = $ENV{'XYMONHOME'};

defined ($XYMONHOME) || die "getting env failed: $!";
print "HOME : $XYMONHOME\n";

defined ($MAXMSG_STATUS) || die "getting env failed: $!";
print "MAX : $MAXMSG_STATUS\n";


my $key         = ftok($XYMONHOME, int($MAXMSG_STATUS));
defined ($key) || die "ftok failed: $!";
print "key $key\n";

my $id          = msgget($key, 0);
defined($id)    || die "msgget failed: $!";
print "id $id\n";

$key and $id are not the one that ipcs -q show me ...
[xymon devmon]$ perl     ipc.pl 
HOME : /opt/xymon/server
MAX : 256
key 11597
msgget failed: No such file or directory at ipc.pl line 23.
[xymon devmon]$ ipcs -q

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages    
0x000004d2 98306      root       666        0            0           
0x0a002d4d 229379     xymon      666        0            0   


So even I can find the msgid with perl let force it :

my $sent = "status coltmon-cf.ipcs  green test";
msgsnd(229379, $sent, 0) || die "msgsnd failed: $!";

And this is working well. 

So if someone knows how to get the correct way to get
the msgid in perl feel free to share :)

oau





More information about the Xymon mailing list