SQL Help

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Developers, Moderators

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

SQL Help

Post by Deano »

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: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

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:

Post by Deano »

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

Who is online

Users browsing this forum: No registered users and 4 guests