Monthly Archives: July 2018

Setting up Zabbix Agent to monitor CPU and HDD Temperatures

First turn off the firewall and disable selinux:
systemctl disable firewalld
vi /etc/selinux/config

Install the Zabbix 3.4 source repo and install zabbix and lm_sensros and smartmontools:
rpm -ivh https://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum install -y zabbix-agent lm_sensors smartmontools

Edit /etc/zabbix/zabbix_agentd.conf and set the Server and ServerActive to the hostname of your zabbix server.

Create a sudoers.d file for zabbix in /etc/sudoers.d/zabbix:
zabbix ALL=NOPASSWD:/usr/sbin/smartctl
zabbix ALL=NOPASSWD:/bin/sensors

Create a new files in /etc/zabbix/zabbix_agentd.d called hdd_temps.conf and enter information like so:
UserParameter=Temperature.HDD2,/usr/share/zabbix-agent/hdd2.sh
UserParameter=Temperature.HDD1,/usr/share/zabbix-agent/hdd1.sh
UserParameter=Temperature.CPU1,/usr/share/zabbix-agent/cpu1.sh

Create the /usr/share/zabbix-agent directory and add hdd1, hdd2 and cpu1 shell scripts:
#!/bin/bash
sudo smartctl -a /dev/sdb | grep Temperature_Celsius | awk {'print $10'}

#!/bin/bash
sudo smartctl -a /dev/sdc | grep Temperature_Celsius | awk {'print $10'}

#!/bin/bash
sudo sensors | grep Core | awk -F'[+|.]' {'print $2'}

In zabbix you need to add the items for HDD1, HDD2 and CPU1 to the configuration of the host. Once it is added zabbix will collect the date periodically.

Advertisements

Setting postgresql default database locale

UPDATE pg_database SET datallowconn = TRUE WHERE datname = 'template0';
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
drop database template1;
CREATE DATABASE template1 ENCODING = 'utf8' TEMPLATE = template0 LC_CTYPE ='en_US.utf8' LC_COLLATE = 'en_US.utf8';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template0';

Setting up mediasmartserverd for Centos 7 on EX490

This post details setting up mediasmartserverd under Centos 7 on an HP EX490. This allows for the status LED to be used as an indicator for updates and also the drive lights to be illuminated according to disk state/activity. The mediasmartserverd binary is built on the local machine:
yum -y install wget zip libudev-devel
yum -y groupinstall "Development Tools"
wget https://github.com/merelin/mediasmartserverd/archive/0.5.6.tar.gz
tar -zxvf 0.5.6.tar.gz
cd mediasmartserverd-0.5.6
make
cp mediasmartserverd /usr/local/sbin/
vi /usr/lib/systemd/system/mediasmartserverd.service

The enter the following into the file and exit with [Esc]:wq:

[Unit]
Description=MediaSmartServer

[Service]
ExecStart=/usr/local/sbin/mediasmartserverd --activity --update-monitor
Restart=always

[Install]
WantedBy=multi-user.target

Then enable and start the service:
systemctl enable mediasmartserverd.service
systemctl start mediasmartserverd.service

Advertisements