# Midware User Manual ###### tags: `By_Ivan` ## Program usage ### Required arguments ```shell usage: xxxx_main.py [-h] [options] {start,stop,restart,daemon} ``` Note : In order to run the python script directly, change the script file's mode beforehand. ```shell sudo chmod +x xxxx_main.py ``` ### Optional arguments: -h, --help show this help message and exit >Shows a Linux-style help menu. -c path, --config path config file path -l path, --log path log file path -o path, --out_Dir path output directory path -p path, --pidfile path pidfile path >Change the pathing setting. :::info Note that the arguments only accept absolute paths. ::: If no input is given, the fallowing files in the **project dirctory** would be used as default.</br> Default file/directory name: |Argument | Option | Default name | |:---: | :-------- | -------- | |-c | config | midware.conf | |-l | log | .midware.log | |-o | out dirctory | /probe | |-p | pidfile | .pidfile | -v logging level >Adjust the verbose level. Add more v's to increase the verbose level : "-vv", "-vvv", etc.</br> By default, only those messages with level higher then **Info** will be logged, and trace back is disabled.</br> Add any level of verbose will enable traceback logging. ## Endpoint usage 1. zabbix_midware > **show:**</br> > curl -X GET IP:8880/show | curl -X GET IP:8880/show?pretty - Shows the current setting information, in which contains the list of monitored items. - The result would be shown in json format. ```shell! curl "127.0.0.1:8880/show?pretty" { "zabbix_probe": { "3": { "10020": { "name": "Zabbix agent ping", "probe_server": "-" } } } } ``` > **init:**</br> > curl -X GET IP:8880/init - Reset the setting to default. - By default, all the items in zabbix's system would be monitored. ```shell! curl "127.0.0.1:8880/init" {"message":"init complete"} ``` > **update:**</br> > curl -X POST --data "ItemID=someItemId" IP:8880/update - Given a item's ID, the item would be added to the monitored list; or, update its information (its item name). ```shell! curl -X POST -d "itemID=10020" "127.0.0.1:8880/update" {"message":"update complete"} ``` > **delete:**</br> > curl -X POST --data "ItemID=someItemId" IP:8880/delete - Given a item's ID, the item would be removed from the monitored list. ```shell! curl -X POST -d "itemID=10020" "127.0.0.1:8880/delete" {"message":"delete complete"} ``` 2. snmp_midware > **show:**</br> > curl -X GET IP:8890/show </br> > curl -X GET IP:8890/show?pretty - Shows the current setting information, including information of the hosts, the output name, and a list of OIDs. - The result would be shown in json format. ```shell! curl "127.0.0.1:8890/show?pretty" { "name": "snmpProbe", "OIDs": [ ".1.3.6.1.4.1.2021.11", ".1.3.6.1.4.1.2021.4", ".1.3.6.1.2.1.2.2", ".1.3.6.1.2.1.2.1.0", ".1.3.6.1.2.1.25.2.3.1", ".1.3.6.1.4.1.2021.9.1" ], "table": { "public": { "2": [ "127.0.0.1" ] } } } ``` > **init:**</br> > curl -X GET IP:8890/init - Clear the host table, except localhost, and reset the OID list. - Default OID list : 1. ".1.3.6.1.4.1.2021.11" 2. ".1.3.6.1.4.1.2021.4" 3. ".1.3.6.1.2.1.2.2" 4. ".1.3.6.1.2.1.2.1.0" 5. ".1.3.6.1.2.1.25.2.3.1" 6. ".1.3.6.1.4.1.2021.9.1" ```shell! curl "127.0.0.1:8890/init" {"message":"init complete"} ``` > **addSession:**</br> > curl -X POST --data "host=IPaddress" --data "version=2" --data "community=public" IP:8890/addSession - Connect to the given host's IP and create a new session. - Required argument -- "host" - Optional argument -- "version":2, "community":"public" ```shell! curl -X POST -d "host=127.0.0.1" "127.0.0.1:8890/addSession" {"message":"add Session complete"} ``` > **deleteSession:**</br> > curl -X POST --data "host=IPaddress" --data "version=2" --data "community=public" IP:8890/addSession - Delete the session with the given argument entry. - Required argument -- "host" - Optional argument -- "version":2, "community":"public" ```shell! curl -X POST -d "host=127.0.0.1" "127.0.0.1:8890/deleteSession" {"message":"delete Session complete"} ``` > **addOID, deleteOID:**</br> > curl -X POST --data "OID=.oid" IP:8890/addUID</br> > curl -X POST --data "OID=.oid" IP:8890/deleteUID - Add or Delete a OID according to the given argument. 3. promitheus_midware</br> > **show:**</br> </br> [TOC] ___