[racktables-users] Re: query fails after update
- From: Denis Ovsienko <pilot@xxxxxxxxxx>
- To: racktables-users@xxxxxxxxxxxxx
- Date: Thu, 11 Jun 2009 00:57:24 +0400
On Wed, 10 Jun 2009 15:54:24 +0200 Frank Altpeter wrote:
>
> Hi list,
>
> I just managed to finally update from 0.16.4 to 0.17.1, but I'm stuck with
> a little problem getting data from RackTables via script.
>
> I've built a nagios script which checks the presence of a monitored object
> and gets the uplink port(s). This used to work with 0.16.4 like this:
A quick fix is below.
>
> # How to query the uplink data from an oid - contains 1 %s for the oid
> my $uplinkquery = "SELECT Port.name AS Port_name, RemotePort.name AS
> RemotePort_name, RackObject.name AS RackObject_name FROM ( ( ( Port INNER
> JOIN Dictionary ON Port.type = dict_key NATURAL JOIN Chapter ) LEFT JOIN
JOIN Dictionary ON Port.type = dict_key ) LEFT JOIN
> Link ON Port.id=Link.porta OR Port.id=Link.portb ) LEFT JOIN Port AS
> RemotePort ON Link.portb=RemotePort.id OR Link.porta=RemotePort.id ) left
> JOIN RackObject ON RemotePort.object_id=RackObject.id where Chapter.name =
> 'PortType' AND Port.object_id=%s AND (Port.id != RemotePort.id OR
JOIN RackObject ON RemotePort.object_id=RackObject.id where
Port.object_id=%s AND (Port.id != RemotePort.id OR
> RemotePort.id is null) AND RemotePort.name IS NOT NULL AND ( Port.type =
> 24 OR RemotePort.type = 24 ) ORDER BY Port_name;";
I'd suggest replacing this call with one higher-level PHP function,
which will not break after one of upgrades.
Other related posts: