Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json schema for agent cfg #447

Open
robot-ranger opened this issue Apr 24, 2024 · 8 comments
Open

json schema for agent cfg #447

robot-ranger opened this issue Apr 24, 2024 · 8 comments
Labels

Comments

@robot-ranger
Copy link
Contributor

I would like to contribute a json schema for agent cfg. Can anyone point me to a COMPLETE list of all params available for agent cfg? is that even possible?

(location in code where it is parsed would be fine; i can extract from there)

@neildes2
Copy link
Collaborator

The readme in this repo has all the agent.cfg params

@robot-ranger
Copy link
Contributor Author

robot-ranger commented Apr 24, 2024

Most are there, some arent. I swear i learn about new params ~1/wk
Here are a few that arent documented: CreateUniqueIds, Sender, MonitorInterval

@robot-ranger
Copy link
Contributor Author

robot-ranger commented Apr 24, 2024

i dumped the readme section into copilot and asked it to give me a schema. Also dumped a few snippets from the source code to fill in a few gaps. had to do a little bit of cleanup, but in general it seems to work, so here is a start:

{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"type": "object",
	"properties": {
		"AgentDeviceUUID": {
			"type": "string",
			"description": "Set the UUID of the agent device",
			"default": "UUID derived from the IP address and port of the agent"
		},
		"DataPath": {
			"type": "string",
			"description": "The path to the data files",
			"default": "/mtconnect/data"
		},
		"DisableAgentDevice": {
			"type": "boolean",
			"description": "When the schema version is >= 1.7, disable the creation of the Agent device",
			"default": false
		},
		"AllowPut": {
			"type": "boolean",
			"description": "Allow HTTP PUT or POST of data item values or assets",
			"default": false
		},
		"AllowPutFrom": {
			"type": "string",
			"description": "Allow HTTP PUT or POST from a specific host or list of hosts. Lists are comma (,) separated and the host names will be validated by translating them into IP addresses",
			"default": "none"
		},
		"BufferSize": {
			"type": "integer",
			"description": "The 2^X number of slots available in the circular buffer for samples, events, and conditions",
			"default": 17,
			"minimum": 8,
			"maximum": 17
		},
		"CheckpointFrequency":{
			"type": "integer",
			"description": "The frequency checkpoints are created in the stream. This is used for current with the at argument. This is an advanced configuration item and should not be changed unless you understand the internal workings of the agent",
			"default": 1000
		},
		"Devices": {
			"type": "string",
			"description": "The XML file to load that specifies the devices and is supplied as the result of a probe request. If the key is not found the defaults are tried",
			"default": "devices.xml"
		},
		"HttpHeaders": {
			"type": "object",
			"properties": {
				"Access-Control-Allow-Origin": {
					"type": "string"
				},
				"Access-Control-Allow-Methods": {
					"type": "string",
					"enum": ["GET", "POST"]
				},
				"Access-Control-Allow-Headers": {
					"type": "string",
					"enum": ["Accept", "Content-Type"]
				}
			},
			"description": "Additional headers to add to the HTTP Response for CORS Security. ",
			"default": {
				"Access-Control-Allow-Origin": "*",
				"Access-Control-Allow-Methods": "GET",
				"Access-Control-Allow-Headers": "Accept"
			}
		},
		"JsonVersion": {
			"type": "string",
			"description": "JSON Printer format. Old format: 1, new format: 2",
			"default": "2"
		},
		"LogStreams": {
			"type": "array",
			"items": {
				"type": "string"
			}
		},
		"MaxAssets": {
			"type": "integer",
			"description": "The maximum number of assets the agent can hold in its buffer. The number is the actual count, not an exponent",
			"default": 1024
		},
		"MaxCachedFileSize": {
			"type": "integer"
		},
		"MinCompressFileSize": {
			"type": "integer"
		},
		"MinimumConfigReloadAge": {
			"type": "integer",
			"description": "The minimum age of a config file before an agent reload is triggered (seconds)",
			"default": 15
		},
		"MonitorConfigFiles": {
			"type": "boolean",
			"description": "Monitor agent.cfg and Devices.xml files and restart agent if they change",
			"default": false
		},
		"MonitorInterval": {
			"type": "integer"
		},
		"PidFile": {
			"type": "string",
			"description": "UNIX only. The full path of the file that contains the process id of the daemon. This is not supported in Windows",
			"default": "agent.pid"
		},
		"Port": {
			"type": "integer",
			"description": "The port number the agent binds to for requests",
			"default": 5000
		},
		"Pretty": {
			"type": "boolean",
			"description": "Pretty print the output with indentation",
			"default": false
		},
		"SchemaVersion": {
			"type": "string",
			"description": "Change the schema version to a different version number",
			"default": "2.0"
		},
		"ServerIp": {
			"type": "string",
			"description": "The server IP Address to bind to. Can be used to select the interface in IPV4 or IPV6",
			"default": "0.0.0.0"
		},
		"ServiceName": {
			"type": "string",
			"description": "Changes the service name when installing or removing the service. This allows multiple agents to run as services on the same machine",
			"default": "MTConnect Agent"
		},
		"Sender": {
			"type": "string"
		},
		"TlsCertificateChain": {
			"type": "string",
			"description": "The name of the file containing the certificate chain created from signing authority",
			"default": "NULL"
		},
		"TlsCertificatePassword": {
			"type": "string",
			"description": "The password used when creating the certificate. If none was supplied, do not use.",
			"default": "NULL"
		},
		"TlsClientCAs": {
			"type": "string",
			"description": "For TlsVerifyClientCertificate, specifies a file that contains additional certificate authorities for verification",
			"default": "NULL"
		},
		"TlsDHKey": {
			"type": "string",
			"description": "The name of the file containing the Diffie–Hellman key",
			"default": "NULL"
		},
		"TlsOnly": {
			"type": "boolean",
			"description": "Only allow secure connections, http requests will be rejected",
			"default": false
		},
		"TlsPrivateKey": {
			"type": "string",
			"description": "The name of the file containing the private key for the certificate",
			"default": "NULL"
		},
		"TlsVerifyClientCertificate": {
			"type": "boolean",
			"description": "Request and verify the client certificate against root authorities",
			"default": false
		},
		"CreateUniqueIds": {
			"type": "boolean"
		},
		"VersionDeviceXml": {
			"type": "string"
		},
		"EnableSourceDeviceModels": {
			"type": "boolean"
		},
		"WorkerThreads": {
			"type": "integer",
			"description": "The number of operating system threads dedicated to the Agent",
			"default": 1
		},
		"Protocol": {
			"type": "string",
			"enum": ["shdr", "mqtt"],
			"default": "shdr"
		},
		"ConversionRequired": {
			"type": "boolean",
			"default": true
		},
		"Heartbeat": {
			"type": "string",
			"default": "None"
		},
		"IgnoreTimestamps": {
			"type": "boolean",
			"default": false
		},
		"LegacyTimeout": {
			"type": "integer",
			"default": 600
		},
		"PreserveUUID": {
			"type": "boolean",
			"default": true
		},
		"ReconnectInterval": {
			"type": "integer",
			"default": 10000
		},
		"ShdrVersion": {
			"type": "integer",
			"default": 1
		},
		"UpcaseDataItemValue": {
			"type": "boolean",
			"default": true
		},
		"Sinks": {
			"type":"object",
			"properties": {
				"Mqtt2Service":{
					"type":"object",
					"properties": {
						"MqttCaCert": {
							"type": "string",
							"description": "CA Certificate for MQTT TLS connection to the MQTT Broker",
							"default": "NULL"
						},
						"MqttHost": {
							"type": "string",
							"description": "IP Address or name of the MQTT Broker",
							"default": "127.0.0.1"
						},
						"MqttPort": {
							"type": "integer",
							"description": "Port number of MQTT Broker",
							"default": 1883
						},
						"MqttTls": {
							"type": "boolean",
							"description": "TLS Certificate for secure connection to the MQTT Broker",
							"default": false
						},
						"MqttWs": {
							"type": "boolean",
							"description": "Instructs MQTT to connect using web sockets",
							"default": false
						},
						"AssetTopic": {
							"type": "string",
							"description": "Prefix for the Assets",
							"default": "MTConnect/Asset/[device]"
						},
						"CurrentTopic": {
							"type": "string",
							"description": "Prefix for the Current",
							"default": "MTConnect/Current/[device]"
						},
						"ProbeTopic": {
							"type": "string",
							"description": "Prefix for the Device Model topic",
							"default": "MTConnect/Probe/[device]"
						},
						"SampleTopic": {
							"type": "string",
							"description": "Prefix for the Sample",
							"default": "MTConnect/Sample/[device]"
						},
						"MqttLastWillTopic": {
							"type": "string",
							"description": "The topic used for the last will and testament for an agent",
							"default": "MTConnect/Probe/[device]/Availability"
						},
						"MqttCurrentInterval": {
							"type": "string",
							"description": "The frequency to publish currents. Acts like a keyframe in a video stream.",
							"default": "10000ms"
						},
						"MqttSampleInterval": {
							"type": "string",
							"description": "The frequency to publish samples. Works the same way as the interval in the rest call. Groups observations up and publishes with the minimum interval given. If nothing is available, will wait until an observation arrives to publish.",
							"default": "500ms"
						},
						"MqttSampleCount": {
							"type": "integer",
							"description": "The maximum number of observations to publish at one time.",
							"default": 1000
						}
					}
				}
			}
		},
		"Adapters": {
			"type": "object",
			"additionalProperties": {
				"type": "object",
				"properties": {
					"Device": {
						"type": "string",
						"description": "The name of the device that corresponds to the name of the device in the Devices file. Each adapter can map to one device. Specifying a \"*\" will map to the default device.",
						"default": ""
					},
					"Host": {
						"type": "string",
						"description": "The host the adapter is located on.",
						"default": "localhost"
					},
					"Port": {
						"type": "integer",
						"description": "The port to connect to the adapter.",
						"default": 7878
					},
					"Manufacturer": {
						"type": "string",
						"description": "Replaces the manufacturer attribute in the device XML.",
						"default": ""
					},
					"Station": {
						"type": "string",
						"description": "Replaces the Station attribute in the device XML.",
						"default": ""
					},
					"SerialNumber": {
						"type": "string",
						"description": "Replaces the SerialNumber attribute in the device XML.",
						"default": ""
					},
					"UUID": {
						"type": "string",
						"description": "Replaces the UUID attribute in the device XML.",
						"default": ""
					},
					"AutoAvailable": {
						"type": "boolean",
						"description": "For devices that do not have the ability to provide available events, if yes, this sets the Availability to AVAILABLE upon connection.",
						"default": false
					},
					"AdditionalDevices": {
						"type": "string",
						"description": "Comma separated list of additional devices connected to this adapter. This provides availability support when one adapter feeds multiple devices.",
						"default": ""
					},
					"FilterDuplicates": {
						"type": "boolean",
						"description": "If value is yes, filters all duplicate values for data items. This is to support adapters that are not doing proper duplicate filtering.",
						"default": "no"
					},
					"LegacyTimeout": {
						"type": "integer",
						"description": "Length of time an adapter can be silent before it is disconnected. This is only for legacy adapters that do not support heartbeats. If heartbeats are present, this will be ignored.",
						"default": 600
					},
					"ReconnectInterval": {
						"type": "integer",
						"description": "The amount of time between adapter reconnection attempts. This is useful for implementation of high performance adapters where availability needs to be tracked in near-real-time. Time is specified in milliseconds (ms). Defaults to the top level ReconnectInterval.",
						"default": 10000
					},
					"IgnoreTimestamps": {
						"type": "string",
						"description": "Overwrite timestamps with the agent time. This will correct clock drift but will not give as accurate relative time since it will not take into consideration network latencies. This can be overridden on a per adapter basis.",
						"default": "Top Level Setting"
					},
					"PreserveUUID": {
						"type": "boolean",
						"description": "Do not overwrite the UUID with the UUID from the adapter, preserve the UUID in the Devices.xml file. This can be overridden on a per adapter basis.",
						"default": false
					},
					"RealTime": {
						"type": "boolean",
						"description": "Boost the thread priority of this adapter so that events are handled faster.",
						"default": false
					},
					"RelativeTime": {
						"type": "boolean",
						"description": "The timestamps will be given as relative offsets represented as a floating point number of milliseconds. The offset will be added to the arrival time of the first recorded event.",
						"default": false
					},
					"ConversionRequired": {
						"type": "string",
						"description": "Adapter setting for data item units conversion in the agent. Assumes the adapter has already done unit conversion. Defaults to global.",
						"default": "Top Level Setting"
					},
					"UpcaseDataItemValue": {
						"type": "string",
						"description": "Always converts the value of the data items to upper case.",
						"default": "Top Level Setting"
					},
					"ShdrVersion": {
						"type": "integer",
						"description": "Specifies the SHDR protocol version used by the adapter. When greater than one (1), allows multiple complex observations, like Condition and Message on the same line. If it equals one (1), then any observation requiring more than a key/value pair need to be on separate lines. Applies to only this adapter.",
						"default": 1
					},
					"SuppressIPAddress": {
						"type": "boolean",
						"description": "Suppress the Adapter IP Address and port when creating the Agent Device ids and names.",
						"default": false
					},
					"AdapterIdentity": {
						"type": "string",
						"description": "Adapter Identity name used to prefix dataitems within the Agent device ids and names.",
						"default": ""
					}
				}
			} 
		}
	}
}

@robot-ranger
Copy link
Contributor Author

I will make a branch on my repo and eventually submit a PR

@robot-ranger
Copy link
Contributor Author

Which are considered "Required"?

@wsobel
Copy link
Member

wsobel commented Apr 24, 2024

You can base it on the XML Schema:

https://schemas.mtconnect.org Use the schemas without _1.0, those are for legacy validators (not 1.1).

The normative source is the XMI, but that takes a bit of annoyance to parse.

Geet back if you need help or more info. I can probably extract enumerations and such.

@wsobel
Copy link
Member

wsobel commented Apr 24, 2024

And thanks a lot!

@robot-ranger
Copy link
Contributor Author

You can base it on the XML Schema:

https://schemas.mtconnect.org Use the schemas without _1.0, those are for legacy validators (not 1.1).

The normative source is the XMI, but that takes a bit of annoyance to parse.

Geet back if you need help or more info. I can probably extract enumerations and such.

I am referring to the agent.cfg, i assume that isnt defined in the formal MTConnect schema?

@wsobel wsobel added the feature label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants