How to install and configure check mk agent using systemd on ubuntu
Download check mk agent installation file
[email protected]:~$ curl -O https://monitoring.wachid.web.id/monitor/check_mk/agents/check-mk-agent_1.5.0p4-1_all.deb
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 26162 100 26162 0 0 18122 0 0:00:01 0:00:01 --:--:-- 18130
[email protected]:~$ ls
check-mk-agent_1.5.0p4-1_all.deb oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm wch_backres_vta.sh
junk oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
[email protected]:~$
Add execute permission to check mk agent installation file
[email protected]:~$ chmod +x check-mk-agent_1.5.0p4-1_all.deb
[email protected]:~$ ls
check-mk-agent_1.5.0p4-1_all.deb oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm wch_backres_vta.sh
junk oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm vta-vta-backup.2018-10-12_01-30-01.sql
[email protected]:~$ ls -l
total 1996840
-rwxrwxr-x 1 sysop sysop 26162 Oct 30 17:01 check-mk-agent_1.5.0p4-1_all.deb
drwxrwxr-x 2 sysop sysop 4096 Oct 30 15:44 junk
-rw-rw-r-- 1 sysop sysop 62587782 Sep 7 15:58 oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
-rw-rw-r-- 1 sysop sysop 634803 Sep 7 16:25 oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
-rw-rw-r-- 1 sysop sysop 52826628 Sep 7 15:23 oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
-rw-r--r-- 1 sysop sysop 1928659028 Oct 12 08:44 vta-vta-backup.2018-10-12_01-30-01.sql
-rwxr-xr-x 1 sysop sysop 7608 Oct 30 16:22 wch_backres_vta.sh
[email protected]:~$
Install the check mk agent package file
[email protected]:~$ dpkg -i check-mk-agent_1.5.0p4-1_all.deb
dpkg: error: requested operation requires superuser privilege
[email protected]:~$ sudo dpkg -i check-mk-agent_1.5.0p4-1_all.deb
[sudo] password for sysop:
Selecting previously unselected package check-mk-agent.
(Reading database ... 73756 files and directories currently installed.)
Preparing to unpack check-mk-agent_1.5.0p4-1_all.deb ...
Unpacking check-mk-agent (1.5.0p4-1) ...
Setting up check-mk-agent (1.5.0p4-1) ...
Enable Check_MK_Agent in systemd...
Created symlink from /etc/systemd/system/sockets.target.wants/check_mk.socket to /etc/systemd/system/check_mk.socket.
[email protected]:~$
Reload the daemon and enable start and check status of check mk agent service
[email protected]:~$ sudo systemctl daemon-reload
[email protected]:~$ sudo systemctl enable check_mk.socket
[email protected]:~$ sudo systemctl start check_mk.socket
[email protected]:~$ sudo systemctl status check_mk.socket
● check_mk.socket - Check_MK Agent Socket
Loaded: loaded (/etc/systemd/system/check_mk.socket; enabled; vendor preset: enabled)
Active: active (listening) since Tue 2018-10-30 17:01:58 WIB; 9min ago
Listen: [::]:6556 (Stream)
Accepted: 0; Connected: 0
Oct 30 17:01:58 cloud systemd[1]: Listening on Check_MK Agent Socket.
Oct 30 17:10:55 cloud systemd[1]: Listening on Check_MK Agent Socket.
[email protected]:~$
Check the listen port
[email protected]:~$ netstat -ant | grep 6556
tcp6 0 0 :::6556 :::* LISTEN
[email protected]:~$
Listing the service directory, we can see there are two check mk file (service and socket file)
[email protected]:~$ ls -l /etc/systemd/system/
total 60
-rw-r--r-- 1 root root 168 Sep 11 02:22 [email protected]
-rw-r--r-- 1 root root 149 Sep 11 02:22 check_mk.socket
drwxr-xr-x 2 root root 4096 Sep 3 18:39 cloud-final.service.wants
drwxr-xr-x 2 root root 4096 Aug 28 15:22 default.target.wants
drwxr-xr-x 2 root root 4096 Oct 30 17:11 docker.service.d
drwxr-xr-x 2 root root 4096 Sep 3 18:39 final.target.wants
drwxr-xr-x 2 root root 4096 Aug 28 15:22 getty.target.wants
drwxr-xr-x 2 root root 4096 Aug 28 16:03 graphical.target.wants
lrwxrwxrwx 1 root root 38 Aug 28 16:03 iscsi.service -> /lib/systemd/system/open-iscsi.service
drwxr-xr-x 2 root root 4096 Oct 30 16:51 multi-user.target.wants
drwxr-xr-x 2 root root 4096 Aug 28 15:22 network-online.target.wants
drwxr-xr-x 2 root root 4096 Aug 28 16:03 paths.target.wants
-rw-r--r-- 1 root root 257 Sep 5 23:44 redis.service
drwxr-xr-x 2 root root 4096 Oct 30 17:01 sockets.target.wants
lrwxrwxrwx 1 root root 31 Aug 28 16:03 sshd.service -> /lib/systemd/system/ssh.service
drwxr-xr-x 2 root root 4096 Aug 28 16:03 sysinit.target.wants
lrwxrwxrwx 1 root root 35 Aug 28 15:22 syslog.service -> /lib/systemd/system/rsyslog.service
drwxr-xr-x 2 root root 4096 Sep 3 19:54 timers.target.wants
[email protected]:~$
The content of check mk systemd service file[email protected]:~$ sudo cat /etc/systemd/system/[email protected]
# systemd service definition file
[Unit]
Description=Check_MK
[Service]
ExecStart=/usr/bin/check_mk_agent
KillMode=process
User=root
Group=root
StandardInput=socket
[email protected]:~$
The content of check mk systemd socket file
[email protected]:~$ sudo cat /etc/systemd/system/check_mk.socket
# systemd socket definition file
[Unit]
Description=Check_MK Agent Socket
[Socket]
ListenStream=6556
Accept=true
[Install]
WantedBy=sockets.target
[email protected]:~$
Testing the check mk agent service
[email protected]:~$ telnet localhost 6556
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
<<<check_mk>>>
Version: 1.5.0p4
AgentOS: linux
Hostname: vta-cloud
AgentDirectory: /etc/check_mk
DataDirectory: /var/lib/check_mk_agent
SpoolDirectory: /var/lib/check_mk_agent/spool
PluginsDirectory: /usr/lib/check_mk_agent/plugins
LocalDirectory: /usr/lib/check_mk_agent/local
<<<df>>>
udev devtmpfs 4059644 0 4059644 0% /dev
tmpfs tmpfs 815768 50292 765476 7% /run
/dev/sda4 ext4 495251272 85776392 384294516 19% /
tmpfs tmpfs 4078820 0 4078820 0% /dev/shm
tmpfs tmpfs 5120 0 5120 0% /run/lock
tmpfs tmpfs 4078820 0 4078820 0% /sys/fs/cgroup
..
..
..
Config check mk agent service to use caching
Check is there check mk caching agent executable file on /usr/bin directory
[email protected]:~$ ls -l /usr/bin/ | grep check
-rwxr-xr-x 1 root root 6136 Jul 26 09:41 checkgid
-rwxr-xr-x 1 root root 2771 Jul 29 2016 check-language-support
-rwxr-xr-x 1 root root 42687 Sep 11 02:22 check_mk_agent
-rwxr-xr-x 1 root root 4461 Sep 11 02:22 check_mk_caching_agent
-rwxr-xr-x 1 root root 7503 Mar 15 2018 dpkg-checkbuilddeps
-rwxr-xr-x 1 root root 254408 Mar 22 2018 grub-script-check
-rwxr-xr-x 1 root root 14264 Apr 19 2018 innochecksum
-rwxr-xr-x 1 root root 4090 Apr 25 2018 linux-check-removal
lrwxrwxrwx 1 root root 10 Apr 19 2018 mysqlanalyze -> mysqlcheck
-rwxr-xr-x 1 root root 3388504 Apr 19 2018 mysqlcheck
lrwxrwxrwx 1 root root 10 Apr 19 2018 mysqloptimize -> mysqlcheck
lrwxrwxrwx 1 root root 10 Apr 19 2018 mysqlrepair -> mysqlcheck
-rwxr-xr-x 1 root root 19104 Jul 13 20:54 pkcheck
-rwxr-xr-x 1 root root 3699 Jun 13 02:30 podchecker
-rwxr-xr-x 1 root root 10232 Dec 20 2015 redis-check-aof
-rwxr-xr-x 1 root root 22520 Dec 20 2015 redis-check-dump
-rwxr-xr-x 1 root root 10544 Apr 15 2016 vmware-checkvm
[email protected]:~$
Open the check mk agent systemd service file, and change the check mk execution file from check mk agen to check mk caching agent and restart the service again
[email protected]:~$ sudo vi /etc/systemd/system/[email protected]
[email protected]:~$
syso[email protected]:~$ sudo systemctl restart check_mk.socket
[email protected]:~$
Here are the file after updated
[email protected]:~$ sudo cat /etc/systemd/system/[email protected]
# systemd service definition file
[Unit]
Description=Check_MK
[Service]
#ExecStart=/usr/bin/check_mk_agent
ExecStart=/usr/bin/check_mk_caching_agent
KillMode=process
User=root
Group=root
StandardInput=socket
[email protected]:~$
Testing the check mk service again by running telnel on localhost port 6556
[email protected]:~$ telnet localhost 6556
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
<<<check_mk>>>
Version: 1.5.0p4
AgentOS: linux
Hostname: vta-cloud
AgentDirectory: /etc/check_mk
DataDirectory: /var/lib/check_mk_agent
SpoolDirectory: /var/lib/check_mk_agent/spool
PluginsDirectory: /usr/lib/check_mk_agent/plugins
LocalDirectory: /usr/lib/check_mk_agent/local
<<<df>>>
udev devtmpfs 4059644 0 4059644 0% /dev
tmpfs tmpfs 815768 50516 765252 7% /run
/dev/sda4 ext4 495251272 85973928 384096980 19% /
tmpfs tmpfs 4078820 80 4078740 1% /dev/shm
tmpfs tmpfs 5120 0 5120 0% /run/lock
tmpfs tmpfs 4078820 0 4078820 0% /sys/fs/cgroup
/dev/sda1 ext4 474730 57648 388052 13% /boot
/dev/sda5 ext4 4673664 2006592 2406620 46% /home
tmpfs tmpfs 100 0 100 0% /run/lxcfs/controllers
tmpfs tmpfs 815768 0 815768 0% /run/user/1000
none aufs 495251272 85973928 384096980 19% /var/lib/docker/aufs/mnt/8
Testing the check mk service again by running telnel on localhost port 6556
[email protected]:~$ telnet localhost 6556
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
<<<check_mk>>>
Version: 1.5.0p4
AgentOS: linux
Hostname: vta-cloud
AgentDirectory: /etc/check_mk
DataDirectory: /var/lib/check_mk_agent
SpoolDirectory: /var/lib/check_mk_agent/spool
PluginsDirectory: /usr/lib/check_mk_agent/plugins
LocalDirectory: /usr/lib/check_mk_agent/local
<<<df>>>
udev devtmpfs 4059644 0 4059644 0% /dev
tmpfs tmpfs 815768 50516 765252 7% /run
/dev/sda4 ext4 495251272 85973928 384096980 19% /
tmpfs tmpfs 4078820 80 4078740 1% /dev/shm
tmpfs tmpfs 5120 0 5120 0% /run/lock
tmpfs tmpfs 4078820 0 4078820 0% /sys/fs/cgroup
/dev/sda1 ext4 474730 57648 388052 13% /boot
/dev/sda5 ext4 4673664 2006592 2406620 46% /home
tmpfs tmpfs 100 0 100 0% /run/lxcfs/controllers
tmpfs tmpfs 815768 0 815768 0% /run/user/1000
none aufs 495251272 85973928 384096980 19% /var/lib/docker/aufs/mnt/8
You can also use netcat to testing the check mk agent
[email protected]:~$ nc -v localhost 6556
Connection to localhost 6556 port [tcp/*] succeeded!
<<<check_mk>>>
Version: 1.5.0p4
AgentOS: linux
Hostname: vta-cloud
AgentDirectory: /etc/check_mk
DataDirectory: /var/lib/check_mk_agent
SpoolDirectory: /var/lib/check_mk_agent/spool
PluginsDirectory: /usr/lib/check_mk_agent/plugins
LocalDirectory: /usr/lib/check_mk_agent/local
<<<df>>>
udev devtmpfs 4059644 0 4059644 0% /dev
tmpfs tmpfs 815768 50488 765280 7% /run
/dev/sda4 ext4 495251272 85974012 384096896 19% /
Configure the firewall
Check firewall status
Check firewall status
[email protected]:~$ sudo ufw status numbered
Status: active
To Action From
-- ------ ----
[ 1] 80 ALLOW IN Anywhere
[ 2] 80 (v6) ALLOW IN Anywhere (v6)
[email protected]:~$
Add firewall rule to allow check mk agent service (port 6556) and check the status[email protected]:~$ sudo ufw allow from any to any port 6556
Rule added
Rule added (v6)
[email protected]:~$
[email protected]:~$ sudo ufw status numbered
Status: active
To Action From
-- ------ ----
[ 1] 80 ALLOW IN Anywhere
[ 2] 6556 ALLOW IN Anywhere
[ 3] 80 (v6) ALLOW IN Anywhere (v6)
[ 4] 6556 (v6) ALLOW IN Anywhere (v6)
[email protected]:~$
Testing check mk agent from another host[email protected]:~$ nc -v 192.168.71.26 6556
Connection to 192.168.71.26 6556 port [tcp/*] succeeded!
<<<check_mk>>>
Version: 1.5.0p4
AgentOS: linux
Hostname: vta-cloud
AgentDirectory: /etc/check_mk
DataDirectory: /var/lib/check_mk_agent
SpoolDirectory: /var/lib/check_mk_agent/spool
PluginsDirectory: /usr/lib/check_mk_agent/plugins
LocalDirectory: /usr/lib/check_mk_agent/local
<<<df>>>
udev devtmpfs 4059644 0 4059644 0% /dev
tmpfs tmpfs 815768 50460 765308 7% /run
/dev/sda4 ext4 495251272 86246892 383824016 19% /
tmpfs tmpfs 4078820 80 4078740 1% /dev/shm
tmpfs tmpfs 5120 0 5120 0% /run/lock
tmpfs tmpfs 4078820 0 4078820 0% /sys/fs/cgroup
/dev/sda1 ext4 474730 57648 388052 13% /boot
/dev/sda5 ext4 4673664 2006640 2406572 46% /home
tmpfs tmpfs 100 0 100 0% /run/lxcfs/controllers
tmpfs tmpfs 815768 0 815768 0% /run/user/1000
Tidak ada komentar :
Posting Komentar