How to install RabbitMQ?

Use the following commands to install and start RabbitMQ (Tested on: CentOS 7.2.1511)
yum install erlang
yum install socat logrotate
wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm
rpm -ivh rabbitmq-server-3.6.6-1.el7.noarch.rpm
systemctl enable rabbitmq-server
systemctl start rabbitmq-server

HTTP Get explained in C++

I use all type of languages to download files, However, recently I have realised I have never done so in C++. Lets take a look at it today:

Ok here is a simple start, is it compiling ? Looks like it is:

[[email protected] cppdownload]# cat download.cpp
#include <iostream>
using namespace std;
int main()
{
return 0;
}
[[email protected] cppdownload]# g++ download.cpp
[[email protected] cppdownload]# ./a.out

Next step .. Download curl-dev libraries:

yum install libcurl-devel.x86_64

Include the header file in your code:

#include <curl/curl.h>

Thanks to a simple example in curl documentation, your code should look like this:

#include <iostream>
#include <curl/curl.h>
using namespace std;
int main()
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://jahansyed.co.uk");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}

Compile the code and give it reference to curl library and run the program:
g++ download.cpp -lcurl
./a.out

How to use/manage systemd in Centos 7?

Systemd! who doesn’t know about it eh? But do you really know how to use it to find service names, service statuses, binary associated to the service, reloading systemd config etc etc .. may be not. Well lets try to address that today:

How to list all the services:

systemctl list-units --all

You can then use “/STRINGNAME” to find the service you are concerned about or if you are a GREP< fan you can use systemctl list-units –no-pager | grep “mariadb”

The above can be useful for nagios or zabbix checks.

How to start the service:

systemctl start mariadb

How to stop the service:

systemctl stop mariadb

How to enable service on boot:

systemctl enable mariadb

How to disable service on boot:

systemctl disable mariadb

How to find file associated to a service:

systemctl show mariadb --no-pager | grep Fragment

FragmentPath=/usr/lib/systemd/system/mariadb.service

How to cat the service file associated to a file:

systemctl cat mariadb