Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Champion
Champion

One-liner for Remote Access VPN Statistics

COVID-19 💊 We take care of your Remote Access VPN needs!
👩‍💻 Reviewed by RnD.
👍 Available as SmartConsole Extension.

One-liner (Bash) to show a summary about the remote access statistics of a VPN gateway.
Run in SmartConsole as one-time script or from your scripts repository or directly on your Gateway in expert mode:

echo; if [[ `if [[ $(cat /etc/cp-release) == *"Embed"* ]]; then grep 1 /opt/fw1/conf/active_blades.txt | tr '[:upper:]' '[:lower:]'; else enabled_blades 2>/dev/null; fi` != *'vpn'* ]]; then echo ' Not a VPN gateway!'; else echo ' REMOTE ACCESS VPN STATS - Current'; printf '%.s-' {1..70}; echo; function f { if [[ "$TERM" == "xterm" ]]; then fw tab -t $1 -s | tail -n1 | awk '{print "\033[0;32m"$4"\033[0m (Peak: "$5")"}'; else fw tab -t $1 -s | tail -n1 | awk '{print $4" (Peak: "$5")"}'; fi; }; function t { [ "$TERM" == "xterm" ] && tput bold; }; t; echo -n " Assigned OfficeMode IPs    : "; f "om_assigned_ips"; t; echo -n " Capsule/Endpoint VPN Users : "; echo `f "userc_users"` using Visitor Mode: `vpn show_tcpt 2>/dev/null | grep 'Visitor' | tail -n1 | awk '{print $NF}' | tr -s 'Mode:' '0'`; t; echo -n " Capsule Workspace Users    : "; f "mob_mail_session"; if [[ `cat /etc/cp-release` != *"Embed"* ]]; then t; echo -n " MAB Portal Users           : "; f "cvpn_session"; fi; t; echo -n " L2TP Users                 : "; f "L2TP_tunnels"; t; echo -n " SNX Users                  : "; f "sslt_om_ip_params"; echo; echo ' LICENSES'; printf '%.s-' {1..70}; t; echo; function s { awk '{ sum += $1 } END { print sum }'; }; function u { echo Unlimited; }; l=`cplic print -p 2>/dev/null | awk --re-interval 'BEGIN{today="date +%s"; today | getline today; } $1 ~ /([1-9][0-9]*\.?){4}/ {if ($2 != "never") {expdate=$2; cmd="date -d " expdate " +%s"; cmd | getline expdate; if (expdate>today) {print} } else {print}}' | tr ' ' '\n'`; echo -n ' SecuRemote Users           : '; if [[ "$l" == *'srunlimited'* ]]; then u; else echo "$l" | grep fw1:6.0:sr | cut -c 11- | s; fi; echo -n ' Endpoint Connect Users     : '; grep -a sc_users $FWDIR/database/fwauth.NDB | tr -dc '[:digit:]\n' | awk '{print $1/5}' | echo $(cat); echo -n ' Mobile Access Users        : '; if [[ "$l" == *'cvpnunlimited'* ]]; then u; else echo "$l" | grep cvpn:6.0:cvpn | cut -c 14- | tr -d 'user' | s; fi; echo -n ' SNX Users                  : '; if [[ "$l" == *'nxunlimit'* ]]; then u; else echo "$l" | grep fw1:6.0:nx | cut -c 11- | s; fi; [ "$TERM" == "xterm" ] && tput sgr0; unset l; fi; echo

image.pngimage.png

This One-liner is also integrated with our ccc script.

Thanks to @PhoneBoy for license macro information in this thread. [ VPN License Guide ]
Thanks to @HristoGrigorov for SMB support and testing.
Thanks to CheckMates for these Remote Access SmartEvent Reports: Basic, Enhanced, Application Monitoring, Custom User Stats

-- More one-liners --

One-liner for Address Spoofing Troubleshooting
One-liner to show VPN topology on gateways
One-liner to show Geo Policy on gateways
FW Monitor SuperTool

70 Replies
Highlighted
Leader
Leader

@Danny 

great job. I love these oneliners.

Wolfgang

 

Highlighted

great , I was looking for it.

 The statistics match for   the last hour/day/week ?

0 Kudos
Highlighted

I can understand that the current number is the live stat from the gateway at the point in time of running the one liner but what about the peak number? - that must be historical, surely?  Over what historical period?

0 Kudos
Highlighted
Champion
Champion

The peak number is always counted since last reboot of the system.

0 Kudos
Highlighted
Employee+
Employee+

Very good! Thanks for sharing.
0 Kudos
Highlighted
Champion
Champion

👍

0 Kudos
Highlighted
Leader
Leader

@Danny 

running in export mode is fine, but from Smartconsole repository some small formatting errors are seen.

SmartConsole.PNG

Maybee you can find the problem.

Wolfgang 

0 Kudos
Highlighted
Champion
Champion

Thanks @Wolfgang, I fixed it.

0 Kudos
Highlighted
Employee
Employee

It will show also Capsule Workspace connected Users?

Capsule Workspace it part of MAB Portal Users count?

0 Kudos
Highlighted
Champion
Champion

Hi @Bechor, I've just included stats for Capsule Workspace users as well. ✔️

Highlighted
Employee
Employee

That's great!
Thank you!
0 Kudos
Highlighted
Employee+
Employee+

Untitled.png

Untitled2.png

 

Hi Danny, thank you for the great one-liner script!

It's certainly helping a lot.

Quick feedback on when running Gateways CG IaaS (VE), the outcome is "Not a firewall gateway!".

We had to bypassed it by getting rid of the first "if" of the script.

Highlighted
Champion
Champion

Thanks for the enabled_blades tip, @Eduardo_Pereira, I just improved the One-liner to check the VPN blade.

Highlighted
Contributor

Quality one-liners as always!
Highlighted
Champion
Champion

Thanks @PatrikSkoglund! 😃

Participant

Great script for quick stats,

so are they full day stats? or current stats?

0 Kudos
Highlighted
Champion
Champion

Thanks for the tip. I'll add the word 'current' to the title. The peak score is an overall status since last reboot of the system.

Highlighted

Hi :

Thank you very much for your work 

I have spent tons of hours trying to do the same thing

In my script I have used the following kernel table to obtain SNX users:

  1. SNX users ---> fw tab -t sslt_connectra_sessions -s

I have counted the lines with SNX users on the smartview monitor users table, and with this number I could find the "correct" kernel table 

If I use your script,  the number shown is different from the number that you can obtain from   the kernel table shown above.

What are the differences between your number,  my number and the number of users listed on the smartview monitor table?

I think your result is correct (you are a checkpoint expert) , but the number is different from the number of snx users you can see (and count, line by line) on the  smartview monitor users table.

Thanks in advanced for your answer

PD: Sorry about my bad english 

0 Kudos
Highlighted
Participant

Great job! Thx for very useful one liner.

0 Kudos
Highlighted
Champion
Champion

I'm glad you like it. 🙂

0 Kudos
Highlighted
Employee+
Employee+

Hey @Danny,

This is a one-liner that I did for a client few days ago to monitor VPN clients and the performance of the appliance. It was a huge appliance with thousands of users.

It help to find any heavy connections and monitor the connected users real time.

Have you ever wrote something to find/monitor heavy connections/elephant flows? (VPN or not related).

monitor VPN heavy conn.jpg

Script:

watch -n 0.1 "echo ' CPU UTILIZATION'; printf '%.s-' {1..100}; echo;echo;mpstat -P ALL 1 1 | grep -v Average;echo;echo;echo;echo ' ENABLED BLADES'; printf '%.s-' {1..100};echo;enabled_blades;echo;echo;echo ' LAST INSTALLED POLICY'; printf '%.s-' {1..100};echo; fw stat | grep -o '.\{0,5\}2020.\{0,10\}';echo;echo;echo ' NUMBER OF CONNECTED USERS'; printf '%.s-' {1..100};echo;fw tab -t userc_users -s | grep userc_users | awk '{print \$4}';echo;echo ' NUMBER OF OFFICE MODE IPs'; printf '%.s-' {1..100};echo;fw tab -t om_assigned_ips -s | grep om_assigned_ips | awk '{print \$4}';echo;echo ' SHOW HEAVY CONNECTIONS'; printf '%.s-' {1..100}; echo;echo;fw ctl multik print_heavy_conn;echo;"

 

Attached a printscreen of the outcome as well.

Highlighted
Champion
Champion

Thanks for sharing your code with us. 😀 I haven't yet created a solution to identify top VPN remote users.

It's impressive to see what we can bring up together while working from home focusing on getting home workers connected and protected maintaining their businesses during COVID-19.

corona.gif

0 Kudos
Highlighted
Employee+
Employee+

True that! 😉

Let me know if you ever get inspiried to code such thing! 😉

Thank you!
0 Kudos
Highlighted
Champion
Champion

Will do! 😉

0 Kudos
Highlighted
Participant

Super thank you.
This is a super mega command, very useful.
Thanks again

0 Kudos
Highlighted
Champion
Champion

I'm glad it's useful to you. This one-liner also got reviewed by R&D today as Check Point SE's now use it, too. 👩‍💻

0 Kudos
Highlighted

The command is great!! I have one question: What is the difference between MAB Portal Users and SNX Users?

My case:

REMOTE ACCESS VPN STATS - Current
----------------------------------------------------------------------
Assigned OfficeMode IPs : 1499 (Peak: 1692)
Capsule/Endpoint VPN Users : 1447 (Peak: 1501) using Visitor Mode: 60
Capsule Workspace Users : 0 (Peak: 0)
MAB Portal Users : 141 (Peak: 232)
L2TP Users : 0 (Peak: 0)
SNX Users : 122 (Peak: 198)

Regards

0 Kudos
Highlighted
Employee+
Employee+

A user may login to MAB portal but not connect SNX. In this case he will be counted as MAB user and will not be counted as SNX user.

0 Kudos