<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic QoS Monitoring (for PRTG Network Monitor) in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/67436#M1177</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because there are no useful methods to monitor the configured QoS values (at least til 7.0.3, I don't know if there will be a monitoring of QoS in the future), I have written a little script in powershell which gets all the required values over the XML API and the creates an output which could be used for the software &lt;A href="https://www.paessler.com/prtg" target="_blank"&gt;PRTG Network Monitor &lt;/A&gt;(there is also a free version with limited amount of sensors).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The syntax looks like the following:&lt;/P&gt;
&lt;P&gt;"script.ps1 &amp;lt;fwhostname&amp;gt; &amp;lt;physicalinterface&amp;gt; [&amp;lt;qosrule/tunnelinterface&amp;gt;] [tunnel-traffic]"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example for a cleartext rule named "Traffic-to-Internet" on ethernet1/3:&lt;/P&gt;
&lt;P&gt;script.ps1 "firewall.domain.local" "ethernet1/3" "Traffic-to-Internet"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example for monitoring a tunnel-traffic rule for tunnel 10 on ethernet1/2:&lt;/P&gt;
&lt;P&gt;script.ps1 "firewall.domain.local" "ethernet1/2" "tunnel.10" "tunnel-traffic"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If someone is interested, you can find the script here: &lt;A title="PaloAlto Network QoS Monitoring Script" href="https://github.com/inaxis/Palo_QoS_Mon/blob/master/Palo_QoS_Mon_Script.ps1" target="_blank"&gt;https://github.com/inaxis/Palo_QoS_Mon/blob/master/Palo_QoS_Mon_Script.ps1&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you have to be carefully and do not run too many instances of the script at the same time towards a single firewall (specially not a pa-2000), or if you do it have a look at the management cpu utilization.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested the script on the following device/software combinations:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;PA-5050 (PAN-OS 6.1.7)&lt;/LI&gt;
&lt;LI&gt;PA-5020 (PAN-OS 7.0.3)&lt;/LI&gt;
&lt;LI&gt;PA-3020 (PAN-OS 6.1.7)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The output of the devices is slightly different, so the channel which shows the dropped packets/second does not work on PA-5000 series.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Remo&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example screenshots:&lt;/P&gt;
&lt;P&gt;Actual bandwidth:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/1019i012E633CA5762FAF/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="class-8-actual-traffic.PNG" title="class-8-actual-traffic.PNG" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;Utilization in percent:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/1020i7203B133CBB69355/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="class-8-percentage.PNG" title="class-8-percentage.PNG" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;Dropped packets/second:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/1021i1F872303B6E3CBE1/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="class-8-dropped-packets.PNG" title="class-8-dropped-packets.PNG" border="0" /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Nov 2015 11:06:17 GMT</pubDate>
    <dc:creator>Remo</dc:creator>
    <dc:date>2015-11-16T11:06:17Z</dc:date>
    <item>
      <title>QoS Monitoring (for PRTG Network Monitor)</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/67436#M1177</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because there are no useful methods to monitor the configured QoS values (at least til 7.0.3, I don't know if there will be a monitoring of QoS in the future), I have written a little script in powershell which gets all the required values over the XML API and the creates an output which could be used for the software &lt;A href="https://www.paessler.com/prtg" target="_blank"&gt;PRTG Network Monitor &lt;/A&gt;(there is also a free version with limited amount of sensors).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The syntax looks like the following:&lt;/P&gt;
&lt;P&gt;"script.ps1 &amp;lt;fwhostname&amp;gt; &amp;lt;physicalinterface&amp;gt; [&amp;lt;qosrule/tunnelinterface&amp;gt;] [tunnel-traffic]"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example for a cleartext rule named "Traffic-to-Internet" on ethernet1/3:&lt;/P&gt;
&lt;P&gt;script.ps1 "firewall.domain.local" "ethernet1/3" "Traffic-to-Internet"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example for monitoring a tunnel-traffic rule for tunnel 10 on ethernet1/2:&lt;/P&gt;
&lt;P&gt;script.ps1 "firewall.domain.local" "ethernet1/2" "tunnel.10" "tunnel-traffic"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If someone is interested, you can find the script here: &lt;A title="PaloAlto Network QoS Monitoring Script" href="https://github.com/inaxis/Palo_QoS_Mon/blob/master/Palo_QoS_Mon_Script.ps1" target="_blank"&gt;https://github.com/inaxis/Palo_QoS_Mon/blob/master/Palo_QoS_Mon_Script.ps1&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you have to be carefully and do not run too many instances of the script at the same time towards a single firewall (specially not a pa-2000), or if you do it have a look at the management cpu utilization.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested the script on the following device/software combinations:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;PA-5050 (PAN-OS 6.1.7)&lt;/LI&gt;
&lt;LI&gt;PA-5020 (PAN-OS 7.0.3)&lt;/LI&gt;
&lt;LI&gt;PA-3020 (PAN-OS 6.1.7)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The output of the devices is slightly different, so the channel which shows the dropped packets/second does not work on PA-5000 series.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Remo&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example screenshots:&lt;/P&gt;
&lt;P&gt;Actual bandwidth:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/1019i012E633CA5762FAF/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="class-8-actual-traffic.PNG" title="class-8-actual-traffic.PNG" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;Utilization in percent:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/1020i7203B133CBB69355/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="class-8-percentage.PNG" title="class-8-percentage.PNG" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;Dropped packets/second:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/1021i1F872303B6E3CBE1/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="class-8-dropped-packets.PNG" title="class-8-dropped-packets.PNG" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2015 11:06:17 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/67436#M1177</guid>
      <dc:creator>Remo</dc:creator>
      <dc:date>2015-11-16T11:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: QoS Monitoring (for PRTG Network Monitor)</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/161710#M1382</link>
      <description>&lt;P&gt;Hello, I think your post is interesting, but I also have a question about: in what language is it written and how to put it together with PRTG Network Monitor?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 21:20:59 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/161710#M1382</guid>
      <dc:creator>javier.brito</dc:creator>
      <dc:date>2017-06-16T21:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: QoS Monitoring (for PRTG Network Monitor)</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/161711#M1383</link>
      <description>&lt;P&gt;Hi &lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/20421"&gt;@javier.brito&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script is written in powershell. To make it work you need to place the script in the PRTG folder for custom scripts and then you need to create a new "EXE/Script Advanced" sensor and add the parameters as needed into the corresponding inputfield on the create sensor page.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would be cool to know someone will actually use my solution &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 21:33:21 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/161711#M1383</guid>
      <dc:creator>Remo</dc:creator>
      <dc:date>2017-06-16T21:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: QoS Monitoring (for PRTG Network Monitor)</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/242320#M1823</link>
      <description>&lt;P&gt;- Where I need to apply syntax ?&lt;/P&gt;&lt;P&gt;- What paramater should I put to moinitor qos all class ?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 02:10:04 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/242320#M1823</guid>
      <dc:creator>chaopov</dc:creator>
      <dc:date>2018-12-06T02:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: QoS Monitoring (for PRTG Network Monitor)</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/242592#M1825</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/71127"&gt;@chaopov&lt;/a&gt;&lt;/P&gt;&lt;P&gt;What PAN-OS Version do you use? (Because of some changes in the API my script needs some adjustments for PAN-OS &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Dec 2018 09:59:14 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/242592#M1825</guid>
      <dc:creator>Remo</dc:creator>
      <dc:date>2018-12-08T09:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: QoS Monitoring (for PRTG Network Monitor)</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/242796#M1826</link>
      <description>&lt;P&gt;- I use PAN-OS 8.0.10.&lt;/P&gt;&lt;P&gt;- I have modify script as below&lt;/P&gt;&lt;P&gt;- In PRTG I have add XML EXE/Script Sensor. and PRTG show qos class channel already but didn't show realtime bandwidth per qos class.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;param(
[string]$fw ,
[string]$if ,
[string]$rule = "regular-traffic",
[string]$type = "regular-traffic")

$api_login_string = "LUFRPT1neUxuT1ZvTnpQUlZxejcwVlZlcm5GVTNoc0E9dTZoTWxjZTg0bCtYbXo1R0VMZExHVlJBNVovYkRVZlhtdEY2aWQvTVpPQT0="

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
[Net.ServicePointManager]::SecurityProtocol = 
[Net.SecurityProtocolType]::Tls12

Function callApiOp ($fw, $param)
{
    # Function to call an operational-api action
    $request = New-Object System.Net.WebClient
    $apiurl = "https://" + $fw + "/api/?key=" + $api_login_string + "&amp;amp;type=op&amp;amp;cmd=" + "&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;"
    return [xml]$request.DownloadString($apiurl)
    
}

Function getConfig ($fw, $xp)
{
    # Function to call a config-api action
    $request = New-Object System.Net.WebClient
    $apiurl = "https://" + $fw + "/api/?key=" + $api_login_string + "&amp;amp;type=config&amp;amp;action=get&amp;amp;xpath=" + $xp
    [xml]$xml = [xml]$request.DownloadString($apiurl)
    return [xml]$xml.response.result.innerXML
}

#Get the QoS configuration of the firewall
$xp = getConfig $fw "/config/devices/entry[@name='localhost.localdomain']/network/qos"
#xp = callApiOp $fw "&amp;lt;show&amp;gt;&amp;lt;config&amp;gt;&amp;lt;running&amp;gt;&amp;lt;/running&amp;gt;&amp;lt;/config&amp;gt;&amp;lt;/show&amp;gt;"
#$param = callApiOp $fw "&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;entry name=$if&amp;gt;&amp;lt;throughtput&amp;gt;0&amp;lt;/throughtput&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;"


#Extracte the QoS configuration for the supplied interface
$qosinterface = $xp.qos.interface.entry | Where {$_.name -eq $if}

#Check if a rule was supplied, if yes extract the configuration of that particular rule
if ($rule -ne "regular-traffic")
{
    $qosRegularRule = $qosinterface.$type.groups.entry.members.entry | Where {$_.name -eq $rule}
}
#If the variable $rule is equal to $null then set the following variables
else
{
    $qosRegularRule = "regular"
    $rule = "regular-traffic"
    $rulenumber = 0
}

#Set the xml header and expected prtg root tag
$prtgoutput = '&amp;lt;?xml version="1.0" encoding="Windows-1252" ?&amp;gt;'
$prtgoutput += "&amp;lt;prtg&amp;gt;`n"

#Check if either the interfaceconfig or the ruleconfig is empty
if ($qosinterface -eq $null)
{
    $prtgoutput += "&amp;lt;error&amp;gt;1&amp;lt;/error&amp;gt;`n"
    $prtgoutput += "&amp;lt;text&amp;gt;Invalid interface&amp;lt;/text&amp;gt;`n"
    $prtgoutput += "&amp;lt;/prtg&amp;gt;`n"
    $prtgoutput
    exit
}
if ($qosRegularRule -eq $null)
{
    $prtgoutput += "&amp;lt;error&amp;gt;1&amp;lt;/error&amp;gt;`n"
    $prtgoutput += "&amp;lt;text&amp;gt;Invalid QoS Rule&amp;lt;/text&amp;gt;`n"
    $prtgoutput += "&amp;lt;/prtg&amp;gt;`n"
    $prtgoutput
    exit
}

#Additionally, check if QoS is enabled on the supplied interface
if ($xp.SelectSingleNode("/qos/interface/entry[@name='$if']/enabled").get_InnerXML() -ne "yes")
{
    $prtgoutput += "&amp;lt;error&amp;gt;1&amp;lt;/error&amp;gt;`n"
    $prtgoutput += "&amp;lt;text&amp;gt;QoS disabled on this interface&amp;lt;/text&amp;gt;`n"
    $prtgoutput += "&amp;lt;/prtg&amp;gt;"
    $prtgoutput
    exit
}

if ($rulenumber -ne 0)
{
    #Create an empty hashtable for storing a mappingtable for Qos rulenumber (=node ID) and the rulename
    $rulearray = @{}

    #Count through the regular rules and add their numbers and names to the hashtable
    $count = 1
    foreach ($regularrule in $qosinterface.'regular-traffic'.groups.entry.members.entry)
    {
        $rulearray.Add($regularrule.GetAttribute('name'), $count)
        $count++
    }
    #Get the Node ID for the supplied rulename
    $rulenumber = $rulearray[$rule].tostring()
}

#Get the output of the command "show qos interface &amp;lt;ifname&amp;gt; throughput &amp;lt;nodeid&amp;gt; or for the supplied tunnelinterface"
switch ($type)
{
    "regular-traffic"
    {
        $traffic = callApiOp $fw "&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;entry name=$if&amp;gt;&amp;lt;throughput&amp;gt;$rulenumber&amp;lt;/throughput&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;"
    }
    "tunnel-traffic"
    {
        $traffic = callApiOp $fw "&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;entry name=$if&amp;gt;&amp;lt;tunnel-throughput&amp;gt;$rule&amp;lt;/tunnel-throughput&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;"
    }
    default
    {
        $prtgoutput += "&amp;lt;error&amp;gt;1&amp;lt;/error&amp;gt;`n"
        $prtgoutput += "&amp;lt;text&amp;gt;Wrong traffic type. Leave blank for 'regular-traffic' or enter 'tunnel-traffic'&amp;lt;/text&amp;gt;`n"
        $prtgoutput += "&amp;lt;/prtg&amp;gt;"
        $prtgoutput
        exit
    }
}

#Reduce the output to an array of max. 8 values which should only contain bandwidth values in kbps
$regex = '([cC]lass\s\d[:\s]\s{0,}\d{0,}\skbps)'
$traffic = $traffic.response.result | Select-String -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value }

#Replace special characters, which need to be escaped in a regex string
$temprule = $rule.Replace(".","\.").Replace(" ","\s")
#Regex string which extracts the needed information from the command "show qos interface &amp;lt;IF&amp;gt; counter"
$counterRegex = '(\s{1,}\d{1,}\s{1,}\d{1,}\s' + $temprule + '\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\n((?:\s{1,}-Class\s{1,}\d{1}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,3}\n)+)|\s{1,}\d{1,}\s{1,}\d{1,}\s' + $temprule + '\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\n)'
$qoscounter = callApiOp $fw "&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;entry name=$if&amp;gt;&amp;lt;counter&amp;gt;&amp;lt;/counter&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;"
$qoscounter = $qoscounter.response.result  | Select-String -Pattern $counterRegex | % { $_.Matches } | % { $_.Value }

#Create sensors for every QoS class
for ($i = 1; $i -le 8; $i++)
{
    $regex = '([cC]lass\s' + $i.tostring() + '[:\s]\s{0,}\d{0,}\skbps)'
    $line = $traffic | Select-String -Pattern $regex | % { $_.Matches } | % { $_.Value }
    $maxbandwidth = $null
    $egressguaranteed = $null

    if ($line -eq $null)
    {
        $trafficvalue = 0
        $class = $i
        $classname = "class" + $class.ToString()
    }
    else 
    {
        #convert the $line variable with the bandwith to an integer variable
        $trafficvalue = $line | Select-String -Pattern '(\d*\skbps)' | % { $_.Matches } | % { $_.Value } | Select-String -Pattern '(\d*)' | % { $_.Matches } | % { $_.Value }
        $trafficvalue = [int]$trafficvalue
        $class = $line | Select-String -Pattern '([cC]lass\s\d)' | % { $_.Matches } | % { $_.Value } | Select-String -Pattern '(\d)' | % { $_.Matches } | % { $_.Value }
        $classname = "class" + $class.ToString()
    }
    [decimal]$bps = $trafficvalue * 1024
    [decimal]$kbps = $trafficvalue
    [decimal]$mbps = $trafficvalue / 1024

    #Get the applied QoS Profilename if a rulename was supplied or get the profile for default profile for regular/tunnel traffic
    if ($rule -ne "regular-traffic")
    {
        $qosProfileName = $xp.SelectSingleNode("/qos/interface/entry [@name='$if']/$type/groups/entry [@name='$type-group']/members/entry [@name='$rule']/qos-profile").get_InnerXML()
    }
    else
    {
        $qosProfileName = $qosinterface.$type.'default-group'.InnerText
    }

    #Check if a maximum egress value was set in the profile for the specific class
    if ($xp.SelectSingleNode("/qos/profile/entry [@name='$qosProfileName']/class/entry [@name='$classname']/class-bandwidth/egress-max") -ne $null)
    {
        try {
            [int32]$maxbandwidth = $xp.SelectSingleNode("/qos/profile/entry [@name='$qosProfileName']/class/entry [@name='$classname']/class-bandwidth/egress-max").get_InnerXML()
        }
        catch {
            $maxbandwidth = $null
        }
    }

    #Check if the max-egress value was empty or zero; if yes get the aggregate max-egress value from the QoS Profile
    if (($maxbandwidth -eq $null) -or ($maxbandwidth -eq 0))
    {
        try {
            [int32]$maxbandwidth = $xp.SelectSingleNode("/qos/profile/entry [@name='$qosProfileName']/aggregate-bandwidth/egress-max").get_InnerXML()
        }
        catch {
            $maxbandwidth = $null
        }

        #Check if the aggregate max-egress value was empty or zero; if yes get the max-egress value for regular traffic on that interface
        if (($maxbandwidth -eq $null) -or ($maxbandwidth -eq 0))
        {
            try {
                [int32]$maxbandwidth = $qosinterface.$type.bandwidth.'egress-max'
            }
            catch {
                $maxbandwidth = $null
            }

            #Check if the regular traffic max-egress value was empty or zero; if yes get the max-egress value of the interface
            if (($maxbandwidth -eq $null) -or ($maxbandwidth -eq 0))
            {
                try {
                    [int32]$maxbandwidth = $qosinterface.'interface-bandwidth'.'egress-max'
                }
                catch {
                    $maxbandwidth = $null
                }

                #Check if the max-egress value on the interface is empty or zero; if yes get the speed value of the physical interface
                if (($maxbandwidth -eq $null) -or ($maxbandwidth -eq 0))
                {
                    $op = "&amp;lt;show&amp;gt;&amp;lt;interface&amp;gt;" + $if + "&amp;lt;/interface&amp;gt;&amp;lt;/show&amp;gt;"
                    $interface = callApiOp $fw $op
                    [int32]$maxbandwidth = $interface.response.result.hw.speed
                }
            }
        }
    }

    #Check if a guaranteed egress value was set in the profile for the specific class
    if ($xp.SelectSingleNode("/qos/profile/entry [@name='$qosProfileName']/class/entry [@name='$classname']/class-bandwidth/egress-guaranteed") -ne $null)
    {
        try {
            [int32]$egressguaranteed = $xp.SelectSingleNode("/qos/profile/entry [@name='$qosProfileName']/class/entry [@name='$classname']/class-bandwidth/egress-guaranteed").get_InnerXML()
        }
        catch {
            $egressguaranteed = $null
        }
    }

    #Check if the guaranteed-egress value was empty or zero; if yes get the aggregate guaranteed-egress value from the QoS Profile
    if (($egressguaranteed -eq $null) -or ($egressguaranteed -eq 0))
    {
        try {
            [int32]$egressguaranteed = $xp.SelectSingleNode("/qos/profile/entry [@name='$qosProfileName']/aggregate-bandwidth/egress-guaranteed").get_InnerXML()
        }
        catch {
            $egressguaranteed = $null
        }

        #Check if the aggregate guaranteed-egress value was empty or zero; if yes get the guaranteed-egress value for regular traffic on that interface
        if (($egressguaranteed -eq $null) -or ($egressguaranteed -eq 0))
        {
            try {
                [int32]$egressguaranteed = $qosinterface.$type.bandwidth.'egress-guaranteed'
            }
            catch {
                $egressguaranteed = $null
            }
        }
    }

    $prtgoutput += "&amp;lt;result&amp;gt;`n"
    $prtgoutput += "&amp;lt;channel&amp;gt;" + $classname +"&amp;lt;/channel&amp;gt;`n"
    $prtgoutput += "&amp;lt;unit&amp;gt;Custom&amp;lt;/unit&amp;gt;`n"
    $prtgoutput += "&amp;lt;customunit&amp;gt;Mbit/s&amp;lt;/customunit&amp;gt;`n"
    $prtgoutput += "&amp;lt;mode&amp;gt;Absolute&amp;lt;/mode&amp;gt;`n"
    $prtgoutput += "&amp;lt;showChart&amp;gt;1&amp;lt;/showChart&amp;gt;`n"
    $prtgoutput += "&amp;lt;showTable&amp;gt;1&amp;lt;/showTable&amp;gt;`n"
    $prtgoutput += "&amp;lt;float&amp;gt;1&amp;lt;/float&amp;gt;`n"
    $prtgoutput += "&amp;lt;value&amp;gt;" + $mbps.ToString() + "&amp;lt;/value&amp;gt;`n"
    $prtgoutput += "&amp;lt;LimitMode&amp;gt;1&amp;lt;/LimitMode&amp;gt;`n"
    $prtgoutput += "&amp;lt;LimitMaxError&amp;gt;" + $maxbandwidth.ToString() + "&amp;lt;/LimitMaxError&amp;gt;`n"
    $prtgoutput += "&amp;lt;LimitErrorMsg&amp;gt;The bandwidth  of " + $classname + " exeeds the configured max. value of " + $maxbandwidth.ToString() + " mbps&amp;lt;/LimitErrorMsg&amp;gt;`n"

    #if there is a value for egress-guaranteed and it is not 0 then create a warning-limit in the traffic-channel and an additional sensor for making this limit visible in the chart
    if ($egressguaranteed -ne $null -and $egressguaranteed -ne 0)
    {
        $prtgoutput += "&amp;lt;LimitMaxWarning&amp;gt;" + $egressguaranteed.ToString() + "&amp;lt;/LimitMaxWarning&amp;gt;`n"
        $prtgoutput += "&amp;lt;LimitWarningMsg&amp;gt;The bandwidth of " + $classname + " exeeds the configured guaranteed value of " + $egressguaranteed.ToString() + " mbps&amp;lt;/LimitWarningMsg&amp;gt;`n"
        $prtgoutput += "&amp;lt;/result&amp;gt;`n"

        $prtgoutput += "&amp;lt;result&amp;gt;`n"
        $prtgoutput += "&amp;lt;channel&amp;gt;" + $classname +" egress-guaranteed&amp;lt;/channel&amp;gt;`n"
        $prtgoutput += "&amp;lt;unit&amp;gt;Custom&amp;lt;/unit&amp;gt;`n"
        $prtgoutput += "&amp;lt;customunit&amp;gt;Mbit/s&amp;lt;/customunit&amp;gt;`n"
        $prtgoutput += "&amp;lt;mode&amp;gt;Absolute&amp;lt;/mode&amp;gt;`n"
        $prtgoutput += "&amp;lt;showChart&amp;gt;1&amp;lt;/showChart&amp;gt;`n"
        $prtgoutput += "&amp;lt;showTable&amp;gt;0&amp;lt;/showTable&amp;gt;`n"
        $prtgoutput += "&amp;lt;float&amp;gt;1&amp;lt;/float&amp;gt;`n"
        $prtgoutput += "&amp;lt;value&amp;gt;" + $egressguaranteed.ToString() + "&amp;lt;/value&amp;gt;`n"
        $prtgoutput += "&amp;lt;/result&amp;gt;`n"
    }
    else
    {
        $prtgoutput += "&amp;lt;/result&amp;gt;`n"            
    }

    $prtgoutput += "&amp;lt;result&amp;gt;`n"
    $prtgoutput += "&amp;lt;channel&amp;gt;" + $classname +" egress-max&amp;lt;/channel&amp;gt;`n"
    $prtgoutput += "&amp;lt;unit&amp;gt;Custom&amp;lt;/unit&amp;gt;`n"
    $prtgoutput += "&amp;lt;customunit&amp;gt;Mbit/s&amp;lt;/customunit&amp;gt;`n"
    $prtgoutput += "&amp;lt;mode&amp;gt;Absolute&amp;lt;/mode&amp;gt;`n"
    $prtgoutput += "&amp;lt;showChart&amp;gt;1&amp;lt;/showChart&amp;gt;`n"
    $prtgoutput += "&amp;lt;showTable&amp;gt;0&amp;lt;/showTable&amp;gt;`n"
    $prtgoutput += "&amp;lt;float&amp;gt;1&amp;lt;/float&amp;gt;`n"
    $prtgoutput += "&amp;lt;value&amp;gt;" + $maxbandwidth.ToString() + "&amp;lt;/value&amp;gt;`n"
    $prtgoutput += "&amp;lt;/result&amp;gt;`n"

    #Calculate the used bandwidth in percent
    $percent = ($mbps / $maxbandwidth) * 100

    $prtgoutput += "&amp;lt;result&amp;gt;`n"
    $prtgoutput += "&amp;lt;channel&amp;gt;" + $classname +" Percentage&amp;lt;/channel&amp;gt;`n"
    $prtgoutput += "&amp;lt;unit&amp;gt;Percent&amp;lt;/unit&amp;gt;`n"
    $prtgoutput += "&amp;lt;mode&amp;gt;Absolute&amp;lt;/mode&amp;gt;`n"
    $prtgoutput += "&amp;lt;showChart&amp;gt;1&amp;lt;/showChart&amp;gt;`n"
    $prtgoutput += "&amp;lt;showTable&amp;gt;1&amp;lt;/showTable&amp;gt;`n"
    $prtgoutput += "&amp;lt;float&amp;gt;1&amp;lt;/float&amp;gt;`n"
    $prtgoutput += "&amp;lt;value&amp;gt;" + $percent + "&amp;lt;/value&amp;gt;`n"
    $prtgoutput += "&amp;lt;/result&amp;gt;`n"

    $regex = 'Class\s' + $class.toString() + '\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}(\d{1,12})\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,3}'
    $droppedPackets = $qoscounter | Select-String -Pattern $regex | % { $_.Matches } | % { $_.Value }
    if ($droppedPackets -ne $null)
    {
        $regex = 'Class\s' + $class.toString() + '\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}\d{1,}\s{1,}'
        $droppedPackets = $droppedPackets -replace $regex,'' | Select-String -Pattern '\d{1,}' | % { $_.Matches } | % { $_.Value }
        $prtgoutput += "&amp;lt;result&amp;gt;`n"
        $prtgoutput += "&amp;lt;channel&amp;gt;" + $classname +" dropped Packets&amp;lt;/channel&amp;gt;`n"
        $prtgoutput += "&amp;lt;unit&amp;gt;#&amp;lt;/unit&amp;gt;`n"
        $prtgoutput += "&amp;lt;mode&amp;gt;Difference&amp;lt;/mode&amp;gt;`n"
        $prtgoutput += "&amp;lt;showChart&amp;gt;1&amp;lt;/showChart&amp;gt;`n"
        $prtgoutput += "&amp;lt;showTable&amp;gt;1&amp;lt;/showTable&amp;gt;`n"
        $prtgoutput += "&amp;lt;float&amp;gt;0&amp;lt;/float&amp;gt;`n"
        $prtgoutput += "&amp;lt;value&amp;gt;" + $droppedPackets + "&amp;lt;/value&amp;gt;`n"
        $prtgoutput += "&amp;lt;/result&amp;gt;`n"
    }
}

#Close the xml root tag and show the output
$prtgoutput += "&amp;lt;/prtg&amp;gt;"
$prtgoutput&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.JPG" style="width: 674px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/17873iD96ED27334E125DA/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="2.JPG" alt="2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.JPG" style="width: 543px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/17875iB42E0E066890B5AF/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="1.JPG" alt="1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 03:24:12 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/242796#M1826</guid>
      <dc:creator>chaopov</dc:creator>
      <dc:date>2018-12-11T03:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: QoS Monitoring (for PRTG Network Monitor)</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/275324#M1969</link>
      <description>&lt;P&gt;trying to implement this and am able to get it working in a testing environment, but in prod we have the PA's managed by Panorama.&amp;nbsp; For some reason when calling the config using the api, I dont get the ethernet names, ie ethernet1/1, so it breaks the PS script.&amp;nbsp; Is someone able to point out as to why the ethernets are not showing?&lt;/P&gt;&lt;P&gt;looking into the PS script, it is written as &amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;, i get a status="error"&lt;/P&gt;&lt;P&gt;when i manually call same thing, but if i add the addition xml of&amp;nbsp; &amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;entry name="ethernet1/1"&amp;gt;&amp;lt;show-bypass-node/&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;, i can see the data no problem&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 13:40:53 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/qos-monitoring-for-prtg-network-monitor/m-p/275324#M1969</guid>
      <dc:creator>nubsys</dc:creator>
      <dc:date>2019-07-08T13:40:53Z</dc:date>
    </item>
  </channel>
</rss>

