Category: Linux

InfluxDB insert multiples values at once using curl

If you have to insert multiples values in an influxdb database. You can use curl and insert the values one at the time.

But there is a better way like in this example

Let’s say you want to insert your tree loadaverage values in you influxdb database.

First put them into variables using these 3 lines.

Then using this curl line, insert them all at once in your influxdb database

Orange PI Zero Plus – A simple and, powerfull SBC

if you follow what’s new in the SBC world. You must know Xunglong Orange pi, they are a Chinese manufacturer known for making very cheap sbc’s based on Allwinner chip’s.

One of their most interesting sbc’s was the orange pi zero. It was small, powerful, and was ideal for a small headless server. (still available)

It was extremely cheap: less than 10€ but was plagued with some issues like very poor wifi stability, and poor software support from the manufacturer and, only 100mbps on the Ethernet port.

 

Now Xunlong has come up with an improved version of this board.

  • The wifi chip is now a well supported Realtek RTL8189FTV
  • The Ethernet port is now capable of 1Gb/s transfer rate
  • The cpu is improved with an Allwinner H5
  • The layout stay exactly the same so case are compatible.

I’ve already ordered one of these boards. At 16,02€ including shipping

It’s available at Aliexpress

OrangePI : Install OpenRTSP on a ARM device

One of my project with my OrangePI is to setup the device as a basic IP security camera server ,

the OrangePI zero , will connect to RTSP flux of the IP camera , and dump the stream on to an external disk , where it will be kept for 7 days before getting automaticly deleted
At a latter date i will run a motion detection program on these files and send a mail if motion is detected on a specific part of the frame.

after a little research , i found that a lot of people are using a program called openRTSP to record their RTSP stream to disk

But , after connecting on my OrangePi zero and trying to look for the program i found out that it’s not part of the default installation of armbian stable.

I tried to install the package using apt install openRTSP

I went to google and searched , openRTSP package ,and found out , on the debian website that openRTSP is part of the livemedia-utils package,

I went back to my SSH session and typed apt-get install livemedia-utils

There is no man pages associated with the program , you have to rely on the developer website to understand all the different options . The documentation is available here : http://www.live555.com/openRTSP/  or here if the website is down.
but as usual , in the officials repositories you only get dated version

you might want to compile the source code to have the last version available:

as root

Go to /usr/src: cd /usr/src
Get the live555 liveMedia source code: wget http://www.live555.com/liveMedia/public/live555-latest.tar.gz
Unpack it: tar -xzf live555-latest.tar.gz
Go into the  unpacked directory: cd live
Generate the make files: ./genMakefiles linux
Build the code: make
Install the latest version: make install

Bash script to clean movies name


The issue when you download movies online, is that most of the time the file name is going to be complete trash , filled with useless info like the team that made the rip or the website from where the movie was downloaded.
This is very annoying when you sort by name and the website made the idiotic decision to put their name in front of the actual film name.

for example here a typical movie name
[ Torrent9.info ] Dont.Think.Twice.2016.FRENCH.WEBRip.XviD-NEWCiNE.avi
the actual useful data that i wish to keep is Dont.Think.Twice.2016.avi

for this purpose i’ve developped a small bash script that will list all the files in a chosen directory then , if necessary , will rename the file.

this is not a very efficient script
but it’s fulfill it’s purpose and very rarely encounter a filename that he is unable to clean.

BASH:check if a number is even or odd


In a bash script you might need to check if a var is even or odd , 

in my case im going to use a if to make that check

You can use this simple code to make that check and display the result.

the result will be : 

BASH : Make a SQL query from bash

MySQL is a very convenient way to store data .
To use stored MySQL data in a BASH script you can use this simple command

this will display the result in you terminal without ASCII decorations.
if you need to use that data for something , you can store it in a var

BASH : IP validation 

if you have a list of ip to validate ,
you can use this little bash script ,
this will open your IP list ,
then test if all the 4 numbers that make a standard IP.are beeten 0 and 255

if the ip is valid then the script will return valid , else it will return : not valid

after execution , you will get the following result :

Use AWK to display x-th and y-th lines after a regex match

In a script you might be interested to keep 2 or more lines after a regex match ,
the line that interest you are not always going to be right after the match ,
the first one might be X lines after the match and the second one Y lines afters the match

in this example , i’m interested in keeping the lines with the price and the number in stock
i’m going to use awk to search for item desc , and display the 4th line after the match, and 6th line.

Bash : Delete some characters from a file with TR

in this little example of usage of the command tr
we want to clean a file so the values contained in it can be used
Example File

In my example i wish to only keep the value and deleting the character < and >

the tr command used with the -d (delete) option will allow you to delete the list of characters contained between the quotes.

You will obtain the following result