ab’s blog

ab’s blog

インフラmemo

18÷0は

18÷0は解なしだそう

現実世界で言えば 18個のみかんを5袋に分けたら袋のなかはという質問で、 18みかん÷5袋=3みかん(袋の中) 余り(袋の外)3個だと思うので

18÷0なら 18みかん÷0袋=0みかん(袋の中) 余り(袋の外)18個であまりが割る数より大きいと駄目なんて、現実世界のルールにはないかなと思う次第。

Redhat9 postfixとsendmailの送信履歴が紐づくようにする。

はじめに

postfixの送信ログはデフォルトではメールの件名などが表示されず、どの送信メールのログかというのがわからないので、わかるようにする設定メモ。

メールの件名を表示させるのもよいのですが、今回はsendmailでメール送信時にカスタムメールヘッダ(X-custom-header:[識別番号])を付与してそれをpostfixのログに表示させるということをします。

postfixの設定

potfixの設定ファイル「main.cf」と「header_checks」に以下を足します。

/etc/postfix/main.cf

header_checks = regexp:/etc/postfix/header_checks

/etc/postfix/header_checks

/^X-Custom-Header:/     INFO

設定したらpostfix再起動systemctl restart postfix

sendmailからメール送信

メールにヘッダ情報を付与するにはsendmailを使います。(mailx(s-nail)だとつけ方がわからなかった)

echo -e "Subject: test\nX-Custom-Header: No123456780\nFrom: from@xxxxxxx.com\nTo: to@xxxxx.com\n\n 本文" | sendmail -t -f from@xxxxxxx.com

ログチェック

/var/log/maillogに「X-Custom-Header」部分が追加されて表示されるようになります。

postfix/pickup[1373876]: A68B31825460: uid=0 from=<from@xxxxxxx.com>
postfix/cleanup[1373882]: A68B31825460: info: header X-Custom-Header: No123456789 from local; from=<from@xxxxxxx.com>
postfix/cleanup[1373882]: A68B31825460: message-id=<20241201071455.A68B31825460@xxxxxx.com>
postfix/smtp[1373884]: A68B31825460: to=<to@xxxxx.com>, relay=smtp-server.com:587,~status=sent (250 Ok 0106019381128926)
postfix/qmgr[1373877]: A68B31825460: removed

以上

Zabbix6のテーマを作る(画面配色のカスタマイズ)

はじめに

ZBXが複数あってどれか何用がわからなくなるので、画面の配色を変え判別しやすいようにしたい、それで配色テーマを増やす方法をメモ。

zabbixテーマ

テーマスタイルシートを複製して編集

デフォルトテーマ(blue-theme)をコピーして(red-theme)とかを作る

cd /usr/share/zabbix/assets/styles/
cp -p blue-theme.css red-theme.css

[root styles]# ll
合計 1152
-rw-r--r-- 1 root root 225276 12月 13  2023 blue-theme.css
-rw-r--r-- 1 root root 230686 12月 13  2023 dark-theme.css
-rw-r--r-- 1 root root 248520 12月 13  2023 hc-dark.css
-rw-r--r-- 1 root root 244861 12月 13  2023 hc-light.css
-rw-r--r-- 1 root root 225276 10月 14 03:56 red-theme.css
drwxr-xr-x 3 root root     21 12月 13  2023 vendors

複製したテーマスタイルシートを編集してバックグラウンドの色をかえる。vi red-theme.css(43行目あたりと493行目あたりのbackgroundの色指定を変える。その他の箇所も変えたければ変える)

diff red-theme.css blue-theme.css
43c43
<   background-color: #e6dc55;
---
>   background-color: #ebeef0;
493c493
<   background: #419c7f;
---
>   background: #0a466a;

APP.phpの編集

cssの編集が終わったら、APP.phpファイルを編集vi /usr/share/zabbix/include/classes/core/APP.php 

require_once dirname(__FILE__).'/ZBase.php';

/**
 * A wrapper for the ZBase class.
 *
 * Feel free to modify and extend it to change the functionality of ZBase.
 */
ここからーーー
class APP extends ZBase {
  public static function getThemes() {
      return array_merge(parent::getThemes(), [
          'red-theme' => _('Red-theme')
      ]);
  }
ここまでーーー
}

テーマの選択

管理→一般設定→「表示設定」に作ったテーマ(今回の場合は'Red-theme')が出ればOK

以上