Compare commits

..

No commits in common. "main" and "scripts" have entirely different histories.

36 changed files with 235 additions and 1188 deletions

25
.gitignore vendored
View file

@ -1,25 +0,0 @@
# ---> Go
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
# Go temporary test files
**/plugins/tmptest/**

View file

@ -1,3 +0,0 @@
{
"go.buildFlags": ["-tags=linux"],
}

View file

@ -1,30 +0,0 @@
# docker build -t IMAGE_NAME:VERSION .
# after cd ahenk-go
# docker run -it -d --name CONT_NAME --mount type=bind,source=".",target=/ahenk-go/ IMAGE_NAME:VERSION "/bin/bash"
# THIS IS NOT A DOCKERFILE FOR RUNNING AHENK-GO, THIS DOCKERFILE IS JUST FOR SETTING UP DEVELOPMENT ENVIRONMENT
# TODO UPDATE DOCKERFILE TO PROVIDE A RUNNING AHENK-GO DOCKER ENVIRONMENT
FROM bitnami/minideb
RUN apt-get update
RUN apt-get upgrade -y
### INSTALL USEFUL UTILITIES ###
RUN apt-get install git curl wget tree nano procps lintian -y
### INSTALL BUILD DEPENDENCIES ###
RUN apt-get install sudo dpkg-dev debhelper golang-any -y
### CONFIGURATIONS ###
# Enable UTF8 Encoding
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
RUN echo "tr_TR.UTF-8 UTF-8" >> /etc/locale.gen
RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN apt install locales -y
RUN locale-gen en_US.UTF-8

165
LICENSE
View file

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View file

@ -1,60 +0,0 @@
REPO_NAME=ahenk-go
REPO_LINK=https://git.aliberksandikci.com.tr/liderahenk/${REPO_NAME}
DAEMON_NAME=ahenk-go
OLD_DAEMON_NAME=ahenkd-go
PYTHON_DAEMON_NAME=ahenkd
DATA_DIR=/etc/ahenk-go/
LIB_DIR=/usr/share/ahenk-go/
PLUGIN_DIR=${LIB_DIR}/plugins/
TEMP_DIR=$(mktemp -d)
MAIN_DIR=${TEMP_DIR}/${REPO_NAME}/
info:
@echo "Made by Aliberk Sandıı - 2023"
@echo "preclean: for cleaning old files, configurations"
@echo "TODO test: Test go files"
@echo "install: Build and install ahenk-go to DESTDIR"
@echo "uninstall: Uninstall ahenk-go from DESTDIR"
preclean:
sudo rm -rf /usr/bin/$(DAEMON_NAME)
sudo rm -rf /usr/bin/${OLD_DAEMON_NAME}
sudo rm -rf /usr/bin/${PYTHON_DAEMON_NAME}
@# TODO systemd control for both three process for docker
@# REVIEW are both killall and systemctl commands running?
@pgrep -x ${DAEMON_NAME} && (sudo killall "${DAEMON_NAME}" || sudo systemctl disable "${DAEMON_NAME}" || sudo systemctl stop "${DAEMON_NAME}") || echo "no ${DAEMON_NAME} found"
@pgrep -x ${OLD_DAEMON_NAME} && (sudo killall "${OLD_DAEMON_NAME}" || sudo systemctl disable "${OLD_DAEMON_NAME}" || sudo systemctl stop "${OLD_DAEMON_NAME}") || echo "no ${OLD_DAEMON_NAME} found"
@# TODO
@# echo -e "Do you want to remove python implementation of ahenk if installed in system?"
@# read -rp "(Y/N) " input
@pgrep -x ${PYTHON_DAEMON_NAME} && (sudo killall "${PYTHON_DAEMON_NAME}" || sudo systemctl disable "${PYTHON_DAEMON_NAME}" || sudo systemctl stop "${PYTHON_DAEMON_NAME}") || echo "no ${PYTHON_DAEMON_NAME} found"
sudo systemctl daemon-reload
sudo rm -rf ${DATA_DIR}
@echo -e "PRE-CLENING DONE\n"
test:
@echo -e "Testing go files not implemented yet!"
install:
sudo go build -o ${DESTDIR}/usr/bin/${REPO_NAME} ./cmd/ahenk-go/
@sudo mkdir -p "${DESTDIR}/${LIB_DIR}"
@sudo mkdir -p "${DESTDIR}/${PLUGIN_DIR}"
sudo go build -buildmode=plugin -o ${DESTDIR}/${PLUGIN_DIR}/resources.so ./plugins/resources
sudo go build -buildmode=plugin -o ${DESTDIR}/${PLUGIN_DIR}/tmptest.so ./plugins/tmptest
@sudo mkdir -p "${DESTDIR}/${DATA_DIR}"
windows_install:
sudo env GOOS=windows GOARCH=amd64 go build -o ${DESTDIR}/usr/bin/${REPO_NAME} ./cmd/ahenk-go/
@sudo mkdir -p "${DESTDIR}/${LIB_DIR}"
@sudo mkdir -p "${DESTDIR}/${PLUGIN_DIR}"
sudo GOOS=windows GOARCH=amd64 go build -buildmode=plugin -o ${DESTDIR}/${PLUGIN_DIR}/resources.so ./plugins/resources
sudo GOOS=windows GOARCH=amd64 go build -buildmode=plugin -o ${DESTDIR}/${PLUGIN_DIR}/tmptest.so ./plugins/tmptest
@sudo mkdir -p "${DESTDIR}/${DATA_DIR}"
uninstall:
@sudo rm -rf ${DESTDIR}/usr/bin/${REPO_NAME}

View file

@ -1,45 +0,0 @@
# Ahenk Go
tamamlanmamış değişiklikler için goloader-changes branch'ına ve dökümantasyona bakınız !!!
**Liderahenk** is an open source project which provides solutions to manage, monitor and audit unlimited number of different systems and users on a network.
Ahenk-go is a Linux agent written in Go which enables Lider to manage & monitor clients remotely.
## Packaging
1. Install necessary packages (You dont need this step if you are using docker file [godeb](https://git.aliberksandikci.com.tr/Liderahenk/ahenk-docs/src/branch/main/dev/environment.md#creating-docker-development-environment))
```sh
sudo apt install sudo dpkg-dev debhelper golang-any
```
2. Clone the repository and move to main directory
```sh
git clone https://git.aliberksandikci.com.tr/Liderahenk/ahenk-go/
cd ahenk-go/
```
3. Build program and create binary/source packages
```sh
dpkg-buildpackage
```
> Refer to Makefile for more info
4. *optional*, look for package errors and warnings
```sh
lintian
```
## Documentation & Changelog
- See comprehensively prepared [documentation](https://git.aliberksandikci.com.tr/Liderahenk/ahenk-docs/)
- See how to [setup development environment](https://git.aliberksandikci.com.tr/Liderahenk/ahenk-docs/src/branch/main/dev/environment.md)<!-- Web Documentation Link Here -->
- See [changelog](https://git.aliberksandikci.com.tr/Liderahenk/ahenk-docs/src/branch/main/admin/changelog.md)
<!-- Web Changelog Link Here -->
## Other Liderahenk Projects
- [Pardus-LiderAhenk/ahenk](https://github.com/Pardus-LiderAhenk/ahenk/): Current Python Implementation of Ahenk
- [Lider UI](https://github.com/Pardus-LiderAhenk/liderui): Lider Administration User Interface
- [Lider API](https://github.com/Pardus-LiderAhenk/liderapi): Lider API
- [Liderahenk-ansible](https://github.com/Pardus-LiderAhenk/liderahenk-ansible): Liderahenk setup with ansible
- [Ahenkdesk](https://github.com/Pardus-LiderAhenk/ahenkdesk): Ahenk User Interface
- See more in our [GitHub Page](https://github.com/Pardus-LiderAhenk)
## License
Liderahenk and its sub projects are licensed under the [LGPL v3](./LICENSE).

View file

@ -1,78 +0,0 @@
package main
import (
"log"
"os"
"os/user"
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/utils"
"github.com/sevlyar/go-daemon"
"golang.org/x/exp/slices"
)
const PidFile = "/run/ahenk-go.pid"
const ExecutablePath = "/usr/bin/ahenk-go"
const DataDir = "/etc/ahenk-go/"
const LogFile = DataDir + "ahenk.log"
const LibDir = "/usr/share/ahenk-go/"
const PluginDir = LibDir + "/plugins/"
// Main Function that starts daemon and controls arguments
func main() {
if len(os.Args) == 2 && slices.Contains([]string{"start", "stop", "restart", "nodaemon", "tmptest"}, os.Args[1]) {
switch os.Args[1] {
case "start":
utils.CreatePath(DataDir)
cntxt := &daemon.Context{
PidFileName: PidFile,
PidFilePerm: 0644,
LogFileName: LogFile,
LogFilePerm: 0640,
WorkDir: LibDir,
Umask: 027,
Args: []string{ExecutablePath, "start"},
}
d, err := cntxt.Reborn()
if err != nil {
log.Fatal("Daemon Reborn ERROR:", err)
}
if d != nil {
return
}
defer cntxt.Release()
log.Println("- - - - - - - - - - - - - - - - - -")
log.Print("Daemon Succesfully Started")
case "stop":
i, _ := daemon.ReadPidFile(PidFile)
Stop(i, 15)
case "restart":
i, _ := daemon.ReadPidFile(PidFile)
Restart(i, 15)
case "nodaemon":
log.Print("STARTED AS NO-DAEMON")
f := utils.OpenLogFile(LogFile)
defer f.Close()
log.SetOutput(f)
// TODO Also pipe fmt.Print* commands
case "tmptest":
log.Print("TEMPORARY TEST STARTED, log files are NOT redirecting!")
PluginManager("tmptest")
}
} else {
panic("Please enter a valid option !")
}
current, err := user.Current()
if err != nil {
log.Fatal(err)
}
if current.Uid != "0" {
log.Fatal("Ahenk-go requires superuser privilege")
}
PluginManager()
// NEXT Make PluginManager async !
}

View file

@ -1,36 +0,0 @@
//go:build linux && !windows
package main
import (
"log"
"os"
"syscall"
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/utils"
)
// FIXME there isn't any difference with Stop() function
// TODO There can be a Start() function in it but start function doesnt work properly right now
// Restart ahenk daemon with a specific PID (running from second copy)
func Restart(pid, signal int) {
Stop(pid, signal)
}
// Stop ahenk daemon with a specific PID (running from second copy)
func Stop(pid, signal int) {
log.Println("Stop Signal Caught")
// FILLME what you want to do before stopping daemon?
if err := syscall.Kill(pid, syscall.Signal(signal)); err == nil {
log.Printf("Ahenk Daemon with pid number %v Successfully stopped", pid)
f := utils.OpenLogFile(LogFile)
defer f.Close()
log.SetOutput(f)
log.Printf("Ahenk Daemon with pid number %v Successfully stopped", pid)
} else {
log.Fatal(err)
}
os.Exit(0)
}

View file

@ -1,18 +0,0 @@
//go:build windows
package main
import (
"log"
"os"
)
func Restart(pid, signal int) {
Stop(pid, signal)
}
func Stop(pid, signal int) {
log.Println("Stop Signal Caught")
log.Println("TODO, STOP FUNCTION IS NOT FUNCTIONAL IN WINDOWS YET!")
os.Exit(0)
}

View file

@ -1,103 +0,0 @@
package main
import (
"encoding/json"
"log"
"time"
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/utils"
)
// General Functions/Methods that each plugin has
type PlugGeneral interface {
Info() map[string]interface{}
}
// plugins/resources
type Resources interface {
AgentInfo() map[string]interface{}
ResourceUsage() map[string]interface{}
}
// plugins/resources
type TmpTest interface {
TmpTest()
}
// FILLME creating new plugin interface, template
// type NewPluginInterface interface {
// PluginMethod() returnType
// }
// Loads Plugins and runs them concurrently.
// When you create a new plugin create a new interface and call this plugin in this function
func PluginManager(params ...string) {
chanPlug := make(chan interface{})
go LoadPlugin("resources", chanPlug)
res, ok := <-chanPlug
var resources Resources = res.(Resources)
checkPlugin(resources, ok)
if len(params) > 0 && params[0] == "tmptest" {
go LoadPlugin("tmptest", chanPlug)
res, ok := <-chanPlug
var tmptest TmpTest = res.(TmpTest)
checkPlugin(res, ok)
tmptest.TmpTest()
}
// FILLME Loading new plugin, template
// go LoadPlugin("pluginName", chanPlug)
// res, ok = <-chanPlug
// var pluginName NewPluginInterface = res.(NewPluginInterface)
// checkPlugin(res, ok)
// Run plugins concurrently and log out
go logPlugin("AgentInfo", resources.AgentInfo(), true)
for {
go logPlugin("ResourceUsage", resources.ResourceUsage(), true)
// FILLME Running/Log out a plugin, template
// go logPlugin("InfoAboutFunction", pluginName.Function(), true)
time.Sleep(30 * time.Second)
}
}
// Logs plugin outputs.
func logPlugin(title string, mp map[string]interface{}, toJson bool) {
log.Printf("\n----- %v -----\n", title)
if toJson {
data, err := json.MarshalIndent(&mp, "", " ")
utils.Check(err)
log.Println(string(data))
} else {
for i, v := range mp {
log.Printf("%v: %v\n", i, v)
}
}
}
// Checks plugin status
func checkPlugin(plugVal interface{}, status bool) {
if status {
if plugVal == nil {
log.Fatal("Plugin loaded but there is no value!")
} else {
plugInfo := plugVal.(PlugGeneral).Info()
log.Printf("Plugin \"%v\" loaded and ready to use, version \"%v\" ", plugInfo["name"], plugInfo["version"])
}
} else {
if plugVal == nil {
log.Fatal("Plugin closed and there is no value! ")
} else {
log.Fatal("Plugin closed or there is an error")
}
}
}
// // TODO response to Lider
// // func createResponse() {
// // }

View file

@ -1,37 +0,0 @@
package main
import (
"fmt"
"os"
"plugin"
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/utils"
)
// Load Plugin placed in PluginDir, returns empty interface with channel
// Do not forget to cast in plugin manager
//
// Give Plugin Name as argument and be sure you compiled plugins with `-buildmode=plugin` to PluginDir as `pluginname.so`
func LoadPlugin(plugName string, chn chan interface{}) {
// TODO if error caugth try without relative path, this will be good for local testing
plug, err := plugin.Open(PluginDir + plugName + ".so")
utils.Check(err)
// TODO also allow lookup another symbol other than PlugnameConnect
symPlug, err := plug.Lookup(utils.FirstUpperEN(plugName) + "Connect")
utils.Check(err)
var plugOut interface{}
plugOut, ok := symPlug.(interface{})
if !ok {
fmt.Println("unexpected type from module symbol")
os.Exit(1)
}
chn <- plugOut
}
// NEXT implement unload function
// func UnloadPlugin(plugName string) interface{} {
// }

View file

@ -1,17 +0,0 @@
[Unit]
Description=Ahenk Agent
Wants=network-online.target
After=network.target network-online.target
[Service]
Type=forking
User=root
Group=root
ExecStart=/usr/bin/ahenk-go start
ExecStop=/usr/bin/ahenk-go stop
ExecReload=kill -HUP $MAINPID
PIDFile=/run/ahenk-go.pid
Restart=always
[Install]
WantedBy=multi-user.target

5
debian/changelog vendored
View file

@ -1,5 +0,0 @@
ahenk-go (0.0.1-1) UNRELEASED; urgency=low
* Initial release
-- Aliberk Sandıı <asandikci@aliberksandikci.com.tr> Mon, 21 Aug 2023 13:05:24 +0000

23
debian/control vendored
View file

@ -1,23 +0,0 @@
Source: ahenk-go
Maintainer: Aliberk Sandıı <asandikci@aliberksandikci.com.tr>
Section: utils
Testsuite: autopkgtest-pkg-go
Priority: optional
Build-Depends: debhelper (>= 13),
debhelper-compat (= 10),
Standards-Version: 4.6.0
Vcs-Browser: https://git.aliberksandikci.com.tr/Liderahenk/go-ahenk
Vcs-Git: https://git.aliberksandikci.com.tr/Liderahenk/go-ahenk.git
Homepage: https://liderahenk.org
Rules-Requires-Root: no
XS-Go-Import-Path: git.aliberksandikci.com.tr/Liderahenk/ahenk-go
Package: ahenk-go
Architecture: any
Depends: ${misc:Depends},
${shlibs:Depends}
Built-Using: ${misc:Built-Using}
Description: The client side of the Lider Ahenk Project
Lider Ahenk is an open source project which provides solutions
to manage, monitor and audit unlimited number of different
systems and users on a network.

13
debian/copyright vendored
View file

@ -1,13 +0,0 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ahenk-go
Upstream-Contact: Aliberk Sandıı <asandikci@aliberksandikci.com.tr>
Source: https://git.aliberksandikci.com.tr/Liderahenk/ahenk-go
Files: *
Copyright: 2023 Aliberk Sandıı <asandikci@aliberksandikci.com.tr>
License: LGPL-3.0+
Files: debian/*
Copyright: 2023 Aliberk Sandıı <asandikci@aliberksandikci.com.tr>
License: LGPL-3.0+
Comment: Debian packaging is licensed under the same terms as upstream

8
debian/rules vendored
View file

@ -1,8 +0,0 @@
#!/usr/bin/make -f
%:
dh $@
override_dh_auto_install:
dh_auto_install
dh_installsystemd

92
docker-build.sh Normal file
View file

@ -0,0 +1,92 @@
#!/bin/bash
# see https://people.debian.org/~stapelberg/2015/07/27/dh-make-golang.html
GIT_HOST="git.aliberksandikci.com.tr"
GIT_ORG="liderahenk"
GIT_REPO="ahenk-go"
FULL_URL="https://$GIT_HOST/$GIT_ORG/$GIT_REPO"
DEV_NAME="Aliberk Sandıı"
GIT_MAIL="git@aliberksandikci.com.tr"
UPLOAD_URL="127.0.0.1"
UPLOAD_PORT="8000"
echo "Editing git configs..."
git config --global init.defaultBranch main
git config --global user.name "$DEV_NAME"
git config --global user.email $GIT_MAIL
git config --global color.status auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global color.diff auto
mkdir /build
cd /build || exit
if [[ "$1" != "update" ]]; then
dh-make-golang make -allow_unknown_hoster "$GIT_HOST/$GIT_ORG/$GIT_REPO"
if [[ ! ("$1" != "notodo" || "$2" != "notodo") ]]; then
# TODO Add option to disable writing all these files all the time (-s --skip)
nano "itp-$GIT_REPO.txt"
sendmail -t <"itp-$GIT_REPO.txt"
cd $GIT_REPO || exit
grep --color=always -r TODO debian
echo -e "\nThese files needs review. Starting reviewing automatically in 10sec...\n"
sleep 10
# TODO Allow users to escape from automatic review and manually do it while in this script
while [[ $(grep -r TODO debian | wc --lines) -ne 0 ]]; do
nano "$(grep -r TODO debian | awk '{sub(/:.*/,"")} NR==1')"
echo "Continuing from next file..."
sleep 1
grep --color=always -r TODO debian
sleep 5
# TODO Allow user to reviewing remaining files, choosing between them, optional skipping, and waiting for an answer (continue? [Y/n])
done
echo "ALL FILES DONE"
dh_installsystemd
echo """
#!/usr/bin/make -f
%:
dh \$@ --builddirectory=_build --buildsystem=golang --with=golang --with-systemd
override_dh_auto_install:
dh_auto_install -- --no-source
""" >debian/rules
sleep 5
# FIXME Not working!
else
cd $GIT_REPO || exit
fi
else
gbp clone "$FULL_URL"
cd $GIT_REPO || exit
git checkout debian/sid
pwd
if [[ "$1" == "nmu" ]]; then
dch --nmu
else
dch
fi
echo "Succesfully Updated deb package information"
fi
# TODO ask user to continue
git add debian && git commit -a -m 'Initial packaging'
gbp buildpackage
cd ..
lintian -- *.changes
echo -e "SOLVE LINTIAN ERRORS / WARNINGS\nAFTER THAT, PUSH REPO"

24
go.mod
View file

@ -1,24 +0,0 @@
module git.aliberksandikci.com.tr/Liderahenk/ahenk-go
go 1.20
require (
github.com/sevlyar/go-daemon v0.1.6
github.com/zcalusic/sysinfo v1.0.1
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b
golang.org/x/text v0.12.0
)
require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
)
require (
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // direct
golang.org/x/sys v0.11.0 // direct
)

29
go.sum
View file

@ -1,29 +0,0 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/sevlyar/go-daemon v0.1.6 h1:EUh1MDjEM4BI109Jign0EaknA2izkOyi0LV3ro3QQGs=
github.com/sevlyar/go-daemon v0.1.6/go.mod h1:6dJpPatBT9eUwM5VCw9Bt6CdX9Tk6UWvhW3MebLDRKE=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zcalusic/sysinfo v1.0.1 h1:cVh8q3codjh43AGRTa54dJ2Zq+qPejv8n2VWpxKViwc=
github.com/zcalusic/sysinfo v1.0.1/go.mod h1:LxwKwtQdbTIQc65drhjQzYzt0o7jfB80LrrZm7SWn8o=
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI=
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

73
install.sh Normal file
View file

@ -0,0 +1,73 @@
#!/bin/bash
### Ahenk Agent Local Installation Script
### IMPORTANT NOTICE !
# Consider to use makefile for building or .deb file for installing package,
# using this scripts is not suggested anymore !
### --------------------- ###
### --> Prerequisites
# git
# go 1.20+
# systemd
# wget -qO- https://git.aliberksandikci.com.tr/liderahenk/ahenk-go/raw/branch/main/scripts/install.sh | bash
### --> Variable Set
REPO_NAME="ahenk-go"
REPO_LINK="https://git.aliberksandikci.com.tr/liderahenk/${REPO_NAME}"
DAEMON_NAME="ahenk-go"
CONF_DIR="/etc/ahenk-go/"
TEMP_DIR="$(mktemp -d)"
MAIN_DIR="${TEMP_DIR}/${REPO_NAME}/"
echo -e "VARIABLES SET\n"
### --> Pre-Cleaning
sudo rm /usr/bin/${DAEMON_NAME}
sudo killall "$DAEMON_NAME"
sudo systemctl disable "$DAEMON_NAME"
sudo systemctl stop "$DAEMON_NAME"
sudo systemctl daemon-reload
sudo rm -rf "$CONF_DIR"
sudo mkdir -p "$CONF_DIR"
echo -e "PRE-CLENING DONE\n"
### --> Building
cd "$TEMP_DIR" || exit
echo "$TEMP_DIR"
git clone "$REPO_LINK"
cd "$MAIN_DIR" || exit
# cmd/ahenkd-go
cd cmd/ahenkd-go || exit
sudo go build -o "/usr/bin/ahenkd-go"
echo -e "BUILDING DONE\n"
### --> Configurations
sudo touch "$CONF_DIR/user.info"
sudo cat << EOF | sudo tee -a "$CONF_DIR/user.info" > /dev/null
The current working directory is: $PWD
You are logged in as $(whoami)
$HOME $USER $SUDO_USER
EOF
sudo chown root:root "$CONF_DIR/user.info"
sudo chmod 640 "$CONF_DIR/user.info"
echo -e "CONFIGURATIONS DONE\n"
### --> Installing
if [[ $(ps -p 1 | awk 'FNR == 2 {print $4} ') == "systemd" ]]
then
sudo mv "${MAIN_DIR}build/package/deb/${DAEMON_NAME}.service" /etc/systemd/system/
fi
sudo systemctl daemon-reload
sudo systemctl enable "$DAEMON_NAME"
sudo systemctl start "$DAEMON_NAME"
echo -e "INSTALLING DONE\n"
### --> Post-Cleaning
sudo rm -rf "$TEMP_DIR"
echo -e "POST-CLEANING DONE\n"

3
local-build.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash
sudo go build -o "build/package/bin/ahenkd-go" cmd/ahenkd-go/ahenkd-go.go

67
local-install.sh Normal file
View file

@ -0,0 +1,67 @@
#!/bin/bash
### Ahenk Agent Local Installation Script
### --> Prerequisites
# go 1.20+
# systemd
# Change directory to main repo (cd ahenk-go)
# bash scripts/local-install.sh
### --> Variable Set
REPO_NAME="ahenk-go"
DAEMON_NAME="ahenk-go"
CONF_DIR="/etc/ahenk-go/"
TEMP_DIR="$(mktemp -d)"
MAIN_DIR="${TEMP_DIR}/${REPO_NAME}/"
echo -e "VARIABLES SET\n"
### --> Pre-Cleaning
sudo rm /usr/bin/${DAEMON_NAME}
sudo killall "$DAEMON_NAME"
sudo systemctl disable "$DAEMON_NAME"
sudo systemctl stop "$DAEMON_NAME"
sudo systemctl daemon-reload
sudo rm -rf "$CONF_DIR"
sudo mkdir -p "$CONF_DIR"
echo -e "PRE-CLENING DONE\n"
### --> Building
cp -r ../ "$TEMP_DIR"
cd "$TEMP_DIR" || exit
echo "$TEMP_DIR"
cd "$MAIN_DIR" || exit
# cmd/ahenkd-go
cd cmd/ahenkd-go || exit
sudo go build -o "/usr/bin/ahenkd-go"
echo -e "BUILDING DONE\n"
### --> Configurations
sudo touch "$CONF_DIR/user.info"
sudo cat << EOF | sudo tee -a "$CONF_DIR/user.info" > /dev/null
The current working directory is: $PWD
You are logged in as $(whoami)
$HOME $USER $SUDO_USER
EOF
sudo chown root:root "$CONF_DIR/user.info"
sudo chmod 640 "$CONF_DIR/user.info"
echo -e "CONFIGURATIONS DONE\n"
### --> Installing
if [[ $(ps -p 1 | awk 'FNR == 2 {print $4} ') == "systemd" ]]
then
sudo mv "${MAIN_DIR}debian/${DAEMON_NAME}.service" /etc/systemd/system/
fi
sudo systemctl daemon-reload
sudo systemctl enable "$DAEMON_NAME"
sudo systemctl start "$DAEMON_NAME"
echo -e "INSTALLING DONE\n"
### --> Post-Cleaning
sudo rm -rf "$TEMP_DIR"
echo -e "POST-CLEANING DONE\n"

View file

@ -1,43 +0,0 @@
package osinfo
import (
"runtime"
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/utils"
"github.com/shirou/gopsutil/cpu"
"github.com/zcalusic/sysinfo"
)
type CPU struct {
Vendor string `json:"vendor,omitempty"`
Model string `json:"model,omitempty"`
Speed uint `json:"speed,omitempty"` // CPU clock rate in MHz
Cache uint `json:"cache,omitempty"` // CPU cache size in KB
Cpus uint `json:"cpus,omitempty"` // number of physical CPUs
Cores uint `json:"cores,omitempty"` // number of physical CPU cores
Threads uint `json:"threads,omitempty"` // number of logical (HT) CPU cores
}
func (h *System) getCPUInfo() {
if runtime.GOOS == "linux" {
var si sysinfo.SysInfo
si.GetSysInfo()
h.CPU.Vendor = si.CPU.Vendor
h.CPU.Model = si.CPU.Model
h.CPU.Speed = si.CPU.Speed
h.CPU.Cache = si.CPU.Cache
h.CPU.Cpus = si.CPU.Cpus
h.CPU.Cores = si.CPU.Cores
h.CPU.Threads = si.CPU.Threads
} else {
cpuInfo, err := cpu.Info()
utils.Check(err)
h.CPU.Vendor = cpuInfo[0].VendorID
h.CPU.Vendor = cpuInfo[0].Model
// h.CPU.Vendor = cpuInfo[0].Speed // TODO
}
}
// REVIEW Windows compatibility and separate files

View file

@ -1,55 +0,0 @@
package osinfo
import (
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/utils"
"github.com/shirou/gopsutil/disk"
)
type Disk struct {
Devices string `json:"devices,omitempty"` // physical disk devices as string
Total float64 `json:"total,omitempty"` // Total Disk size in GiB
Used float64 `json:"used,omitempty"` // Used Disk size in GiB
Free float64 `json:"free,omitempty"` // Free Disk size in GiB
}
func (h *System) getDiskInfo() {
for _, v := range GetDisks() {
h.Disk.Devices += v.Device + ", "
}
h.Disk.Total = GetDiskUsage()["spaceTotal"]
h.Disk.Used = GetDiskUsage()["usedTotal"]
h.Disk.Free = GetDiskUsage()["usedFree"]
}
// return all physical disks, USB and CD-ROM devices
//
// An example output:
// device: /dev/example, mountpoint: /, fstype: ext4, opts:rw,noatime
func GetDisks() []disk.PartitionStat {
parts, err := disk.Partitions(false)
utils.Check(err)
return parts
}
// return disk usage as GiB
//
// TODO different functions for all disks / a specified disk?
// FIXME Wrong Disk values for docker !!! (probably because counting also virtual mountpoints?)
func GetDiskUsage() map[string]float64 {
var totalSize, freeSize, usedSize uint64
for _, part := range GetDisks() {
u, err := disk.Usage(part.Mountpoint)
utils.Check(err)
totalSize += u.Total
freeSize += u.Free
usedSize += u.Used
}
return map[string]float64{
"spaceTotal": utils.Byte2GiB(totalSize),
"freeTotal": utils.Byte2GiB(freeSize),
"usedTotal": utils.Byte2GiB(usedSize),
}
}
// REVIEW Windows compatibility and separate files

View file

@ -1,32 +0,0 @@
package osinfo
import (
"syscall"
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/utils"
"github.com/zcalusic/sysinfo"
)
type Kernel struct {
Sysname string `json:"sysname,omitempty"`
Release string `json:"release,omitempty"`
Version string `json:"version,omitempty"`
Arch string `json:"arch,omitempty"`
}
func (h *System) getKernelInfo() {
var si sysinfo.SysInfo
si.GetSysInfo()
var uname syscall.Utsname
if err := syscall.Uname(&uname); err != nil {
panic(err)
}
h.Kernel.Sysname = utils.Byte2String(uname.Sysname[:])
h.Kernel.Release = si.Kernel.Release
h.Kernel.Version = si.Kernel.Version
h.Kernel.Arch = si.Kernel.Architecture
}
// REVIEW Windows compatibility

View file

@ -1,39 +0,0 @@
package osinfo
const KB = uint64(1024)
type System struct {
Kernel Kernel `json:"kernel"`
OS OS `json:"OS"`
Node Node `json:"node"`
CPU CPU `json:"cpu"`
Memory Memory `json:"memory"`
Disk Disk `json:"disk"`
}
// initializes all hardware structs that gets software and hardware (system) information
func (h *System) GetSystemInfo() {
h.getKernelInfo()
h.getOSInfo()
h.getNodeInfo()
h.getCPUInfo()
h.getMemoryInfo()
h.getDiskInfo()
}
// TODO seperate file structure (as in gopsutil)
/*
main.go
disk/
--disk.go
--disk_linux.go
--disk_windows.go
cpu/
--cpu.go
--cpu_linux.go
--cpu_windows.go
memory/ ...
...
*/

View file

@ -1,33 +0,0 @@
package osinfo
import (
"runtime"
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/utils"
"github.com/shirou/gopsutil/mem"
"github.com/zcalusic/sysinfo"
)
type Memory struct {
Type string `json:"type,omitempty"`
Speed uint `json:"speed,omitempty"` // RAM data rate in MT/s
Total float64 `json:"total,omitempty"` // Total RAM size in GiB
Used float64 `json:"used,omitempty"` // Used RAM size in GiB
}
func (h *System) getMemoryInfo() { // TODO also implement swap usage
memInfo, err := mem.VirtualMemory()
utils.Check(err)
h.Memory.Used = utils.Byte2GiB(memInfo.Used)
h.Memory.Total = utils.Byte2GiB(memInfo.Total)
if runtime.GOOS == "linux" {
var si sysinfo.SysInfo
si.GetSysInfo()
h.Memory.Type = si.Memory.Type
h.Memory.Speed = si.Memory.Speed
}
}
// REVIEW Windows compatibility and separate files

View file

@ -1,34 +0,0 @@
package osinfo
import (
"syscall"
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/utils"
"github.com/zcalusic/sysinfo"
)
type Node struct {
Domainname string `json:"domainname,omitempty"`
Hostname string `json:"hostname,omitempty"`
MachineID string `json:"machineid,omitempty"`
Hypervisor string `json:"hypervisor,omitempty"`
Timezone string `json:"timezone,omitempty"`
}
func (h *System) getNodeInfo() {
var si sysinfo.SysInfo
si.GetSysInfo()
var uname syscall.Utsname
if err := syscall.Uname(&uname); err != nil {
panic(err)
}
h.Node.Domainname = utils.Byte2String(uname.Domainname[:])
h.Node.Hostname = si.Node.Hostname
h.Node.MachineID = si.Node.MachineID
h.Node.Hypervisor = si.Node.Hypervisor
h.Node.Timezone = si.Node.Timezone
}
// REVIEW Windows compatibility

View file

@ -1,9 +0,0 @@
package osinfo
type OS struct {
Name string `json:"name,omitempty"`
Distro string `json:"distro,omitempty"`
Version string `json:"version,omitempty"`
Release string `json:"release,omitempty"`
Arch string `json:"architecture,omitempty"`
}

View file

@ -1,16 +0,0 @@
//go:build linux && !windows
package osinfo
import "github.com/zcalusic/sysinfo"
func (h *System) getOSInfo() { //REVIEW review info in pardus
var si sysinfo.SysInfo
si.GetSysInfo()
h.OS.Name = si.OS.Name
h.OS.Distro = si.OS.Vendor
h.OS.Version = si.OS.Version
h.OS.Release = si.OS.Release
h.OS.Arch = si.OS.Architecture
}

View file

@ -1,21 +0,0 @@
//go:build windows
package osinfo
import (
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/utils"
"golang.org/x/sys/windows/registry"
)
func (h *System) getOSInfo() {
reg, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
utils.Check(err)
defer reg.Close()
pn, _, err := reg.GetStringValue("ProductName")
utils.Check(err)
h.OS.Name = pn
// TODO add other h.OS values
}

View file

@ -1,69 +0,0 @@
package utils
import (
"log"
"os"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
func Byte2String(arr []int8) string {
b := make([]byte, len(arr))
for i, v := range arr {
b[i] = byte(v)
}
return string(b)
}
func Byte2MiB(b uint64) float64 {
return float64(float64(b) / (1024 * 1024))
}
func Byte2GiB(b uint64) float64 {
return float64(float64(b) / (1024 * 1024 * 1024))
}
func MB2GiB(b uint64) float64 {
return float64(float64(b*1000*1000) / (1024 * 1024 * 1024))
}
func CheckPath(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
func CreatePath(path string) {
if flag, err := CheckPath(path); flag {
if err != nil {
log.Fatal(err)
}
} else if err := os.Mkdir(path, os.ModePerm); err != nil {
log.Fatal(err)
}
}
func Check(err error) {
if err != nil {
panic(err)
}
}
func OpenLogFile(path string) *os.File {
f, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
if err != nil {
panic(err)
}
return f
}
// Makes first character uppercase of given English string
func FirstUpperEN(str string) string {
return cases.Title(language.English).String(str)
} // TODO cases.NoLower vs cases.Compact !

View file

@ -1,14 +0,0 @@
package main
func (p plug) Info() map[string]interface{} {
return map[string]interface{}{
"name": "resources",
"version": "0.1.0",
"support": map[string]interface{}{
"linux": "debian",
"windows": "10",
},
"description": "Resource Usage Information and Controls",
"developer": "asandikci@aliberksandikci.com.tr",
}
}

View file

@ -1,67 +0,0 @@
package main
import (
"runtime"
"git.aliberksandikci.com.tr/Liderahenk/ahenk-go/pkg/osinfo"
)
type plug string
// exported plugin Symbol
var ResourcesConnect plug
// return instant resource usage information
func (p plug) ResourceUsage() map[string]interface{} {
var system osinfo.System
system.GetSystemInfo()
data := map[string]interface{}{
// CPU Information
"CPU Physical Core Count": system.CPU.Cores,
// "CPU Logical Core Count": system.CPU.Logical_core_count, // TODO
// "CPU Actual Hz": system.CPU.ActualHz, // TODO
// "CPU Advertised Hz": system.CPU.Hz_advertised, // TODO
// "Processor": system.CPU.Brand, // TODO
// Memory Information
"Total Memory": system.Memory.Total,
"Usage": system.Memory.Used,
// Disk Information
"Total Disk": system.Disk.Total,
"Usage Disk": system.Disk.Used,
"Device": system.Disk.Devices,
}
// TODO see https://github.com/Pardus-LiderAhenk/ahenk/blob/master/src/plugins/resource-usage/resource_info_fetcher.py
return data
}
// return general Agent system information
//
// these values changes rarely, see ResourceUsage() function for instant resource usage information
func (p plug) AgentInfo() map[string]interface{} {
var system osinfo.System
system.GetSystemInfo()
// Common data
data := map[string]interface{}{
"System": runtime.GOOS,
"DiskSpaceTotal": system.Disk.Total,
"MemoryTotal": system.Memory.Total,
// TODO "AhenkVersion": get Ahenk self version here
"Name": system.OS.Name,
"Distribution": system.OS.Distro,
"Arch": system.OS.Arch,
"Version": system.OS.Version,
"Hostname": system.Node.Hostname,
"KernelVersion": system.Kernel.Version,
"KernelRelease": system.Kernel.Release,
}
// REVIEW is calling all functions one by one slow downs code?
// TODO see https://github.com/Pardus-LiderAhenk/ahenk/blob/master/src/plugins/resource-usage/agent_info.py
return data
}

View file

@ -1,11 +0,0 @@
package main
func (p plug) Info() map[string]interface{} {
return map[string]interface{}{
"name": "tmptest",
"version": "1.0.2",
"support": "any",
"description": "Temporary testing",
"developer": "asandikci@aliberksandikci.com.tr",
}
}

View file

@ -1,26 +0,0 @@
package main
import (
"fmt"
"time"
)
type plug string
// exported plugin Symbol
var TmptestConnect plug
func (p plug) TmpTest() {
fmt.Println()
fmt.Println("----- Entered Test Area -----")
fmt.Println()
fmt.Println()
//s
// THIS FILE WON'T UPDATE ANYMORE (bsecause of .gitignore)
fmt.Println()
fmt.Println()
fmt.Println("----- End of Test Area -----")
fmt.Println()
time.Sleep(5 * time.Second)
}