Problems with telemetry (jtimon/Telegraf) on Juniper OS (Junos) - grpc

we are trying to set some telemetry environment on a Juniper VMX (virtual) router located on AWS.
We configured the router following the documentation, and tried to get some telemetry data from it via jtimon and Telegraf.
The gRPC connection is established and we do receive data, but not exactly what we want. Before continuing, I'm sharing the configuration that we use :
Router configuration (telemetry-related) :
system {
services {
extension-service {
request-response {
grpc {
clear-text {
port 32767;}
skip-authentication;
}
}
notification {
allow-clients {
address 0.0.0.0/0;
}
}
}
}
schema {
openconfig {
unhide;}
On Telegraf, we have these settings (for example) :
[[inputs.jti_openconfig_telemetry]]
servers = ["10.0.100.202:32767"]
sample_frequency = "10000ms"
sensors = [
"15000ms /junos/system/linecard/cpu/memory"
"2000ms /components"
]
collection_jitter = "0s"
flush_interval = "15s"
flush_jitter = "0s"
precision = ""
debug = true
quiet = false
Basically, our sensors gets created on the router, and we can see them with the show agent sensors command. What we cannot understand is that if we change the sensor in the configuration file of Telegraf, we will still receive the information of all previously subscribed sensors. To be clear : in the example, we subscribe to /junos/system/linecard/cpu/memory and /components. If I delete these lines, subscribe to /interfaces and run Telegraf, we will receive the information from the 3 sensors (/components, .../cpu/memory and /interfaces).
As we understand, this is due to an "ephemeral-configuration" called "junos-analytics", as written in the official documentation :
Starting in Junos OS Release 18.2R1, when an external streaming server, or collector, provisions sensors to export data through gRPC on devices running Junos OS, the sensor configuration is committed to the junos-analytics instance of the ephemeral configuration database, and the configuration can be viewed by using the show ephemeral-configuration instance junos-analytics operational command.
Thing is, we don't understand how to edit/disable/delete this "junos-analytics" instance. From what we see, some new sensors (sometimes with the exact same path) get created (with a different sensor ID / name) everytime we run Telegraf. We don't know how to delete them (we tried with a delete services analytics sensor *sensor_name* but it resulted in a "statement not found" error message...).
To sum up, we do receive our sensors' data, but it comes in the middle of lots and lots of other (useless) previously subscribed data.
I feel like we might be missing something in the router configuration, as Telegraf and jtimon show the same behaviour/results.
Any help is appreciated, I can of course share more information if needed ! Thanks in advance :)

Just in case someone is having the same problem : we contacted the Juniper support, they asked us to upgrade our Junos version (from 18.2 to 19.X) and that solves the problem !

Related

GetTwinAsync() are not supported in IoT edge Simulator v0.14.10

GetTwinAsync() returns always Twin object with empty properties, all properties of my IoT edge module are null when I run my IoT edge device in Simulator, in my Linux server works everything fine. I should wait also about 20 seconds to get a response from GetTwinAync().
If we look at it, this problem is expected. If you read this Understand and use module twins in IoT Hub document, then you will see that from module app, only has permission to read desired properties and read/write reported properties. If you check this image below you will understand better.
The lifecycle of a module twin is linked to the corresponding module identity. Modules twins are implicitly created and deleted when a module identity is created or deleted in IoT Hub.
To access all module properties, you can do it from solution back end and require the ServiceConnect permission. You will need Microsoft.Azure.Devices V1.16.0-preview-001 or later. The following is a console app code snippet.
...
RegistryManager registryManager = RegistryManager.CreateFromConnectionString(connectionString);
Module module;
try
{
module = await registryManager.AddModuleAsync(new Module(deviceID, moduleID));
}
catch (ModuleAlreadyExistsException)
{
module = await registryManager.GetModuleAsync(deviceID, moduleID);
}
...
For more detailed explanation and example check this Get started with IoT Hub module identity and module twin (.NET). If your issue still persist then you can open an issue on azure-iot-sdk-csharp repository.

SignalR not working correctly after deployment on windows server 2012

I am facing issues in live environment. When ever a ever a page is loaded signal r connection is created but connectionids of other connects are not available for the new connectionids and also for old connectionId this newly created connection is not available. To make it better understand see the code below
My method in chathub.vb which is called from server side
Public Sub getGonnected()
Clients.Client(Context.ConnectionId).hello("Connection is connected CONNECTIONID = " + Context.ConnectionId)
Dim heartBeat = GlobalHost.DependencyResolver.Resolve(Of ITransportHeartbeat)()
Dim connectionAlive = heartBeat.GetConnections().Where(Function(c) c.ConnectionId <> Context.ConnectionId).ToList()
Clients.Client(Context.ConnectionId).hello("Other Connections Available ..............................................................")
For Each item In connectionAlive
Clients.Client(Context.ConnectionId).hello(".................................................................. " + item.ConnectionId)
Next
Clients.Client(Context.ConnectionId).hello("End of other connections available ........................................................")
Clients.All.hello("Total Number of users available ..................................................................")
Clients.All.hello("........................................................................... " + connectionAlive.Count().ToString())
Clients.All.hello("End total Number of users available ...............................................................")
End Sub
And in my clients side
chat.client.hello = function(ping)
{
console.log(ping);
}
$.connection.hub.start().done(function () {
});
setInterval(function () {
chat.server.getGonnected().done(function (result) {
console.log('connectionRequestsent')
});
}, 5000);
Also in my web.config I have added following settings
target framework 4.5
As per above example code above
I am not able to see a new connection in the borwsers console when some new user registers will signalr. And also that new user is unable to see the ConnectionId's of already present users in signalr in the browser console.
This thing is only happening on server. An help would be much appretiated. I have already enabled websockets and my websockets handshake is successfull. Moreover the spefic conntectionId is able to send and recieve messages to and from server. But not with other connectionId as the are not availble.
In simple words some times
Dim connectionAlive = heartBeat.GetConnections().Where(Function(c)
c.ConnectionId <> Context.ConnectionId).ToList()
Length is 0 where as there are already other connections in the app. Which I am not sure why is happening.
Any help or guidance will be much appreciated.
SignalR version is 2.1.0
Regards
Abdul
I don't think this has anything to do with WIndows Server 2012. You will have to implement this yourself in either a dictionary, database or something else suitable to your situation.
Using the OnConnect event, you can broadcast to every currently connected client an update that someone has joined or with the OnDisconnect that someone has left as well. If you want it to be a list of currently connected users you would query your dictionary/database/else... and broadcast.
SignalR Documentation has some examples.
Download working signalr project at https://github.com/aspnet/SignalR-samples from the developer
After downloading select any of the examples in the directory which you will run through your visual studio.
I select ChatSample run and follow the on-screen instruction
After that go through the documentation to read through each files how it works at
https://learn.microsoft.com/en-us/aspnet/core/signalr/
Please install the latest version of .Net Framework, in my case this solve the problem, I installed 4.8 and all broadcast messages were sent.

No such interface 'org.freedesktop.DBus.Properties' on object at path /org/freedesktop/NetworkManager/ActiveConnection/

I start my qt application in the user's .profile file (not root) to make the app start on boot. Sometimes when my application start, it reports an warning as below:
"No such interface 'org.freedesktop.DBus.Properties' on object at path /org/freedesktop/NetworkManager/ActiveConnection/1"
I searched on google but did not find a explanation.
It seems my app is still working fine, but I want to locate the problem.
The application is running on ubuntu and using Qt5.
Thanks in advance.
Edit
I tried to debug dbus based on Eligijus Pupeikis's help with running:
gdbus introspect --system \
--dest org.freedesktop.NetworkManager \
--object-path /org/freedesktop/NetworkManager/ActiveConnection
it returns:
node /org/freedesktop/NetworkManager/ActiveConnection {
node 0 {
};
};
So, this means there is no such object just as the error message said, right?
And also, this gns3 team member says this problem is about Qt and Ubuntu.
Does this mean I don't need to solve it? I not familiar with the relationship between dbus and qt.
Most likely there is no such object "/org/freedesktop/NetworkManager/ActiveConnection/1" and because of that it can't find 'org.freedesktop.DBus.Properties' interface.
From documentation org.freedesktop.NetworkManager.Connection.Active :
Objects that implement the Connection.Active interface represent an attempt to connect to a network using the details provided by a Connection object. The Connection.Active object tracks the life-cycle of the connection attempt and if successful indicates whether the connected network is the "default" or preferred network for access. NetworkManager has the concept of connections, which can be thought of as settings, a profile or a configuration that can be applied on a networking device. Such settings-connections are exposed as D-Bus object and the active-connection expresses this relationship between device and settings-connection. At any time a settings-connection can only be activated on one device and vice versa. However, during activation and deactivation multiple active-connections can reference the same device or settings-connection as they are waiting to be activated or to be deactivated.
You can't know that that ActiveConnection object with specifically index 1 exists so you need to check by reading ActiveConnections property from /org/freedesktop/NetworkManager object's org.freedesktop.NetworkManager interface.
To have better visualize and understand how it looks I suggest D-Bus debugger. If you are using Gnome check out D-Feet.

setting static IP for wifi connection in QT

I am trying to create a QT based application that scan and connect WiFi networks. I am using this example as a reference code.
Is it possible to assign static IP for the WiFi connection using QNetworkConfiguration or any related class ?
How to authenticate the networks that are password protected ?
thanks in advance......
I have created a net work session using the below code set..
void BearerMonitor::createNewSessionFromQml(QString ssid)
{
QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations();
while (!allConfigurations.isEmpty()) {
QNetworkConfiguration config = allConfigurations.takeFirst();
if(config.name()==ssid)
createSessionFor(config);
}
}
SessionWidget::SessionWidget(const QNetworkConfiguration &config, QObject *parent):QObject(parent)
{
session = new QNetworkSession(config, this);
session->open();
}
No you can't. At least not with just Qt APIs.
Please read this and in particular this. QNetworkConfiguration is just a facility to manage network configurations. Editing such configurations is demanded to native code / OS interactions. From the second link:
Note that the QNetworkConfiguration object only provides limited information about the configuration details themselves. It's main purpose is to act as a configuration identifier through which link layer connections can be created, destroyed and monitored.
Even the "start/stop network interfaces" claim is not entirely true since such a feature is available only in certain OSs (not the mobile ones). See the "Platform capabilities" section of the second link for more details about that.
The same reasoning applies to the password question. Once a network is registed in the OS with the corresponding password (because of native code or the user physically registering it) a new configuration is available to the NetworkConfigurationManager, granted that the list of configurations is updated via updateConfigurations(). The new configuration contains the password but you can't edit it from Qt APIs.
Native code is the only solution, as said. Still, Apple does not want you to mess up with WiFi programatically since private APIs for that cannot be used in iOS > 5.1 (the oldest version supported by Qt as for Qt 5.4).

Read weight of package from a Fedex scale within web application?

I've been asked if I can read the weight from a scale, connected via RS232, and dump it into a web application. Reading the weight of the scale from the local machine isn't bad (this SO question gives an explanation: RS232 question - how to read weight to PC), but...
How do I then get that data to paste into a box in my web application...? Ideas?
I'm running into a similar-but-reverse situation with Fedex and UPS labels. I can get the label data within the web application, but I need to send that data via a raw printer socket (i.e. I can't just File > Print) to the local printer... how?
FedEx and UPS now how Zebra printers that can be network attached. Printing to them is easy via .NET and the standard Windows Spooler using the UNC path to the printer. The trick is how to expose the printer to your web application. If you web application is on the same network as your printer (intranet), the answer is simple. Send the data to the printer via the Windows Spooler from your web server in a server side call from your web app clients. If your web application is hosted outside of your local network, stand up a web service and write a web service to receive the ZPL (Zebra Printer Language) from your web app. The web service would also use the windows spooler to send to the printer on the same network.
Usually web applications are unable to communicate directly with a PC unless there's a full trust between the server and the client. Even then, web pages lack the ability to talk to peripheral devices for myriad security reasons. For a problem like this, you'd almost have to run some kind of client/service background application on the PC.
For the print from web app functionality, QZ Tray is a little java app that does the heavy lifting for you. You can snakeoil a cert, too, instead of paying for their custom cert for their silent printing.
I've been asked if I can read the weight from a scale, connected via RS232, and dump it into a web application.
Although this can't be done directly through JavaScript, a custom client-side or server-side solution can help. There are some server-side and desktop products which expose this functionality to a webpage (RS232 scales, USB scales)
To elaborate specifically on Gordon's recommended QZ Tray approach (assumes the PC has QZ Tray installed; assumes the page has been configured to use QZ Tray), here's a technique which will work for a serial port connected to a Mettler Toledo scale. The commands vary between scale suppliers, so adapt as needed.
Disclaimer, we're the authors of QZ Tray.
Connect to COM1, send command, disconnect
// MT = Mettler Toledo. Change as needed.
var port = 'COM1'; // <-- COM1, '/dev/ttyUSB0', etc
var cmd = 'W\n'; // <--- MT Weight command
var baud = {
baudRate: 9600,
dataBits: 7, // <--- MT Changed from 8
stopBits: 1,
parity: 'EVEN', // <--- MT Changed from NONE
flowControl: 'NONE'
};
var delims = {
begin: '\x02', // <--- MT start of message
end: '\x0D', // <--- MT end of message
width: null // <--- MT doesn't use width
};
qz.serial.openPort(port, delims).then(function() {
return qz.serial.sendData(port, cmd, baud);
}).catch(function(err) { console.error(err); } );
qz.serial.setSerialCallbacks(function(evt) {
if (evt.type !== 'ERROR') {
console.log('Serial', evt.portName, 'received output', evt.output);
} else {
console.error(evt.exception);
}
// Close port
return qz.serial.closePort(evt.portName);
});
I'm running into a similar-but-reverse situation with Fedex and UPS labels. I can get the label data within the web application, but I need to send that data via a raw printer socket (i.e. I can't just File > Print) to the local printer... how?
Duplicate of https://stackoverflow.com/a/28783269/3196753.

Resources