2023/10/14

最近nas因為更新發生nfs不能使用的問題

因此暫時把graylog搬到其他台還沒更新的nas上

搬完後發現ES變成red

 








下指令看一下是那些shards


curl -XGET localhost:9200/_cat/shards|grep UNASSIGNED


index.action       0 r UNASSIGNED

index.do           0 r UNASSIGNED

index.aspx         0 r UNASSIGNED

graylog_159        2 p UNASSIGNED

index.htm          0 r UNASSIGNED

index.py           0 r UNASSIGNED

index.php          0 r UNASSIGNED

index.cgi          0 r UNASSIGNED

index.html         0 r UNASSIGNED

index.cfm          0 r UNASSIGNED

index.pl           0 r UNASSIGNED

index.jsp          0 r UNASSIGNED

index.asp          0 r UNASSIGNED


graylog_159 這個是放資料的 直接砍了 就損失一天的log

curl -XDELETE 'localhost:9200/graylog_159/'

此時ES已經變 yellow

但其他的shards也不知道砍了會不會有問題
forum上說的是因為沒有第二台可以replication所以會出現 UNASSIGNED
如果覺得礙眼不想看到 可以取消 replication
指令如下

curl -X PUT "http://localhost:9200/index_name/_settings" -H 'Content-Type: application/json' -d '{"index":{"number_of_replicas":0}}'

目前就先醬放著吧
再觀察看看




2023/08/14

之前寫過一篇有關如何在librenms加上 service 監控的
在新版本上要修正一下
目前版本

23.7.0-73-gd865e3b37 - Sun Aug 13 2023 22:56:54 GMT+0800

以ubuntu為例子
首先要安裝nagios套件

sudo apt install nagios-plugins

chmod +x /usr/lib/nagios/plugins/*

更改設定檔
vi /opt/librenms/config.php

# nagios-plugins
$config['show_services']           = 1;
$config['nagios_plugins']   = "/usr/lib/nagios/plugins";


vi /etc/cron.d/librenms

*/5  *    * * *   librenms    /opt/librenms/services-wrapper.py 1

設定完成後就會在web介面上多出 service 的選項可以使用

接下來碰到的問題是
如果把service設定到 localhost
是無法正常使用的

要新加一個device
設定為 service_chcek
然後把 snmp 及 ping check都關掉
再把service設定到 service_check 這個device上
才能正常

如果在check service 時有加上參數捉取回應時間
librenms 會自動使用這個值畫出圖
可以由此觀察服務的回應時間 看出service有沒有lag的情況




2023/08/05

最近把pmg 升到8

關機或重開的時候一直出現

fail to connect bus no such file or directory

查了一下 好像是原廠的lxc沒裝dbus

apt install -y dbus

裝完後就沒再出現了

另外原本在7版只給一個cpu運作都正常

可是在8版開机時cpu都會吃到滿然後持續一陣子

目前給二顆 運作正常

再觀察看看

2023/07/06

整理一下zap的使用

首先到

https://www.zaproxy.org/download/

選擇下載
Cross Platform Package 

OS必須要有 java環境才能執行

在debian 安裝 java指令

apt install default-jre

解壓後執行 zap.sh

會出現UI畫面 第一次執行預設會跳出更新畫面 要執行更新

更新完成後 執行zap的這台几器對外網路要關閉

因為進行scan時預設會往下爬五層

有可能會爬到外面去

因為目前沒辦法一次掃多個網站 不管是UI或使用指令

所以如果有多個網站要掃

可以使用命令模式 指令如下

./zap.sh -cmd -quickurl http://abc.com.tw -quickout /tmp/81.html


寫個shell來做

一行一個網站       

https://aa.bb.com
https://dd.ee.com

寫到  /tmp/site_to_test


#!/bin/bash

while read line
do

    echo "$line"
    ./zap.sh -cmd -quickurl "$line" -quickout /tmp/`echo $line|cut -d '/' -f 3`.html

done < /tmp/site_to_test



2023/07/05

zap目前還是沒找到能一次掃描多個url的方法
以下是命令列的指令
不呼叫 UI 執行掃描並產生報告 並在執行完成後退出

./zap.sh -cmd -quickurl http://abc.com.tw -quickout /tmp/81.html


2023/07/04

最近使用zap auto scan的時候

在全部使用預設值的情況下

不知道為什麼都會去scan外部的網站

看了一下預設的層數是5層 也不知道是不是因為這個原因

目前的做法是先把zap這台對外的網路先關掉

再觀察看看



 

2023/06/12

最近在幫人家改bat檔
碰到二個問題
記一下解法

wmic qfe list >> a.txt
執行以上指令時 會同時產生 ascii 和 unicode
完全無法理解為什麼會有這個問題
為了解決 可以使用以下二個語法

wmic qfe list | findstr "^" >> a.txt
wmic qfe list | find /v "" >> a.txt


再來是如果
echo <abc> >> a.txt
會出現錯誤
必須使用跳脫字元
echo ^<abc^> >> a.txt

再來是換行的問題
要換行可以使用
echo. >> a.txt

如果不想換行 可以使用
echo|set /p="abc" >> a.txt




2023/06/05

朋友介紹的好用免費 P2V 軟体


https://www.starwindsoftware.com/starwind-v2v-converter

2023/05/24


/usr/sbin/iptables -A INPUT -p tcp -s 192.168.1.0/24 --dport 22 -j ACCEPT
/usr/sbin/iptables -A INPUT -p tcp -s 0/0 --dport 22 -j DROP
/usr/sbin/iptables -A INPUT -s 127.0.0.1 -j ACCEPT
/usr/sbin/iptables -A INPUT -s 192.168.0.0/16 -j ACCEPT
/usr/sbin/iptables -A INPUT -s 10.0.0.0/8 -j ACCEPT

/usr/sbin/iptables -A INPUT -m state --state  ESTABLISHED -j ACCEPT
在DROP前必須加上以上這行 封包才能出去

/usr/sbin/iptables -A INPUT -s 0/0 -j DROP

2023/05/05

一直以來都會定時去 graylog 撈 資料

會使用到多個 OR 的下法

accept AND ( 192.168.33.238 OR 192.168.34.215 OR 192.168.33.43 OR 192.168.34.142 OR 192.168.54.247 OR 192.168.7.253 OR 192.168.26.237 OR 192.168.26.228 OR 192.168.25.211 OR 192.168.25.206 OR 192.168.25.117 OR 192.168.26.104 OR 192.168.25.183 OR 192.168.31.241 OR 192.168.30.112 OR 192.168.30.80 OR 192.168.29.6 OR 192.168.29.3 OR 192.168.30.60 OR 192.168.30.58 OR 192.168.29.143 OR 192.168.30.57 OR 192.168.29.223 OR 192.168.29.164 OR 192.168.29.84 OR 192.168.30.200 OR 192.168.30.32 OR 192.168.29.29 OR 192.168.29.199 OR 192.168.29.205 OR 192.168.29.210 OR 192.168.29.200 OR 192.168.29.234 OR 192.168.30.220 OR 192.168.30.194 OR 192.168.29.83 OR 192.168.29.4 OR 192.168.30.108 OR 192.168.29.177 OR 192.168.29.107 OR 192.168.29.32 OR 192.168.30.33 OR 192.168.30.173 OR 192.168.30.247 OR 192.168.30.122 OR 192.168.30.55 OR 192.168.29.19 OR 192.168.29.10 OR 192.168.30.123 OR 192.168.30.201 OR 192.168.29.253 OR 192.168.30.85 OR 192.168.29.48 OR 192.168.30.37 OR 192.168.30.66 OR 192.168.9.100 OR 192.168.30.163 OR 192.168.30.114 OR 192.168.30.59 OR 192.168.30.199 OR 192.168.30.227 OR 192.168.30.41 OR 192.168.29.246 OR 192.168.29.161 OR 192.168.74.248 OR 192.168.74.12 OR 192.168.10.111 OR 192.168.10.104 OR 192.168.50.154 OR 192.168.52.1 OR 192.168.52.3 OR 192.168.50.243 OR 192.168.50.220 OR 192.168.50.179 OR 192.168.50.99 OR 192.168.50.138 OR 192.168.50.98 OR 192.168.50.182 OR 192.168.50.206 OR 192.168.50.234 )


但今天使用同樣的語法

出現以下的 error


While retrieving data for this widget, the following error(s) occurred:

OpenSearch exception [type=too_many_nested_clauses, reason=Query contains too many nested clauses; maxClauseCount is set to 1024].


問了bing


要修改 /etc/opensearch/opensearch.yml

加上 

indices.query.bool.max_clause_count: 10240

重啟 opensearch 目前正常

2023/05/03

因應centos 7 的EOS 
最近把 grafana 轉到 debian

grafana 安裝好後移轉資料


Install used plugin on new server

    grafana-cli plugins install grafana-image-renderer
    grafana-cli plugins install grafana-clock-panel
    grafana-cli plugins install grafana-worldmap-panel

Stop Grafana service on source and destination server

Copy /var/lib/grafana/grafana.db from old to new server

Check /etc/grafana/grafana.ini

    以上copy完後要注意檔案擁有者及權限問題

Restart Grafana

Regular connection to the grafana url

Dashboard, datasource, users, psw, team,… are the same


因為之前有在本机開 influxdb
所以移轉

influxd backup /tmp/backup
    
    只備分資料結構不備分資料

influxd restore -metadir /var/lib/influxdb/meta /tmp


本來有開API給遠端撈資料
在9版之後改成 service accounts
所以直接轉換

轉後去後遠端還是撈不到資料 本來以為是key的問題
查了log才發現要補一些package

apt install libglib2.0-0
apt install libnss3
apt install libatk1.0-0
apt install libatk-bridge2.0-0
apt install libcups2
apt install libdrm2
apt install libxkbcommon0
apt install libxcomposite1
apt install libxdamage1
apt install libxfixes3
apt install libxrandr2
apt install libgbm1
apt install libpangocairo-1.0-0
apt install libasound2


目前看來是都正常了




2023/04/21

mobasshtunnel  local port forwarding 使用時机如下
有一台僅供內部使用的 proxy 或 server
想要透過 tunnel 使用
架構圖如下




synology在儲存管理員中修改以下二個設定 可以再增加一些效能












2023/04/20

graylog時不時就會出現以下的訊息




 


修改一下 config

預設值是1秒

#gc_warning_threshold = 1s

先改成5秒再觀察看看

新机器進來

把graylog升到5版順便搬進去

原本机器上的設定要移過去

之前都是一個一個做

今天才發現有 content pack 這個功能 超方便的 可以一次搬好

首先進入舊几上的 content pack













建一個新的 content pack

 





填寫必要欄位 名稱不能使用純數字 否則會有問題












往下拉選擇那些要匯出












選完後下一步下一步就會建立一個新的 content pack  叫 test


在 more actions 可以 download






接下來在新机上一樣進到 content pack 就可以upload









上傳後直接install 就可以了




proxmox安裝almalinux 9 時會出現以下的問題無法開几

 










cpu不能使用預設的kvm64

要改成host才行

2023/04/14

為了因應centos 7 EOS

今天在轉移程式到 almalinux 9 時 mutt 一直無法寄信

mail server 的log如下

Apr 14 10:09:09 mail postfix/smtpd[523701]: connect from unknown[10.0.0.1]

Apr 14 10:09:09 mail postfix/smtpd[523701]: lost connection after STARTTLS from unknown[10.0.0.1]

看來almalinux 9的mutt 預設會使用 STARTTLS

在 .muttrc 加上以下這行

set ssl_force_tls = no


目前寄信正常了


20240308 後記


轉換到新mail server後 有些mutt又出現不能寄信的狀況

以下是log


Mar  8 06:13:01 mail postfix/smtpd[27212]: warning: TLS library problem: error:0A000126:SSL routines::unexpected eof while reading:ssl/record/rec_layer_s3.c:320:

Mar  8 06:13:01 mail postfix/smtpd[27212]: lost connection after STARTTLS from unknown[10.0.0.1]


必須在.muttrc再加上 set ssl_starttls = no 
包括之前說明的共二行如下

set ssl_force_tls = no
set ssl_starttls = no

目前正常了 再觀察看看

2023/04/09

在 proxmox backup server 中使用 api 撈取相關資料

先建立 API token 要記住 token













再設定權限















使用 curl 撈取相關資料 範例如下

curl --location --insecure --request GET 'https://10.0.0.1:8007/api2/json/nodes/{localhost}/tasks' --header 'Authorization: PBSAPIToken=root@pam!abc:your_token'|jq

API相關資料路徑可參考以下原廠連結


2023/03/02

使用curl  撈取 loki 資料的語法 

依需求需要更改之處

job="abc"

查詢的關鍵字 192.168.1.2

查詢的區間


curl -G -s "http://10.0.0.1:3100/loki/api/v1/query_range" --data-urlencode 'query={job="abc"} |~ "192.168.1.2"' --data-urlencode "start=$(date -u +'%Y-%m-%dT%H:%M:%SZ' -d '-8 hour')" --data-urlencode "end=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"


curl -G -s "http://10.0.0.1:3100/loki/api/v1/query_range" --data-urlencode 'query={job="abc"} |~ "192.168.1.2"' --data-urlencode "start=$(date -u +'%Y-%m-%dT%H:%M:%SZ' -d '-7 day')" --data-urlencode "end=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"|jq

2023/02/28

今天早上三點多開始收到ntopng的告警

進主几看了一下 process不見了

重開也沒用

看了一下log

ntopng果然有更新

更新後起不來

接下來看ntopng的log

發現本次更新後必須使用到 libbpf.so.0


Feb 28 08:09:17 W-ntopng-ubuntu-2004 ntopng[3247]: /usr/bin/ntopng: error while loading shared libraries: libbpf.so.0: cannot open shared object file: No such file or directory

Feb 28 08:09:22 W-ntopng-ubuntu-2004 ntopng[3272]: /usr/bin/ntopng: error while loading shared libraries: libbpf.so.0: cannot open shared object file: No such file or directory

Feb 28 08:09:28 W-ntopng-ubuntu-2004 ntopng[3294]: /usr/bin/ntopng: error while loading shared libraries: libbpf.so.0: cannot open shared object file: No such file or directory

 

apt install libbpf0

目前正常了 再觀察看看