Commit f43d509a authored by Alonso Ibarra, Juncal's avatar Alonso Ibarra, Juncal

Adds Adapt Monitoring M12

parent 177e1b31
**/bin/
**/sources/
**/target/
**/generated/
**/.classpath
**/.settings/
**/node_modules/
jhipster-jdl.jh
**/*.log
/.project
/****************************************************************
*Copyright (c) 2017 Tecnalia.
*Licensed under MIT License (the "License");
*Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
*The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*
*
*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*Contributors (in alphabetical order):
*Gorka Benguria Tecnalia
*Iñaki Etxaniz Tecnalia
*Juncal Alonso Tecnalia
*Leire Orue-Echevarria Tecnalia
*Maria Jose Lopez Tecnalia
*Marisa Escalante Tecnalia
*
*Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu
*****************************************************************************/
**/bin/
**/sources/
**/target/
**/generated/
**/.classpath
**/.settings/
**/node_modules/
**/*.log
**/.vagrant/
**/output-virtualbox-iso/
**/packer_cache/
**/*.box
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>eu.decideh2020.int.adapt.monitoring.grafana.server.src.dvp</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
/****************************************************************
*Copyright (c) 2017 Tecnalia.
*Licensed under MIT License (the "License");
*Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
*The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*
*
*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*Contributors (in alphabetical order):
*Gorka Benguria Tecnalia
*Iñaki Etxaniz Tecnalia
*Juncal Alonso Tecnalia
*Leire Orue-Echevarria Tecnalia
*Maria Jose Lopez Tecnalia
*Marisa Escalante Tecnalia
*
*Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu
*****************************************************************************/
#!groovy
//http://groovy-lang.org/semantics.html
node {
//Required constants
currentBuild.result = "SUCCESS"
//Provided vars
def devopsSourcesRelativePath = 'Adapt_monitoring/eu.decideh2020.int.adapt.monitoring.grafana.server.src.dvp'
def devopsSourcesRepo = 'https://git.code.tecnalia.com/decide/WP4.git'
def dependingTasks=[
"",
""
]
//Params defaults
Boolean currentVerbose=false
Boolean hasCredentials=false
Boolean currentContinueTasks=true
Boolean currentStopContainer=true
Boolean currentForceClear=false
Boolean currentClearOnFail=false
try {
//Computed vars
def devopsSourcesPath
def devopsSourcesGitRepoPath
def devopsSourcesGitPath
def workspace
def jenkinsWorkspace
Boolean hasEmptyWorkspace=false
String workspaceContent=""
Boolean hasNewDevopsSources=false
String devopsSourcesLastCommitFile
String devopsSourcesLastChangedCommitFile
String devopsSourcesDiffPreviousCommit
String devopsSourcesCurrentCommit
String devopsSourcesLastCommit
String devopsSourcesLastChangedCommit
String mvnHome;
stage ('Params Processing'){
//def verbose -> defaults to "false"
//def scmCredentials -> defaults to undefined
//def continueTasks -> defaults to "true"
//def stopContainer -> defaults to "true"
//def forceClear -> defaults to "false"
//def clearOnFail -> defaults to "false"
//WARNING JENKINS SEND BOOLEANS AS STRING
try{
currentVerbose=((verbose=="true")||(verbose==true))
} catch (err){
println ("verbosity not provided defaults to false")
}
if (currentVerbose) println ("verbose = " + currentVerbose)
try{
currentClearOnFail=((clearOnFail=="true")||(clearOnFail==true))
} catch (err){
println ("clearOnFail not provided defaults to false")
}
if (currentVerbose) println ("currentClearOnFail = " + currentClearOnFail)
try{
currentContinueTasks=((continueTasks=="true")||(continueTasks==true))
} catch (err){
println ("continueTasks not provided defaults to true")
}
if (currentVerbose) println ("continueTasks = " + currentContinueTasks)
try{
currentStopContainer=((stopContainer=="true")||(stopContainer==true))
} catch (err){
println ("stopContainer not provided defaults to true")
}
if (currentVerbose) println ("currentStopContainer = " + currentStopContainer)
try{
currentForceClear=((forceClear=="true")||(forceClear==true))
} catch (err){
println ("forceClear not provided defaults to false")
}
if (currentVerbose) println ("currentForceClear = " + currentForceClear)
}
if (currentForceClear){
stage ('Forced Clear'){
sh "rm -rf ${WORKSPACE}/src"
}
}
stage ('Calculate Variables'){
workspace=WORKSPACE
if (currentVerbose) println ("workspace = " + workspace)
jenkinsWorkspace=WORKSPACE+"/../workspace\\@script"
if (currentVerbose) println ("jenkinsWorkspace = " + jenkinsWorkspace)
devopsSourcesPath=workspace
if (currentVerbose) println ("devopsSourcesPath = " + devopsSourcesPath)
devopsSourcesGitRepoPath=jenkinsWorkspace
if (currentVerbose) println ("devopsSourcesGitRepoPath = " + devopsSourcesGitRepoPath)
devopsSourcesGitPath=devopsSourcesGitRepoPath + "/" + devopsSourcesRelativePath
if (currentVerbose) println ("devopsSourcesGitPath = " + devopsSourcesGitPath)
devopsSourcesLastCommitFile=devopsSourcesPath+"/src.dvp.last.commit"
if (currentVerbose) println ("devopsSourcesLastCommitFile = " + devopsSourcesLastCommitFile)
devopsSourcesLastChangedCommitFile=devopsSourcesPath+"/src.dvp.last.changed.commit"
if (currentVerbose) println ("devopsSourcesLastChangedCommitFile = " + devopsSourcesLastChangedCommitFile)
}
try {
workspaceContent=sh(returnStdout: true, script: "ls ${workspace} 2>/dev/null").trim()
} catch (err){
}
if (currentVerbose) println ("workspaceContent = " + workspaceContent)
hasEmptyWorkspace=(""==workspaceContent)
if (currentVerbose) println ("hasEmptyWorkspace = " + hasEmptyWorkspace)
if (hasEmptyWorkspace) {
hasNewDevopsSources=true
} else {
stage ('Assess New Sources'){
sh "touch ${devopsSourcesLastCommitFile}"
devopsSourcesLastCommit = sh(returnStdout: true, script: "cat ${devopsSourcesLastCommitFile}").trim()
if (currentVerbose) println ("devopsSourcesLastCommit = " + devopsSourcesLastCommit)
try{
devopsSourcesCurrentCommit = sh(returnStdout: true, script: "git -C ${devopsSourcesGitRepoPath} rev-parse HEAD").trim()
} catch (err){
}
if (currentVerbose) println ("devopsSourcesCurrentCommit = " + devopsSourcesCurrentCommit)
if (devopsSourcesCurrentCommit!=''){
sh "echo \"${devopsSourcesCurrentCommit}\" > ${devopsSourcesLastCommitFile}"
}
if (devopsSourcesCurrentCommit!=devopsSourcesLastCommit) {
sh "touch ${devopsSourcesLastChangedCommitFile}"
devopsSourcesLastChangedCommit = sh(returnStdout: true, script: "cat ${devopsSourcesLastChangedCommitFile}").trim()
if (currentVerbose) println ("devopsSourcesLastChangedCommit = " + devopsSourcesLastChangedCommit)
if (devopsSourcesLastChangedCommit=="") {
devopsSourcesDiffPreviousCommit="force"
}
else {
try{
devopsSourcesDiffPreviousCommit=sh(returnStdout: true, script: "git -C ${devopsSourcesGitRepoPath} diff HEAD:${devopsSourcesRelativePath} ${devopsSourcesLastChangedCommit}:${devopsSourcesRelativePath}").trim()
} catch(err) {
}
}
try{
devopsSourcesDiffPreviousCommit=sh(returnStdout: true, script: "git -C ${devopsSourcesGitRepoPath} diff HEAD:${devopsSourcesRelativePath} ${devopsSourcesLastChangedCommit}:${devopsSourcesRelativePath}").trim()
} catch(err) {
}
if (currentVerbose) println ("devopsSourcesDiffPreviousCommit = " + devopsSourcesDiffPreviousCommit)
if (devopsSourcesDiffPreviousCommit!=""){
sh "echo \"${devopsSourcesCurrentCommit}\" > ${devopsSourcesLastChangedCommitFile}"
hasNewDevopsSources=true
}
}
}
}
if (currentVerbose) println ("hasNewDevopsSources = " + hasNewDevopsSources)
stage ('Prepare Variables'){
// Get the Maven tool.
// ** NOTE: This 'M3' Maven tool must be configured
// ** in the global configuration.
mvnHome = tool 'Maven 3.3.9 colocated'
}
if(hasNewDevopsSources){
stage ('Devops Source Move'){
sh "rm -rf ${devopsSourcesPath}/src"
sh "mv ${devopsSourcesGitPath}/src ${devopsSourcesPath}"
sh "rm -rf ${devopsSourcesPath}/pom.xml"
sh "mv ${devopsSourcesGitPath}/pom.xml ${devopsSourcesPath}/pom.xml"
}
}
if(currentVerbose){
stage ('Variables Echo'){
sh "'${mvnHome}/bin/mvn' antrun:run@echobase -f ${devopsSourcesPath}/pom.xml"
sh "'${mvnHome}/bin/mvn' antrun:run@echo -f ${devopsSourcesPath}/pom.xml"
}
}
if (currentStopContainer){
stage ('Docker Stop'){
sh "'${mvnHome}/bin/mvn' docker:stop --non-recursive -Dmaven.test.skip=true -f ${devopsSourcesPath}/pom.xml"
}
}
stage ('Docker Start'){
sh "'${mvnHome}/bin/mvn' docker:start --non-recursive -Dmaven.test.skip=true -f ${devopsSourcesPath}/pom.xml"
}
if (currentContinueTasks) {
stage('Launch Depending Tasks') {
int i=0;
for (i=0;i<dependingTasks.size();i++){
if (dependingTasks[i]!=""){
//build job: 'eu.decideh2020.int.adapt.monitoring.jnk.tsk.build.images', wait: false
if (currentVerbose) println ("starting job " + dependingTasks[i])
build job: dependingTasks[i], wait: false, parameters: [booleanParam(name: 'stopContainer', value: false)]
}
}
}
}
} catch (err) {
currentBuild.result = "FAILURE"
emailext (
subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""",
recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
if (currentClearOnFail){
stage ('Clear on Fail'){
sh "rm -rf ${WORKSPACE}/src"
}
}
throw err
}
}
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.decideh2020.int.adapt.monitoring</groupId>
<artifactId>eu.decideh2020.int.adapt.monitoring.src.dvp</artifactId>
<version>ALPHA</version>
</parent>
<artifactId>eu.decideh2020.int.adapt.monitoring.src.dvp.grafana.server</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
<!-- We check the value of some properties values -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>echo</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Displaying values of properties</echo>
<echo>[project.build.sourceDirectory]=${project.build.sourceDirectory}</echo>
<echo>[docker.image.name]=${docker.image.name}</echo>
<echo>[docker.image.version]=${docker.image.version}</echo>
<echo>[docker.port1.mapping]=${docker.port1.mapping}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<!-- added to support docker image creation -->
<plugin>
<groupId>org.jolokia</groupId>
<artifactId>docker-maven-plugin</artifactId>
<!-- last version in https://mvnrepository.com/artifact/org.jolokia/docker-maven-plugin -->
<version>0.13.9</version>
<configuration>
<images>
<image>
<alias>${docker.name}</alias>
<name>${docker.image.name}:${docker.image.version}</name>
<build>
<assembly>
<!-- this time we will do it from a docker file element is needed
to switch the usage of the extrenal file -->
<dockerFileDir>.</dockerFileDir>
<!-- end -->
</assembly>
</build>
<run>
<namingStrategy>alias</namingStrategy>
<ports>
<port>${docker.port1.mapping}</port>
</ports>
</run>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<docker.name>eu.decideh2020.grafana.server</docker.name>
<docker.image.name>${docker.registry.name}${docker.submitter}/${docker.name}</docker.image.name>
<docker.image.version>${project.version}</docker.image.version>
<docker.port1.external>${eu.decideh2020.grafana.port}</docker.port1.external>
<docker.port1.mapping>${docker.port1.external}:3000</docker.port1.mapping>
</properties>
</project>
\ No newline at end of file
# I take a official mono image https://hub.docker.com/r/grafana/grafana/
FROM grafana/grafana
ADD etc /etc
ADD var /var
ADD grafana-init.sh /grafana-init.sh
RUN chmod 750 /grafana-init.sh
ADD run-aux.sh /run-aux.sh
RUN chmod 750 /run-aux.sh
ENTRYPOINT ["/run-aux.sh"]
\ No newline at end of file
#!/bin/bash
echo 'Starting Grafana...'
AddDataSource() {
curl --silent --output /dev/null 'http://admin:admin@127.0.0.1:3000/api/datasources' -X POST -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"name":"decideh2020adapt","type":"influxdb","url":"http://10.0.2.15:8086","access":"proxy","isDefault":false,"database":"decideh2020adapt","user":"n/a","password":"n/a"}'
}
echo 'Configuring Grafana start...'
until AddDataSource; do
echo 'Configuring Grafana...'
sleep 1
done
echo 'Done!'
wait
# http://editorconfig.org
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
node_modules
npm-debug.log
coverage/
.aws-config.json
awsconfig
/emails/dist
/public_gen
/tmp
vendor/phantomjs/phantomjs
docs/AWS_S3_BUCKET
docs/GIT_BRANCH
docs/VERSION
docs/GITCOMMIT
docs/changed-files
docs/changed-files
# locally required config files
public/css/*.min.css
# Editor junk
*.sublime-workspace
*.swp
.idea/
*.iml
/data/*
/bin/*
conf/custom.ini
fig.yml
profile.cov
grafana
.notouch
.sass-cache/
/dist/src/
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-execute');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.initConfig({
clean: ["dist"],
copy: {
src_to_dist: {
cwd: 'src',
expand: true,
src: ['**/*', '!**/*.js', '!**/*.scss'],
dest: 'dist'
},
img_to_dist: {
cwd: 'src',
expand: true,
src: ['img/*'],
dest: 'dist/src/'
},
pluginDef: {
expand: true,
src: [ 'plugin.json', 'README.md' ],
dest: 'dist'
}
},
sass: {
dist: {
files: [{
expand: true,
cwd: 'src',
src: ['css/*.scss'],
dest: 'dist',
ext: '.css'
}]
}
},
watch: {
rebuild_all: {
files: ['src/**/*', 'plugin.json'],
tasks: ['default'],
options: {spawn: false}
}
},
babel: {
options: {
sourceMap: true,
presets: ['es2015'],
plugins: ['transform-es2015-modules-systemjs', 'transform-es2015-for-of']
},
dist: {
files: [{
cwd: 'src',
expand: true,
src: ['*.js'],
dest: 'dist',
ext:'.js'
}]
}
}
});
grunt.registerTask('default', ['clean', 'sass', 'copy:src_to_dist', 'copy:img_to_dist', 'copy:pluginDef', 'babel']);
};
Copyright 2016 Vonage Holdings Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
# Grafana Status Panel
This is a plugin meant to be used as a centralized view for the status of component in a glance.
It is very similar to the Single Stat panel, but it can hold multiple values from the same data source.
Each value can be used to customize the panel in different ways:
* Mark the severity of the component
* Mark if the component is disabled
* Show extra data in the panel about the component
## The General Idea
Lets say that you want to monitor a bunch of servers, and you want to keep track of multiple stats for each of them, and see in a glance the status of all of them.
This plugin will make it easier to do. You just add all the metrics you want to track, and choose how you want their values to be treated:
1. Component severity marker - Set the threshold for each and you get an overview that will report to you if there is anything wrong with any metrics. That means that if all the metrics are in the OK zone, the panel will be green. If evan one of the metrics is in the WARNING zone, it will be yellow, and red if any of them is CRITICAL.
2. Component disable marker - Set the exact value that represent if the component is disabled, the panel will be grey.
3. Display as text - show extra information about the component in the panel
Severity and text values can be shown in 2 modes:
1. Regular - under the panel title
2. Annotation - In the top left side of the panel
**Note:** The disable markers are prioritized over the severity ones.
You can also repeat the panel on a template if you have multiple instances that you want to watch.
## How to install (for debugging purposes only)
1. Copy the contents of "Grafana_Status_panel" to the "/var/lib/grafana/plugins" folder
2. Restart grafana by using "service grafana-server restart"
3. Now this panel should be installed.
## How to use
1. Add the queries you want to the panel and give each of them a unique alias
2. Choose the name of the panel to be displayed in the `Panel Title` field.
**Note:** this field supports Grafana templates, so if you repeat the panel the correct name will show