<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000099" bgcolor="#FFFFFF">
    <p><font face="Verdana">Hello there,</font></p>
    <p><font face="Verdana">I want to log all user's bytes usage </font><font
        face="Verdana"><font face="Verdana"> (received+sent)</font> in
        my MySQL database,</font></p>
    <p><font face="Verdana">I think I can get it from : "<b>strongswan
          statusall</b>" command, (I can't find another command to
        achieve this, is there any?)<br>
      </font></p>
    <p><font face="Verdana">This is the output:</font></p>
    <blockquote>
      <p><font face="Verdana" size="-2" color="#cc0000">Status of IKE
          charon daemon (strongSwan 5.4.0, Linux
          3.10.0-514.6.1.el7.x86_64, x86_64):<br>
            uptime: 4 days, since Jun 24 00:50:59 2017<br>
            malloc: sbrk 2703360, mmap 0, used 572240, free 2131120<br>
            worker threads: 11 of 16 idle, 5/0/0/0 working, job queue:
          0/0/0/0, scheduled: 4<br>
            loaded plugins: charon aes des rc2 sha2 sha1 md4 md5 random
          nonce x509 revocation constraints acert pubkey pkcs1 pkcs8
          pkcs12 pgp dnskey sshkey pem openssl gcrypt fips-prf gmp xcbc
          cmac hmac ctr ccm gcm curl attr kernel-netlink resolve
          socket-default farp stroke vici updown eap-identity eap-md5
          eap-gtc eap-mschapv2 eap-tls eap-ttls eap-peap xauth-generic
          xauth-eap xauth-pam xauth-noauth dhcp<br>
          Virtual IP pools (size/online/offline):<br>
            10.86.86.0/24: 254/1/0<br>
          Listening IP addresses:<br>
            138.68.247.27<br>
            10.46.0.7<br>
          Connections:<br>
           IPSec-IKEv2:  %any...%any  IKEv2, dpddelay=300s<br>
           IPSec-IKEv2:   local:  [C=US, O=VpnTest, CN=vpn-test.com]
          uses public key authentication<br>
           IPSec-IKEv2:    cert:  "C=US, O=VpnTest, CN=vpn-test.com"<br>
           IPSec-IKEv2:   remote: uses public key authentication<br>
           IPSec-IKEv2:   child:  0.0.0.0/0 === dynamic TUNNEL,
          dpdaction=clear<br>
          IPSec-IKEv2-EAP:  %any...%any  IKEv2, dpddelay=300s<br>
          IPSec-IKEv2-EAP:   local:  [vpn-test.com] uses public key
          authentication<br>
          IPSec-IKEv2-EAP:    cert:  "C=US, O=VpnTest, CN=vpn-test.com"<br>
          IPSec-IKEv2-EAP:   remote: uses EAP_MSCHAPV2 authentication
          with EAP identity '%any'<br>
          IPSec-IKEv2-EAP:   child:  0.0.0.0/0 === dynamic TUNNEL,
          dpdaction=clear<br>
            CiscoIPSec:  %any...%any  IKEv1, dpddelay=300s<br>
            CiscoIPSec:   local:  [C=US, O=VpnTest, CN=vpn-test.com]
          uses public key authentication<br>
            CiscoIPSec:    cert:  "C=US, O=VpnTest, CN=vpn-test.com"<br>
            CiscoIPSec:   remote: uses public key authentication<br>
            CiscoIPSec:   remote: uses XAuth authentication: any<br>
            CiscoIPSec:   child:  0.0.0.0/0 === dynamic TUNNEL,
          dpdaction=clear<br>
          <b>Security Associations (1 up, 0 connecting):</b><b><br>
          </b><b>  CiscoIPSec[8]: ESTABLISHED 7 seconds ago,
            138.68.247.27[C=US, O=VpnTest,
            CN=vpn-test.com]...178.247.243.133[C=US, O=VpnTest,
            <a class="moz-txt-link-abbreviated" href="mailto:CN=client@vpn-test.com">CN=client@vpn-test.com</a>]</b><b><br>
          </b><b>  CiscoIPSec[8]: Remote XAuth identity: testu</b><b><br>
          </b><b>  CiscoIPSec[8]: IKEv1 SPIs: ecea85f05ddf6333_i
            3c1f0c592ea2372f_r*, rekeying disabled</b><b><br>
          </b><b>  CiscoIPSec[8]: IKE proposal:
            AES_CBC_256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_2048</b><b><br>
          </b><b>  CiscoIPSec{3}:  INSTALLED, TUNNEL, reqid 3, ESP in
            UDP SPIs: ce1d218e_i 06491def_o</b><b><br>
          </b><b>  CiscoIPSec{3}:  AES_CBC_256/HMAC_SHA1_96, 511 bytes_i
            (8 pkts, 6s ago), 1111 bytes_o (7 pkts, 6s ago), rekeying
            disabled</b><b><br>
          </b><b>  CiscoIPSec{3}:   0.0.0.0/0 === 10.86.86.1/32</b></font></p>
      <p><font face="Verdana" size="-2" color="#cc0000"><b><br>
          </b></font></p>
    </blockquote>
    <p><font face="Verdana">Do I need to look "Security Associations"
        part of the output? <br>
      </font></p>
    <p><font face="Verdana">According to this log, does "<b>511 by</b><b>tes_i</b>"
        and "<b>1111 bytes_o</b>" represents the incoming and outgoing
        bytes count of <b>testu</b> user?</font></p>
    <p><font face="Verdana">Also when I want to get only "testu" user
        statistics, according to docs I'm typing this: <b>"</b></font><font
        face="Verdana"><b>strongswan statusall test</b><b>u"</b><br>
      </font></p>
    <p><font face="Verdana"><br>
      </font></p>
    <p><font face="Verdana">But I'm getting no statistics: <br>
      </font></p>
    <blockquote>
      <p><font face="Verdana"><font size="-1" color="#ff0000">Connections:<br>
            Security Associations (1 up, 0 connecting):<br>
              no match</font></font></p>
    </blockquote>
    <p><font face="Verdana"><font size="-1" color="#ff0000"><br>
        </font></font></p>
    <p><br>
      <font face="Verdana">And my last  question; I will count bytes
        usage of users and if someone exceed his quota I want to kick
        him, how can I do that?</font></p>
    <p><font face="Verdana">Thank you!</font><br>
    </p>
  </body>
</html>