Article ID: 111223, created on May 3, 2011, last review on Jun 17, 2016

  • Applies to:
  • Virtuozzo 6.0

Symptoms

When writing applications to manage hosts via Virtual Automation Agent or when troubleshooting Power Panel issues, it is useful to see working examples of XML requests and packet sequences.

Apart from the XML API reference guide, it is also useful to capture packets in the Agent log with the debug log level. Read on to see some practical examples.

Resolution

Example: Sending an XML API request to find out traffic usage for container 701.

  1. Find the EID of the container in question. It is usually stored in the private container area, in the .vza/eid.conf file:

    ~# cat /vz/private/701/.vza/eid.conf
    cee8df85-bab4-a94e-9799-4fd8f8fb7a96
    
  2. Enable debug logging for PVA Agent:

    ~# sed '/log_level/s/>.*.</>5</g' /var/opt/pva/agent/etc/vzagent.conf -i
    ~# grep log_level /var/opt/pva/agent/etc/vzagent.conf
    <log_level>5</log_level>
    ~# pvaagent restart
    

    NOTE: Do not forget to switch it off when done:
    NOTE: vzagent.conf may be located inside /vz/pva/agent/etc directory

    ~# sed '/log_level/s/>.*.</>3</g' /var/opt/pva/agent/etc/vzagent.conf -i
    ~# pvaagent restart
    
  3. Log in to Power Panel of container 701 (on port 4643).

  4. It is suggested to attach the tail -f command to the log file, right before any actions in the GUI, to capture only the required part of the logs:

    ~# tail -f /var/log/pva/agent/2011.05.03-vzagent.log > /tmp/xmlapi.701.log
    
  5. Click on Traffic Log:

    Traffic log

  6. Detach the tail from the log by pressing Ctrl-C.

  7. Find the packet by operator name (res_log) or by the container EID found earlier. Below is an example of the exact packet sent by Power Panel to VA Agent to retrieve all traffic statistics for container 701:

    ~# less /tmp/xmlapi.701.log T=2011.05.03 16:05:40.394; L=(debug) ; PID=8615; TID=1187964016; [VZLDirectorPrototype::handleIncoming] Incoming message
    <packet xmlns:ns1="http://www.swsoft.com/webservices/vzl/4.0.0/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" uid="" priority="0" time="2011-05-03T09:05:40+0000" type="2" id="33kgfkyba
    aaaasvy6ftc1qqcciefdaaa" version="4.5.0">
    <target>res_log</target>
    <dst>
    <host>bd76f8ec-f5c8-3b4f-a558-551bc60ed939</host>
    </dst>
    <data>
    <res_log>
    <get_log>
    <eid>cee8df85-bab4-a94e-9799-4fd8f8fb7a96</eid>
    <class>
    <name>counters_vz_net</name>
    </class>
    <start_time>2011-05-01T00:00:00+0000</start_time>
    <end_time>2011-06-01T00:00:00+0000</end_time>
    <period>86400</period>
    <report_empty/>
    </get_log>
    </res_log>
    </data>
    <origin>vzclient2-bd76f8ec-f5c8-3b4f-a558-551bc60ed939</origin>
    <cookie>
    <src>
    <index>3</index>
    <director>pvappd</director>
    <target>webcp</target>
    </src>
    </cookie>
    <auth xsi:type="ns1:tokenType">
    <ns1:user>AQUAAAAAIAEOWHmuxkFDkp51B+UXSMzRAAAAAA==</ns1:user>
    <ns1:groups>
    <ns1:sid>AQEAAAAAA+jpAwAA</ns1:sid>
    <ns1:sid>AQUAAAAAIAAOWHmuxkFDkp51B+UXSMzRAAAAAA==</ns1:sid>
    <ns1:sid>AQUAAAAAIADs+Ha9yPVPO6VYVRvGDtk5AAAAAA==</ns1:sid>
    <ns1:sid>AQUAAAAAIAEOWHmuxkFDkp51B+UXSMzRAAAAAA==</ns1:sid>
    </ns1:groups>
    <ns1:deny_only_sids/>
    <ns1:privileges/>
    <ns1:name xsi:type="ns1:auth_nameType">
    <ns1:domain>YWU3OTU4MGUtNDFjNi05MjQzLTllNzUtMDdlNTE3NDhjY2Qx</ns1:domain>
    <ns1:name>cm9vdA==</ns1:name>
    <ns1:realm>00000000-0000-0000-0100-000000000000</ns1:realm>
    </ns1:name>
    </auth>
    </packet>
    
  8. Now, using the schema from page 459 of the XML API reference, we can cut off unnecessary fields, like cookie and auth, and compose our own request:

    <packet version="4.5.0">
    <target>res_log</target>
    <data>
    <res_log>
    <get_log>
    <eid>cee8df85-bab4-a94e-9799-4fd8f8fb7a96</eid>
    <class>
    <name>counters_vz_net</name>
    </class>
    <start_time>2011-05-01T00:00:00+0000</start_time>
    <end_time>2011-06-01T00:00:00+0000</end_time>
    <period>86400</period>
    <report_empty/>
    </get_log>
    </res_log>
    </data>
    </packet>
    
  9. To verify this is a working request, we can send it using the Perl client as described in this article:

    ~#./pvaapi.pl -name=root -password='PASSWORD' -host=HOSTNAME -packet='<packet version="4.5.0"><target>res_log</target><data><res_log><get_log><eid>cee8df85-bab4-a94e-9799-4fd8f8fb7a96</eid><class><name>counters_vz_net</name></class><start_time>2011-05-01T00:00:00+0000</start_time><end_time>2011-06-01T00:00:00+0000</end_time><period>86400</period><report_empty/></get_log></res_log></data></packet>'
    <packet xmlns:ns1="http://www.swsoft.com/webservices/vzl/4.0.0/protocol" xmlns:ns2="http://www.swsoft.com/webservices/vzl/4.0.0/res_log" xmlns:ns3="http://www.swsoft.com/webservices/vzl/4.0.0/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" time="2011-05-03T09:25:35+0000" priority="0" version="4.5.0">
    <ns1:origin>res_log</ns1:origin>
    <ns1:target>vzclient6-f12d909c-ab91-714f-bca3-6637042239b4</ns1:target>
    <ns1:dst>
    <director>gend</director>
    </ns1:dst>
    <ns1:data>
    <ns2:res_log>
    <ns2:data xsi:type="ns3:perf_dataType">
    <ns3:eid>cee8df85-bab4-a94e-9799-4fd8f8fb7a96</ns3:eid>
    <ns3:interval xsi:type="ns3:intervalType">
    <ns3:start_time>2011-05-01T00:00:00+0000</ns3:start_time>
    <ns3:end_time>2011-05-02T00:00:00+0000</ns3:end_time>
    </ns3:interval>
    <ns3:class>
    <ns3:name>counters_vz_net</ns3:name>
    <ns3:instance>
    <ns3:name></ns3:name>
    <ns3:counter>
    <ns3:name>counter_net_incoming_bytes</ns3:name>
    <ns3:value>
    <ns3:avg>3766</ns3:avg>
    <ns3:min>0</ns3:min>
    <ns3:max>2475</ns3:max>
    <ns3:cur>0</ns3:cur>
    </ns3:value>
    </ns3:counter>
    <ns3:counter>
    <ns3:name>counter_net_incoming_packets</ns3:name>
    <ns3:value>
    <ns3:avg>6</ns3:avg>
    <ns3:min>0</ns3:min>
    <ns3:max>4</ns3:max>
    <ns3:cur>0</ns3:cur>
    </ns3:value>
    </ns3:counter>
    <ns3:counter>
    <ns3:name>counter_net_outgoing_bytes</ns3:name>
    <ns3:value>
    <ns3:avg>1010</ns3:avg>
    <ns3:min>0</ns3:min>
    <ns3:max>752</ns3:max>
    <ns3:cur>0</ns3:cur>
    </ns3:value>
    </ns3:counter>
    <ns3:counter>
    <ns3:name>counter_net_outgoing_packets</ns3:name>
    <ns3:value>
    <ns3:avg>14</ns3:avg>
    <ns3:min>0</ns3:min>
    <ns3:max>12</ns3:max>
    <ns3:cur>0</ns3:cur>
    </ns3:value>
    </ns3:counter>
    </ns3:instance>
    <ns3:instance>
    <ns3:name>0</ns3:name>
    <ns3:counter>
    <ns3:name>counter_net_incoming_bytes</ns3:name>
    <ns3:value>
    <ns3:avg>0</ns3:avg>
    <ns3:min>0</ns3:min>
    <ns3:max>0</ns3:max>
    <ns3:cur>0</ns3:cur>
    </ns3:value>
    ............................................
     </ns3:counter>
    </ns3:instance>
    </ns3:class>
    </ns2:data>
    </ns2:res_log>
    </ns1:data>
    <src>
    <director>gend</director>
    </src>
    </packet>
    

Packets also may be captured from pvacc log, as it contains complete packets without truncating them.

To capture packets in pvacc log:

  1. Increase the log level:

    # diff /etc/opt/pva/cc/pvacc.conf.orig /etc/opt/pva/cc/pvacc.conf
    34,35c34,35
    <               <level>1</level>
    <               <agent_level>3</agent_level>
    
    ---
    
    >               <level>50</level>
    >               <agent_level>5</agent_level>
    
  2. Restart pvacc service (it will not interrupt active operations like backup or migration, but all active sessions will be dropped):

    # pvacc restart
    
  3. Go to VA MN GUI and perform actions you want to perform with API query.
  4. Open /var/log/pva/cc/agent.log and find the required packet.

Additional information

Knowledgebase articles mentioned:

6981 Virtual Automation troubleshooting troubleshooting

111220 How to send an XML API request to Virtual Automation (VA)

Search Words

PVA Agent

XML API requests

API

319940068c5fa20655215d590b7be29b c9ea6ca1b35b3385431f406f1be737be 2897d76d56d2010f4e3a28f864d69223 5356b422f65bdad1c3e9edca5d74a1ae caea8340e2d186a540518d08602aa065 2554725ed606193dd9bbce21365bed4e 614fd0b754f34d5efe9627f2057b8642 0dd5b9380c7d4884d77587f3eb0fa8ef c62e8726973f80975db0531f1ed5c6a2

Email subscription for changes to this article
Save as PDF