Skip to content

Commit

Permalink
get tests going again
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Jan 7, 2024
1 parent 46b56e2 commit 09ac86b
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 156 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "04:00"
pull-request-branch-name:
separator: "-"
open-pull-requests-limit: 10
18 changes: 18 additions & 0 deletions .github/workflows/citest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: citest
on:
push:
pull_request:
schedule:
- cron: '30 4 * * 1'
jobs:
test:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: abbbi/github-actions-tune@v1
- run: sudo apt-get -y install phpunit
- uses: actions/checkout@v4
- run: tar xzf conf/vendor.tar.gz
- run: php --version
- run: phpunit -c conf/phpunit.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ build
vendor
*.geany
templates/custom
conf/.phpunit.result.cache
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
# Histou
#### Adds templates to Grafana in combination with [Nagflux](https://github.com/ConSol/nagflux).
Histou is designed to add templates to Grafana from Nagios Data. Therefor Nagflux sends the informations from Nagios/Icinga(2) to an InfluxDB. On the otherhand, Grafana is used to display this performancedata. Histou adds a custom dashboard to Grafana which will display dynamic dashboards, depending on the given host and service name in the URL. Histou fetches first additional informations from the InfluxDB and select afterwards a template. Templates can be JSON or PHP Files which contains a Grafana dashboard, the have also a rule, which defines when this template is used.

Adds templates to Grafana in combination with [Nagflux](https://github.com/ConSol-Monitoring/nagflux).

Histou is designed to add templates to Grafana from Nagios/Naemon data. Therefor Nagflux sends the informations from Naemon/Nagios/Icinga(2) to an InfluxDB. On the otherhand, Grafana is used to display this performancedata. Histou adds a custom dashboard to Grafana which will display dynamic dashboards, depending on the given host and service name in the URL. Histou fetches first additional informations from the InfluxDB and select afterwards a template. Templates can be JSON or PHP Files which contains a Grafana dashboard, the have also a rule, which defines when this template is used.

## Installation

### Dependencies

- Webserver with PHP 5.3.3+
- PHP commandline tool / phpcgi

### Webserver

- The whole Histoufolder accessible by copying to your webserver. On Debian with apache this would mean, to copy the whole Histoufolder to /var/www/

### Grafana

- Move the file `histou.js` in the `public/dashboards/` folder within Grafana.
- Depending on the URL the `index.php` is published on the webserver, change the Variable `var url = 'http://localhost/histou/';` in in the histou.js file. If you copied the Histoufolder to the root of your webserver, the default URL is perfect.

### OMD - the easy way
Nagflux is fully integrated in [OMD-Labs](https://github.com/ConSol/omd), as well as Histou is. Therefor if you wanna try it out, it's maybe easier to install OMD-Labs.

Nagflux is fully integrated in [OMD-Labs](https://github.com/ConSol-Monitoring/omd), as well as Histou is. Therefor if you wanna try it out, it's maybe easier to install OMD-Labs.

## Configuration

### Configfile

Here are some of the important config-options:

| Section | Config-Key | Meaning |
Expand All @@ -35,6 +44,7 @@ Here are some of the important config-options:
|influxdb|hostcheckAlias|This string will be used on hostchecks, because normaly there is no service name for it, but Histou needs one.|

### URL-Parameters

They are just valid for the current call, you can't change anything permanently.

| Name | Type | Meaning |
Expand All @@ -48,16 +58,19 @@ They are just valid for the current call, you can't change anything permanently.
|disablePanelTitle|Flag|If set the Paneltitel will be hidden|
|specificTemplate|String|If a filename is passed this away, only this template will be used, regardless the rules. E.g. ping.simple. Makes more or less just sens with simple templates|
|disablePerfdataLookup|Flag|If set no data will be fetched from the InfluxDB, so the only data available in the template is the host and servicename. Works only if specificTemplate is set!|
|customCSSFile|String|You could give the address of an CSS file which will be loaded into the Grafana context. Here an example: ![Custom CSS Example](https://github.com/ConSol/histou/blob/master/wheel_animation_example.gif "Custom CSS Example")|
|customCSSFile|String|You could give the address of an CSS file which will be loaded into the Grafana context. Here an example: ![Custom CSS Example](wheel_animation_example.gif "Custom CSS Example")|
|reduce|Flag|If set distracting elements of a graph will be hidden, used for Thruk.|

## Templates

There are two types of templates, the simple and the PHP. Simple templates are static, PHP are dynamic. Both cointains a rule, which describes on which host/service combination the template is uses. The type of the template is defined by its file-ending, `.simple` or `.php`

### Rule

A rule contains four keys: host, service, command and perfLabel. The values describes when the template is used. You can write for example an fixed hostname in the host field if the template should be uses just for one Host. It is also possible to use Regular Expressions in every field. Rules have a hierarchy on the to there is the host on the bottom the perfLabel. If a rule does not match in the hostname the perfLabel beneath will not be checked.

#### Typical Rules

- One rule for all ping checks, due to the fact that every check returns an pl and rta as perfLabel you can match on them
- host: .*
- service: .*
Expand All @@ -70,10 +83,13 @@ A rule contains four keys: host, service, command and perfLabel. The values desc
- perfLabel: rta, pl

### Simple

Simple templates contain a rule followed by an JSON object. The reason for this kind of template is, to over the user an easy way to create dashboards. The tradeoff is, that in the simple template it is not possible to use a template created for service1 to use on service2 if the perfLabels differ between those services.

### PHP

In the PHP template you can write PHP code which will be executed when the template gets chosen. You just have to return a JSON string or an object of the build-in PHP dashboard.

## Presentation
Here is a presentation I held about Nagflux and Histou (only in German, sorry): http://www.slideshare.net/PhilipGriesbacher/monitoring-workshop-kiel-2016-performancedaten-visualisierung-mit-grafana-influxdb

Here is a presentation about Nagflux and Histou on [www.slideshare.net](http://www.slideshare.net/PhilipGriesbacher/monitoring-workshop-kiel-2016-performancedaten-visualisierung-mit-grafana-influxdb) (only in German, sorry)
34 changes: 0 additions & 34 deletions circle.yml

This file was deleted.

3 changes: 0 additions & 3 deletions stylecheck.sh

This file was deleted.

11 changes: 3 additions & 8 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,17 @@

require_once 'histou/bootstrap.php';

class MyPHPUnitFrameworkTestCase extends \PHPUnit_Framework_TestCase
class MyPHPUnitFrameworkTestCase extends \PHPUnit\Framework\TestCase
{
protected function setUp()
{
spl_autoload_register('__autoload');
}

private function delCache()
public function delCache(): void
{
$path = join(DIRECTORY_SEPARATOR, array(sys_get_temp_dir(), '.histou_cache'));
if (file_exists($path)) {
unlink($path);
}
}

protected function tearDown()
public function tearDown(): void
{
$path = join(DIRECTORY_SEPARATOR, array(sys_get_temp_dir(), 'histou_test'));
if (file_exists($path)) {
Expand Down
7 changes: 3 additions & 4 deletions tests/histou/folderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
class FolderTest extends \MyPHPUnitFrameworkTestCase
{

protected function setUp()
public function setUp(): void
{
spl_autoload_register('__autoload');
define('DEFAULT_TEMPLATE_FOLDER', join(DIRECTORY_SEPARATOR, array(sys_get_temp_dir(), 'histou_test', 'default')));
define('CUSTOM_TEMPLATE_FOLDER', join(DIRECTORY_SEPARATOR, array(sys_get_temp_dir(), 'histou_test', 'custom')));

Expand Down Expand Up @@ -45,7 +44,7 @@ public function testLoad()
foreach ($files as $file) {
touch($file);
}


$templateFiles2 = \histou\Folder::loadFolders(
array(CUSTOM_TEMPLATE_FOLDER, DEFAULT_TEMPLATE_FOLDER)
Expand All @@ -56,7 +55,7 @@ public function testLoad()
join(DIRECTORY_SEPARATOR, array(DEFAULT_TEMPLATE_FOLDER, 'template2.simple')),
);
$this->assertEquals(sort($expected), sort($templateFiles2));

\histou\Folder::loadFolders(array("adsf"));
}
}
Loading

0 comments on commit 09ac86b

Please sign in to comment.