Skip to content

Commit

Permalink
Add code template and basic facilities
Browse files Browse the repository at this point in the history
  • Loading branch information
i-ky committed Aug 6, 2021
1 parent 23b2d5c commit 54abfe1
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

# Compilations database
compile_commands.json

# clangd index
.clangd/
7 changes: 7 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM gitpod/workspace-full

USER gitpod

RUN sudo apt-get -q update && \
sudo apt-get install -yq autoconf automake libcurl4-openssl-dev bear && \
sudo rm -rf /var/lib/apt/lists/*
7 changes: 7 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tasks:
- init: >-
export ZABBIX_SOURCE="/workspace/zabbix" &&
git clone https://git.zabbix.com/scm/zbx/zabbix.git --depth 1 "$ZABBIX_SOURCE" &&
bear make
image:
file: .gitpod.Dockerfile
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: c
compiler:
- clang
- gcc
dist: xenial
env:
- BRANCH=master
- BRANCH=release/5.4
- BRANCH=release/5.0
- BRANCH=release/4.0
before_script:
- git clone https://git.zabbix.com/scm/zbx/zabbix.git --depth 1 --single-branch --branch $BRANCH
script:
- ZABBIX_SOURCE=zabbix CFLAGS='-Wall -Wextra -Wpedantic -g -O2' make
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files.associations": {
".h": "c"
},
"[c]": {
"editor.insertSpaces": false,
"editor.tabSize": 8
}
}
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CFLAGS:=-fPIC -I$(ZABBIX_SOURCE)/include $(CFLAGS)
OBJECTS:=$(patsubst %.c,%.o,$(wildcard src/*.c))

sheepskin.so: $(OBJECTS)
$(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) `curl-config --libs` -shared -o $@

all: sheepskin.so

clean:
rm -rf $(OBJECTS) sheepskin.so
62 changes: 62 additions & 0 deletions src/sheepskin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <stdint.h>
#include <stdlib.h>

#include <curl/curl.h>

#include "module.h"

int sheep_item_timeout;

int zbx_module_api_version(void)
{
return ZBX_MODULE_API_VERSION;
}

void zbx_module_item_timeout(int timeout)
{
sheep_item_timeout = timeout;
}

int zbx_module_init(void)
{
int ret = ZBX_MODULE_OK;

printf("Initializing \"sheepskin\" module...\n");

/* TODO */

if (ZBX_MODULE_OK == ret)
printf("Module \"sheepskin\" has been successfully initialized.\n");

return ret;
}

int zbx_module_uninit(void)
{
printf("Uninitializing \"sheepskin\" module...\n");

/* TODO */

printf("Module \"sheepskin\" has been successfully uninitialized.\n");

return ZBX_MODULE_OK;
}

static int sheep_web_certificate_get(AGENT_REQUEST *request, AGENT_RESULT *result)
{
/* TODO */
SET_MSG_RESULT(result, NULL);
return SYSINFO_RET_FAIL;
}

ZBX_METRIC *zbx_module_item_list(void)
{
static ZBX_METRIC keys[] =
/* KEY FLAG FUNCTION TEST PARAMETERS */
{
{"web.certificate.get", CF_HAVEPARAMS, sheep_web_certificate_get, "https://www.zabbix.com"},
{NULL}
};

return keys;
}

0 comments on commit 54abfe1

Please sign in to comment.