czerwonk / junos_exporter

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

handle platforms that don't support show system buffers command #239

Closed matejv closed 10 months ago

matejv commented 10 months ago

Juniper ACX platform does not suppoort show system buffers command, so the system collector crashed:

INFO[0000] Loading config from single.yaml 
INFO[0000] Starting JunOS exporter (Version: 0.12.3)    
INFO[0000] Listening for /metrics on :9326 (TLS: false) 
2024/01/17 08:10:18 Running command on rtr1.examle.com: show interfaces descriptions
2024/01/17 08:10:18 Output for rtr1.examle.com: <rpc-reply xmlns:junos="http://xml.juniper.net/junos/22.4R0/junos">
    <interface-information xmlns="http://xml.juniper.net/junos/22.4R1-S1.2-EVO/junos-interface" junos:style="description">
            <physical-interface>
                <name>et-0/0/0</name>
                <admin-status>up</admin-status>
                <oper-status>up</oper-status>
                <description></description>
            </physical-interface>
            <physical-interface>
                <name>et-0/0/1</name>
                <admin-status>up</admin-status>
                <oper-status>up</oper-status>
                <description></description>
            </physical-interface>
            <physical-interface>
                <name>et-0/0/3</name>
                <admin-status>up</admin-status>
                <oper-status>up</oper-status>
                <description></description>
            </physical-interface>
            <physical-interface>
                <name>et-0/0/4</name>
                <admin-status>up</admin-status>
                <oper-status>up</oper-status>
                <description></description>
            </physical-interface>
            <physical-interface>
                <name>et-0/0/38</name>
                <admin-status>up</admin-status>
                <oper-status>up</oper-status>
                <description></description>
            </physical-interface>
            <physical-interface>
                <name>et-0/0/47</name>
                <admin-status>up</admin-status>
                <oper-status>down</oper-status>
                <description></description>
            </physical-interface>
            <physical-interface>
                <name>et-0/0/51</name>
                <admin-status>down</admin-status>
                <oper-status>down</oper-status>
                <description></description>
            </physical-interface>
            <physical-interface>
                <name>et-0/0/53</name>
                <admin-status>up</admin-status>
                <oper-status>up</oper-status>
                <description></description>
            </physical-interface>
            <physical-interface>
                <name>ae1</name>
                <admin-status>up</admin-status>
                <oper-status>up</oper-status>
                <description></description>
            </physical-interface>
    </interface-information>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>

2024/01/17 08:10:18 Running command on rtr1.examle.com: show system buffers
2024/01/17 08:10:18 Output for rtr1.examle.com: 
error: syntax error, expecting <command>: buffers

ERRO[0003] System: could not get buffer information: XML syntax error on line 3: unexpected EOF 

It's still nice to get other metrics (mainly os_version) that the system collector provides so I made a patch that won't crash if buffers command does not exist.

I've looked at pkg/features/environment/collector.go how it handles possible non existing command show chassis environment satellite and made a similar change in system collector.

czerwonk commented 10 months ago

Thanks for your contribution! :+1: