Frameworks like Genie Parser or TextFSM parse the output of the configuration. That is what the device answers when you ask it about some part of the configuration, like show ip route or show access-lists.
For example, this is the output of ACLs and it can be parsed by the aforementioned frameworks:
switch1#show access-lists
Standard IP access list acl-snmp-4
10 permit 10.0.0.1
20 permit 10.0.0.2
30 permit 192.168.0.1
40 permit 192.168.0.2
What I'm looking for is parsing the input - the text people need to type in when configuring the device. This is useful when one wants to programatically verify that the configuration standard is correct.
For example, verify that the following snippet has the correct IPs:
ip access-list standard ACL1
remark Server1
permit host 10.0.0.1
permit host 10.0.0.2
remark Server2
permit host 192.0.0.3
permit 54.101.80.0 0.0.0.63
I'm using some for loops and regex at the moment, but it gets messy when you get dozens of device types, OS types, config styles.
With show access-list you can see the operational data and not directly the configuration and yes, Genie or TextFSM are solutions to convert operational text output into structured data.
For configuration data, I would recommend to take a look at ttp.
I'm not quite sure what use case you are trying to solve. If you want to generate configuration, why not use a templating engine? For example, jinja2
The CLI is not really designed for automation, so check if your devices have proper APIs like netconf-yang.
Related
My requirement is to monitor the helpdesk system of the company which is running inside the Kubernetes cluster, for example, URL https://xyz.zendesk.com
They provide their API set to monitor this efficiently.
We can easily check the status using curl
$ curl -s "https://status.zendesk.com/api/components/support?domain=xyz.zendesk.com" | jq '.active_incidents'
[]
The above output means success status according to zendesk documentation.
Now the main part is, the company uses Prometheus to monitor everything.
How to have Prometheus check the success status from the output of this curl command?.
I did some research already and found somewhat related threads here and using pushgateway
Are they applicable to my requirement or going in the wrong route?
What you probably (!?) want is something that:
Provides an HTTP(s) (e.g. /metrics) endpoint
Producing metrics in Prometheus' exposition format
From Zendesk's API
NOTE curl only gives you #3
There are some examples of solutions that appear to meet the requirements but none is from Zendesk:
https://www.google.com/search?q=%22zendesk%22+prometheus+exporter
There are >2 other lists of Prometheus exporters (neither contains Zendesk):
https://prometheus.io/docs/instrumenting/exporters/
https://github.com/prometheus/prometheus/wiki/Default-port-allocations
I recommend you contact Zendesk and ask whether there's a Prometheus Exporter already. It's surprising to not find one.
It is straightforward to write a Prometheus Exporter. Prometheus Client libraries and Zendesk API client are available and preferred. While it's possible, bash is probably sub-optimal.
If all you want to do is GET that static endpoint, get a 200 response code and confirm that the body is [], you may be able to use Prometheus Blackbox exporter
NOTE Logging and monitoring tools often provide a higher-level tool that provides something analogous to a "universal translator", facilitating translation from 3rd-party systems' native logging|monitoring formats into some canonical form using config rather than code. Although in the logging space, fluentd is an example. To my knowledge, there is no such tool for Prometheus but I sense that there's an opportunity for someone to create one.
I have a next LAN scheme:
<MyPC 10.220.0.x> --- <WinServ 2008r2 10.220.0.x> --- <Xerox WC 192.168.0.x>
Server has PrintServer role enabled and printer is shared. I want to monitor the printer's state/errors through SNMP but problem is that I haven't acess to printer directly because it is in a different network. I can operate with printer ONLY as a shared i.e. through printserver, so my question is - how I can make SNMP requests to shared printer? Is it possible?
If the device in the middle is routing the relevant traffic and the config on the printer allows it to respond to SNMP requests from outside its subnet then there's nothing to stop it from working.
But those are really big caveats, particularly the first one.
If you are doing any NAT on the box in the middle, then either replace it with a Linux box or proper router or find another problem to solve.
If it's not routing, then you need to set this up (note that you want a STATIC route).
If it is routing already then you probably need to look at the firewall to make sure its allowing the traffic.
If that's all working then you need to look at the SNMP policy on the printer.
Your network diagram is vague enough that they could all be on the same LAN.
If so lucky, then just set a static route to the 192.168 network on "My PC". eg.
route add 192.168.0.0 mask 255.255.0.0 IP-ADDRESS-OF-MY-PC
If you can ping your printer, then you can access it via SNMP, assuming
there are no firewalls on the printer disallowing this.
I have a language monitor that I am trying to query the printer from.
First let me apologize for the possible confusion since "port" means 2 things in this description. There is the one use that refers to the port that the printer is configured to use, which could be TCP, USB, etc. And then there is the use of port that refers to the port address to send data to when communicating with the printer's IP address.
I need to be able to specify different port addresses to send different custom queries to a printer over the same IP that are specific to it's firmware. I can't find any examples or documentation on what the standard way is to do this communication... I can extract the IP address and open a net socket, but I am not sure if this is the appropriate way to handle this communication. It's not uncommon for printers to send status over one port, and print data over another. If i want to write to the Default port I can use pfnWritePort and pfnReadPort, but these don't allow me to specify the actual port.. it uses whatever the driver is configured as.
Can anyone provide some guidance or examples of how I should do this from my language monitor?
EDIT: As an example for clarification, all commands are sent to the same IP, but depending on the command/query I need to send, the TCP port needs to change. The way I am handling it now is opening up a net socket with the same IP and different port numbers for data and status channels).
You should be required to write an app that would be able to reconfigure driver. Ideology of OS is that EACH real device would corresponds to instance of driver and\or interface. Which might be an elevated action, because it requires to create new printer interface("port" in Windows GUI terms) and change driver settings.
I am implementing a component that receives IP addresses and port ranges from command line or configuration files. For IP addresses, I use the CIDR notation. However I'm unable to find out if there is a similar standard for specifying network ports or network port ranges.
I currently envision a simple comma-separated list of dash-separated ranges (e.g., "3999,5001-9999") but I'd like to refer to some specification (RFC or otherwise) that defines it. I'm even willing to switch to a different notation as long as there is some standard to back it.
Packet sniffers generally do not capture localhost traffic. I need to inspect some post data in a localhost environment (being generated from a Ruby on Rails development). Do you know of any programs that expose localhost packets?
I use fiddler on my Windows box for http sniffing. Since its only looking at http traffic you don't get nearly the amount of noise you get with something like WireShark.
The trick to getting it to work with data sent and received locally is to use a different endpoint for your urls. Using http://127.0.0.1./YourServiceName instead of http://localhost/YourServiceName has always worked for me. Its important to include the trailing 'dot' in the IP address. Don't ask me why though.
If you use Firefox, you could use the HTTP Logging feature:
https://developer.mozilla.org/en/HTTP_Logging
If you just change your address from localhost to an assigned IP address (like 192.168.12.34 or whatever you may have), your packet sniffer should be able to see the packets.
These packets probably do not exist. There is no reason to packetize data when it is not leaving the host. The data should just go from socket to socket.
You might use something like Instruments or Dtrace to monitor the send system call.
I'm a satisfied user of HTTPScoop: http://www.tuffcode.com/
It's similar to the HTTP traffic analyzer addons you'll see for firefox etc. but works systemwide which is convenient and can be switched to observe any of your available network interfaces.
It is not free, nor does it observe HTTPS traffic, but other than that it's a worthwhile addition to your toolbox.