Coder Social home page Coder Social logo

telegraf-exec-fortiswitch's People

Contributors

emilvonck avatar

Watchers

 avatar  avatar

telegraf-exec-fortiswitch's Issues

set all properties from _property_extractors

Example

    def _property_extractors(self):
        # noqa: D102
        extractors = {
            "system_status": self._get_system_status(),
            "capabilities": self._get_switch_capabilities(),
        }

        for k, v in extractors.items():
            setattr(self, f"_{k}", v)

    @property
    def system_part_number(self):
        # noqa: D102
        return self._system_status["system_part_number"]

ability to define destination port of FortiSwitch API

Add in the init method

class FortiSwitch:
    """Class for interacting with the FortiSwitchOS API."""

    def __init__(self, host: str, username: str, password: str, verify: bool = True):
        """Initializor for the class.

        Args:
            host (str): Host for the API, IP or DNSname.
            username (str): Username.
            password (str): Password.
            verify (bool, optional): Whether to verify SSL certificates or not. Defaults to True.
        """
        self.host = host
        self.username = username
        self.password = password
        self._verify = verify

inconsistent return for psu_status

data returned from get_system_psu_status is inconsistent
Example

[{
	"name": "PSU1",
	"status": "OK"
}, {
	"name": "PSU2",
	"connection": "Not inserted"
}]

Would be better if the method returned something like this instead, so we kan make a influx key for "name" and _value will be "status"

[{
	"name": "PSU1",
	"status": "OK"
}, {
	"name": "PSU2",
	"status": "Not inserted"
}]

convert lanes from module_status to dict

    {
        'status': 'ok',
        'temperature': {'value': 33.039062, 'unit': 'C'},
        'voltage': {'value': 3.1971, 'unit': 'volts'},
        'lanes': [
            {'lane': 0, 'alarm-flags': '0x0040', 'warning-flags': '0x0040', 'laser-bias': {'value': 3.5136, 'unit': 'mAmps'}, 'tx-power': {'value': 0.932115, 'unit': 'dBm'}, 'rx-power': {'value': '-Infinity', 'unit': 'dBm'}},
            {'lane': 1, 'alarm-flags': '0x0040', 'warning-flags': '0x0040', 'laser-bias': {'value': 3.7312, 'unit': 'mAmps'}, 'tx-power': {'value': 0.545748, 'unit': 'dBm'}, 'rx-power': {'value': '-Infinity', 'unit': 'dBm'}},
            {'lane': 2, 'alarm-flags': '0x0040', 'warning-flags': '0x0040', 'laser-bias': {'value': 3.488, 'unit': 'mAmps'}, 'tx-power': {'value': 1.137429, 'unit': 'dBm'}, 'rx-power': {'value': '-Infinity', 'unit': 'dBm'}},
            {'lane': 3, 'alarm-flags': '0x0040', 'warning-flags': '0x0040', 'laser-bias': {'value': 3.8144, 'unit': 'mAmps'}, 'tx-power': {'value': -0.448416, 'unit': 'dBm'}, 'rx-power': {'value': '-Infinity', 'unit': 'dBm'}}
        ],
        'options': {'hex': '0x0023', 'values': ['TX_DISABLE', 'TX_FAULT', 'TX_POWER_LEVEL3']},
        'options-status': {'hex': '0x0020', 'values': ['TX_POWER_LEVEL3']},
        'interface': 'port52'
    }

to something like this

    {
        'status': 'ok',
        'temperature': {'value': 37.417969, 'unit': 'C'},
        'voltage': {'value': 3.3005, 'unit': 'volts'},
         'lane_0': 'alarm-flags': '0x0040', 'warning-flags': '0x0040', 'laser-bias': {'value': 3.5136, 'unit': 'mAmps'}, 'tx-power': {'value': 0.932115, 'unit': 'dBm'}, 'rx-power': {'value': '-Infinity', 'unit': 'dBm'}},
         'lane_1': and so on,
         'lane_2': and so on,
         'lane_3': {and so on,
        'options': {'hex': '0x000F', 'values': ['TX_DISABLE', 'TX_FAULT', 'RX_LOSS', 'TX_POWER_LEVEL1']},
        'options-status': {'hex': '0x0008', 'values': ['TX_POWER_LEVEL1']},
        'interface': 'port1'
    },

add model as property

can be fetched from https://{{host}}/api/v2/monitor/switch/capabilities

{
  "http_method":"GET",
  "results":{
    "fortiswitch":[
      {
        "system-info":{
          "model":"FortiSwitch-108E-FPOE",
          "version":"v7.2.2,build0419,220902 (GA)",

show available values for --cls_method in help for cli

Something like this would be nice

❯ python fortiswitch_cli.py --help
usage: fortiswitch_cli [options]

Fetch data from FortiSwitch API

optional arguments:
  -h, --help            show this help message and exit
  --host HOST           FortiSwitch API host. (default: None)
  --port PORT           Destination port for FortiSwitch API host (default: 443)
  --username USERNAME   FortiSwitch username. (default: None)
  --password PASSWORD   FortiSwitch password. (default: None)
  --cls_method CLS_METHOD
                        FortiSwitch class method: get_switch_poe_status, get_switch_port_state,
                        get_switch_port_statistics, get_switch_properties, get_system_cpu_usage,
                        get_system_fan_status, get_system_mem_usage, get_system_pcb_temp,
                        get_system_poe_status, get_system_psu_status, get_system_upgrade_status
                        (default: None)
  --ignore_ssl          Skip SSL certificate verification. (default: True)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.