2017/11/29

最近graylog總是怪怪的
速度很慢
加了 Disk Journal 還有cpu的個數
還是很慢
buffers常常爆表
而且cpu的使用率還是很高
今天再仔細看了一下
發現 / 的使用率已經 99% 了 XD
再找找是那裡吃掉了

/var/log/graylog/elasticsearch 裡有一堆
graylog-20xx-xx-xx.log的log

看來是每天會產生一個log file
可是到/etc的logrotate相關檔案並沒有看到設定的資料
算了
先寫個排程來處理 有空再來找看看放在graylog那裡

59 23 * * * /bin/rm -f /var/log/graylog/elasticsearch/graylog-`date -d '10 days ago' "+%Y-%m-%d"`.log

留個10天應該是夠了

2017/11/28

之前使用ftp傳檔時一直都用交談的方式
今天在測sftp時才發現lftp就可以了
範例如下

lftp ftp://user:password@host -e "put/tmp/data ; bye"

lftp sftp://user:password@host  -e "put local-file.name; bye"


2017/11/25

設定每天凌晨 01:00 關机指令

schtasks /Create /SC daily /TN shutdown /ST 01:00 /TR "c:\windows\system32\shutdown.exe -s -f"

http://lee5400.blogspot.tw/2011/05/windows-schtasks.html

2017/11/22

近日graylog出現二次以下的訊息







看來應該是 journal buffer不夠了
看了一下主按台果然全都是滿的
先把disk journal調到5G(本來是1G)
調完之後看來就ok了











再觀察看看

2017/11/10

今天把vmware轉到proxmox
要啟動時發生以下的問題

kvm: -drive file=/var/lib/vz/images/102/vm-102-disk-1.qcow2,if=none,id=drive-scsi0,format=qcow2,cache=none,aio=native,detect-zeroes=on: file system may not support O_DIRECT

解決的方法很簡單

把disk cache 改成 write through就好了


2017/11/08

有關proxmox最近備份出現的問題
測試了好久
觀察了一週
做一下整理記錄
之前備份發現問題
不管是linux或windows在備份時都出現hd reset的情況
























目前得到的結論如下

在備份裝置是10G的情況下 (使用nfs 備份) 目前都沒有發現問題 

在備份裝置是1G的情況 
在網路上找到一些方法

1. 把disk 改成virtio

linux 在改完之後就解決問題了

但如果沒辦法改成virtio 則建議把guest file 放在server的 directory 不要放在share storage上


但是windows 改完後並沒有解決問題

必須要修改 /etc/vzdump.conf

加上 bwlimit:150000  (再調高會出現問題)

限制執行vzdump執行時的io 避免跟guest os搶 io 導致出現hd reset的問題

不過改成virtio對windows guest os的效能會有滿大的改善
連idrac都會當G
Orz




2017/10/24

最近更新proxmox後又發生crontab無法寄信的問題
印像中之前不久也發生過
但沒有留下記錄
再找了一下
官方當時說改一下權限就可以了之後會修正
應該是還沒修

chmod g+s /usr/bin/pvemailforward

https://forum.proxmox.com/threads/pve5-problem-when-send-mail-to-root.35733/#post-175325

2017/10/19

最近碰到一個怪問題
就是proxmox 裡的 guest linux主机會出現以下的錯誤訊息

















出現後有時ok
但有時filesystem 就會有錯誤
需要filesystem check
可是如果是windows  運氣不好就直接掛點
一開始是懷疑storage有問題
可是把guest搬到肚子後還是一樣
查了一些資料後有人提到可能是nfs的問題 而且通常都會在backup時發生
於是朝這個方向測試
測了好久
終於有了初步的結論
不管備到那裡 會發生問題就是會發生
而且跟storage的網卡速度也無關
問題在proxmox備分時提供三個選項

不壓縮
lzo
gzip

目前發現如果選擇不壓縮 備分時host會一直搶io
導致上述的情況
如果是選lzo就不會有這個問題了
gzip因為會吃比較多資源
沒有進行測試
所以結論就是

備分時請選擇 lzo 壓縮方式

2017/10/12

今天把snort 升到2.9.11後
要啟動時出現以下的錯誤

/usr/sbin/snort: error while loading shared libraries: libdnet.1: cannot open shared object file: No such file or directory

libdnet這個rpm明明就有裝
因為剛release 所以可能還沒有人升級
先找看看
在/user/lib64下有找到libdnet的相關檔案
而且全部都連結到 libdnet.so.1.0.1

ls -al|grep libdnet
lrwxrwxrwx   1 root root      16 Oct 12 08:41 libdnet.1 -> libdnet.so.1.0.1
lrwxrwxrwx   1 root root      16 Oct 12 08:31 libdnet.so -> libdnet.so.1.0.1
lrwxrwxrwx   1 root root      16 Dec 21  2015 libdnet.so.1 -> libdnet.so.1.0.1
-rwxr-xr-x   1 root root   62936 Jun 10  2014 libdnet.so.1.0.1

想說不然就來試看看
再建一個連結

ln -s libdnet.so.1.0.1 libdnet.1

醬就可以了
目前啟動正常

https://snort.org/

2017/10/08

記錄一下如何在 X11 forword的情況下把聲音一起forword

二台都是linux

近端的機器必須先安裝 pulseaudio paprefs 這二個package
一般而言目前使用的音效都已經裝好且應該都是 pulseaudio   使用的port 是4713
而 paprefs 是設定程式 裝好後執行 paprefs
依照下方的圖進行勾選設定


















設定好後就可以使用ssh 連上遠端机器

ssh -C -c arcfour -X -R 4715:localhost:4713 user@remote.ip

4715:localhost:4713  主要是要把遠端4175的封包傳到近端來

登入遠端後要先執行

export PULSE_SERVER=localhost:4715

把聲音導到 port 4715
(確認port 4715 是不是沒在使用)


再來執行程式

firefox

此時打開youtune 看影片就可以聽到聲音了


http://guildwar23.blogspot.tw/2012/11/

因為一直有把遠端的桌面利用X11 Forwarding的需求
而且是利用internet傳輸
但一直碰到的問題就是感覺非常慢
今天查了一下資料
應該可以改變一下加密的方法來加速
首先先在server上加上加密方法的支援

$ echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,blowfish-cbc,aes128-cbc,3des-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc" | sudo tee --append /etc/ssh/sshd_config

再來連線時就可以使用不同的加密演算法

ssh -c arcfour,blowfish-cbc -XC host.com

以下列出使用不同演算法的速度
自己參考看看囉






















https://godleon.github.io/blog/2016/06/02/HowTo-SpeedUp-X11-Forwarding-in-SSH
http://xmodulo.com/how-to-speed-up-x11-forwarding-in-ssh.html
https://blog.famzah.net/2010/06/11/openssh-ciphers-performance-benchmark/
http://debiannoteofj.blogspot.tw/2010/09/x11-forwarding.html
http://www.miscdebris.net/blog/2007/06/01/speed-up-ssh-x11-forwarding/

2017/10/06

the oid of  clients connected to one ruckus AP

1.3.6.1.4.1.25053.1.1.12.1.1.1.3.1.2.1 is 2.4 GHz clients
1.3.6.1.4.1.25053.1.1.12.1.1.1.3.1.2.2 is 5 GHz clients

2017/10/02

昨天晚上server發生filesystem錯誤

重開後mariadb出現問題
到log去看時發現以下資訊

171002  8:51:09  InnoDB: cannot calculate statistics for table ABC/def
InnoDB: because the .ibd file is missing.  For help, please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
171002  8:51:09 [ERROR] MySQL is trying to open a table handle but the .ibd file for
table ABC/def does not exist.
Have you deleted the .ibd file from the database directory under
the MySQL datadir, or have you used DISCARD TABLESPACE?
See http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
how you can resolve the problem.

到目錄去看時
def.idb這個檔真的不見了
查了一下
這個檔不見是沒辦法由目前的資料再產生的
只能recovery

找了一下備分
倒回去
目前看來正常
再觀察看看

2017/09/14

今天一早上班就有人跟我說網路無法認証
查了一下發現radius 沒起來
再看log發現今天早上centos 7 有很大的更新
其中包含了freeradius的套件
試了几次 daemon就是起不來
後來用 radiusd -X 看訊息如下

rlm_ldap (ldap): Opening additional connection (0), 1 of 32 pending slots used
rlm_ldap (ldap): Connecting to ldap://10.10.10.10:389
rlm_ldap (ldap): Waiting for bind result...
rlm_ldap (ldap): Bind credentials incorrect: Invalid credentials
rlm_ldap (ldap): Server said: NDS error: failed authentication (-669).
rlm_ldap (ldap): Opening connection failed (0)
rlm_ldap (ldap): Removing connection pool
/etc/raddb/mods-enabled/ldap[8]: Instantiation failed for module "ldap"

奇怪為什麼升版前沒問題
升版後就不行了
並沒有去動ldap的config
google了一下發現有類似的情況
問題出在config跟ldap認証的密碼有特殊字元
XD
什麼怪事都有
改掉之後就可以了

再觀察看看

2017/09/01

如果是手動安裝librenms
則nagios plugin並不會安裝
找到以下這篇說明如何安裝

http://olivermarshall.net/enable-ping-tests-in-librenms/

如果是使用ova
那預設就已經裝好了
上篇也有說明如何加入service的監看

不過預設並未加入service down的alert
以下官方文件有說明如何加入

https://docs.librenms.org/Extensions/Services/

2017/08/31

最近在玩librenms
介面看起來真的滿潮的
而且只要她可以辨認的mib
會把所有相關的資料都顯示出來
連USHA的資料都完全出現
包括電壓 負載 溫度....等
這方面比cacti好用很多
不過目前碰到的問題是還無法餵值來畫圖
另外就是一定要使用snmp來偵測裝置

在測的過程中出現一個狀況
就是alert有出現
email通知的設定也沒錯
但device如果down
在畫面上有看到alert
但就是沒收到mail
之後經過了8小時
才開始發mail








試了半天
還是一樣
後來想說去forum 問問
就在要發問時
系統說要先執行validate.php把結果一起po上去
那就先執行看看

./validate.php
====================================
Component | Version
--------- | -------
LibreNMS  | 1.31.02-3-g4683736
DB Schema | 205
PHP       | 7.0.22
MySQL     | 5.5.52-MariaDB
RRDTool   | 1.4.8
SNMP      | NET-SNMP 5.7.2
====================================

[FAIL]  We have found some files that are owned by a different user than librenms, this will stop you updating automatically and / or rrd files being updated causing graphs to fail.
        [FIX] chown -R librenms:librenms /opt/librenms
/opt/librenms/html/plugins/Weathermap/configs
/opt/librenms/html/plugins/Weathermap/configs/testing.conf
[OK]    Database connection successful
[OK]    Database schema correct
[WARN]  Your install is over 24 hours out of date, last update: Tue, 29 Aug 2017 18:53:05 +0000
[FAIL]  You have a different system timezone (CST) specified to the php configured timezone (UTC), please correct this.

果然有几個問題
一個是權限問題
我在想我是用官方提供的ova
為什麼會有這個問題
再來是時區
因為我有去改os的timezone
但php.ini沒改
難怪會晚了8小時才收到信
這個也改了
再來就是說我版本太舊
不是說每天會固定更新??
算了
手動跑一下daily.sh
目前alert發信看來正常了
再觀察看看

後記
權限改完後
刪除裝置時還是會出現














要嗎就再把rrd改成777
不然就用root去刪
算了
反正刪設備的機會也不多
碰到再用root刪吧
使用rsyslog 收資料時
預設會去反解來源的ip
可以修改以下參數停用
加上 -Q -x

範例

SYSLOGD_OPTIONS=”-c3 -Q -x”

https://ssorc.tw/1194

2017/08/25

今天收到了一個zip檔
但user說忘記密碼了
XD
找到fcrackzip這個有趣的東西
ubuntu安裝很簡單
sudo apt install fcrackzip

接下來下個指令 先試10個字範圍內

fcrackzip -b -c 'aA1!' -l 1-10 -u crack_file.zip

再來就是等了

http://topspeedsnail.com/fcrackzip-crack-zip-password/

2017/08/24

今天要登入awacs(網管軟体)時
出現無法連接的訊息
登入主机發現mariadb的daemon不見了
systemctl restart mariadb也起不來
看了一下 /var/log/mariadb/mariadb.log 發現以下的記錄

170824 19:02:01  InnoDB: Page checksum 2583736692 (32bit_calc: 3902863637), prior-to-4.0.14-form checksum 2992650943
InnoDB: stored checksum 218772529, prior-to-4.0.14-form stored checksum 775370784
InnoDB: Page lsn 825440558 909582385, low 4 bytes of lsn at page end 825373998
InnoDB: Page number (if stored to page already) 775303712,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 775041840
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 7.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: See also http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.

按照說明
在/etc/my.cnf 加上

[mysqld]
innodb_force_recovery = 1

重啟mariadb

再查一下log

170824 19:02:01  InnoDB: Error: space id and page n:o stored in the page
InnoDB: read in are 1553519:2, should be 1553541:2!
170824 19:02:01  InnoDB: Error: space id and page n:o stored in the page
InnoDB: read in are 1553519:3, should be 1553541:3!

InnoDB: Apply batch completed
InnoDB: Starting in background the rollback of uncommitted transactions
170824 19:02:01  InnoDB: Rolling back trx with id 127203F, 451 rows to undo
170824 19:02:01  InnoDB: Waiting for the background threads to start

InnoDB: Rolling back of trx id 127203F completed
170824 19:02:01  InnoDB: Rollback of non-prepared transactions completed
170824 19:02:02 Percona XtraDB (http://www.percona.com) 5.5.40-MariaDB-36.1 started; log sequence number 653240202086
170824 19:02:02 InnoDB: !!! innodb_force_recovery is set to 1 !!!
170824 19:02:02 [Note] Plugin 'FEEDBACK' is disabled.
170824 19:02:02 [Note] Server socket created on IP: '0.0.0.0'.
170824 19:02:02 [Note] Event Scheduler: Loaded 0 events
170824 19:02:02 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.41-MariaDB'  socket: '/home/Alopex/mysql/mysql.sock'  port: 3306  MariaDB Server
InnoDB: A new raw disk partition was initialized or
InnoDB: innodb_force_recovery is on: we do not allow
InnoDB: database modifications by the user. Shut down
InnoDB: mysqld and edit my.cnf so that newraw is replaced
InnoDB: with raw, and innodb_force_... is removed.
InnoDB: A new raw disk partition was initialized or
InnoDB: innodb_force_recovery is on: we do not allow
InnoDB: database modifications by the user. Shut down
InnoDB: mysqld and edit my.cnf so that newraw is replaced
InnoDB: with raw, and innodb_force_... is removed.

看來是修好了
不過user還是不能用

InnoDB: innodb_force_recovery is on: we do not allow
InnoDB: database modifications by the user. Shut down
InnoDB: mysqld and edit my.cnf so that newraw is replaced
InnoDB: with raw, and innodb_force_... is removed.

要再把

[mysqld]
innodb_force_recovery = 1

mark掉再重開

目前看來是正常了
再觀察看看


https://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html