tynany / junos_exporter

Prometheus Exporter for Junos Devices
MIT License
19 stars 7 forks source link

Support for multi-routing-engine-item in XML #19

Closed Sparc0 closed 2 months ago

Sparc0 commented 5 months ago

When we try to export route engine metrics it works fine on single nodes or chassi based nodes with 2 route engines. But it cant export any metrics from e.g a SRX cluster because the XML output differs a little, and we endout with no metrics at all for the RE's.

MX with 2 RE's

sparco@mymx-0> show chassis routing-engine | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/20.4R0/junos">
    <route-engine-information xmlns="http://xml.juniper.net/junos/20.4R0/junos-chassis">
        <route-engine>
            <slot>0</slot>
            <mastership-state>master</mastership-state>
            <mastership-priority>master (default)</mastership-priority>
            <status>OK</status>
            <temperature junos:celsius="31">31 degrees C / 87 degrees F</temperature>
            <cpu-temperature junos:celsius="28">28 degrees C / 82 degrees F</cpu-temperature>
            <memory-dram-size>32703 MB</memory-dram-size>
            <memory-installed-size>(32768 MB installed)</memory-installed-size>
            <memory-buffer-utilization>9</memory-buffer-utilization>
            <cpu-user>3</cpu-user>
            <cpu-background>0</cpu-background>
            <cpu-system>4</cpu-system>
            <cpu-interrupt>0</cpu-interrupt>
            <cpu-idle>94</cpu-idle>
            <cpu-user1>3</cpu-user1>
            <cpu-background1>0</cpu-background1>
            <cpu-system1>4</cpu-system1>
            <cpu-interrupt1>0</cpu-interrupt1>
            <cpu-idle1>94</cpu-idle1>
            <cpu-user2>3</cpu-user2>
            <cpu-background2>0</cpu-background2>
            <cpu-system2>4</cpu-system2>
            <cpu-interrupt2>0</cpu-interrupt2>
            <cpu-idle2>93</cpu-idle2>
            <cpu-user3>3</cpu-user3>
            <cpu-background3>0</cpu-background3>
            <cpu-system3>4</cpu-system3>
            <cpu-interrupt3>0</cpu-interrupt3>
            <cpu-idle3>93</cpu-idle3>
            <model>RE-S-1800x4</model>
            <serial-number>123456</serial-number>
            <start-time junos:seconds="1697241610">2023-10-14 02:00:10 CEST</start-time>
            <up-time junos:seconds="20865812">241 days, 12 hours, 3 minutes, 32 seconds</up-time>
            <last-reboot-reason>Router rebooted after a normal shutdown.</last-reboot-reason>
            <load-average-one>0.33</load-average-one>
            <load-average-five>0.29</load-average-five>
            <load-average-fifteen>0.32</load-average-fifteen>
        </route-engine>
        <route-engine>
            <slot>1</slot>
            <mastership-state>backup</mastership-state>
            <mastership-priority>backup (default)</mastership-priority>
            <status>OK</status>
            <temperature junos:celsius="29">29 degrees C / 84 degrees F</temperature>
            <cpu-temperature junos:celsius="27">27 degrees C / 80 degrees F</cpu-temperature>
            <memory-dram-size>32703 MB</memory-dram-size>
            <memory-installed-size>(32768 MB installed)</memory-installed-size>
            <memory-buffer-utilization>9</memory-buffer-utilization>
            <cpu-user>1</cpu-user>
            <cpu-background>0</cpu-background>
            <cpu-system>1</cpu-system>
            <cpu-interrupt>0</cpu-interrupt>
            <cpu-idle>99</cpu-idle>
            <model>RE-S-1800x4</model>
            <serial-number>123456</serial-number>
            <start-time junos:seconds="1697239940">2023-10-14 01:32:20 CEST</start-time>
            <up-time junos:seconds="20867466">241 days, 12 hours, 31 minutes, 6 seconds</up-time>
            <last-reboot-reason>Router rebooted after a normal shutdown.</last-reboot-reason>
            <load-average-one>0.21</load-average-one>
            <load-average-five>0.21</load-average-five>
            <load-average-fifteen>0.17</load-average-fifteen>
        </route-engine>
    </route-engine-information>
    <cli>
        <banner>{master}</banner>
    </cli>
</rpc-reply>

SRX cluster with 2 nodes

sparco@mysrx-0> show chassis routing-engine | display xml                                                                                                                                                                                                                                                                                          [10/289]
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/20.4R0/junos">
    <multi-routing-engine-results>

        <multi-routing-engine-item>

            <re-name>node0</re-name>

            <route-engine-information xmlns="http://xml.juniper.net/junos/20.4R0/junos-chassis">
                <route-engine>
                    <status>OK</status>
                    <temperature junos:celsius="32">32 degrees C / 89 degrees F</temperature>
                    <cpu-temperature junos:celsius="32">32 degrees C / 89 degrees F</cpu-temperature>
                    <memory-system-total>3125</memory-system-total>
                    <memory-system-total-used>563</memory-system-total-used>
                    <memory-system-total-util>18</memory-system-total-util>
                    <memory-buffer-utilization>17</memory-buffer-utilization>
                    <cpu-user>0</cpu-user>
                    <cpu-background>0</cpu-background>
                    <cpu-system>1</cpu-system>
                    <cpu-interrupt>0</cpu-interrupt>
                    <cpu-idle>98</cpu-idle>
                    <cpu-user1>1</cpu-user1>
                    <cpu-background1>0</cpu-background1>
                    <cpu-system1>1</cpu-system1>
                    <cpu-interrupt1>0</cpu-interrupt1>
                    <cpu-idle1>98</cpu-idle1>
                    <cpu-user2>1</cpu-user2>
                    <cpu-background2>0</cpu-background2>
                    <cpu-system2>1</cpu-system2>
                    <cpu-interrupt2>0</cpu-interrupt2>
                    <cpu-idle2>98</cpu-idle2>
                    <cpu-user3>1</cpu-user3>
                    <cpu-background3>0</cpu-background3>
                    <cpu-system3>2</cpu-system3>
                    <cpu-interrupt3>0</cpu-interrupt3>
                    <cpu-idle3>97</cpu-idle3>
                    <model>SRX Routing Engine</model>
                    <serial-number>BUILTIN</serial-number>
                    <start-time junos:seconds="1673702855">2023-01-14 13:27:35 UTC</start-time>
                    <up-time junos:seconds="44405675">513 days, 22 hours, 54 minutes, 35 seconds</up-time>
                    <last-reboot-reason>0x4000:VJUNOS reboot</last-reboot-reason>
                    <load-average-one>0.28</load-average-one>
                    <load-average-five>0.31</load-average-five>
                    <load-average-fifteen>0.27</load-average-fifteen>
                </route-engine>
            </route-engine-information>
        </multi-routing-engine-item>

        <multi-routing-engine-item>

            <re-name>node1</re-name>

            <route-engine-information xmlns="http://xml.juniper.net/junos/20.4R0/junos-chassis">
                <route-engine>
                    <status>OK</status>
                    <temperature junos:celsius="33">33 degrees C / 91 degrees F</temperature>
                    <cpu-temperature junos:celsius="33">33 degrees C / 91 degrees F</cpu-temperature>
                    <memory-system-total>3125</memory-system-total>
                    <memory-system-total-used>469</memory-system-total-used>
                    <memory-system-total-util>15</memory-system-total-util>
                    <memory-buffer-utilization>14</memory-buffer-utilization>
                    <cpu-user>0</cpu-user>
                    <cpu-background>0</cpu-background>
                    <cpu-system>0</cpu-system>
                    <cpu-interrupt>0</cpu-interrupt>
                    <cpu-idle>99</cpu-idle>
                    <cpu-user1>0</cpu-user1>
                    <cpu-background1>0</cpu-background1>
                    <cpu-system1>0</cpu-system1>
                    <cpu-interrupt1>0</cpu-interrupt1>
                    <cpu-idle1>100</cpu-idle1>
                    <cpu-user2>0</cpu-user2>
                    <cpu-background2>0</cpu-background2>
                    <cpu-system2>0</cpu-system2>
                    <cpu-interrupt2>0</cpu-interrupt2>
                    <cpu-idle2>99</cpu-idle2>
                    <cpu-user3>0</cpu-user3>
                    <cpu-background3>0</cpu-background3>
                    <cpu-system3>1</cpu-system3>
                    <cpu-interrupt3>0</cpu-interrupt3>
                    <cpu-idle3>99</cpu-idle3>
                    <model>SRX Routing Engine</model>
                    <serial-number>BUILTIN</serial-number>
                    <start-time junos:seconds="1673701816">2023-01-14 13:10:16 UTC</start-time>
                    <up-time junos:seconds="44406714">513 days, 23 hours, 11 minutes, 54 seconds</up-time>
                    <last-reboot-reason>0x4000:VJUNOS reboot</last-reboot-reason>
                    <load-average-one>0.18</load-average-one>
                    <load-average-five>0.17</load-average-five>
                    <load-average-fifteen>0.16</load-average-fifteen>
                </route-engine>
            </route-engine-information>
        </multi-routing-engine-item>

    </multi-routing-engine-results>
    <cli>
        <banner>{primary:node0}</banner>
    </cli>
</rpc-reply>
tynany commented 2 months ago

Thanks for the detailed output! Multi-routing-engine-item is now supported in v1.4.0.