cpmiquerybin on SmartCenter server

From cpwiki.net
Revision as of 20:23, 15 March 2014 by Nighthawk (Talk | contribs)

Jump to: navigation, search
Check Point Profressional Services

cpmiquerybin is a useful tool found on Check Point Provider-1 servers. Ever wish you had it on a SmartCenter? Well, you can. Copy the cpmiquerybin from a Provider-1 (OF THE SAME Check Point VERSION) to your SmartCenter.


set environment variables

add the following lines to $CPDIR/tmp/.CPprofile.sh, replace the 192.168.1.10 with whatever your SmartCenter IP address is.

MSP_SOMEIP_ADDR="192.168.1.10"; export MSP_SOMEIP_ADDR
MDSDIR="/opt/CPshrd-R75.40"; export MDSDIR

source it to make them take effect...

[Expert@ckkpmgr]# source $CPDIR/tmp/.CPprofile.sh

successful test run

[Expert@ckkpmgr]# cpmiquerybin attr "" network_objects "name='LocalMachine'" -a __name__
get_cust_name: couldn't find /customers/ within fwdir
LocalMachine

The error concerning the customers dir is annoying. I tried to make some dummy dirs to fake it out...

mkdir /opt/CPsuite-R75.40/fw1/customers
mkdir /opt/CPsuite-R75.40/fw1/customers/dummy
mkdir /opt/CPshrd-R75.40/customers
mkdir /opt/CPshrd-R75.40/customers/dummy

but it didn't work... so, best to use a function.


use a function to filter out get_cust_name error

add a global function to /etc/profile

function cpquery() { /usr/local/bin/cpmiquerybin "$@" 2>&1 | grep -v "get_cust_name: couldn't find";}

then, use the function cpquery at the shell command line in place of cpmiquerybin. You aren't supposed to use aliases in scripts, maybe you can use the global function? or you can define the function in all your scripts.