Send Netdot-devel mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Netdot-devel digest..."
Today's Topics:
1. Re: Exporter.pm Pg compat patch (Karl Putland)
----------------------------------------------------------------------
Message: 1
Date: Thu, 13 Sep 2012 09:56:25 -0600
From: Karl Putland <[email protected]>
Subject: Re: [Netdot-devel] Exporter.pm Pg compat patch
To: Carlos Vicente <[email protected]>
Cc: [email protected]
Message-ID:
<ca+exwsztzyai0b+grq+jcvl_ar8dq7m27g-rxfps6tejqvw...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Sorry... There was a problem with the other patch. It never entered the Pg
branch because of a typo... This works now.
Reference for boolean comparison in Pg
http://www.postgresql.org/docs/9.0/static/datatype-boolean.html
--Karl
--- Netdot.orig/Exporter.pm 2012-08-22 20:22:42.175837081 +0000
+++ Netdot/Exporter.pm 2012-09-13 15:50:18.111837447 +0000
@@ -58,6 +58,7 @@
}
$self->{_dbh} = Netdot::Model->db_Main();
+ $self->{_db_type} = Netdot::Model->config->get('DB_TYPE');
return $self;
}
@@ -73,30 +74,54 @@
=cut
sub get_device_info {
my ($self) = @_;
+ my $SQL = "";
return $self->cache('exporter_device_info') if
$self->cache('exporter_device_info');
my %device_info;
$logger->debug("Netdot::Exporter::get_device_info: querying database");
- my $rows = $self->{_dbh}->selectall_arrayref("
- SELECT d.id, d.snmp_managed, d.community,
- d.down_from, d.down_until, entity.name,
contactlist.id,
- target.id, target.address, target.version,
target.parent, rr.name, zone.name,
- i.id, i.number, i.admin_status, i.monitored,
i.contactlist,
- bgppeering.bgppeeraddr, bgppeering.monitored
- FROM rr, zone, interface i, device d
- LEFT JOIN ipblock target ON d.snmp_target=target.id
- LEFT JOIN entity ON d.used_by=entity.id
- LEFT JOIN devicecontacts ON d.id=devicecontacts.device
- LEFT JOIN contactlist ON contactlist.id
=devicecontacts.contactlist
- LEFT JOIN bgppeering ON d.id=bgppeering.device
- WHERE d.monitored=1
- AND i.device=d.id
- AND d.name=rr.id
- AND rr.zone=zone.id
- ");
+ if ($self->{_db_type} eq "mysql") {
+ $SQL = " SELECT d.id, d.snmp_managed, d.community,
+ d.down_from, d.down_until, entity.name, contactlist.id,
+ target.id, target.address, target.version, target.parent, rr.name,
zone.name,
+ i.id, i.number, i.admin_status, i.monitored, i.contactlist,
+ bgppeering.bgppeeraddr, bgppeering.monitored
+ FROM rr, zone, interface i, device d
+ LEFT JOIN ipblock target ON d.snmp_target=target.id
+ LEFT JOIN entity ON d.used_by=entity.id
+ LEFT JOIN devicecontacts ON d.id=devicecontacts.device
+ LEFT JOIN contactlist ON contactlist.id=devicecontacts.contactlist
+ LEFT JOIN bgppeering ON d.id=bgppeering.device
+ WHERE d.monitored=1
+ AND i.device=d.id
+ AND d.name=rr.id
+ AND rr.zone=zone.id
+ ";
+ } elsif($self->{_db_type} eq "Pg") {
+ $SQL = "SELECT d.id, d.snmp_managed, d.community,
+ d.down_from, d.down_until, entity.name, contactlist.id,
+ target.id, target.address, target.version, target.parent, rr.name,
zone.name,
+ i.id, i.number, i.admin_status, i.monitored, i.contactlist,
+ bgppeering.bgppeeraddr, bgppeering.monitored
+ FROM rr, zone, interface i, device d
+ LEFT JOIN ipblock target ON d.snmp_target=target.id
+ LEFT JOIN entity ON d.used_by=entity.id
+ LEFT JOIN devicecontacts ON d.id=devicecontacts.device
+ LEFT JOIN contactlist ON contactlist.id=devicecontacts.contactlist
+ LEFT JOIN bgppeering ON d.id=bgppeering.device
+ WHERE d.monitored=TRUE
+ AND i.device=d.id
+ AND d.name=rr.id
+ AND rr.zone=zone.id
+ ";
+ }
+
+ $logger->debug("Netdot::Exporter::get_device_info: SQL:\n".$SQL);
+
+ my $rows = $self->{_dbh}->selectall_arrayref($SQL);
$logger->debug("Netdot::Exporter::get_device_info: building data
structure");
+ $logger->debug("Netdot::Exporter::get_device_info: processing
".$rows." rows");
foreach my $row ( @$rows ){
my ($devid, $devsnmp, $community,
$down_from, $down_until, $entity, $clid,
--Karl
Karl Putland
Senior VoIP Engineer
*SimpleSignal*
3600 S Yosemite, Suite 150
Denver, CO 80237
One Number Rings All My Phones: 303-242-8608
SimpleSignal.com <http://www.simplesignal.com/> |
Blog<http://www.simplesignal.com/blog>
| Facebook <http://www.facebook.com/SimpleSignal?ref=ts> |
Twitter<http://twitter.com/simplesignal>
On Wed, Sep 12, 2012 at 4:29 PM, Karl Putland <[email protected]> wrote:
> Exporter fails while using Pg.
> boolean to integer explicit cast required.
>
>
> > - WHERE d.monitored=1
>
>
> patch changes query for Pg to be
>
> > + WHERE d.monitored='true'
>
>
>
> --Karl
>
> Karl Putland
> Senior VoIP Engineer
>
> *SimpleSignal*
>
> 3600 S Yosemite, Suite 150
> Denver, CO 80237
> One Number Rings All My Phones: 303-242-8608
>
> SimpleSignal.com <http://www.simplesignal.com/> |
> Blog<http://www.simplesignal.com/blog>
> | Facebook <http://www.facebook.com/SimpleSignal?ref=ts> |
> Twitter<http://twitter.com/simplesignal>
>
>
>
> On Wed, Sep 12, 2012 at 4:05 PM, Carlos Vicente <[email protected]>wrote:
>
>> Karl,
>>
>> It would be useful if you explain what the patch is about.
>>
>> Thanks,
>>
>> cv
>>
>> On 9/12/12 5:43 PM, Karl Putland wrote:
>> > --- Netdot.orig/Exporter.pm2012-08-22 20:22:42.175837081 +0000
>> > +++ Netdot/Exporter.pm2012-09-11 17:35:15.191837116 +0000
>> > @@ -58,6 +58,7 @@
>> > }
>> >
>> > $self->{_dbh} = Netdot::Model->db_Main();
>> > + $self->{_db_type} = Netdot::Model->config->get('DB_TYPE');
>> > return $self;
>> > }
>> >
>> > @@ -73,28 +74,49 @@
>> > =cut
>> > sub get_device_info {
>> > my ($self) = @_;
>> > + my $rows;
>> >
>> > return $self->cache('exporter_device_info')if
>> > $self->cache('exporter_device_info');
>> >
>> > my %device_info;
>> > $logger->debug("Netdot::Exporter::get_device_info: querying
>> database");
>> > - my $rows = $self->{_dbh}->selectall_arrayref("
>> > - SELECT d.id <http://d.id>, d.snmp_managed,
>> d.community,
>> > - d.down_from, d.down_until, entity.name
>> > <http://entity.name>, contactlist.id <http://contactlist.id>,
>> > - target.id <http://target.id>,
>> target.address,
>> > target.version, target.parent, rr.name <http://rr.name>, zone.name
>> > <http://zone.name>,
>> > - i.id <http://i.id>, i.number,
>> i.admin_status,
>> > i.monitored, i.contactlist,
>> > - bgppeering.bgppeeraddr, bgppeering.monitored
>> > - FROM rr, zone, interface i, device d
>> > - LEFT JOIN ipblock target ON d.snmp_target=target.id
>> > <http://target.id>
>> > - LEFT JOIN entity ON d.used_by=entity.id <
>> http://entity.id>
>> > - LEFT JOIN devicecontacts ON d.id
>> > <http://d.id>=devicecontacts.device
>> > - LEFT JOIN contactlist ON contactlist.id
>> > <http://contactlist.id>=devicecontacts.contactlist
>> > - LEFT JOIN bgppeering ON d.id
>> > <http://d.id>=bgppeering.device
>> > - WHERE d.monitored=1
>> > - AND i.device=d.id <http://d.id>
>> > - AND d.name <http://d.name>=rr.id <http://rr.id>
>> > - AND rr.zone=zone.id <http://zone.id>
>> > - ");
>> > + if ($self->{_db_type} eq "mysql") {
>> > +my $rows = $self->{_dbh}->selectall_arrayref("
>> > + SELECT d.id <http://d.id>, d.snmp_managed, d.community,
>> > + d.down_from, d.down_until, entity.name <http://entity.name>,
>> > contactlist.id <http://contactlist.id>,
>> > + target.id <http://target.id>, target.address, target.version,
>> > target.parent, rr.name <http://rr.name>, zone.name <http://zone.name>,
>> > + i.id <http://i.id>, i.number, i.admin_status, i.monitored,
>> > i.contactlist,
>> > + bgppeering.bgppeeraddr, bgppeering.monitored
>> > + FROM rr, zone, interface i, device d
>> > + LEFT JOIN ipblock target ON d.snmp_target=target.id <
>> http://target.id>
>> > + LEFT JOIN entity ON d.used_by=entity.id <http://entity.id>
>> > + LEFT JOIN devicecontacts ON d.id <http://d.id
>> >=devicecontacts.device
>> > + LEFT JOIN contactlist ON contactlist.id
>> > <http://contactlist.id>=devicecontacts.contactlist
>> > + LEFT JOIN bgppeering ON d.id <http://d.id>=bgppeering.device
>> > + WHERE d.monitored=1
>> > +AND i.device=d.id <http://d.id>
>> > +AND d.name <http://d.name>=rr.id <http://rr.id>
>> > +AND rr.zone=zone.id <http://zone.id>
>> > + ");
>> > + } elsif($self->{db_type} eq "Pg") {
>> > +my $rows = $self->{_dbh}->selectall_arrayref("
>> > + SELECT d.id <http://d.id>, d.snmp_managed, d.community,
>> > + d.down_from, d.down_until, entity.name <http://entity.name>,
>> > contactlist.id <http://contactlist.id>,
>> > + target.id <http://target.id>, target.address, target.version,
>> > target.parent, rr.name <http://rr.name>, zone.name <http://zone.name>,
>> > + i.id <http://i.id>, i.number, i.admin_status, i.monitored,
>> > i.contactlist,
>> > + bgppeering.bgppeeraddr, bgppeering.monitored
>> > + FROM rr, zone, interface i, device d
>> > + LEFT JOIN ipblock target ON d.snmp_target=target.id <
>> http://target.id>
>> > + LEFT JOIN entity ON d.used_by=entity.id <http://entity.id>
>> > + LEFT JOIN devicecontacts ON d.id <http://d.id
>> >=devicecontacts.device
>> > + LEFT JOIN contactlist ON contactlist.id
>> > <http://contactlist.id>=devicecontacts.contactlist
>> > + LEFT JOIN bgppeering ON d.id <http://d.id>=bgppeering.device
>> > + WHERE d.monitored='true'
>> > +AND i.device=d.id <http://d.id>
>> > +AND d.name <http://d.name>=rr.id <http://rr.id>
>> > +AND rr.zone=zone.id <http://zone.id>
>> > + ");
>> > + }
>> >
>> > $logger->debug("Netdot::Exporter::get_device_info: building data
>> > structure");
>> > foreach my $row ( @$rows ){
>> >
>> >
>> > --Karl
>> >
>> > Karl Putland
>> > Senior VoIP Engineer
>> >
>> > *SimpleSignal*
>> > 3600 S Yosemite, Suite 150
>> > Denver, CO 80237
>> > One Number Rings All My Phones: 303-242-8608
>> >
>> > SimpleSignal.com <http://www.simplesignal.com/> | Blog
>> > <http://www.simplesignal.com/blog> | Facebook
>> > <http://www.facebook.com/SimpleSignal?ref=ts> | Twitter
>> > <http://twitter.com/simplesignal>
>> >
>> >
>> >
>> > _______________________________________________
>> > Netdot-devel mailing list
>> > [email protected]
>> > https://osl.uoregon.edu/mailman/listinfo/netdot-devel
>> >
>>
>>
>> --
>> cv
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://osl.uoregon.edu/pipermail/netdot-devel/attachments/20120913/8131f392/attachment.html
------------------------------
_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
End of Netdot-devel Digest, Vol 66, Issue 11
********************************************