Skip to content

Instantly share code, notes, and snippets.

Pavol Loffay pavolloffay

Block or report user

Report or block pavolloffay

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View R
install.packages('rjson')
install.packages('RCurl')
install.packages('fpp')
install.packages('xts')
library(rjson)
library(RCurl)
library(fpp)
library(xts)
View Datamining
curl -ivX POST -H 'Hawkular-Tenant: jdoe' -H 'Content-Type: application/json' 'http://localhost:8080/hawkular/datamining/metrics' -d '{"metricId": "metric1", "collectionInterval": "15" }'
curl -ivX PUT -H 'Hawkular-Tenant: jdoe' -H 'Content-Type: application/json' 'http://localhost:8080/hawkular/datamining/metrics/metric1' -d '{"collectionInterval": "22", "forecastingHorizon": 66 }'
curl -ivX PUT -H 'Hawkular-Tenant: jdoe' -H 'Content-Type: application/json' 'http://localhost:8080/hawkular/datamining/metrics/metric1/forecaster' -d '{"windowSize" : "150"}'
curl -ivX PUT -H 'Hawkular-Tenant: jdoe' -H 'Content-Type: application/json' 'http://localhost:8080/hawkular/datamining/metrics/metric1/forecaster' -d '{"ic" : "BIC"}'
curl -ivX PUT -H 'Hawkular-Tenant: jdoe' -H 'Content-Type: application/json' 'http://localhost:8080/hawkular/datamining/metrics/metric1/forecaster' -d '{"modelToUse" : "SimpleExponentialSmoothing"}'
curl -ivX PUT -H 'Hawkular-Tenant: jdoe' -H 'Content-Type: application/json' 'http://lo
View Hawkular Alerts
# Plugins are for example email, sms, irc, snmp... Needs to be deployd as war in the Alerts.
# Actions are instancies of action Plugins. This actions can be assigned to Triggers. Examples of actions - send email to admin, send sms to CEO,
# Trigger has multiple Conditions, based on this condition Action is carried out (send email, create file)
# Alert is created when conditions are met.
# Standalone mode
mvn clean install -Pstandalone
hawkular-alerts-rest-tests/target/wildfly-9.0.1.Final/bin/standalone.sh --debug -Dhawkular.backend=embedded_cassandra
-H 'Hawkular-Tenant: xmen'
@pavolloffay
pavolloffay / Inventory relationships, Predictions
Last active Jan 5, 2016
Inventory relationships, Predictions
View Inventory relationships, Predictions
#tenant
curl -ivX GET 'http://jdoe:password@localhost:8080/hawkular/inventory/tenant'
{
"path" : "/t;28026b36-8fe4-4332-84c8-524e173a68bf",
"id" : "28026b36-8fe4-4332-84c8-524e173a68bf"
* Connection #0 to host localhost left intact
}
#relationships
curl -ivX GET 'http://jdoe:password@localhost:8080/hawkular/inventory/feeds/dhcp130-144/relationships'
@pavolloffay
pavolloffay / BusTest.java
Created Dec 8, 2015
Hawkular Bus serialization test
View BusTest.java
@Test
public void testA() throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
InventoryJacksonConfig.configure(objectMapper);
Query relationships = Query.filter().with(RelationWith.name("__inPrediction")).with(RelationWith.sourceOfType
(Tenant.class)).with(RelationWith.targetOfType(Metric.class)).get();
String json = serialize(relationships, objectMapper);
View Bus context classloader.java
public static <T extends BasicMessage> BasicMessageWithExtraData<T> fromJSON(InputStream in, Class<T> clazz) {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(AbstractMessage.class.getClassLoader());
final T obj;
final byte[] remainder;
try (JsonParser parser = new JsonFactory().configure(Feature.AUTO_CLOSE_SOURCE, false).createParser(in)) {
Method buildObjectMapperForDeserializationMethod = findBuildObjectMapperForDeserializationMethod(clazz);
@pavolloffay
pavolloffay / .sh
Created Dec 10, 2015
BUS samples MDB
View .sh
14:59 0 hawkular-bus-sample-mdb <master>$ mvn clean install -Pdev -Dorg.hawkular.wildfly.home=/home/pavol/projects/hawkular/hawkular/modules/nest/hawkular-nest-distro/target/hawkular-nest-distro-1.0.0.Alpha8-SNAPSHOT-distribution/wildfly-9.0.1.Final^C
15:09 130 hawkular-bus-sample-mdb <master>$
15:09 130 hawkular-bus-sample-mdb <master>$ pwd
/home/pavol/projects/hawkular/hawkular-bus/hawkular-bus-samples/hawkular-bus-sample-mdb
15:09 0 hawkular-bus-sample-mdb <master>$
@pavolloffay
pavolloffay / Datamininig + Alerts
Last active Jan 13, 2016
Hawkular datamining + Alerts
View Datamininig + Alerts
tenant=$(curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/tenant'| grep --color=never -oP 'id" : "\K[0-9a-z\-]+')
feed=$(curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/feeds'| grep --color=never -oP 'id" : "\K[0-9a-z\-]+')
function feed() {
echo `curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/feeds'| grep --color=never -oP 'id" : "\K[0-9a-z\-]+'`
}
function tenant() {
echo `curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/tenant'| grep --color=never -oP 'id" : "\K[0-9a-z\-]+'`
}
@pavolloffay
pavolloffay / Hawkular Data Mining demo
Last active Jan 19, 2016
Hawkular Data Mining demo
View Hawkular Data Mining demo
Helper functions for extracting Tenant and Feed id and their canonical paths.
feedId() {
curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/feeds'| grep --color=never -oP 'id" : "\K[\w-]+'
}
tenantId() {
curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/tenant'| grep --color=never -oP 'id" : "\K[\w-]+'
}
feed() {
curl -s GET 'http://jdoe:password@localhost:8080/hawkular/inventory/feeds'| grep --color=never -oP 'path" : "\K/t;[\w-]+/f;[\w-]+'
View ts.py
#!/usr/bin/env python
# -*- coding: ascii -*-
#-----------------------------------------------------------------------------
"""
Time Series Analysis
pytsa (read "pizza") depends on scipy and numpy.
Pytsa is a simple timeseries utility for python.
It is good for pedagogical purposes, such as to understand moving averages,
linear regression, interpolation, and single/double/triple exponential smoothing.
You can’t perform that action at this time.