Restart failed program every 5 min

Problem

  • Your program fails regularly
  • You need to check if it is running and if not, restart it

Solution

Create a script:

nano restart.sh

Put in the code and replace htop with your program name:

#!/bin/sh

ps cax | grep htop > /dev/null
if [ $? -eq 0 ]; then
echo “Process running.”
else
echo “Process is down.”
fi

Make the script executable:

chmod +x restart.sh

Create a cron job:

crontab -e

Create a new line (replace /home/user/):

*/5 * * * * /home/user/restart.sh

Fin.

 

System wide proxy settings for Xubuntu (16.10)

Problem

  • You have to set http etc. proxy settings for all application
  • XUbuntu GUI is not helpful 😉

Solution

Step 1: Edit environment

sudo nano /etc/environment

Append these lines (fill in your proxy):

http_proxy=http://yourproxy:8080/
https_proxy=http://yourproxy:8080/
HTTP_PROXY=http://yourproxy:8080/
HTTPS_PROXY=http://yourproxy:8080/

To load the new variables:

source /etc/environment

Step 2: Edit apt

Go to /etc/apt/apt.conf.d/ and create a file named 95proxies.

sudo nano /etc/apt/apt.conf.d/95proxies

Fill in these lines:

Acquire::http::proxy “http://yourproxy:8080/”;
Acquire::ftp::proxy “ftp://yourproxy:8080/”;
Acquire::https::proxy “http://yourproxy:8080/”;

Fin.

Import GPX into Splunk

Problem

  • You want to import a GPX File into Splunk
  • You want to define a special sourcetype

Solution

This is the example

<?xml version=”1.0″ encoding=”UTF-8″?>
<gpx version=”1.1″ xsi:schemaLocation=”http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd&gt;
<trk>
<trkseg>
<trkpt lon=”13.7235536575317383″ lat=”51.0877876281738281″>
<ele>154.0</ele>
<time>2016-04-29T15:39:38.000Z</time>
</trkpt>
<trkpt lon=”13.7235345840454102″ lat=”51.0876770019531250″>
<ele>155.0</ele>
<time>2016-04-29T15:39:47.000Z</time>
</trkpt>
<trkpt lon=”13.7242536544799805″ lat=”51.0879554748535156″>
<ele>152.0</ele>
<time>2016-04-29T15:40:11.000Z</time>
</trkpt>
<trkpt lon=”13.7242536544799805″ lat=”51.0879554748535156″>
<ele>152.0</ele>
<time>2016-04-29T15:40:13.000Z</time>
</trkpt>
<trkpt lon=”13.7242908477783203″ lat=”51.0884094238281250″>
<ele>149.0</ele>
<time>2016-04-29T15:40:29.000Z</time>
</trkpt>
</trkseg>
</trk>
</gpx>

Go to the Splunk preferences and add a new sourcetype with the following properties:

BREAK_ONLY_BEFORE = <trkpt

KV_MODE = xml

NO_BINARY_CHECK = true

SHOULD_LINEMERGE = true

pulldown_type = true

FIELDALIAS-rootfields = trkpt.ele as Hight trkpt{@lat} as Latitude trkpt{@lon} as Longitude

This will create events based on TrackPoint. In addition, latitude, longitude and hight will be extracted as extra fields.

gpx

If you want to include RoutePoints (see GPX Wikipedia), you only have to change the BREAK_ONLY_BEFORE  from <trkpt to <\w\w\wpt 

timechart

Fin.

Where to find Windows system log files

Problem

  • You are looking for the system / security / application log file, which are displayed by the Windows Event Viewer.
  • You need to copy the log files to another computer.

Solution

The log files can be found under

C:\Windows\System32\winevt\Logs

Just copy the files ending with “evtx“. You can open them with the Windows Event Viewer on every other computer, even those, you have no access on the original computer (no permission to watch; in that case, boot with linux, copy files …).

Fin

 

Raspberry PI – Static WIFI IP address

Problem

  •  Raspberry PI is configured using Wifi and DHCP by default (Jessie)

Solution

The solution is simple. Open the file /etc/dhcpcd.conf as root (sudo nano /etc/dhcpcd.conf)

At the end of the file, add the following lines:

interface wlan0
static ip_address=192.168.xxx.xxx/24
static routers=192.168.2.1
static domain_name_servers=192.168.2.1

  • static ip_address: your desired IP address
  • static routers: your gateway
  • static domain_name _servers: your DNS server

Save the file and reboot:

sudo reboot

Fin.

Einfache Überstundenerfassung mit Excel

Problem

  • Sie benötigen eine einfach und übersichtliche Art um Ihre Überstunden zu verwalten.
  • Eine vollwertige Zeiterfassung ist zuviel für Ihre Bedürfnisse.

Lösung

Ich habe eine kleine und übersichtliche Excel-Mappe erstellt, bestehend aus 3 Tabellen:

  1. Übersicht – Übersicht über erarbeitete/geenommene sowie Saldo-Überstunden
  2. Überstunden – hier werden die erarbeiteten Überstunden angegeben.
  3. ÜS-Abbau – hier werden die genommenen Überstunden angegeben.

Das ganze ist ohne Makros erstellt und kann frei verwendet werden. Die Überstundenerfassung finden Sie hier.

Viel Spass.