-
Notifications
You must be signed in to change notification settings - Fork 2
Join Development
Do you want to modify the source code of the openITCOCKPIT Monitoring Agent? If yes follow this guide to getting started.
Please make sure you have Golang >= 1.15.6 and Visual Studio Code installed.
- Clone this repository
git clone https://github.com/it-novum/openitcockpit-agent-go.git
-
Run Visual Studio Code and make sure that you have installed the Go extension
-
Install Go tools Press
ctrl
+shift
+P
(Windows and Linux) orcmd
+shift
+P
on macOS and selectGo: Install/Update Tools
Select all tools and confirm with Ok
The installation is completed, as soon as you see All tools successfully installed. You are ready to Go :).
in the VS Code terminal
- Setup VS Code
Press
ctrl
+shift
+P
(Windows and Linux) orcmd
+shift
+P
on macOS and typesettings json
and selectPreferences: Open Settings (JSON)
. Add the following settings to your JSON.
"go.testTimeout": "90s",
"go.useLanguageServer": true,
// Remove this if you do NOT want to enable libvirt
"go.toolsEnvVars": {
"GOFLAGS": "-tags=libvirt"
},
"go.lintTool": "golangci-lint",
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
},
// Optional: Disable snippets, as they conflict with completion ranking.
"editor.snippetSuggestions": "none",
},
"[go.mod]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
},
},
"gopls": {
// Add parameter placeholders when completing a function.
"usePlaceholders": true,
// If true, enable additional analyses with staticcheck.
// Warning: This will significantly increase memory usage.
"staticcheck": false,
}
Source: https://github.com/golang/tools/blob/master/gopls/doc/vscode.md
- Debug Launch Configuration
In the VS Code main menu click on Run
-> Open Configurations
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"env": {
"OITC_AGENT_DEBUG": "1",
},
"args": ["-c", ".\\config.cnf", "--disable-logfile", "--debug"]
}
]
}
Create a new file in workspace folder -> config.ini
[default]
customchecks = ./customchecks.ini
Create a new file in workspace folder -> customchecks.ini
(Windows)
[check_Windows_Services_Status_OSS]
command = echo 'hello world'
interval = 15
timeout = 10
enabled = false
Create a new file in workspace folder -> customchecks.ini
(Linux/macOS)
[check_echo]
command = echo 'hello world'
interval = 15
timeout = 10
enabled = false
By default the agent will assume to be run as Windows Service. If you set OITC_AGENT_DEBUG it will run the default cmd like on linux.
$env:OITC_AGENT_DEBUG="1"
.\agent.exe -c C:\git\openitcockpit-agent-go\config.ini -l "$env:TEMP\agent.log"