PDA

View Full Version : mdsquerydb / cpmiquerybin



jacobsen
2006-12-13, 14:38
Hi all,

today I was asked to run some queries on the firewall.
Because the dashboard seems not to be very useful for getting information like "show me the name, ipaddress and comments of all 'host_plain' objects, i looked around if these information can also be obtained via command line.
and yes it is.

I'd like to share my experience. might be helpful for some of you guys.

The script $MDSDIR/scripts/mdsquerydb takes some attributes, parses the preconfigured query file $MDSDIR/conf/queries.conf and calls $MDSDIR/bin/cpmiquerybin.

there are only a few useful queries configured in the queries.conf file.
You can add more. Syntax is quite easy.

For Example to get the name, ipaddress and comment field of every host object, just add this line:


CMA "" Hostlist attr network_objects "type='host'" __name__,ipaddr,comments


Or if you need a list of your configured networks, try this


CMA "" Netlist attr network_objects "type='network'" __name__,ipaddr,netmask


now change into your CMA environment, execute the script and enjoy the output:


mdsenv myCMA
$MDSDIR/scripts/mdsquerydb Hostlist
$MDSDIR/scripts/mdsquerydb Netlist




i guess, it's useful for scripting nice config-reports too.

have a good time.