SQL Help

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Moderators, Developers

Post Reply
Author
Message
Deano
Cacti User
Posts: 101
Joined: Wed Oct 29, 2003 7:08 am
Contact:

SQL Help

#1 Post by Deano » Tue Nov 10, 2009 3:23 pm

I'm creating a script to bulk load switch ports into the tree. I grabbed this line from Gandalf's add_linux_host script. I can drive the cacti cli ok but I need to amned this line...

$status = array_rekey(db_fetch_assoc("select snmp_index from host_snmp_cache where host_id = $host_id and field_name ='ifOperStatus' and field_value='Up' order by CAST(snmp_index AS UNSIGNED)"),"snmp_index","snmp_index");

I would like to do the same thing (i..e fill an array with valid interfaces) - but have an array of interfaces but with "ifName" rather than "ifindex". I can then search that array easily and add matching interfaces I want ("vlan xxx" or "Gig1/x" etc. I dont want to check for ifindex - just have all interfaces for that host in an array of "ifname"s

Can anyone help with the relevant sql line ?

User avatar
gandalf
Developer
Posts: 22375
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

#2 Post by gandalf » Wed Nov 11, 2009 1:02 am

I won't support my old script anymore Please have a look at the Autom8 plugin. That allows for a quite huge flexibility.
R.

Deano
Cacti User
Posts: 101
Joined: Wed Oct 29, 2003 7:08 am
Contact:

#3 Post by Deano » Wed Nov 11, 2009 5:23 am

Ok - I'll take a look at the plugin. In the immediate term I have my script now doing what I need to initially bulk load certain ports with...

$if = "Te1/";
$status = array_rekey(db_fetch_assoc("select field_value from host_snmp_cache where host_id = $host_id and field_name ='ifName' and field_value like 'if%' order by CAST(snmp_index AS UNSIGNED)"),"field_value","field_value");

Post Reply