{"id":249,"date":"2009-06-19T19:20:39","date_gmt":"2009-06-19T19:20:39","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2009\/06\/19\/r55-resource-usage-report-script\/"},"modified":"2021-07-31T17:39:34","modified_gmt":"2021-07-31T17:39:34","slug":"r55-resource-usage-report-script","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Programming\/Shell-Scripting\/r55-resource-usage-report-script.html","title":{"rendered":"R65 \/ R55 Script – Resource Usage Report"},"content":{"rendered":"
Below is a bash\/sh script to log the resouces of a R55\/R65 Check Point firewall. The following resources are recorded,<\/p>\n
The script will build a .csv file which can then be opened using excel, and the required data (columns) can be selected and converted into graphs. The scripts can be found below,<\/p>\n
# Checkpoint IPSO R55\/R65 Resource Monitoring Tool v3 - Felix\r\n# output is stored in a csv file using the $log variable \r\n# \r\n#!\/bin\/sh \r\n\r\n## Import Environment Variables\r\n. \/var\/etc\/pm_profile && \r\n. \/opt\/CPsuite-R??\/svn\/tmp\/.CPprofile.csh\r\n\r\n## If required create a directory\r\nif [ -d != \/var\/log\/resource_report ] \r\n\tthen\r\n\tmkdir \/var\/log\/resource_report 2>\/dev\/null\r\nfi\r\n\r\n## if required create a README\r\nif [ -e != \/var\/log\/resource_report\/README.txt ]\r\n\tthen\r\n\thead -5 $0 > \/var\/log\/resource_report\/README.txt\r\nfi\r\n\r\n## Assign Variables\r\ntmp=\/tmp\/cp_resource.$$\r\nlog=\/var\/log\/resource_report\/rreport-`date +\"%Y%m%d\"`.csv\r\n\r\n## Log rotate reports older then 31 days\r\nfind \/var\/log\/resource_report\/rreport* -mtime +31 -exec rm -f {} \\; 2>\/dev\/null\r\n\r\n## Gather stats\r\nfw ctl pstat >> $tmp 2>\/dev\/null\r\n\r\nif [ $? != 0 ]\r\nthen\r\n logger -t cp_resource_report -p daemon.err \"Unable to run \\\"fw ctl pstat\\\"\" \r\n exit 1\r\nelse\r\n vmstat 1 5 >> $tmp 2>\/dev\/null\r\nRC=$?\r\nfi\r\nif [ $RC != 0 ]\r\nthen\r\n logger -t cp_resource_report -p daemon.err \"Unable to run \\\"vmstat\\\"\" \r\n\texit 1\r\nelse\r\n peakconn=`grep \"peak concurrent\" $tmp | awk ' { print $1 } '`\r\n cpuidle=`tail -1 $tmp | awk ' { print $NF } '`\r\n cpu=`expr 100 - $cpuidle`\r\n conn=`grep recovered $tmp | awk ' { print $7 } '`\r\n free=`tail -1 $tmp | awk ' { print $4 } '`\r\n freemb=`expr $free \/ 1024`\r\nfi\r\n\r\n## Write stats to a file. If not find is present add a header\r\nif [ ! -r ${log} ] ;\r\nthen\r\n echo date,time,connections,peak connections,cpu \\%,free mem \\(MB\\) >> ${log}\r\n echo `date +\"%d\/%m\/%y\"`,`date \"+%H:%M:%S\"`,$conn,$peakconn,${cpu},${freemb} >> ${log}\r\nelse\r\n echo `date +\"%d\/%m\/%y\"`,`date \"+%H:%M:%S\"`,$conn,$peakconn,${cpu},${freemb} >> ${log}\r\nfi\r\nrm -f $tmp\r\nexit 0\r\n<\/pre>\nSPLAT \/ SOLARIS<\/h2>\n
# Checkpoint Solaris \/ SPLAT R55\/R65 Resource Monitoring Tool v3 - Felix\r\n# output is stored in a csv file using the $log variable \r\n# \r\n#!\/bin\/bash\r\n\r\n## Import Environment Variables\r\n. \/opt\/CPshrd-R??\/tmp\/.CPprofile.sh \r\n\r\n## If required create a directory\r\nif [ -d != \/var\/log\/resource_report ] \r\n\tthen\r\n\tmkdir \/var\/log\/resource_report 2>\/dev\/null\r\nfi\r\n\r\n## if required create a README\r\nif [ -e != \/var\/log\/resource_report\/README.txt ]\r\n\tthen\r\n\thead -5 $0 > \/var\/log\/resource_report\/README.txt\r\nfi\r\n\r\n## Assign Variables\r\ntmp=\/tmp\/cp_resource.$$\r\nlog=\/var\/log\/resource_report\/rreport-`date +\"%Y%m%d\"`.csv\r\n\r\n## Log rotate reports older then 31 days\r\nfind \/var\/log\/resource_report\/rreport* -mtime +31 -exec rm -f {} \\; 2>\/dev\/null\r\n\r\n## Gather stats\r\nfw ctl pstat >> $tmp 2>\/dev\/null\r\n\r\nif [ $? != 0 ]\r\nthen\r\n logger -t cp_resource_report -p daemon.err \"Unable to run \\\"fw ctl pstat\\\"\" \r\n exit 1\r\nelse\r\n vmstat 1 5 >> $tmp 2>\/dev\/null\r\nRC=$?\r\nfi\r\nif [ $RC != 0 ]\r\nthen\r\n logger -t cp_resource_report -p daemon.err \"Unable to run \\\"vmstat\\\"\" \r\n\texit 1\r\nelse\r\n peakconn=`grep \"peak concurrent\" $tmp | awk ' { print $1 } '`\r\n cpuidle=`tail -1 $tmp | awk ' { print $NF } '`\r\n cpu=`expr 100 - $cpuidle`\r\n conn=`grep recovered $tmp | awk ' { print $7 } '`\r\n free=`tail -1 $tmp | awk ' { print $4 } '`\r\n freemb=`expr $free \/ 1024`\r\nfi\r\n\r\n## Write stats to a file. If not find is present add a header\r\nif [ ! -r ${log} ] ;\r\nthen\r\n echo date,time,connections,peak connections,cpu \\%,free mem \\(MB\\) >> ${log}\r\n echo `date +\"%d\/%m\/%y\"`,`date \"+%H:%M:%S\"`,$conn,$peakconn,${cpu},${freemb} >> ${log}\r\nelse\r\n echo `date +\"%d\/%m\/%y\"`,`date \"+%H:%M:%S\"`,$conn,$peakconn,${cpu},${freemb} >> ${log}\r\nfi\r\nrm -f $tmp\r\nexit 0\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"Below is a bash\/sh script to log the resouces of a R55\/R65 Check Point firewall. The following resources are recorded, Free Memory CPU Usage Concurrent Connections Peak Connections Time Date The script will build a .csv file which can then be opened using excel, and the required data (columns) can be selected and converted into … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":248,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"yoast_head":"\n
R65 \/ R55 Script - Resource Usage Report - Fir3net<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n\n\n\n\t\n\t\n\t\n