Skip to content

Commit

Permalink
Clone from the orginal location
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-cheptsov committed May 31, 2017
1 parent 847189c commit f8f6757
Show file tree
Hide file tree
Showing 116 changed files with 14,264 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
bin
build
dist
ext/queue/data-structures-library

**.so
**.o
**.a
**.tar.gz*
*.pid
*.log
*.swp
**mf_*_client
main
164 changes: 164 additions & 0 deletions Client/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
## Copyright 2014-2017 University of Stuttgart

CC = gcc
CXX = g++

#
# compile and link flags
#
COPT_SO = ${CFLAGS} -fpic

CFLAGS = -std=gnu99 -pedantic -Wall -Wwrite-strings -Wpointer-arith \
-Wcast-align -O0 -ggdb -pthread -D_LARGEFILE64_SOURCE \
$(CURL_INC) \
$(PAPI_INC) \
$(APR_INC) \
$(PARSER_INC) \
$(PUBLISHER_INC) \
$(CORE_INC) \
$(EXCESS_QUEUE) \
$(EXCESS_QUEUE_C)

LFLAGS = -lm $(CURL) $(PAPI) $(APR) $(PARSER) $(PUBLISHER)

#
# DEBUG SWITCH
#
DEBUG ?= 0
ifeq ($(DEBUG), 1)
CFLAGS += -DDEBUG -g
else
CFLAGS += -DNDEBUG
endif

#
# includes and libs
#
PWD = ${CURDIR}

CURL = -L$(PWD)/bin/curl/lib/ -lcurl
CURL_INC = -I$(PWD)/bin/curl/include

PAPI = -L$(PWD)/bin/papi/lib/ -lpapi
PAPI_INC = -I$(PWD)/bin/papi/include

APR_CONFIG = $(PWD)/bin/apr/bin/apr-1-config
APU_CONFIG = $(PWD)/bin/apr/bin/apu-1-config
APR = $(shell $(APR_CONFIG) --link-ld) $(shell $(APU_CONFIG) --link-ld)
APR_INC = $(shell $(APR_CONFIG) --includes) $(shell $(APR_CONFIG) --includes)

PARSER = -L$(PWD)/src/parser/ -lparser
PARSER_INC = -I$(PWD)/src/parser/src

PUBLISHER = -L$(PWD)/src/publisher/ -lpublisher
PUBLISHER_INC = -I$(PWD)/src/publisher/src

CORE_INC = -I$(PWD)/src/core

EXCESS_QUEUE = -I$(PWD)/ext/queue/data-structures-library/src/include
EXCESS_QUEUE_C = -I$(PWD)/ext/queue

#
# main source files
#
SRC = $(PWD)/src/agent
FILES = $(shell find $(SRC) -name "*.c")
HEADER = $(shell find $(SRC) -name "*.h")
PLUGIN_DIR = $(PWD)/src/plugins

#
# build and install paths
#
INSTALL_DIR = $(PWD)/dist
INSTALL_BIN_DIR = $(INSTALL_DIR)/bin
INSTALL_PLUGINS_DIR = $(INSTALL_DIR)/bin/plugins
INSTALL_LIB_DIR = $(INSTALL_DIR)/lib

#
# compile and build
#
all: prepare mf_api main plugins lib

${SRC}/%.o: %.c ${HEADER}
$(CC) -c $< $(COPT_SO)

excess_concurrent_queue.o:
$(CXX) -c $(PWD)/ext/queue/excess_concurrent_queue.cpp -o $@ -I. $(EXCESS_QUEUE) $(EXCESS_QUEUE_C) -fpic

prepare:
$(MAKE) -C $(PWD)/src/parser DEBUG=$(DEBUG)
$(MAKE) -C $(PWD)/src/publisher DEBUG=$(DEBUG)
mf_api:
$(MAKE) -C $(PWD)/src/api DEBUG=$(DEBUG)
$(MAKE) -C $(PWD)/src/api/test DEBUG=$(DEBUG)

main: excess_concurrent_queue.o $(SRC)/main.o $(SRC)/thread_handler.o $(SRC)/plugin_discover.o $(SRC)/plugin_manager.o
$(CXX) -o $@ $^ -lrt -ldl -Wl,--export-dynamic $(CFLAGS) $(LFLAGS)

plugins:
$(MAKE) -C $(PLUGIN_DIR)/Board_power DEBUG=$(DEBUG)
$(MAKE) -C $(PLUGIN_DIR)/CPU_perf DEBUG=$(DEBUG)
$(MAKE) -C $(PLUGIN_DIR)/CPU_temperature DEBUG=$(DEBUG)
$(MAKE) -C $(PLUGIN_DIR)/Linux_resources DEBUG=$(DEBUG)
$(MAKE) -C $(PLUGIN_DIR)/Linux_sys_power DEBUG=$(DEBUG)
$(MAKE) -C $(PLUGIN_DIR)/NVML DEBUG=$(DEBUG)

lib:

#
# clean-up
#
clean-all: clean clean-install

clean:
rm -rf *.o *.a *.so $(SRC)/*.o
rm -rf $(PWD)/ext/queue/*.o
rm -f $(PWD)/main
$(MAKE) -C $(PWD)/src/parser clean
$(MAKE) -C $(PWD)/src/publisher clean
$(MAKE) -C $(PWD)/src/api clean
$(MAKE) -C $(PWD)/src/api/test clean
$(MAKE) -C $(PLUGIN_DIR)/Board_power clean
$(MAKE) -C $(PLUGIN_DIR)/CPU_perf clean
$(MAKE) -C $(PLUGIN_DIR)/CPU_temperature clean
$(MAKE) -C $(PLUGIN_DIR)/Linux_resources clean
$(MAKE) -C $(PLUGIN_DIR)/Linux_sys_power clean
$(MAKE) -C $(PLUGIN_DIR)/NVML clean

clean-install:
rm -rf $(INSTALL_DIR)

#
# install
#
install: clean-install prepare-install copy_ini copy_plugins copy_client copy_libs

prepare-install:
@mkdir -p $(INSTALL_BIN_DIR)
@mkdir -p $(INSTALL_PLUGINS_DIR)
@mkdir -p $(INSTALL_LIB_DIR)

copy_ini:
cp -f $(PWD)/src/mf_config.ini $(INSTALL_DIR)

copy_plugins:
cp -f $(PLUGIN_DIR)/Board_power/lib/*.so $(INSTALL_PLUGINS_DIR)/
cp -f $(PLUGIN_DIR)/CPU_perf/lib/*.so $(INSTALL_PLUGINS_DIR)/
cp -f $(PLUGIN_DIR)/CPU_temperature/lib/*.so $(INSTALL_PLUGINS_DIR)/
cp -f $(PLUGIN_DIR)/Linux_resources/lib/*.so $(INSTALL_PLUGINS_DIR)/
cp -f $(PLUGIN_DIR)/Linux_sys_power/lib/*.so $(INSTALL_PLUGINS_DIR)/
cp -f $(PLUGIN_DIR)/NVML/lib/*.so $(INSTALL_PLUGINS_DIR)/ 2>/dev/null || :

copy_client:
cp -f $(PWD)/main $(INSTALL_BIN_DIR)/mf_client

copy_libs:
cp -f $(PWD)/bin/apr/lib/lib*.so* $(INSTALL_LIB_DIR)
cp -f $(PWD)/bin/curl/lib/lib*.so* $(INSTALL_LIB_DIR)
cp -f $(PWD)/bin/hwloc/lib/lib*.so* $(INSTALL_LIB_DIR)
cp -f $(PWD)/bin/libiio/lib/lib*.so* $(INSTALL_LIB_DIR)
cp -f $(PWD)/bin/papi/lib/lib*.so* $(INSTALL_LIB_DIR)
cp -f $(PWD)/bin/sensors/lib/lib*.so* $(INSTALL_LIB_DIR)
cp -f $(PWD)/src/parser/lib*.so* $(INSTALL_LIB_DIR)
cp -f $(PWD)/src/publisher/lib*.so* $(INSTALL_LIB_DIR)
cp -f $(PWD)/src/api/lib*.so* $(INSTALL_LIB_DIR)
145 changes: 145 additions & 0 deletions Client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# PHANTOM monitoring client

> PHANTOM monitoring client is one part of the PHANTOM monitoring framework, which supports metrics collection based on hardware availabilities and platform configuration. The target platform of the monitoring client includes CPUs, GPUs, Myriad2, ACME power measurement kit and FPGA-based platform.

## Introduction
The essential functionality of PHANTOM monitoring client is metrics collection, which is implemented by various plug-ins according to the hardware accessibility.

Currently 7 plug-ins are supported, whose implementation and design details are collected in the directory `src/plugins`. The monitoring client is designed to be pluggable. Loading a plug-in means starting a thread for the specific plug-in based on the users’ configuration at run-time. The folder `src/agent` plays a role as the main control unit, as managing various plug-ins with the help of pthreads. Folders like `src/core`, `src/parser`, and `src/publisher` are used by the main controller for accessorial support, including parsing input configuration file (`src/mf_config.ini`), publishing metrics via HTTP, and so on.

For code instrumentation and user-defined metrics collection, we provide a monitoring library and several APIs, which are kept in the directory `src/api`. Descriptions in detail about how to use the monitoring APIs are given also in this directory.


## Prerequisites
The monitoring client requires at first a running server and database. In order to install these requirements, please
checkout the associated [PHANTOM monitoring server][server] and follow the setup instructions given in the repository `README.md` file. A successful setup process can be checked by the following command as testing whether the server is running in the specific url:
```bash
curl localhost:3033
```

Please note that the installation and setup steps mentioned below assume that you are running a current Linux as operating system. We have tested the monitoring agent with Ubuntu 14.04 LTS as well as with Scientific Linux 6 (Carbon).

Before you can proceed, please clone the repository:
```bash
git clone https://github.com/hpcfapix/phantom_monitoring_client.git
```


### Dependencies
This project requires the following dependencies to be installed:

| Component | Homepage | Version |
|------------------ |------------------------------------------------- |--------- |
| PAPI-C | http://icl.cs.utk.edu/papi/ | 5.4.0 |
| CURL | http://curl.haxx.se/download/ | 7.37.0 |
| Apache APR | https://apr.apache.org/ | 1.5.1 |
| Apache APR Utils | https://apr.apache.org/ | 1.5.3 |
| Nvidia GDK | https://developer.nvidia.com/gpu-deployment-kit/ | 352.55 |
| bison | http://ftp.gnu.org/gnu/bison/ | 2.3 |
| flex | http://prdownloads.sourceforge.net/flex/ | 2.5.33 |
| sensors | https://fossies.org/linux/misc/ | 3.4.0 |
| m4 | https://ftp.gnu.org/gnu/m4 | 1.4.17 |
| libiio | https://github.com/analogdevicesinc/libiio.git | 1.0 |
| hwloc | https://www.open-mpi.org/software/hwloc/v1.11/downloads/ | 1.11.2 |
| EXCESS queue | https://github.com/excess-project/data-structures-library.git | release/0.1.0 |

To ease the process of setting up a development environment, we provide a basic script that downloads all dependencies, installs them locally in the project directory, and then performs some clean-up operations. Thus, compiling the monitoring client can be performed in a sandbox without affecting your current operating system.

Executing the following script
```bash
./setup.sh
```
results in a new directory named `bin`, which holds the required dependencies for compiling the project.


## Installation
This section assumes that you've successfully installed all required dependencies as described in the previous paragraphs.

```bash
make clean-all
make all
make install
```

The above commands clean, compile and install the monitoring agent into the directory `dist` within the project's repository. The `dist` folder includes all required binaries, shared libraries, scripts, and configuration files to get you started. The Makefile has been tested with GNU compiler version 4.9.2.


## Start monitoring
If you haven't yet followed our guide to set up the associated monitoring server and database, please do so now before continuing. Next, start the monitoring client with a default set of plugins enabled to monitor as follows:
```bash
cd scripts
./start.sh
```

You can learn more about various options passed to the monitoring client by calling
```bash
./start.sh -h
```

While the monitoring client is started and is collecting metric data, you can use the RESTful APIs provided by the monitoring server to retrieve run-time metrics and corresponding statistics.


## Configuring plug-ins and update intervals
The monitoring client as well as plug-ins are configurable at run-time by a global configuration file named `mf_config.ini`. The configuration is implemented by using an INI file; each section name such as `timings` or `plugins` is enclosed by square brackets. For each section, various parameters can be set. These parameters are custom-defined for each plug-in.
```bash
;PHANTOM Monitoring Client Configuration

[generic]
server = http://localhost:3033/v1
...

[plugins]
mf_plugin_Board_power = on
mf_plugin_CPU_perf = off
...

[timings]
default = 1000000000ns
update_configuration = 360s
mf_plugin_Board_power = 1000000000ns
...

[mf_plugin_Board_power]
ACME_BOARD_NAME = baylibre-acme.local
device0:current = on
device0:vshunt = off
device0:vbus = off
device0:power = on
...

```

Several parameters such as the `timing` of the plug-ins or the `server` where the server is running can be configured through this configuration file. The file is called `mf_config.ini` and is located at `dist/mf_config.ini`.


## Acknowledgment
This project is realized through [EXCESS][excess] and [PHANTOM][phantom]. EXCESS is funded by the EU 7th Framework Programme (FP7/2013-2016) under grant agreement number 611183. The PHANTOM project receives funding under the European Union's Horizon 2020 Research and Innovation Programme under grant agreement number 688146.


## Contributing
Find a bug? Have a feature request?
Please [create](https://github.com/excess-project/monitoring-agent/website/issues) an issue.


## Main Contributors
**Fangli Pi, HLRS**
+ [github/hpcfapix](https://github.com/hpcfapix)


## Release History

| Date | Version | Comment |
| ----------- | ------- | ---------------- |
| 2017-04-04 | 1.0 | First prototype |


## License
Copyright (C) 2014,2015 University of Stuttgart

[Apache License v2](LICENSE).


[server]: https://github.com/hpcfapix/phantom_monitoring_server
[excess]: http://www.excess-project.eu
[phantom]: http://www.phantom-project.org
46 changes: 46 additions & 0 deletions Client/ext/CuTest/AllTests.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2003 Asim Jalis
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in
* a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/

#include <stdio.h>

#include "CuTest.h"

CuSuite* CuGetSuite();

void RunAllTests(void)
{
CuString *output = CuStringNew();
CuSuite* suite = CuSuiteNew();

CuSuiteAddSuite(suite, CuGetSuite());

CuSuiteRun(suite);
CuSuiteSummary(suite, output);
CuSuiteDetails(suite, output);
printf("%s\n", output->buffer);
}

int main(void)
{
RunAllTests();
}
Loading

0 comments on commit f8f6757

Please sign in to comment.