Glass (2019)

Everyone’s talking about Avengers. I simply don’t give a damn. Glass is the type of Super Hero movie I like.

I wonder why the movie was titled as “Glass” rather than something else like Mr [insert a word here] or something. Hmmm. Maybe I now know the answer to this as I’m writing this blog post. I’m getting more mind-blown even now.

Not for the faint-heart/mind though. I’d give it a 9.5/10

Chili activates 4G in Curepipe?

I got these SMS from Chili MTML as follows :

It’s great. 3.5G coupled with Chili’s Zeness Pack was already awesome. It got even more awesome. MyT is no way near offering such competitive prices despite having such monopoly on the Mauritian market. Hope Chili survives to make Mauritius much more connected.

Basic Security with Asterisk/Freeswitch

This post is not exhaustive. These are the minimum security measures.

  1. Block all access to port 5060 and 5080
    1. /sbin/iptables -A INPUT -p udp –destination-port 5080 -j DROP
    2. /sbin/iptables -A INPUT -p udp –destination-port 5080 -j DROP
  2. Allow only specific IPs to connect
    1. /sbin/iptables -I INPUT -p udp -s {IP} –destination-port 5060 -j ACCEPT
    2. /sbin/iptables -I INPUT -p udp -s {IP} –destination-port 5080 -j ACCEPT

Elasticsearch on Docker Swarm with NGINX

On all Hosts:

sudo sysctl -w vm.max_map_count=262144

On Host 1:

1. We initialize a docker swarm. Add `–advertise-addr X.X.X.X` if inside a private network

# docker swarm init

1. We create a network on docker

# docker network create --driver overlay --subnet 10.0.10.0/24   --opt encrypted elastics

“Overlay networks connect multiple Docker daemons together and enable swarm services to communicate with each other.” [2]

2. We initialize the docker containers with 3 copies

docker service create --name elasticsearch --network=elastics \
  --replicas 3 \
  --env SERVICE_NAME=elasticsearch \
  --env "ES_JAVA_OPTS=-Xms256m -Xmx256m -XX:-AssumeMP" \
  --publish 9200:9200 \
  --publish 9300:9300 \
  youngbe/docker-swarm-elasticsearch:5.5.0

3. We get the command to generate the joining link

# docker swarm join-token worker
To add a worker to this swarm, run the following command:

    docker swarm join \
    --token SWMTKN-TOKEN \
    X.X.X.X:2377

On Worker Host
1. Type the command from the last step from host 1

# docker swarm join \
    --token TOKEN \
    X.X.X.X:2377

On Master 1

1. We now setup nginx

docker service create --name meranginx --network=elastics  nginx
docker service create --name nginx --network=elastics --mount type=bind,source=/root/meradockernginx/elasticsearch.conf,destination=/etc/nginx/conf.d/elasticsearch.conf nginx

To be continued…
#TODO: make a conf file for nginx which listens on port 9200 and uses `elasticsearch` as backend server

References:

[1] https://github.com/imyoungyang/docker-swarm-elasticsearch
[2] https://docs.docker.com/network/#network-drivers

Duplicate Monit IDs in MMonit

when you’re using MMonit software with multiple VMs cloned from a template with monit installed, there are sometimes 2 VM get the same monit IDs. You’ll notice that there are errors on your MMonit dashboard which disappears after a while.

To view the monit id of your VMs, type the following command on your terminal

# monit -i

What do you do if you have hundreds or thousands of VMs? How will you know which ones have duplicate IDs?

I implemented a solution using SQL Triggers.

CREATE TABLE `duplicate_monitids` (
`ipaddrin` varchar(255) NOT NULL DEFAULT ”,
`monitid` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ipaddrin`)
)

delimiter //
CREATE TRIGGER duplicate_monitids AFTER UPDATE
ON host
FOR EACH ROW
BEGIN
INSERT INTO duplicate_monitids(ipaddrin,monitid) VALUES(NEW.ipaddrin,NEW.monitid);
END//
delimiter ;

Then to view the VMs which have duplicate IDs, run the following SQL Query

select ipaddrin from duplicate_monitids where monitid IN (select monitid from duplicate_monitids group by monitid having count(*) > 1);