InfluxDB is time series database that can store huge amount of data for different metrics like CPU, RAM, Storage usage. If you have Grafana in place, one of the databases that would work with it is InfluxDB.
If you setup InfluxDB you can type
Databases in InfluxDB are called well Database :) and tables are called
You are now on
Yes, it is almost similar to MySQL. The main point of such a database is to use monitoring tool in place and push metrics into influxDB, then make graphs by using Grafana.
#influxdb #grafana #measurement #time_series_db
If you setup InfluxDB you can type
influx
and hit enter to see InfluxDB console (like MySQL):infladmin@my_host:~$ influx
Connected to http://localhost:8086 version 1.2.2
InfluxDB shell version: 1.2.2
Databases in InfluxDB are called well Database :) and tables are called
Measurement
. To see list of all databases and make a database active do as below:> SHOW DATABASES
name: databases
name
----
_internal
my_db
monitoring
some_other_db
> USE my_db
Using database my_db
You are now on
my_db
database. To display list of measurements (table) and query it:> SHOW MEASUREMENTS
name: measurements
name
----
cpu_stat
mem_stat
> SELECT * FROM cpu_stat LIMIT 2;
name: cpu_stat
time my_tag metric value
---- ----------- ------ -----
1503999476000000000 CPU_CORE3 CORES 0
1503999476000000000 total 16
Yes, it is almost similar to MySQL. The main point of such a database is to use monitoring tool in place and push metrics into influxDB, then make graphs by using Grafana.
#influxdb #grafana #measurement #time_series_db
Shift time in
To get your new date in
To turn
#python #epoch #datetime #time #timedelta #strftime
python
using datetime
& timedelta
:import datetime
from datetime import timedelta
date1 = datetime.datetime.utcnow()
# output of date1: datetime.datetime(2017, 11, 8, 10, 24, 25, 19492)
date2 = date1 + timedelta(days=1)
# output of date2: datetime.datetime(2017, 11, 9, 10, 24, 25, 19492)
To get your new date in
EPOCH
:at_epoch = (date2 - datetime.datetime(1970, 1, 1)).total_seconds()
# output of subtract: 1510223065.019492
To turn
EPOCH
to datetime
:import time
from_epoch = time.localtime(1510223065.019492)
# output: time.struct_time(tm_year=2017, tm_mon=11, tm_mday=9, tm_hour=13, tm_min=54, tm_sec=25, tm_wday=3, tm_yday=313, tm_isdst=0)
formatted_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1510223065.019492))
# output: 2017-11-09 13:54:25
#python #epoch #datetime #time #timedelta #strftime
Tech C**P
What is LPUSH in REDIS: Insert all the specified values at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations. When key holds a value that is not a list, an error is returned.…
O(1) or O(n) access time?
O(1) means that it takes a constant time, like 14 nanoseconds, or three minutes no matter the amount of data in the set.
O(n) means it takes an amount of time linear with the size of the set, so a set twice the size will take twice the time. You probably don't want to put a million objects into one of these.
#time #complexity #time_complexity
If you have multiple statements and you want to time the whole statements in a bash script you can use
That's it. In case you want to just
#linux #bash #time
time
command, but you don't need to use inside of the script. If you have an script called my_long_tasks.sh
you need to just:$ time my_long_tasks.sh
real 0m20.894s
user 0m3.664s
sys 0m0.452s
That's it. In case you want to just
time
part of your statements in your bash script then you need to:start=`date +%s`
stuff
end=`date +%s`
runtime=$((end-start))
#linux #bash #time