czerwonk / junos_exporter

Exporter for devices running JunOS to use with https://prometheus.io/
MIT License
198 stars 81 forks source link

add metrics for VRRP state #158

Closed kakkotetsu closed 3 years ago

kakkotetsu commented 3 years ago

This PR adds prometheus metrics for VRRP state.

The following metrics are now exposed.

# HELP junos_vrrp_state VRRP state (1: init, 2: backup, 3: master)
# TYPE junos_vrrp_state gauge
junos_vrrp_state{group="255",interface="ge-0/0/0.10",local_interface_address="10.138.125.2",target="ex3200-1",virtual_ip_address="10.138.125.1"} 3
junos_vrrp_state{group="255",interface="ge-0/0/0.10",local_interface_address="10.138.125.3",target="ex3200-2",virtual_ip_address="10.138.125.1"} 2
junos_vrrp_state{group="255",interface="ge-0/0/0.11",local_interface_address="10.138.125.66",target="ex3200-1",virtual_ip_address="10.138.125.65"} 3
junos_vrrp_state{group="255",interface="ge-0/0/0.11",local_interface_address="10.138.125.67",target="ex3200-2",virtual_ip_address="10.138.125.65"} 2

This metrics is based on the output of show vrrp summary | display xml

<rpc-reply xmlns:junos="http://xml.juniper.net/junos/12.3R12/junos">
    <vrrp-information xmlns="http://xml.juniper.net/junos/12.3R12/junos-vrrpd" junos:style="summary">
        <vrrp-interface>
            <interface>ge-0/0/0.10</interface>
            <interface-state>up</interface-state>
            <group>255</group>
            <vrrp-state>backup</vrrp-state>
            <vrrp-mode>Active</vrrp-mode>
            <local-interface-address>10.138.125.3</local-interface-address>
            <virtual-ip-address>10.138.125.1</virtual-ip-address>
        </vrrp-interface>
        <vrrp-interface>
            <interface>ge-0/0/0.11</interface>
            <interface-state>up</interface-state>
            <group>255</group>
            <vrrp-state>backup</vrrp-state>
            <vrrp-mode>Active</vrrp-mode>
            <local-interface-address>10.138.125.67</local-interface-address>
            <virtual-ip-address>10.138.125.65</virtual-ip-address>
        </vrrp-interface>

...

    </vrrp-information>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>
czerwonk commented 3 years ago

Thanks for contributing! 👍