Skip to main content

Posts

sanitize on in CMakeLists.txt

1. CMakeLists.txt set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") add_compile_options(-fsanitize=address) If a subdir is set with add_subdirectory and a module that does not support sanitize is imported from the path and needs to be removed, add -fno-sanitize=address to add_compile_options in CMakeLists.txt of the subdir to remove it. Basically, if you enable sanitize, sanitize will adjust ulimit's core to 0, so core will not occur. You can do this by putting the following part as an environment variable. (Below is the part you put in systemd's service) 2. service file in systemd [Service] LimitCORE=infinity Environment="ASAN_OPTIONS=handle_segv=0:handle_abort=1:abort_on_error=1:disable_coredump=0"

e1000e 0000:00:1f.6 eno1: Detected Hardware Unit Hang

 make a file: /usr/local/etc/ethtool.sh (eno1 is your mgmt i/f, vmbr0 is your bridge i/f.) #!/bin/bash ethtool -K eno1 gso off gro on tso off tx on rx on rxvlan on txvlan on sg on && ethtool -K vmbr0 gso off gro on tso off tx on rx on rxvlan on txvlan on sg on ethtool -G eno1 rx 4096 if you want to activate on reboot. /etc/systemd/system/ethtool.service [Unit] Description=ethtool script [Service] WorkingDirectory=/usr/local/etc/ ExecStart=/usr/local/etc/ethtool.sh [Install] WantedBy=multi-user.target then systemctl enable ethtool.service && systemctl start ethtool.service refs: https://forum.proxmox.com/threads/e1000-driver-hang.58284/page-8#post-390709

Set up VNC login without console login in Ubuntu Gnome environment

 It is said that GNOME does not support VNC connection without logging in by default. So you have to do the following annoying task. 1) gnome-remote-desktop settings Open "Settings" in gnome-remote-desktop, select "Sharing", Find "Remote Desktop" or "Screen Sharing" and disable it.  2) Install x11vnc sudo apt update sudo apt install x11vnc 3) Set x11vnc password x11vnc -storepasswd 4) Set auto-start at boot (create x11vnc.service file) sudo nano /etc/systemd/system/x11vnc.service Contents

Setting ubuntu grub timeout when using efi

 # 1) Edit grub with vi sudo vi /etc/default/grub # 2) Add or modify the following part GRUB_RECORDFAIL_TIMEOUT="5" # 3) Update sudo update-grub The reason is If you look at "/etc/grub.d/00_header" if [ \$grub_platform = efi ]; then set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30} if [ x\$feature_timeout_style = xy ] ; then set timeout_style=menu fi fi Because it's like this.

[WordPress] Change https redirect in DB.

If you make an https redirect without thinking about SSL configuration: Check DB SELECT * from wp_options where option_name IN ('siteurl', 'home'); Update UPDATE wp_options SET option_value = REPLACE(option_value, 'https://your_domain', 'http://your_domain') WHERE option_name IN ('siteurl', 'home');

Setup pyodbc for connecting mssql (with freeTDS)

@Windows 1. pip install pyodbc 2.  Install Windows ODBC driver:  https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-2016 @Linux (Ubuntu-base) 1. freeTDS install using apt apt-get install freetds-dev freetds-bin apt-get install tdsodbc Explanation tdsodbc => /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so freetds-dev freetds-bin => /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so and etc files 2.  edit or add in /etc/odbcinst.ini [FreeTDS] Description = FreeTDS ODBC Driver Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so FileUsage = 1 CPTimeout = CPReuse = Example code: import pyodbc connection_string = ( 'DRIVER={FreeTDS};' 'SERVER=1.2.3.4;' 'PORT=1433;' 'DATABASE=mydbname;' 'UID=myuser;' 'PWD=password;' 'TDS_Version=7.3;' # 'Encrypt=no;TrustServerCertificate=yes;Trusted_Connection=no;' ) ...

[Linux/k8s] set faking hyper-v uuid on k8s woker node

* conclusion     Unable to create weave-net (pod-to-pod connection) which works well with conflicting uuid. So in the end i reinstalled ubuntu in hyper-v (not import mode). remap-uuid.sh #!/bin/bash function make_bind_or_copy() {   if [ "$3" == "bind" ]; then     echo "MountBind $1 > $2"     mount -o ro,bind "$1" "$2"   else # copy     echo "Copy $1 > $2"     cp "$1" "$2"   fi } function make_newID() {   TITLE="$1"   ORG_FILE="$2"   TAR_FILE="$3"   BIND_MODE="$4"   if -f [ -f $TAR_FILE ]; then     make_bind_or_copy "${TAR_FILE}" "${ORG_FILE}" "${BIND_MODE}"     return   fi   CUR_ID=`cat ${ORG_FILE}`   echo "Current   ${TITLE}: ${CUR_ID}"   echo -n "Write New ${TITLE}: "   read NEW_ID   echo "Inputed   ${TITLE}: ${NEW_ID}"   echo "${NEW_ID}" > ${TAR_FILE}   echo -n "Re-Write(mount) ${OR...

Linux/Process fork monitoring

ps_moniter.sh  #!/bin/bash . /etc/profile let LIMIT_PROCESS=400 let LIMIT_BIG_PROCESS=40 ALL_PROCESS_NUM=`ps x |wc -l` if [ ${ALL_PROCESS_NUM} -gt ${LIMIT_PROCESS} ]; then   echo ${ALL_PROCESS_NUM} fi BIG_PROCESS=`ps x -o cmd |sort  |uniq -c |sort -n |tail -n 10` BIG_PROC_SUM=`echo "${BIG_PROCESS}" |awk ' { SUM=SUM+$1 } END { print SUM } '` if [ ${BIG_PROC_SUM} -gt ${LIMIT_BIG_PROCESS} ]; then   MESSAGE="Process Report [Big Process Larger than ${LIMIT_BIG_PROCESS}] ${BIG_PROCESS}"   echo "$MESSAGE" fi crontab */5 * * * * cd /root/bin && ./ps_moniter.sh &>/dev/null

uri modificatin on http response

In haproxy : cannot. In nginx : possible. Backend Host: 1.2.3.4 Frontend Host: 2.2.2.2         location ^~ /its/         {             proxy_buffering   off;             rewrite           /its/(.*) /$1 break;             proxy_pass        http://1.2.3.4/;             proxy_redirect    default;             sub_filter_once off;             sub_filter ' href="/' ' href="/its/';             sub_filter ' src="/' ' src="/its/';             sub_filter ' src="http://1.2.3.4/' ' src="/its/';             sub_filter ' action="/' ' action="/its/';         } ex1. 2.2.2.2/its --> (2.2.2.2 connect to 1.2.3...

rsyslog file log to remote syslog

 1. rsyslog    [file-A]     <--->    [remote rsyslog] 1) Edit conf file (The filename is your choice.)   @: udp   @@: tcp /etc/rsyslog.d/01-testlog.conf $ModLoad imfile # Default Apache Access Log $InputFileName /var/log/haproxy.log #$InputFileName /var/log/httpd/access_log #$InputFileTag httpd-access-default: #$InputFileStateFile stat-httpd-access #$InputFileSeverity info $InputFileFacility local4 $InputRunFileMonitor $InputFilePollInterval 10 local4.* @127.0.0.1:514 2) ignore local4 from /var/log/message and /var/log/syslog   edit /etc/rsyslog.conf Before: *.*;auth,authpriv.none    -/var/log/syslog After: *.*;!(local4.*);auth,authpriv.none    -/var/log/syslog Before: *.=debug;\   auth,authpriv.none;\   news.none;mail.none -/var/log/debug *.=info;*.=notice;*.=warn;\   auth,authpriv.none;\   cron,daemon.none;\   mail,news.none    -/var/log/messages  After: *...

Redmine save_revision error by DB charset

* Check unit rails runner "Repository.fetch_changesets" -e production * ErrorLog /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `_query': Mysql2::Error: Incorrect string value:.......) (ActiveRecord::StatementInvalid)         from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:80:in `block in query'         from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `handle_interrupt'         from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/mysql2-0.3.21/lib/mysql2/client.rb:79:in `query'         from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `block in ex...

Mysql/MariaDB Recovery.

[DB_NAME]: DB-name to recovery. /dev/shm Usage: First, check your memory if you can use shm directory.   For recovery speed, I use /dev/shm/ directory. Process flow. 01. Stop DB  service mysqld stop 02. Stop web-service. (If you don't use, block DB-connection by using firewall-cmd.)  service httpd stop 03. Change DB-mode on server.cnf   set innodb_force_recovery = 5 on /etc/my.cnf.d/server.cnf 04. Start DB for recovery.  service mysqld start 05. Run DB-dump.  mysqldump -u root -p --databases [DB_NAME] > /dev/shm/[DB_NAME].sql 06. Stop DB  service mysqld stop 07. Change DB-mode on server.cnf (normal mode)  set innodb_force_recovery = 0 on /etc/my.cnf.d/server.cnf 08. Backup old DB-files. (Run follows if you necessarily need backup.)  mkdir /backup/DB_BackupTmp  mv /backup/DB/ibdata1 /backup/DB_BackupTmp  mv /backup/DB/ib_logfile0 /backup/DB_BackupTmp  mv /backup/DB/ib_logfile1 /backup/DB_BackupTmp  mv /backup/DB/[DB...

[redmine] repository trouble shooting

 1) Timeout occurs when deleting repository.    Check queries by using processlist.   "show processlist;" 2) If the reason of that case is timeout, set follows.  show variables like '%timeout';  set global innodb_lock_wait_timeout=300;  set session innodb_lock_wait_timeout=300;  If you necessary, kill process to restart process.     "kill <id>;" 3) Check if you have dummy data. SELECT changesets.repository_id FROM changesets WHERE changesets.repository_id NOT IN (SELECT id from repositories) group by changesets.repository_id ; Do A or B. * A DELETE FROM changes WHERE changes.changeset_id IN (SELECT changesets.id FROM changesets WHERE changesets.repository_id NOT IN (SELECT id from repositories)); DELETE FROM changesets WHERE changesets.repository_id NOT IN (SELECT id from repositories); * or B (415 = your target repository id) DELETE FROM changes WHERE changes.changeset_id IN (SELECT changesets.id FROM changesets WHERE changesets.r...

[raspbian] How To Install Python-3.6.11

Environment   raspbian: jessie   Linux phome 4.9.35-v7+ #1014 SMP Goal:   To setup Jupyter Notebook.   (needed pip3 18.1. (It required Python 3.5 but mine is 3.4.2) Conclusion:   - Python-3.6.11 : OK   - Python-3.8.3      make : OK, but pip cannot connect TLS/SSL       ( https://stackoverflow.com/questions/62827291/warning-pip-is-configured-with-locations-that-require-tls-ssl-however-the-ssl )      I think that it occurred by the difference of  openssl versions.      (But I did not to try figure out)    - Python-3.7.4 : Same problem like 3.8.3.    - Python-3.5.9 : Compile error by gcov dependency. Method:   - Download 3.6.11 source and compile.   - Type "make altinstall"   - Make file links with "update-alternatives" command.

Redmine production.log to uri log

But.. It doesn't work well. (Because the sequence of line is not arranged.) It is better way to use ' redmine_access_logger' plugin than this #!/bin/bash # Setting LOG_FILE=/redmine-3.3.3/log/production.log #LOG_FILE=mylog.log PIDFILE=/var/run/redmine_info_log.pid # Program Variables OUTPUT_LOGDIR=`dirname ${LOG_FILE}` OPT_DEBUG=0 URI_FILTER_REGEX="(^\"/people/avatar)|(^/attachments/thumbnail/)|(^\"/issues/.*\.xml)" function echo_log() { if [ "$2" != "" ]; then echo "$1" >> $2 else echo "$1" fi } if [ -f $PIDFILE ] then PID=$(cat $PIDFILE) ps -p $PID > /dev/null 2>&1 if [ $? -eq 0 ] then echo "Process already running" exit 1 else ## Process not found assume not running echo $$ > $PIDFILE if [ $? -ne 0 ] then echo "Could not create PID file" exit 1 fi fi else echo $$ > $PIDFILE if [ $? -ne 0 ] ...

using docker.io/licensefinder/license_finder, and solve erros.

My errors npm ERR! peer dep missing: acorn@^6.0.0, required by acorn-dynamic-import@4.0.0 npm ERR! extraneous: ajv@6.9.1 /scan/node_modules/@angular-devkit/build-webpack/node_modules/ajv Try follows 1) npm install -g npm-check-updates 2) ncu -u 3) npm install 4) npm dedupe 5) npm prune --production 1),2),3) upgrade packages to lastest 4) remove duplicated packages 5) prune for removing extraneous

[Linux/BashScript/Vim] Encrypted vim file, cat util.

cat_vim_file.sh =============== #!/bin/bash usage() {   echo "$1 <filename>" } FILENAME=$1 if [ "$FILENAME" == "" ]; then   usage $0 elif [ -f ${FILENAME} ]; then   echo -n "EnterPassword:"   # Without echo (-s)   read -s szPassword   echo $szPassword| vim -es '+%print' '+:q!' $FILENAME else   echo "FileNotFound: $FILENAME"   usage $0 fi =============== Reference: https://stackoverflow.com/questions/3980668/how-to-get-a-password-from-a-shell-script-without-echoing

Ubuntu xrdp settings

Base : Ubuntu 18.04 Command of xrdp session restart -  systemctl restart xrdp-sesman.service /etc/xrdp/startwm.sh Example (For session bus error exception : unset.) ============ unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS if test -r /etc/profile; then #xrdp multiple users configuration  . /etc/profile fi xfce-session mate-session if test -r /etc/default/locale; then         . /etc/default/locale         test -z "${LANG+x}" || export LANG         test -z "${LANGUAGE+x}" || export LANGUAGE         test -z "${LC_ADDRESS+x}" || export LC_ADDRESS         test -z "${LC_ALL+x}" || export LC_ALL         test -z "${LC_COLLATE+x}" || export LC_COLLATE         test -z "${LC_CTYPE+x}" || export LC_CTYPE         test -z "${LC_IDENTIFICATION+x}" || export LC_IDENTIFICATION...