2019年8月11日 星期日
Configure A Postfix Relay Through Gmail On CentOS 7
參考:
https://devops.ionos.com/tutorials/configure-a-postfix-relay-through-gmail-on-centos-7/
yum -y install postfix cyrus-sasl-plain mailx
#systemctl restart postfix
#systemctl enable postfix
# Configure Postfix
vi /etc/postfix/main.cf
# 必須修改
inet_interfaces = all
# 以下加入
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt
---
# 修改密碼檔
vi /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 username:password
---
chown root:postfix /etc/postfix/sasl_passwd*
chmod 640 /etc/postfix/sasl_passwd*
systemctl reload postfix
---
Test Relay
echo "This is a test." | mail -s "test message" cc.vbhsieh@gmail.com
---
2019年7月11日 星期四
00_nagios 相關資訊
Nagios 03 Install
http://c9992.blogspot.com/2019/06/install-nagios-core-from-tar-ball-on.html
04_pnp4nagios
http://c9992.blogspot.com/2019/06/04pnp4nagios.html
05_MK
http://c9992.blogspot.com/2019/06/05mk.html
非必要有取代方案
06_ndoutils
http://c9992.blogspot.com/2019/06/06ndoutils.html
有用的資訊
http://bigpxuan.blogspot.com/2017/02/nagios.html
2019年7月9日 星期二
08_NRDP
# https://support.nagios.com/kb/article.php?id=96
直接發送狀態給 nagios
yum install php-xml php-json
Downloading the Source
cd /tmp wget -O nrdp.tar.gz https://github.com/NagiosEnterprises/nrdp/archive/1.5.1.tar.gz tar xzf nrdp.tar.gzCopy Files
The /usr/local/nrdp directory is going to be created to store the NDRP php files.cd /tmp/nrdp-1.5.1/ mkdir -p /usr/local/nrdp cp -r clients server LICENSE* CHANGES* /usr/local/nrdp chown -R nagios:nagios /usr/local/nrdpDefine Tokens
The token is what the client uses to authenticate with NRDP on the Nagios Core server. You can use the same token on all your clients, or you could defined a different token for each client. Defining a different token for each client allows you to revoke access at a later date by removing the token, but it also adds an extra level of administration.You will need to edit the config.inc.php file and define the token(s) you want to use. Execute the following command to open the file in vi:vi /usr/local/nrdp/server/config.inc.phpThe section to define the tokens will be at the top of the file, it is a PHP array. Here is an example of three tokens:$cfg['authorized_tokens'] = array( "cda35gtdfu72", "90dfs7jwncsd908fng8fhgb54ynq690xc9vt8uw9ty53", "+23rf==34m12n-v73nciu", );Each token must be surrounded by double quotes and end with a comma:"",Once you've added the tokens save the config.inc.php file and exit vi.Copy Apache Config File
cp nrdp.conf /etc/httpd/conf.d/TEst Command
cd /usr/local/nrdp/clients
sh send_nrdp.sh -u http://192.168.240.79/nrdp/ -t 90dfs7jwncsd908fng8fhgb54ynq690xc9vt8uw9ty53 -H localhost -s HTTP -S OK -o abcd6
2019年7月7日 星期日
07_nagvis
# 01 安裝需要的軟體
yum install php-mbstring php-pdo graphviz php-mysql -y
# install php-mbstring-5.4.16-46.el7.x86_64.rpm
#wget https://rpmfind.net/linux/centos/7.6.1810/os/x86_64/Packages/php-mbstring-5.4.16-46.el7.x86_64.rpm
#rpm -ivh php-mbstring-5.4.16-46.el7.x86_64.rpm
# 下載並安裝 nagvis-1.9.tar.gz 這個版本有測試過 可以使用
cd /tmp
wget http://www.nagvis.org/share/nagvis-1.9.12.tar.gz
tar zxfv nagvis*.gz
cd nagvis*
./install.sh
DB的部份要自己選擇,看是用
mklive
還是 mariadb
socket tcp:192.168.240.79:6557
2019年6月18日 星期二
05_mk
08_mk
##look DOC
參考文件
# # https://exchange.nagios.org/directory/Documentation/MK-Livestatus/details
參考文件
# # https://exchange.nagios.org/directory/Documentation/MK-Livestatus/details
yum install -y gcc*
yum -y install centos-release-scl
yum -y install devtoolset-4-gcc*
scl enable devtoolset-4 bash
cd /tmp
wget https://mathias-kettner.de/download/mk-livestatus-1.2.8p18.tar.gz --no-check-certificate
tar xzf mk-livestatus-1.2.8p18.tar.gz
cd mk-livestatus-1.2.8p18
./configure --with-nagios4
make
make install
#
##test
echo 'GET hosts' | unixcat /usr/local/nagios/var/rw/livestatus
#
echo 'broker_module=/usr/local/lib/mk-livestatus/livestatus.o /usr/local/nagios/var/rw/livestatus' >> /usr/local/nagios/etc/nagios.cfg
systemctl restart nagios
wget https://mathias-kettner.de/download/mk-livestatus-1.2.8p18.tar.gz --no-check-certificate
tar xzf mk-livestatus-1.2.8p18.tar.gz
cd mk-livestatus-1.2.8p18
./configure --with-nagios4
make
make install
#
##test
echo 'GET hosts' | unixcat /usr/local/nagios/var/rw/livestatus
#
echo 'broker_module=/usr/local/lib/mk-livestatus/livestatus.o /usr/local/nagios/var/rw/livestatus' >> /usr/local/nagios/etc/nagios.cfg
systemctl restart nagios
yum -y install xinetd
echo 'service livestatus
{
type = UNLISTED
port = 6557
socket_type = stream
protocol = tcp
wait = no
# limit to 100 connections per second. Disable 3 secs if above.
cps = 100 3
# set the number of maximum allowed parallel instances of unixcat.
# Please make sure that this values is at least as high as
# the number of threads defined with num_client_threads in
# etc/mk-livestatus/nagios.cfg
instances = 500
# limit the maximum number of simultaneous connections from
# one source IP address
per_source = 250
# Disable TCP delay, makes connection more responsive
flags = NODELAY
user = nagios
server = /usr/local/bin/unixcat
server_args = /usr/local/nagios/var/rw/livestatus
# configure the IP address(es) of your Nagios server here:
#only_from = 172.30.6.0/24
disable = no
}
' > /etc/xinetd.d/live
systemctl restart nagios xinetd
systemctl enable nagios xinetd
06_ndoutils
06_ndoutils
其實不好用,使用mk-live 比較好但這邊還是貼一下步驟
# 01 安裝需要的軟體
yum install -y mariadb mariadb-server mariadb-devel
# 啟動 mysql
systemctl start mariadb.service
systemctl enable mariadb.service
# set password
/usr/bin/mysqladmin -u root password 'mypassword'
# login mysql
mysql -u root -p'mypassword'
--# Create User
CREATE DATABASE nagios DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'ndoutils'@'localhost' IDENTIFIED BY 'ndoutils_password';
GRANT USAGE ON *.* TO 'ndoutils'@'localhost' IDENTIFIED BY 'ndoutils_password' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT ALL PRIVILEGES ON nagios.* TO 'ndoutils'@'localhost' WITH GRANT OPTION ;
\q
# test
echo 'show databases;' | mysql -u ndoutils -p'ndoutils_password' -h localhost
## 02 下載
cd /tmp
wget https://sourceforge.net/projects/nagios/files/ndoutils-2.x/ndoutils-2.1.3/ndoutils-2.1.3.tar.gz/download \
-O ndoutils.tar.gz
tar -zxvf ndoutils.tar.gz
cd /tmp/ndoutils-2.1.3/
./configure
make all
make install
## Initialize Database
cd db/
./installdb -u 'ndoutils' -p 'ndoutils_password' -h 'localhost' -d nagios
cd ..
make install-config
mv /usr/local/nagios/etc/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
sed -i 's/^db_user=.*/db_user=ndoutils/g' /usr/local/nagios/etc/ndo2db.cfg
sed -i 's/^db_pass=.*/db_pass=ndoutils_password/g' /usr/local/nagios/etc/ndo2db.cfg
mv /usr/local/nagios/etc/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
## Install Service
make install-init
systemctl enable ndo2db.service
systemctl start ndo2db.service
## Update Nagios Broker
printf "\n\n# NDOUtils Broker Module\n" >> /usr/local/nagios/etc/nagios.cfg
printf "broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg\n" >> /usr/local/nagios/etc/nagios.cfg
## restart Nagios
systemctl restart nagios.service
systemctl status nagios.service
##
echo 'select * from nagios.nagios_logentries;' | mysql -u ndoutils -p'ndoutils_password'
## debug
grep -v '#\|^$' /usr/local/nagios/etc/ndo2db.cfg
grep -v '#\|^$' /usr/local/nagios/etc/ndomod.cfg
grep -v '#\|^$' /usr/local/nagios/etc/nagios.cfg
yum install -y mariadb mariadb-server mariadb-devel
# 啟動 mysql
systemctl start mariadb.service
systemctl enable mariadb.service
# set password
/usr/bin/mysqladmin -u root password 'mypassword'
# login mysql
mysql -u root -p'mypassword'
--# Create User
CREATE DATABASE nagios DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'ndoutils'@'localhost' IDENTIFIED BY 'ndoutils_password';
GRANT USAGE ON *.* TO 'ndoutils'@'localhost' IDENTIFIED BY 'ndoutils_password' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT ALL PRIVILEGES ON nagios.* TO 'ndoutils'@'localhost' WITH GRANT OPTION ;
\q
# test
echo 'show databases;' | mysql -u ndoutils -p'ndoutils_password' -h localhost
## 02 下載
cd /tmp
wget https://sourceforge.net/projects/nagios/files/ndoutils-2.x/ndoutils-2.1.3/ndoutils-2.1.3.tar.gz/download \
-O ndoutils.tar.gz
tar -zxvf ndoutils.tar.gz
cd /tmp/ndoutils-2.1.3/
./configure
make all
make install
## Initialize Database
cd db/
./installdb -u 'ndoutils' -p 'ndoutils_password' -h 'localhost' -d nagios
cd ..
make install-config
mv /usr/local/nagios/etc/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
sed -i 's/^db_user=.*/db_user=ndoutils/g' /usr/local/nagios/etc/ndo2db.cfg
sed -i 's/^db_pass=.*/db_pass=ndoutils_password/g' /usr/local/nagios/etc/ndo2db.cfg
mv /usr/local/nagios/etc/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
## Install Service
make install-init
systemctl enable ndo2db.service
systemctl start ndo2db.service
## Update Nagios Broker
printf "\n\n# NDOUtils Broker Module\n" >> /usr/local/nagios/etc/nagios.cfg
printf "broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg\n" >> /usr/local/nagios/etc/nagios.cfg
## restart Nagios
systemctl restart nagios.service
systemctl status nagios.service
##
echo 'select * from nagios.nagios_logentries;' | mysql -u ndoutils -p'ndoutils_password'
## debug
grep -v '#\|^$' /usr/local/nagios/etc/ndo2db.cfg
grep -v '#\|^$' /usr/local/nagios/etc/ndomod.cfg
grep -v '#\|^$' /usr/local/nagios/etc/nagios.cfg
04_pnp4nagios
04_pnp4nagios
application/models/data.php [979]:
Ubuntu 18.04 php 7.2
solution:
change
if(sizeof($pages) > 0 ){
to
if(is_arrary($pages) && sizeof($pages) > 0 ){
change
if(sizeof($pages) > 0 ){
to
if(is_arrary($pages) && sizeof($pages) > 0 ){
##look DOC
參考文件
#https://support.nagios.com/kb/article/nagios-core-performance-graphs-using-pnp4nagios-801.html
# 01 安裝需要的軟體
yum install -y rrdtool perl-rrdtool perl-Time-HiRes php-gd
## 2 下載pnp4nagios
cd /tmp
wget https://sourceforge.net/projects/pnp4nagios/files/latest/download -O pnp4nagios.tar.gz
tar zxfv pnp4nagios.tar.gz
cd pnp4nagios*
## 3 安裝
./configure
make all
make all
make install
make install-webconf
make install-config
make install-init
systemctl daemon-reload
systemctl enable npcd.service
systemctl start npcd.service
systemctl restart httpd.service
## test url
https://ip/pnp4nagios
mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php-ori
以下要一段一段貼
sed -i 's/process_performance_data=0/process_performance_data=1/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/#host_perfdata_file=/host_perfdata_file=/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^host_perfdata_file=.*/host_perfdata_file=\/usr\/local\/pnp4nagios\/var\/service-perfdata/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#host_perfdata_file_template=.*/host_perfdata_file_template=DATATYPE::HOSTPERFDATA\\tTIMET::$TIMET$\\tHOSTNAME::$HOSTNAME$\\tHOSTPERFDATA::$HOSTPERFDATA$\\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\\tHOSTSTATE::$HOSTSTATE$\\tHOSTSTATETYPE::$HOSTSTATETYPE$/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/#host_perfdata_file_mode=/host_perfdata_file_mode=/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#host_perfdata_file_processing_interval=.*/host_perfdata_file_processing_interval=15/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#host_perfdata_file_processing_command=.*/host_perfdata_file_processing_command=process-host-perfdata-file-bulk-npcd/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/#service_perfdata_file=/service_perfdata_file=/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^service_perfdata_file=.*/service_perfdata_file=\/usr\/local\/pnp4nagios\/var\/service-perfdata/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#service_perfdata_file_template=.*/service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\\tTIMET::$TIMET$\\tHOSTNAME::$HOSTNAME$\\tSERVICEDESC::$SERVICEDESC$\\tSERVICEPERFDATA::$SERVICEPERFDATA$\\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\\tHOSTSTATE::$HOSTSTATE$\\tHOSTSTATETYPE::$HOSTSTATETYPE$\\tSERVICESTATE::$SERVICESTATE$\\tSERVICESTATETYPE::$SERVICESTATETYPE$/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/#service_perfdata_file_mode=/service_perfdata_file_mode=/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#service_perfdata_file_processing_interval=.*/service_perfdata_file_processing_interval=15/g' /usr/local/nagios/etc/nagios.cfg
sed -i 's/^#service_perfdata_file_processing_command=.*/service_perfdata_file_processing_command=process-service-perfdata-file-bulk-npcd/g' /usr/local/nagios/etc/nagios.cfg
echo '/usr/local/nagios/etc/objects/commands.cfg'
echo '' >> /usr/local/nagios/etc/objects/commands.cfg
echo 'define command {' >> /usr/local/nagios/etc/objects/commands.cfg
echo ' command_name process-host-perfdata-file-bulk-npcd' >> /usr/local/nagios/etc/objects/commands.cfg
echo ' command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$' >> /usr/local/nagios/etc/objects/commands.cfg
echo ' }' >> /usr/local/nagios/etc/objects/commands.cfg
echo '' >> /usr/local/nagios/etc/objects/commands.cfg
echo 'define command {' >> /usr/local/nagios/etc/objects/commands.cfg
echo ' command_name process-service-perfdata-file-bulk-npcd' >> /usr/local/nagios/etc/objects/commands.cfg
echo ' command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$' >> /usr/local/nagios/etc/objects/commands.cfg
echo ' }' >> /usr/local/nagios/etc/objects/commands.cfg
echo '' >> /usr/local/nagios/etc/objects/commands.cfg
echo '/usr/local/nagios/etc/objects/templates.cfg'
echo '' >> /usr/local/nagios/etc/objects/templates.cfg
echo 'define host {' >> /usr/local/nagios/etc/objects/templates.cfg
echo ' name host-pnp' >> /usr/local/nagios/etc/objects/templates.cfg
echo ' action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' >> /usr/local/nagios/etc/objects/templates.cfg
echo ' register 0' >> /usr/local/nagios/etc/objects/templates.cfg
echo '}' >> /usr/local/nagios/etc/objects/templates.cfg
echo '' >> /usr/local/nagios/etc/objects/templates.cfg
echo 'define service {' >> /usr/local/nagios/etc/objects/templates.cfg
echo ' name service-pnp' >> /usr/local/nagios/etc/objects/templates.cfg
echo ' action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' >> /usr/local/nagios/etc/objects/templates.cfg
echo ' register 0' >> /usr/local/nagios/etc/objects/templates.cfg
echo '}' >> /usr/local/nagios/etc/objects/templates.cfg
echo '' >> /usr/local/nagios/etc/objects/templates.cfg
sed -i '/name.*generic-host/a\ use host-pnp' /usr/local/nagios/etc/objects/templates.cfg
sed -i '/name.*generic-service/a\ use service-pnp' /usr/local/nagios/etc/objects/templates.cfg
cp contrib/ssi/status-header.ssi /usr/local/nagios/share/ssi/
for i in httpd npcd nagios
do
systemctl restart $i
systemctl enable $i
done
## Verify PNP4Nagios Is Working
function test()
{
ls -la /usr/local/pnp4nagios/var/perfdata/localhost/
}
Install Nagios Core from tar ball on CentOS 7 / RHEL 7 03_install nagios
03_install nagios
1##look DOC
參考文件
##https://www.itzgeek.com/how-tos/linux/centos-how-tos/monitor-centos-7-rhel-7-using-nagios-4-0-7.html
# 01 安裝需要的軟體
yum groupinstall "Development Tools" -y
yum -y install wget httpd php gcc glibc glibc-common wget perl gd gd-devel unzip zip
## 2 建立帳號
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
## 3 下載nagios 4.4.2
cd /tmp/
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.2.tar.gz
tar -zxvf /tmp/nagios-4.*.tar.gz
cd /tmp/nagios-4.*
## 4 安裝
./configure --with-nagios-group=nagios --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
make install-exfoliation
## 5 設定密碼
htpasswd -c -b /usr/local/nagios/etc/htpasswd.users nagiosadmin nagiosadmin
# 安裝 plugings
cd /tmp
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
tar -zxvf /tmp/nagios-plugins-*.tar.gz
cd /tmp/nagios-plugins-*/
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
## check
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
systemctl restart httpd nagios
systemctl enable httpd nagios
===
2019年1月26日 星期六
Install Nagios Core from RPM on CentOS 7 / RHEL 7
引用: http://www.tuxfixer.com/install-nagios-core-from-rpm-on-centos-7-red-hat-7/
yum install httpd -y
vi /etc/yum.repos.d/rpmfind.repo
# Rpmfind repository file
[rpmfind]
name=Rpmfind repository
baseurl=http://195.220.108.108/linux/epel/7/x86_64/
enabled=1
gpgcheck=0
yum install nagios nagios-common nagios-plugins-all -y
htpasswd -c /etc/nagios/passwd nagiosadmin
systemctl start httpd
systemctl enable httpd
systemctl start nagios
systemctl enable nagios
systemctl stop firewalld
systemctl disable firewalld
訂閱:
文章 (Atom)
RHEL install EPEL
https://www.linuxtechi.com/install-epel-repo-on-rhel-system/ EPEL dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest...
-
轉自 ORA-01722 during upgrade 10.2 to 11.2 Yesterday I was trying to upgrade my 10.2 database to 11.2 version in new host and I got below e...
-
記事本開啟 HKEY_CLASSES_ROOT\*\shell] [HKEY_CLASSES_ROOT\*\shell\NotePad] @="用記事本開啟" [HKEY_CLASSES_ROOT\*\shell\NotePad\command] @=...
-
爆笑到不行