Thursday, December 31, 2015

Install Google Chrome on CentOS 6.7

Add Google Chrome official repository. Create a new file:
vi /etc/yum.repos.d/google-chrome.repo
Copy this content to file:
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
Download Chrome installation script:
wget http://chrome.richardlloyd.org.uk/install_chrome.sh
Set the script exetuable:
chmod u+x install_chrome.sh
Execute script:
./install_chrome.sh

Wednesday, December 30, 2015

4K Video Downloader silent install

Download latest installer:
https://www.4kdownload.com/products/product-videodownloader

silent-install.cmd
@echo off
setlocal EnableDelayedExpansion
set sw=HKLM\SOFTWARE
set u=Microsoft\Windows\CurrentVersion\Uninstall
set k=4K Video Downloader_is1
if not "%ProgramFiles(x86)%"=="" set x=Wow6432Node\
reg query "%sw%\%x%%u%\%k%" > nul 2>&1
if not !errorlevel!==0 (
for /f "tokens=*" %%a in ('dir /b "%~dp04kvideodownloader*.exe"') do (
echo 4K Video Downloader
start /wait "" "%~dp0%%a" /SILENT
)
) else echo 4K Video Downloader already installed!
endlocal

Tuesday, December 29, 2015

Force / replace boot.wim image, SCCM 2012

If you want to use specific boot image then:
1) Assign your new boot image to [Boot Images] section. Do not distribute it!

2) Open image [Properties]

3) Make sure to check "Deploy this boot image from the PXE-enabled distribution point"

4) Distribute content:


5) Wait for success status

6) Create new task sequence

7) make sure you assign just exact same boot image you created before:

8) Complete task sequence

9) Deploy task sequence

10) Celebrate. Boot image now are replaced:

Send email through google server for Raspberry Pi

Enter super user mode:
sudo su
Download necessary script:
mkdir -p /var/zabbix/alertscripts
wget https://gist.githubusercontent.com/superdaigo/3754055/raw/e28b4b65110b790e4c3e4891ea36b39cd8fcf8e0/zabbix-alert-smtp.sh -O zabbix-alert-smtp.py
chmod +x /var/zabbix/alertscripts/zabbix-alert-smtp.py
Set up user and password:
sed -i "s/your.account@gmail.com/name.surname@gmail.com/" /var/zabbix/alertscripts/zabbix-alert-smtp.py
sed -i "s/your mail password/yoursecretpassword/" /var/zabbix/alertscripts/zabbix-alert-smtp.py
sed -i "s/Zabbix Alert/Alehandro/" /var/zabbix/alertscripts/zabbix-alert-smtp.py
Enable less secure apps for your google account:
https://www.google.com/settings/security/lesssecureapps

Test if this works:
/var/zabbix/alertscripts/zabbix-alert-smtp.py blah.blah@gmail.com "$(hostname)" "$(uptime)"
Schedule email:
crontab -e
Enter something like:
31 * * * * /var/zabbix/alertscripts/zabbix-alert-smtp.py blah.blah@gmail.com "$(hostname)" "$(uptime)"

Monday, December 28, 2015

Windows PE cannot start because the actual SYSTEMROOT directory (X:\Windows) is different from the configured one (X:\$windows.~bt\Windows)


Solution is use "Microsoft Windows PE Setup" (index 2) instead of "Microsoft Windows PE" (index 1):

Images used in example:

64-bit Windows 10 PE:
curl -N -r 24584192-282367313 http://care.dlservice.microsoft.com/dl/download/B/B/3/BB3611B6-9781-437F-A293-AB43B85C2190/10586.0.151029-1700.TH2_RELEASE_CLIENTENTERPRISEEVAL_OEMRET_X64FRE_EN-US.ISO -owinpe10x64.wim
46a3092cf5327349638503b6890035aa
56af2bb96d729773d1478520f85d583e52e56a96

32-bit Windows 10 PE:
curl -N -r 23744512-238798652 http://care.dlservice.microsoft.com/dl/download/B/B/3/BB3611B6-9781-437F-A293-AB43B85C2190/10586.0.151029-1700.TH2_RELEASE_CLIENTENTERPRISEEVAL_OEMRET_X86FRE_EN-US.ISO -owinpe10x86.wim
4fe1efdcff4ea3462a768cc9995f7934
5c79a62469a996a3c647b942190e46129f32ab70

Set dynamic hostname for Raspbian image

Set hostname for session based of full MAC address:
sudo hostname rpi$(ifconfig -a eth0 | grep "HWaddr" | sed "s/^.*HWaddr //" | sed "s/://g")
Every Pi MAC address starts with b8:27:eb so lets truncate this off.
To set hostname for session based only on end part of MAC address:
sudo hostname rpi$(ifconfig -a eth0 | grep "HWaddr" | sed "s/^.*HWaddr .........//" | sed "s/://g")
Lets create new service:
cat > /etc/init.d/zdhostname << EOF
#!/bin/sh
case "\$1" in
start)
#newname=rpi\$(ifconfig -a eth0 | grep "HWaddr" | sed "s/^.*HWaddr //" | sed "s/://g") #based on full MAC address
newname=rpi\$(ifconfig -a eth0 | grep "HWaddr" | sed "s/^.*HWaddr .........//" | sed "s/://g") #based on MAC address. truncate b8:27:eb cause it is same for every pi
sed -i "s/^127.0.1.1.*\$/127.0.1.1\\t\$newname/" /etc/hosts
echo \$newname> /etc/hostname
/etc/init.d/hostname.sh
echo "Hostname changed"
;;
*)
echo "Usage: /etc/init.d/zdhostname {start}"
exit 1
;;
esac
EOF
At the end file /etc/init.d/zdhostname look like:
#!/bin/sh
case "$1" in
start)
#newname=rpi$(ifconfig -a eth0 | grep "HWaddr" | sed "s/^.*HWaddr //" | sed "s/://g") #based on full MAC address
newname=rpi$(ifconfig -a eth0 | grep "HWaddr" | sed "s/^.*HWaddr .........//" | sed "s/://g") #based on MAC address. truncate b8:27:eb cause it is same for every pi
sed -i "s/^127.0.1.1.*$/127.0.1.1\t/" /etc/hosts
echo $newname> /etc/hostname
/etc/init.d/hostname.sh
echo "Hostname changed"
;;
*)
echo "Usage: /etc/init.d/zdhostname {start}"
exit 1
;;
esac
Set the file executable:
chmod 755 /etc/init.d/zdhostname
Refresh startup services:
update-rc.d zdhostname defaults
Chenge hostname instantly:
/etc/init.d/zdhostname start

Wednesday, December 23, 2015

Get all links from page, BeautifulSoup, python

Install BeautifulSoup module for Raspberry Pi:
sudo apt-get install python-bs4
Create file get-all-links.py
import urlparse
import urllib
from bs4 import BeautifulSoup

#define urls you have to work with. seperate multiple values with coma
url = "https://www.salidzini.lv/search.php?q=samsung+evo+850+250gb"

#put all urls in array. this is necesary to learn for future projects
#once every url will be processed from array it will be erased at the end of loop
urls = [url]

#define visited url array
visited = [url]

#start while loop. remember that tabs matter in python
#while something is inside in urls array then do the folowing steps
while len(urls) > 0:
        try:
                #read url
                htmltext = urllib.urlopen(urls[0]).read()
        except:
                #if the link is really broken or can not be reached this time
                #then the link name will be printed on screen
                print urls[0]

        #convert whole html to soup to easy look for everything
        soup = BeautifulSoup(htmltext)

        #decrease urls array. erase element from array
        urls.pop(0)

        #we have still content in soup so we can do whatever we want
        #this time print all urls which has <a></a> tag in html and have something in href
        print soup.findAll('a',href=True)
Launch code:
python get-all-links.py

Tuesday, December 22, 2015

Raspbian Jessie, First things first, Raspberry Pi

Update system:
sudo apt-get update -y && sudo apt-get upgrade -y
Set Up proper time zone:
sudo cp /usr/share/zoneinfo/Etc/GMT-2 /etc/localtime
Extend filesystem:
sudo raspi-config
Remove black borders from screen - Use native full hd resolution:
sudo sed -i "s/^.*disable_overscan=.*$/disable_overscan=1/" /boot/config.txt
Do not allow screen go blank:
sudo sed -i "s/^.*xserver-command=.*$/xserver-command=X -s 0 dpms/" /etc/lightdm/lightdm.conf
Install git command so it can be easy to work with github:
sudo apt-get install git -y
Install Firefox:
sudo apt-get install iceweasel -y
Colorize vim editor for user root and main user:
sudo su
apt-get install vim -y
mkdir -p ~/.vim/colors
wget https://raw.github.com/altercation/vim-colors-solarized/master/colors/solarized.vim -O ~/.vim/colors/solarized.vim
cat > ~/.vimrc << EOF
syntax enable
set background=dark
colorscheme solarized
EOF
exit
mkdir -p ~/.vim/colors
wget https://raw.github.com/altercation/vim-colors-solarized/master/colors/solarized.vim -O ~/.vim/colors/solarized.vim
cat > ~/.vimrc << EOF
syntax enable
set background=dark
colorscheme solarized
EOF
Force to use plain openbox instead of LXDE:
sudo sed -ri "s/exec \/usr\/bin\/lxsession -s LXDE-pi -e LXDE/exec \/usr\/bin\/openbox-session/" /usr/bin/x-session-manager
Configure to run application at openbox startup:
mkdir -p ~/.config/openbox/autostart
echo "#!/bin/sh" > ~/.config/openbox/autostart
vi ~/.config/openbox/autostart
chmod +x ~/.config/openbox/autostart
Configure to run application at LXDE startup:
vi /home/pi/.config/lxsession/LXDE-pi/autostart
Install pip for python2:
sudo apt-get install python-pip -y
Install pip3 for python3:
sudo apt-get install python3-pip -y
Install 7z support:
sudo apt-get install p7zip-full -y
Clone 2015-11-21-raspbian-jessie-lite card with another raspberry pi via usb port::
dd if=/dev/sda of=/home/pi/git-installed.img bs=1M count=1391
Connect to active session into the Raspbian:

Install Chromium on Raspberry Pi 2:

Chromium browser fresh start:

Shutdown Raspberry Pi through GPIO short circuit:

Set dynamic hostname for Raspbian image:

Monday, December 21, 2015

Install Chromium on Raspbian Jessie

This method only works for Raspberry Pi 2 NOT 1
The problem is related to CPU power that is why Raspberry Pi 1 gets error:

To Install Chromium 45 do the folowing steps:

Install libgcrypt package:
wget http://ftp.us.debian.org/debian/pool/main/libg/libgcrypt11/libgcrypt11_1.5.0-5+deb7u3_armhf.deb
sudo dpkg -i libgcrypt11_1.5.0-5+deb7u3_armhf.deb
Install chromium codecs:
wget http://launchpadlibrarian.net/218525711/chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
sudo dpkg -i chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
Chromium browser:
wget http://launchpadlibrarian.net/218525709/chromium-browser_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
sudo dpkg -i chromium-browser_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
Mirror:
wget https://4df6e1cc06542c4058f9d4374eb3a7780e74b91b.googledrive.com/host/0B_esWdErYKaLY3ZQUlJJRDNLSlU/libgcrypt11_1.5.0-5+deb7u3_armhf.deb
wget https://4df6e1cc06542c4058f9d4374eb3a7780e74b91b.googledrive.com/host/0B_esWdErYKaLY3ZQUlJJRDNLSlU/chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
wget https://4df6e1cc06542c4058f9d4374eb3a7780e74b91b.googledrive.com/host/0B_esWdErYKaLY3ZQUlJJRDNLSlU/chromium-browser_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
sudo dpkg -i libgcrypt11_1.5.0-5+deb7u3_armhf.deb
sudo dpkg -i chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
sudo dpkg -i chromium-browser_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb

Friday, December 18, 2015

Use external storage for roms, RetroPie

Place your roms in external storage using direcotry structure:
/psx
/nes
/genesis
Do not use like this! :
/roms/psx
/roms/nes
/roms/genesis
Push fresh RetroPie image

Use putty and ssh into the pi.

Install NTFS files system support:
sudo apt-get install ntfs-3g -y
If you are not using putty you have to quit emulation station using menu.
Select quit emulation station. This will jump you into terminal window:

Now you plug your ntfs media and mount with command:
sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sda1 /home/pi/RetroPie/roms/
Now you can execute again emulation station with command:
emulationstation
Or you can modify settings so this will work in the next startup automatically.
Open fstab:
sudo nano /etc/fstab
At the end add:
/dev/sda1 /home/pi/RetroPie/roms ntfs-3g 0 1
Source:
http://blog.petrockblock.com/wp-content/uploads/2015/07/Getting-strated-with-Retropie.pdf

Thursday, December 17, 2015

Extract all bin files from PLAYSTATION USA REDUMP

I have created script to extract and unecm all PSX games from these torrents:
PS1 PSX PLAYSTATION USA REDUMP EVERY GAME 1 OF 4
PS1 PSX PLAYSTATION USA REDUMP EVERY GAME 2 OF 4
PS1 PSX PLAYSTATION USA REDUMP EVERY GAME 3 OF 4
PS1 PSX PLAYSTATION USA REDUMP EVERY GAME 4 OF 4
https://github.com/catonrug/extract-psx-usa-redump/archive/master.zip

Sample code looks like:
@echo off
set path=%path%;%~dp0
setlocal EnableDelayedExpansion
set t=%temp%\psx
set d=%~dp0playable
if exist "%t%" rd "%t%" /Q /S
if not exist "%t%" md %t%
if exist "%d%" rd "%d%" /Q /S
if not exist "%d%" md %d%
dir /b /s > "%~dp0all.lst"

for /f "tokens=*" %%a in ('grep "\.7z$" "%~dp0all.lst"') do (
for /f "tokens=*" %%n in ('echo "%%a" ^| sed "s/^.*\\\|\.7z.*$//g"') do (
echo %%n
"%~dp07z.exe" x "%%a" -o"%t%" > nul 2>&1
if not !errorlevel!==0 echo NOT OK %%n
"%~dp0unecm.exe" "%t%\Track 01.bin.ecm" "%d%\%%n.bin" > nul 2>&1
if not !errorlevel!==0 (
echo %%n is probably in "~t7z" direcotry
move "%t%\*.bin" "%d%" > nul 2>&1
if exist "%t%" rd "%t%" /Q /S > nul 2>&1
if not exist "%t%" md "%t%" > nul 2>&1
)
del "%t%\Track 01.bin.ecm" /Q /F > nul 2>&1
)
)
pause
endlocal

Wednesday, December 16, 2015

Reset PostgreSQL database password

Backup this file:
cp /var/lib/pgsql/data/{pg_hba.conf,pg_hba.conf.backup}
Overwrite all content with super user mode:
echo local  all   all   trust> /var/lib/pgsql/data/pg_hba.conf
Check if there really is some content:
cat /var/lib/pgsql/data/pg_hba.conf
Restart service:
service postgresql restart
Enter database mode:
psql -U postgres
Set new password to user postgres:
ALTER USER postgres with password 'rand0m';
Exit database mode:
\q
Restore configuration file:
cp /var/lib/pgsql/data/{pg_hba.conf.backup,pg_hba.conf}
Check if there is some old content:
grep -v "^$\|#" /var/lib/pgsql/data/pg_hba.conf
Restart service:
service postgresql restart

Tuesday, December 15, 2015

4K Video Downloader silent uninstall

silnet-uninstall.cmd
@echo off
set sw=HKLM\SOFTWARE
set u=Microsoft\Windows\CurrentVersion\Uninstall
set k=4K Video Downloader_is1
if not "%ProgramFiles(x86)%"=="" set x=Wow6432Node\
for /f delims^=^"^ tokens^=2 %%a in ('^
reg query "%sw%\%x%%u%\%k%" /v UninstallString ^|
find "UninstallString"') do (
start /wait "" "%%a" /SILENT
)

Connect to active session into the Raspbian

Enter root mode:
sudo su
Update system:
apt-get update -y && apt-get upgrade -y
Install x11vnc server:
apt-get install x11vnc -y
Configure password for VNC server:
sudo x11vnc -storepasswd /etc/x11vnc.pass
Create startup service:
cat > /etc/init.d/x11vnc << EOF
#!/bin/sh
case "\$1" in
start)
/usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -ncache 10 -rfbauth /etc/x11vnc.pass -forever -bg -rfbport 5900 -o /var/log/x11vnc.log
echo "x11vnc Started"
;;
stop)
pkill x11vnc
echo "x11vnc Terminated"
;;
*)
echo "Usage: /etc/init.d/x11vnc {start|stop}"
exit 1
;;
esac
EOF

Set file executable:
chmod 755 /etc/init.d/x11vnc
Update startup situation:
update-rc.d x11vnc defaults
Reboot or start VNC server immediately:
/etc/init.d/x11vnc start
Now you can use TightVNC viewer to connect to your raspberry pi IP address.
For example 192.168.88.90:0

Monday, December 14, 2015

Send mail through smtp gmail server from Zabbix

Check and set AlertScriptsPath definition in zabbix_server.conf.

If you can not found this file then search it:
whereis zabbix_server.conf
Check for existing setting. This can report nothing:
grep "^AlertScriptsPath" /usr/local/etc/zabbix_server.conf
Check if you can use existing line. This should report only one line
grep "AlertScriptsPath=" /usr/local/etc/zabbix_server.conf
Set that AlertScriptsPath will be in /var/zabbix/alertscripts:
sed -i "s/^.*AlertScriptsPath=.*$/AlertScriptsPath=\/var\/zabbix\/alertscripts/" /usr/local/etc/zabbix_server.conf
Make sure you have this directory and the owner is zabbix:
mkdir -p /var/zabbix/alertscripts
chown -R zabbix:zabbix /var/zabbix/
Go to this directory and download script:
cd /var/zabbix/alertscripts
wget https://gist.githubusercontent.com/superdaigo/3754055/raw/e28b4b65110b790e4c3e4891ea36b39cd8fcf8e0/zabbix-alert-smtp.sh -O zabbix-alert-smtp.py
Set file executable:
chmod +x zabbix-alert-smtp.py
Open this file and enter your email address and password at line 14 and 15:
vi zabbix-alert-smtp.py
Test if sending works.
./zabbix-alert-smtp.py yourname@gmail.com "subject" "this is test"
If you receive error like this:
Traceback (most recent call last):
  File "./zabbix-alert-smtp.sh", line 58, in <module>
    body=sys.argv[3])
  File "./zabbix-alert-smtp.sh", line 42, in send_mail
Please log in via your web browser and\n5.7.14 then try again.\n5.7.14  Learn more at\n5.7.14  https://support.google.com/mail/answer/78754 dq10sm1596135lbc.12 - gsmtp')
Then go to https://www.google.com/settings/security/lesssecureapps and turn on less secure apps.

Now go to zabbix WEB interface:

Open [Media types] section and click [Create media type]


Select type Script and write down zabbix-alert-smtp.py


Now you have new media type configured:


Now go to your administrative usesr:


Go for [Media] and click [add]


Select zabbix-alert-smtp.py and write down your e-mail address. Press [Add] at the end:


This is very important step. Press [Update]:


Make sure the [Actions] are enabled:


If you ever assign different users or user groups make sure you hit the first update button at first and then hit second update button:
That is all!

Sunday, December 13, 2015

KB3114409 silent uninstall, detection rule

This update is related only to Office 2010 (not 2013 or other):

Update existence symbolize this key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{90140000-0011-0000-0000-0000000FF1CE}_Office14.PROPLUS_{14CDCBF7-3CCC-42E2-A5BB-2D4926E16FAA}]
"DisplayName"="Update for Microsoft Outlook 2010 (KB3114409) 32-Bit Edition"
"MoreInfoURL"="http://support.microsoft.com/kb/3114409"
"URLInfoAbout"="http://support.microsoft.com/kb/3114409"
"HelpLink"="http://support.microsoft.com/kb/3114409"
"Publisher"="Microsoft"
"ParentKeyName"="Office14.PROPLUS"
"ParentDisplayName"="Microsoft Office Professional Plus 2010"
"UninstallString"="\"C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE14\\Oarpmany.exe\" /removereleaseinpatch \"{90140000-0011-0000-0000-0000000FF1CE}\" \"{14CDCBF7-3CCC-42E2-A5BB-2D4926E16FAA}\" \"1033\" \"0\""
"NoRemove"=dword:00000000
"NoModify"=dword:00000001
"IsMinorUpgrade"=dword:00000000
"NoRepair"=dword:00000001
To uninstall kb3114409 with detection rule for 32-bit and 64-bit office 2010 use this code:
kb3114409-silent-uninstall.cmd
@echo off
setlocal EnableDelayedExpansion
set sw=HKLM\SOFTWARE
set u=Microsoft\Windows\CurrentVersion\Uninstall
set k={90140000-0011-0000-0000-0000000FF1CE}_Office14.PROPLUS_{14CDCBF7-3CCC-42E2-A5BB-2D4926E16FAA}
reg query "%sw%\%u%\%k%" > nul 2>&1
if not !errorlevel!==0 (
reg query "%sw%\Wow6432Node\%u%\%k%" > nul 2>&1
if not !errorlevel!==0 goto good
)
echo kb3114409 detected. Uninstalling..
%systemroot%\System32\msiexec.exe /I {90140000-0011-0000-0000-0000000FF1CE} MSIPATCHREMOVE={14CDCBF7-3CCC-42E2-A5BB-2D4926E16FAA} /qn
:good
endlocal

Friday, December 11, 2015

Simple web page check scenario, Zabbix

1) Go to "Web scenarios" section
2) Open [Steps] tab
3) Press [Add] button

4) Write down name for example "google page check"
5) Write down url for exampl "https://www.google.com/"
6) Set "Timeout" for example to 45 seconds:

Press [Add] button at the end and you got.

Now go to [Scenario] tab and write the same name as before for example "google page check"
Set update interval for example to 45 seconds

And finally create trigger:
Name:
Google not reachable!
Trigger:
{servername:web.test.fail[google page check].avg(300)}=1

Wednesday, December 9, 2015

Set up Zabbix Agent on Raspberry Pi

To install from github:
#this code is tested un fresh 2015-11-21-raspbian-jessie-lite Raspberry Pi image
#sudo raspi-config -> extend partition -> reboot
#sudo su
#apt-get update -y && apt-get upgrade -y && apt-get install git -y
#git clone https://github.com/catonrug/raspberry-pi-zabbix.git && cd raspberry-pi-zabbix && chmod +x agent-install.sh server-install.sh
#./agent-install.sh
Manual install:

Go to root mode
sudo su
Add new group zabbix create new user zabbix inside this group:
groupadd zabbix
useradd -g zabbix zabbix
Create log directories and assign that zabbix user can write to these directories:
mkdir -p /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix/
Download and extract zabbix source:
wget http://vorboss.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.6/zabbix-2.4.6.tar.gz -O ~/zabbix-2.4.6.tar.gz
cd ~
tar -vzxf zabbix-*.tar.gz
Let zabbix know that we want only zabbix-agent. This will take 5 minutes
cd ~/zabbix-*/
./configure --enable-agent
Compile and install agent. This will take 5 minutes or something.
make install
Set zabbix agent to launch at system startup:
cp ~/zabbix-*/misc/init.d/debian/zabbix-agent /etc/init.d/
update-rc.d zabbix-agent defaults
Generate zabbix agent configuration.
Client name will be RPi plus fourth octet from IP address
fourth=$(ifconfig | grep "inet.*addr.*Bcast.*Mask" | sed "s/  Bcast.*$//g" | sed "s/^.*\.//g")
cat > /usr/local/etc/zabbix_agentd.conf << EOF
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=192.168.88.80
ServerActive=192.168.88.80
EnableRemoteCommands=1
Hostname=RPi$fourth
EOF
Restart zabbix agent
/etc/init.d/zabbix-agent restart
That is all!

All together:
groupadd zabbix
useradd -g zabbix zabbix
mkdir -p /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix/
wget http://vorboss.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.6/zabbix-2.4.6.tar.gz -O ~/zabbix-2.4.6.tar.gz
cd ~
tar -vzxf zabbix-*.tar.gz
cd ~/zabbix-*/
./configure --enable-agent
make install
cp ~/zabbix-*/misc/init.d/debian/zabbix-agent /etc/init.d/
update-rc.d zabbix-agent defaults
fourth=$(ifconfig | grep "inet.*addr.*Bcast.*Mask" | sed "s/  Bcast.*$//g" | sed "s/^.*\.//g")
cat > /usr/local/etc/zabbix_agentd.conf << EOF
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=192.168.88.80
ServerActive=192.168.88.80
EnableRemoteCommands=1
Hostname=RPi$fourth
EOF
/etc/init.d/zabbix-agent restart

Tuesday, December 8, 2015

Raspberry Pi as Zabbix Server, MySQL basics

To install from gitgub:
#this code is tested un fresh 2015-11-21-raspbian-jessie-lite Raspberry Pi image
#sudo raspi-config -> extend partition -> reboot
#sudo su
#apt-get update -y && apt-get upgrade -y && apt-get install git -y
#git clone https://github.com/catonrug/raspberry-pi-zabbix.git && cd raspberry-pi-zabbix && chmod +x agent-install.sh server-install.sh
#./server-install.sh
Push 2015-11-21-raspbian-jessie-lite.img to SD card.

Expand files system.
sudo raspi-config
Go to native root mode:
sudo su
Update system:
apt-get update -y && apt-get upgrade -y
To follow my example install mysql-server and set root password to reverse
apt-get install mysql-server -y

Install additional MySQL packages:
apt-get install mysql-client libmysqlclient-dev -y
Install Apache web server (httpd) packages:
apt-get install apache2 apache2-dev -y
Install php packages:
apt-get install php5 php5-dev php5-gd php5-mysql -y
Install fping:
apt-get install fping -y
Fix future errors in compiling process:

configure: error: Jabber library not found

apt-get install libiksemel-dev -y

configure: error: LIBXML2 library not found

apt-get install libxml2-dev -y

configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config

apt-get install libsnmp-dev -y

configure: error: SSH2 library not found

apt-get install libssh2-1-dev -y

configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h

apt-get install libopenipmi-dev -y

configure: error: Curl library not found

apt-get install libcurl4-openssl-dev -y
Set new MySQL root password:
/usr/bin/mysqladmin -u root -preverse password 'LCq9LCFCNMZEqatm'
Create database with name zabbix:
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'CREATE DATABASE zabbix CHARACTER SET UTF8'

ERROR 1006 (HY000) at line 1: Can't create database 'zabbix' (errno: 28)

If you receive this message then you have missed first step to extend SD card cause now it is full. Use df -h to make sure.

Create MySQL user zabbix with password drFJ7xx5MNTbqJ39
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'GRANT ALL PRIVILEGES on zabbix.* to "zabbix"@"localhost" IDENTIFIED BY "drFJ7xx5MNTbqJ39"'
Create new user zabbix and add this user to zabbix group:
groupadd zabbix
useradd -g zabbix zabbix
Create dircetories for logfiles:
mkdir -p /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix/
Create dirs for alert & external scripts:
mkdir -p /var/zabbix/alertscripts
mkdir -p /var/zabbix/externalscripts
chown -R zabbix:zabbix /var/zabbix/
Download zabbix source:
wget http://vorboss.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.6/zabbix-2.4.6.tar.gz -O ~/zabbix-2.4.6.tar.gz
Extract archive:
cd ~
tar -vzxf zabbix-*.tar.gz
Move to directory where the database stucture for zabbix is located
cd ~/zabbix-*/database/mysql
Execute schema making process. This will take 3 minutes on Raspberry Pi 1:
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < schema.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < images.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < data.sql
Move back to zabbix root direcotry:
cd ~/zabbix-*/
Configure zabbix server with MySQL database with all commmon futures:
./configure --enable-server --enable-agent --with-mysql --with-libcurl --with-libxml2 --with-ssh2 --with-net-snmp --with-openipmi --with-jabber
At the end we got:
Configuration:

  Detected OS:           linux-gnueabihf
  Install path:          /usr/local
  Compilation arch:      linux

  Compiler:              gcc
  Compiler flags:        -g -O2  -I/usr/include/mysql -DBIG_JOINS=1  -fno-strict-aliasing    -g -DNDEBUG     -I/usr/include/libxml2   -I/usr/local/include -I/usr/lib/arm-linux-gnueabihf/perl/5.20/CORE -I. -I/usr/include -I/usr/include -I/usr/include

  Enable server:         yes
  Server details:
    With database:         MySQL
    WEB Monitoring:        cURL
    Native Jabber:         yes
    SNMP:                  yes
    IPMI:                  yes
    SSH:                   yes
    ODBC:                  no
    Linker flags:          -rdynamic      -L/usr/lib/arm-linux-gnueabihf        -L/usr/lib/arm-linux-gnueabihf -L/usr/lib -L/usr/lib   -L/usr/lib/arm-linux-gnueabihf
    Libraries:             -lm -ldl  -lresolv    -lmysqlclient     -liksemel -lxml2    -lnetsnmp -lssh2 -lOpenIPMI -lOpenIPMIposix   -lcurl

  Enable proxy:          no

  Enable agent:          yes
  Agent details:
    Linker flags:          -rdynamic      -L/usr/lib/arm-linux-gnueabihf
    Libraries:             -lm -ldl  -lresolv     -lcurl

  Enable Java gateway:   no

  LDAP support:          no
  IPv6 support:          no

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************
Install all. This will take like 40 minutes to build on Raspberry Pi 1
make install
Set zabbix-server and zabbix-agent to boot at system startup:
cp ~/zabbix-*/misc/init.d/debian/* /etc/init.d/
sudo update-rc.d zabbix-server defaults
sudo update-rc.d zabbix-agent defaults
Change connection username for database:
sed -i "s/^DBUser=.*$/DBUser=zabbix/" /usr/local/etc/zabbix_server.conf
Set connection password for MySQL database
sed -i "s/^.*DBPassword=.*$/DBPassword=drFJ7xx5MNTbqJ39/" /usr/local/etc/zabbix_server.conf
Fix Fping location:
sed -i "s/^.*FpingLocation=.*$/FpingLocation=\/usr\/bin\/fping/" /usr/local/etc/zabbix_server.conf
Set AlertScriptsPath path
sed -i "s/^.*AlertScriptsPath=.*$/AlertScriptsPath=\/var\/zabbix\/alertscripts/" /usr/local/etc/zabbix_server.conf
Set ExternalScripts path
sed -i "s/^.*ExternalScripts=.*$/ExternalScripts=\/var\/zabbix\/externalscripts/" /usr/local/etc/zabbix_server.conf
Set LogFile path
sed -i "s/^LogFile=.*$/LogFile=\/var\/log\/zabbix\/zabbix_server.log/" /usr/local/etc/zabbix_server.conf
Prepare php files for zabbix frontend web interface:
mkdir /var/www/html/zabbix
cd ~/zabbix-*/frontends/php/
cp -a . /var/www/html/zabbix/
Fix some php settings:
sed -i "s/^post_max_size = .*$/post_max_size = 16M/" /etc/php5/apache2/php.ini
sed -i "s/^max_execution_time = .*$/max_execution_time = 300/" /etc/php5/apache2/php.ini
sed -i "s/^max_input_time = .*$/max_input_time = 300/g" /etc/php5/apache2/php.ini
sed -i "s/^.*date.timezone =.*$/date.timezone = Europe\/Riga/g" /etc/php5/apache2/php.ini
sed -i "s/^.*always_populate_raw_post_data = .*$/always_populate_raw_post_data = -1/g" /etc/php5/apache2/php.ini
Autoconfigure web interface. Please change IP adress:
ipaddress=$(ifconfig | grep "inet.*addr.*Bcast.*Mask" | sed "s/  Bcast.*$//g" | sed "s/^.*://g")
cat > /var/www/html/zabbix/conf/zabbix.conf.php << EOF
<?php
// Zabbix GUI configuration file.
global \$DB;

\$DB['TYPE']     = 'MYSQL';
\$DB['SERVER']   = 'localhost';
\$DB['PORT']     = '0';
\$DB['DATABASE'] = 'zabbix';
\$DB['USER']     = 'zabbix';
\$DB['PASSWORD'] = 'drFJ7xx5MNTbqJ39';

// Schema name. Used for IBM DB2 and PostgreSQL.
\$DB['SCHEMA'] = '';

\$ZBX_SERVER      = 'localhost';
\$ZBX_SERVER_PORT = '10051';
\$ZBX_SERVER_NAME = '$ipaddress';

\$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>
EOF
Reboot system and go to your IP adress:
http://192.168.88.80/zabbix
Enter username Admin (case sensitive) with password zabbix!
All script together:
#!/bin/bash
apt-get update -y && apt-get upgrade -y
apt-get install mysql-server -y
apt-get install mysql-client libmysqlclient-dev -y
apt-get install apache2 apache2-dev -y
apt-get install php5 php5-dev php5-gd php5-mysql -y
apt-get install fping -y
apt-get install libiksemel-dev -y
apt-get install libxml2-dev -y
apt-get install libsnmp-dev -y
apt-get install libssh2-1-dev -y
apt-get install libopenipmi-dev -y
apt-get install libcurl4-openssl-dev -y
/usr/bin/mysqladmin -u root -preverse password 'LCq9LCFCNMZEqatm'
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'CREATE DATABASE zabbix CHARACTER SET UTF8'
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'GRANT ALL PRIVILEGES on zabbix.* to "zabbix"@"localhost" IDENTIFIED BY "drFJ7xx5MNTbqJ39"'
groupadd zabbix
useradd -g zabbix zabbix
mkdir -p /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix/
mkdir -p /var/zabbix/alertscripts
mkdir -p /var/zabbix/externalscripts
chown -R zabbix:zabbix /var/zabbix/
wget http://vorboss.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.6/zabbix-2.4.6.tar.gz -O ~/zabbix-2.4.6.tar.gz
cd ~
tar -vzxf zabbix-*.tar.gz
cd ~/zabbix-*/database/mysql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < schema.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < images.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < data.sql
cd ~/zabbix-*/
./configure --enable-server --enable-agent --with-mysql --with-libcurl --with-libxml2 --with-ssh2 --with-net-snmp --with-openipmi --with-jabber
make install
cp ~/zabbix-*/misc/init.d/debian/* /etc/init.d/
sudo update-rc.d zabbix-server defaults
sudo update-rc.d zabbix-agent defaults
sed -i "s/^DBUser=.*$/DBUser=zabbix/" /usr/local/etc/zabbix_server.conf
sed -i "s/^.*DBPassword=.*$/DBPassword=drFJ7xx5MNTbqJ39/" /usr/local/etc/zabbix_server.conf
sed -i "s/^.*FpingLocation=.*$/FpingLocation=\/usr\/bin\/fping/" /usr/local/etc/zabbix_server.conf
sed -i "s/^.*AlertScriptsPath=.*$/AlertScriptsPath=\/var\/zabbix\/alertscripts/" /usr/local/etc/zabbix_server.conf
sed -i "s/^.*ExternalScripts=.*$/ExternalScripts=\/var\/zabbix\/externalscripts/" /usr/local/etc/zabbix_server.conf
sed -i "s/^LogFile=.*$/LogFile=\/var\/log\/zabbix\/zabbix_server.log/" /usr/local/etc/zabbix_server.conf
mkdir /var/www/html/zabbix
cd ~/zabbix-*/frontends/php/
cp -a . /var/www/html/zabbix/
sed -i "s/^post_max_size = .*$/post_max_size = 16M/" /etc/php5/apache2/php.ini
sed -i "s/^max_execution_time = .*$/max_execution_time = 300/" /etc/php5/apache2/php.ini
sed -i "s/^max_input_time = .*$/max_input_time = 300/g" /etc/php5/apache2/php.ini
sed -i "s/^.*date.timezone =.*$/date.timezone = Europe\/Riga/g" /etc/php5/apache2/php.ini
sed -i "s/^.*always_populate_raw_post_data = .*$/always_populate_raw_post_data = -1/g" /etc/php5/apache2/php.ini
ipaddress=$(ifconfig | grep "inet.*addr.*Bcast.*Mask" | sed "s/  Bcast.*$//g" | sed "s/^.*://g")
cat > /var/www/html/zabbix/conf/zabbix.conf.php << EOF
<?php
// Zabbix GUI configuration file.
global \$DB;

\$DB['TYPE']     = 'MYSQL';
\$DB['SERVER']   = 'localhost';
\$DB['PORT']     = '0';
\$DB['DATABASE'] = 'zabbix';
\$DB['USER']     = 'zabbix';
\$DB['PASSWORD'] = 'drFJ7xx5MNTbqJ39';

// Schema name. Used for IBM DB2 and PostgreSQL.
\$DB['SCHEMA'] = '';

\$ZBX_SERVER      = 'localhost';
\$ZBX_SERVER_PORT = '10051';
\$ZBX_SERVER_NAME = '$ipaddress';

\$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>
EOF
If you enter at the top #!/bin/sh instead of #!/bin/bash then executing lines
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'CREATE DATABASE zabbix CHARACTER SET UTF8'
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'GRANT ALL PRIVILEGES on zabbix.* to "zabbix"@"localhost" IDENTIFIED BY "drFJ7xx5MNTbqJ39"'
You will get:

Syntax error: redirection unexpected

Set up proxy for wget, yum, rpm, CentOS

Set proxy for wget

Open file:
vi /etc/wgetrc
There a a hundred lines or something but you have to search and uncoment these three lines:
Set these lines:
https_proxy = http://proxy.yoyodyne.com:18023/
http_proxy = http://proxy.yoyodyne.com:18023/
ftp_proxy = http://proxy.yoyodyne.com:18023/

Set proxy for yum

Open file:
vi /etc/yum.conf
You have to manually add proxy configuration line:
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
distroverpkg=centos-release
proxy=http://my.proxy.com:3128

Set proxy for rpm

You have to manually add proxy paramater to each rpm line:
rpm -Uvh --httpproxy my.proxy.com --httpport 3128 http://yum.spacewalkproject.org/2.4/RHEL/6/x86_64/spacewalk-repo-2.4-3.el6.noarch.rpm
Related:
http://xmodulo.com/how-to-install-rpm-packages-behind-proxy.html

Monday, December 7, 2015

system_thread_exception_not_handled wpprecorder.sys


To solve this situation you have to boot with windows installation media.
Do not install anything!

Once you have boot the media press Shift+F10 to launch command prompt

Now figure out which is the system drive:
diskpart
list volume
exit
Unlock drive:
manage-bde –unlock D: -recoverypassword 111111-222222-333333-444444-555555-666666-777777-888888
Decompress drivers:
D:\Windows\system32\compact.exe /U D:\Windows\system32\drivers\*.sys
Reboot.

Load operating system.

Do not let this happen again:
Open command prompt in "Run as administrator" mode and execute:
fsutil behavior set DisableCompression 1
Related:
https://technet.microsoft.com/en-US/library/ff829849.aspx

Source:
https://social.technet.microsoft.com/Forums/en-US/e98498f1-a6fe-4235-999d-c2f8f507fea7/bsod-systemthreadexcptionnothandled-wpprecordersys?forum=winserverhyperv

Saturday, December 5, 2015

error:0200100D:system library:fopen:Permission denied:fopen

nginx: [emerg] BIO_new_file("/etc/pki/tls/certs/bungle.pem") failed (SSL: error:0200100D:system library:fopen:Permission denied:fopen('/etc/pki/tls/certs/bungle.pem','r') error:2006D002:BIO routines:BIO_new_file:system lib)
Debug the situation of your direcotry where the certificate file is located:
ls -lrtZ /etc/pki/tls/certs
Usually every file should have line starting like:
-rw-r--r--. root root unconfined_u:object_r:cert_t:s0
And at your scenario one of lines have this content:
-rw-r--r--. root root unconfined_u:object_r:user_home_t:s0
Solution is move back your pem file where it has begin the story.
Please copy pem file to /etc/pki/tls/certs and check again permissions:
ls -lrtZ /etc/pki/tls/certs
Interesting files:
http://curl.haxx.se/ca/cacert.pem

Friday, December 4, 2015

Configure Zabbix Server 2.4 via web interface

This is second part of Set up CentOS 6.7 to act like a Zabbix Server 2.4

So you go to the url for example http://192.168.88.61/zabbix and you got:


The pre-requsites screen. Everything should be green out of the box:


Make sure you set MySQL user to zabbix with zabbix password.
In my autoinstall scenario MySQL zabbix user password is drFJ7xx5MNTbqJ39


Write down the same IP address as you were used before - 192.168.88.61 in my scenario


Summary screen:


And now everything is done


Log in to web console with default username Admin (case sensitive) and password zabbix (also case sensitive)


And now you are there:


Firest things first - Please enable zabbix agent on zabbix server:

Take closer look to file /etc/zabbix/web/zabbix.conf.php it has content:
<?php
// Zabbix GUI configuration file.
global $DB;

$DB['TYPE']     = 'MYSQL';
$DB['SERVER']   = 'localhost';
$DB['PORT']     = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER']     = 'zabbix';
$DB['PASSWORD'] = 'drFJ7xx5MNTbqJ39';

// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';

$ZBX_SERVER      = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '192.168.88.61';

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>
If you want to automatize this process you have to escape dolar sign in this configuration and restart zabbix-server:
cat > /etc/zabbix/web/zabbix.conf.php << EOF
<?php
// Zabbix GUI configuration file.
global \$DB;

\$DB['TYPE']     = 'MYSQL';
\$DB['SERVER']   = 'localhost';
\$DB['PORT']     = '0';
\$DB['DATABASE'] = 'zabbix';
\$DB['USER']     = 'zabbix';
\$DB['PASSWORD'] = 'drFJ7xx5MNTbqJ39';

// Schema name. Used for IBM DB2 and PostgreSQL.
\$DB['SCHEMA'] = '';

\$ZBX_SERVER      = 'localhost';
\$ZBX_SERVER_PORT = '10051';
\$ZBX_SERVER_NAME = '192.168.88.61';

\$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>
EOF
service zabbix-server restart
Post settings Labels zabbix Published on 12/4/15, 7:00 AM Eastern European Time Permalink Location Options Complain

Thursday, December 3, 2015

Set up CentOS 6.7 to act like a Zabbix Server 2.4

Install CentOS-6.7-x86_64-minimal.iso

Update system
yum update -y
Install Apache:
yum install httpd httpd-devel -y
Install MySQL server
yum install mysql mysql-server -y
Install PHP
yum install php php-cli php-common php-devel php-pear php-gd php-mbstring php-mysql php-xml -y
Start Apache
service httpd start
Set Apache to run at startup
chkconfig httpd on
Start MySQL server
service mysqld start
Set MySQL server to run at system startup
chkconfig mysqld on
Set MySQL root password to LCq9LCFCNMZEqatm
/usr/bin/mysqladmin -u root password 'LCq9LCFCNMZEqatm'
Install Zabbix repository
rpm -Uvh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
Turn off GPG check in yum. This will let to install packages more automatically
sed -i "s/gpgcheck=1/gpgcheck=0/g" /etc/yum.conf
Install all necessary zabbix packages. Do not skip any of them
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway -y
Uncoment your time location at Apache configuration
sed -i "s/# php_value date.timezone/php_value date.timezone/" /etc/httpd/conf.d/zabbix.conf
Restart Apache
service httpd restart
Use root account togerher with password LCq9LCFCNMZEqatm to create database zabbix
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'CREATE DATABASE zabbix CHARACTER SET UTF8'
Create new user zabbix with password drFJ7xx5MNTbqJ39 and allow it to access database zabbix from localhost location
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'GRANT ALL PRIVILEGES on zabbix.* to "zabbix"@"localhost" IDENTIFIED BY "drFJ7xx5MNTbqJ39"'
Apply permissions
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'FLUSH PRIVILEGES'
Move to directory where basic zabbix mysql structure located
cd /usr/share/doc/zabbix-server-mysql-*/create
Create necessary tables and objects into database using MySQL user zabbix with password drFJ7xx5MNTbqJ39
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < schema.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < images.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < data.sql
Set password drFJ7xx5MNTbqJ39 into zabbix server configuration file
sed -i "s/^.*DBPassword=.*$/DBPassword=drFJ7xx5MNTbqJ39/" /etc/zabbix/zabbix_server.conf
List zabbix server configuration without comments
grep -v "^#\|^$" /etc/zabbix/zabbix_server.conf
Start zabbix server
service zabbix-server start
Allow to access web interface (port 80) from everywhere and zabbix ports (10050, 10051)
iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 5 -p tcp -m tcp --dport 10050 -j ACCEPT
iptables -I INPUT 5 -p tcp -m tcp --dport 10051 -j ACCEPT
Save IP tables configuration
service iptables save
Restart firewall service
service iptables restart
Fix:

Zabbix server is not running: the information displayed may not be current.

setsebool -P httpd_can_network_connect=true
Set zabbix server to start at system bootup
chkconfig zabbix-server on
Check service sitiation about all services related to zabbix server
chkconfig --list | grep "zabbix\|mysqld\|httpd"
Set zabbix agent to boot at system startup
chkconfig zabbix-agent on
Look at zabbix agent configuration file
grep -v "^#\|^$" /etc/zabbix/zabbix_agentd.conf
Now you can go at you server IP adress and continue to set up zabbix server:
http://ip.address.goes.here/zabbix
If you want to do all steps in one click then create new file:
vi install-zabbix-server.sh
Paste this content:
yum update -y
yum install httpd httpd-devel -y
yum install mysql mysql-server -y
yum install php php-cli php-common php-devel php-pear php-gd php-mbstring php-mysql php-xml -y
service httpd start
chkconfig httpd on
service mysqld start
chkconfig mysqld on
/usr/bin/mysqladmin -u root password 'LCq9LCFCNMZEqatm'
rpm -Uvh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
sed -i "s/gpgcheck=1/gpgcheck=0/g" /etc/yum.conf
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway -y
sed -i "s/# php_value date.timezone/php_value date.timezone/" /etc/httpd/conf.d/zabbix.conf
service httpd restart
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'CREATE DATABASE zabbix CHARACTER SET UTF8'
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'GRANT ALL PRIVILEGES on zabbix.* to "zabbix"@"localhost" IDENTIFIED BY "drFJ7xx5MNTbqJ39"'
mysql -h localhost -uroot -pLCq9LCFCNMZEqatm -P 3306 -s <<< 'FLUSH PRIVILEGES'
cd /usr/share/doc/zabbix-server-mysql-*/create
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < schema.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < images.sql
mysql -uzabbix -pdrFJ7xx5MNTbqJ39 zabbix < data.sql
sed -i "s/^.*DBPassword=.*$/DBPassword=drFJ7xx5MNTbqJ39/" /etc/zabbix/zabbix_server.conf
grep -v "^#\|^$" /etc/zabbix/zabbix_server.conf
service zabbix-server start
iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 5 -p tcp -m tcp --dport 10050 -j ACCEPT
iptables -I INPUT 5 -p tcp -m tcp --dport 10051 -j ACCEPT
service iptables save
service iptables restart
setsebool -P httpd_can_network_connect=true
chkconfig zabbix-server on
chkconfig --list | grep "zabbix\|mysqld\|httpd"
chkconfig zabbix-agent on
grep -v "^#\|^$" /etc/zabbix/zabbix_agentd.conf
No need to change any of lines for success story, BUT please replace MySQL root password LCq9LCFCNMZEqatm and please replace MySQL zabbix password drFJ7xx5MNTbqJ39 with something else!

Set file executable:
chmod +x install-zabbix-server.sh
Launch installation process:
./install-zabbix-server.sh
Continue to next step:
Configure Zabbix Server 2.4 via web interface

Wednesday, December 2, 2015

Set up writable public samba share on CentOS 7

Install samba application:
yum install samba samba-client samba-common policycoreutils-python -y
Set up samba to start at the next boot up:
systemctl enable smb.service
systemctl enable nmb.service
Set up firewall rules:
firewall-cmd --permanent --zone=public --add-service=samba
firewall-cmd --reload
firewall-cmd --list-all | grep samba
Empty existing samba configuration:
> /etc/samba/smb.conf
Go to edit configuration in your way:
vi /etc/samba/smb.conf
Paste this content:
#======================= Global Settings =========================
[global]
workgroup = WORKGROUP
security = share
map to guest = bad user
#======================= Share Definitions =======================
[public]
path = /public
browsable =yes
writable = yes
guest ok = yes
read only = no
Create missing directory:
mkdir -p /public
Set the right permissions for this share:
chmod -R 0755 /public
Set correct group:
chown -R nobody:nobody /public
Restart samba service:
systemctl restart smb.service
systemctl restart nmb.service
Fix SELinux permissions:
chcon -t samba_share_t -R /public
semanage fcontext -a -t samba_share_t "/public(/.*)?"
restorecon -R -v /public
Related:
https://fedoraproject.org/wiki/SELinux/samba

Tuesday, December 1, 2015

Move MariaDB database /var/lib/mysql on CentOS 7

Check if the default directory is still the default:
grep "/var/lib/mysql" /etc/my.cnf
This will output something like this:
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
Check if service is running:
systemctl status mariadb
Stop the service:
systemctl stop mariadb
Check if service is NOT running:
systemctl status mariadb
Backup config:
ts=$(date +"%y-%m-%d-%H-%M-%S")
cd /etc
cp my.cnf my.cnf.$ts
Check if the backup with current time stamp is made:
ls -ld my*
Replace /var/lib/mysql with /mnt/custom/mysql:
sed -i "s/\/var\/lib\/mysql/\/mnt\/custom\/mysql/g" /etc/my.cnf
Check if the new directory is in config:
grep "/mnt/custom/mysql" /etc/my.cnf
Set the right owner:
chown -R mysql:mysql /mnt/custom/mysql

Can't create test file lower-test

Reset permissions:
chcon -Rt mysqld_db_t /mnt/custom/mysql
chcon -Ru system_u /mnt/custom/mysql
chown -R mysql:mysql /mnt/custom/mysql

Blog Archive