snmp: getting the short interface name instead of long ifDescr (again)
257
It seems that using IF-MIB::ifDescr
for the interface name is simply wrong.
As the name of the OID implies, this is meant to be a (verbose) description ofthe interface, rather than a (unique) name.
The proper OID to use is IF-MIB::ifName
$ snmpwalk -Os -c public -v 1 wheezy 1.3.6.1.2.1.31.1.1.1.1
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "lo"
iso.3.6.1.2.1.31.1.1.1.1.2 = STRING: "eth0"
iso.3.6.1.2.1.31.1.1.1.1.3 = STRING: "eth1"
$ snmpwalk -Os -c public -v 1 jessie 1.3.6.1.2.1.31.1.1.1.1
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "lo"
iso.3.6.1.2.1.31.1.1.1.1.2 = STRING: "eth0"
iso.3.6.1.2.1.31.1.1.1.1.3 = STRING: "eth1"
In the case of cricket
this means that i changed the cricket-configuration of the interface-map to:
OID ifName 1.3.6.1.2.1.31.1.1.1.1
map interface-name
base-oid = ifName
match = %interface-name%
Related videos on Youtube
Author by
Robert Marciniak
Updated on September 18, 2022Comments
-
Robert Marciniak almost 2 years
I have a dash app where I added a JS code to print.window on button. The code works fine on each page of the multipage app and when printing multiple times on the page, but once I migrate back to a page I previously hit the button, it fails to work. Would this be a JS not executing problem? or something else? The code should execute 'on click', not on n_clicks count so nothing needs to be reset to zero. Thanks.
from dash import Dash, dcc, html, Input, Output, callback import dash_bootstrap_components as dbc app = Dash(__name__, suppress_callback_exceptions=True) app.layout = html.Div([ dcc.Location(id='url', refresh=False), html.Div(id='page-content') ]) index_page = html.Div([ dcc.Link('Go to Page 1', href='/page-1'), html.Br(), dcc.Link('Go to Page 2', href='/page-2'), ]) page_1_layout = html.Div([ html.H1('Page 1'), html.Div(id='hidden-content'), dbc.Button('Print', id='printing', color="#D3D3D3", outline=False, style={"background": "transparent", 'color': 'grey', 'border': '0px'}, className="mr-1"), html.Div(id='page-1-content'), html.Br(), dcc.Link('Go to Page 2', href='/page-2'), html.Br(), dcc.Link('Go back to home', href='/'), ]) @callback(Output('page-1-content', 'children'), [Input('page-1-dropdown', 'value')]) def page_1_dropdown(value): return f'You have selected {value}' page_2_layout = html.Div([ html.H1('Page 2'), dbc.Button('Print', id='printing', color="#D3D3D3", outline=False, style={"background": "transparent", 'color': 'grey', 'border': '0px'}, className="mr-1"), html.Div(id='page-2-content'), html.Br(), dcc.Link('Go to Page 1', href='/page-1'), html.Br(), dcc.Link('Go back to home', href='/') ]) @callback(Output('page-2-content', 'children'), [Input('page-2-radios', 'value')]) def page_2_radios(value): return f'You have selected {value}' # Update the index @callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/page-1': return page_1_layout elif pathname == '/page-2': return page_2_layout else: return index_page # You could also return a 404 "URL not found" page here app.clientside_callback( """ (function() { registerPrintButtonHandler(); return; function registerPrintButtonHandler() { var button = document.getElementById("printing"); if (!button || button.onclick === onPrintButtonClick) { setTimeout(registerPrintButtonHandler, 500); return; } button.onclick = onPrintButtonClick; } function onPrintButtonClick() { { setTimeout(window.print, 700); }; } })(); """, Output('blank-output2', 'children'), Input('printing', 'value') ) if __name__ == '__main__': app.run_server(debug=True)
-
emher over 2 yearsCould you add a complete (i.e. runnable) MWE? That would ease reproduction/debugging of the issue.
-
emher over 2 yearsAlso, could you elaborate on why you are not using Dash callback rather than doing JS event handling manually?
-
Robert Marciniak over 2 yearsThank you for your help. I made a copy and paste functional MWE that seems to replicate my issue. Specifically, when I navigate from "home page" to page 1 and hit print, it works well, but when I nagivate "home" and back to page one I cannot get it to execute.
-
Robert Marciniak over 2 yearsAs per your question: I believe print.window() functions cannot be executed with a Dash callback but necessitate either a client-side callback or JS file in the assetsf folder. But please correct me if I'm wrong.
-
emher over 2 yearsI just tested your code, and on my PC, the print popup is shown on every button click.
-
Robert Marciniak over 2 yearsI tried the code again in Safari and Chrome. Both replicated the failure. To clarify, the problem occurs going to page 1 -> back to home page and -> returning to page 1. The print function fails to execute. However, if I navigate from page 1-2 and back to page 1 it works fine. Quite bizarre
-