Posts

Showing posts from 2016

Turning display on and off - raspberry pi

 Turning display on and off - raspberry pi vcgencmd display_power 0 turns off the screen vcgencmd display_power 1 turns on the screen More explanations here: https://github.com/nezticle/RaspberryPi-BuildRoot/wiki/VideoCore-Tools

Random sleep in bash script

Random sleep in bash script To insert a random sleep into a running script:  sleep $[ ( $RANDOM % 10 )  + 1 ]s   This will introduce a 1-10 second random sleep in the script. 

Glassfish 4.1 admin reset password

Glassfish 4.1 admin reset password 1. Go t o   /opt/glassfish4/glassfish/domains/domain1/config/local_password   its contents are a backup password to log in as admin 2. You can replace the domain\config\admin-keyfile contents with the following: admin;{SSHA256}UV9EsTaoxzAdtxiNMKTkb3g0WjnoUBEBgpDQIGSdOu8QhprFoWiSCw==;asadmin This will give you a username of 'admin' and password 'changeit'.

NFS, Centos 7, firewalld setup

NFS, Centos 7, firewalld setup On server systemctl enable rpcbind systemctl enable nfs-server systemctl enable nfs-lock systemctl enable nfs-idmap systemctl start rpcbind systemctl start nfs-server systemctl start nfs-lock systemctl start nfs-idmap edit  /etc/exports /media/USB-drive/ 192.168.200.2(rw,sync,no_root_squash,no_all_squash) (path do shared folder, IP of client, permissions and configs) firewall-cmd --permanent --add-service=nfs firewall-cmd --permanent --add-service=mountd firewall-cmd --permanent --add-service=rpc-bind firewall-cmd --reload   to check if everything is correct exportfs   from client mount the nfs share create folder /mnt/nfs/USB-drive     mount -t nfs 192.168.200.1:/media/USB-drive /mnt/nfs/USB-drive

How to test NFS speed or HDD speed

How to test NFS speed or HDD speed > hdparm -tT /dev/sda /dev/sda:  Timing cached reads:   24960 MB in  2.00 seconds = 18504.33 MB/sec  Timing buffered disk reads: 6746 MB in  3.00 seconds = 4247.95 MB/sec for more reliable outcome for i in 1 2 3; do hdparm -tT /dev/sda; done or > dd if=/dev/zero of=/tmp/output.img bs=8k count=256k 262144+0 records in 262144+0 records out 2147483648 bytes (2.1 GB) copied, 0.873801 s, 2.5 GB/s   NFS: at first create test folder  > bonnie+++ -d /mnt/nfs/test/ -u root to see some human readable report bonnie++ -d /mnt/nfs/test/ -r 2048 -u root | bon_csv2html > /root/bonnietest.html

How to delete lines (not) containing specific string

How to delete lines (not) containing specific string Remove lines not containing 2016-10-30  sed -i.bak '/2016-10-30/ !d' ./log.txt  Remove lines  containing 2016-10-30   sed -i.bak '/2016-10-30/ d' ./log.txt option -i.bak will create backup file.

Firewalld.service start operation timed out. Terminating. Centos 7

centos 7 systemd[1]: firewalld.service start operation timed out. Terminating. the fastest way to restart is: systemctl stop firewalld    pkill -f firewalld    systemctl start firewalld

Install namebench from google to test dns response on Centos

Install namebench from google to test dns response on Centos yum install tkinter wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/namebench/namebench-1.3.1-source.tgz tar xvfvz namebench-1.3.1-source.tgz cd namebench-1.3.1 ./namebench.py   It should automatically start like this: namebench 1.3.1 - best source (automatic) on 2016-08-29 17:00:06.588538 threads=40/2 queries=250 runs=1 timeout=3.5 health_timeout=3.75 servers=11 ------------------------------------------------------------------------------ - Reading Top 2,000 Websites (Alexa): data/alexa-top-2000-domains.txt (0.7MB) - Reading Cache Latency Test (100% hit): data/cache-hit.txt (0.1MB) - Reading Cache Latency Test (100% miss): data/cache-miss.txt (0.1MB) - Reading Cache Latency Test (50% hit, 50% miss): data/cache-mix.txt (0.1MB) - Reading Mozilla Firefox: /root/.mozilla/firefox/e3z6bpz8.default/places.sqlite (10.0MB) - Generating tests from Mozilla Firefox (68 records, select

How to log/save all commands in CentOS

How to log/save all commands in CentOS One of the easy ways to log/save/record all issued commands by users is setup logger. I use rsyslog. 1. Add at the end of /etc/bashrc export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$(whoami) [$$]: $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" ) [$RETRN_VAL]"' if you want to log also IP use this (I know it is not perfect if there are few the same users connected from different IPs) export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$(w -i -h| grep -Eo "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" ) : $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" ) [$RETRN_VAL]"' Output will be like this: date time server-name user-name: IP address : command Jul  7 13:36:45 server1 root: 192.168.0.5 : 07/07/16 13:36:38 ls -la [0] 2.  Create new config file at: /etc/rsyslog.d/bash.conf and put inside: local6.*    /var/log/logger.log 3. Restart syslog systemctl

Graphs shows no data (nan) or empty graphs - Observium

Graphs shows no data - Observium Probably cron does not work. Manual recommends using these: 33 */6 * * *   root    /opt/observium/discovery.php -h all >> /dev/null 2>&1 */15 * * * *   root    /opt/observium/discovery.php -h new >> /dev/null 2>&1 */15 * * * *   root    /opt/observium/poller-wrapper.py 2 >> /dev/null 2>&1 it will not work when edited using crontab -e Create new file in /etc/cron.d/observium and paste there. If still does not work try this: 33 */6 * * *   root    cd /opt/observium/ && ./discovery.php -h all >> /dev/null 2>&1 */15 * * * *   root    cd /opt/observium/ && ./discovery.php -h new >> /dev/null 2>&1 */15 * * * *   root    cd /opt/observium/ && ./poller.php -h all >> /dev/null 2>&1 If still does not work, try to add above cron entries into /etc/crontab and restart cron service.

Raspberry pi change IP via webpage

  Raspberry pi change IP via webpage  Save this as ip.php and put inside /var/www do not forget to change permissions for /etc/network/interfaces chown root:www-data /etc/network/interfaces chmod g+w /etc/network/interfaces   <?php // configuration $localIP = getHostByName(getHostName()); $url1 = 'http://'.$_SERVER['HTTP_HOST']; $url2 = '/ip.php'; //echo '{$url1 . $url2'}; $url = $url1.$url2; echo $url; $file = '/etc/network/interfaces'; // check if form has been submitted if (isset($_POST['text'])) {     // save the text contents     file_put_contents($file, $_POST['text']);     // redirect to form again     header(sprintf('Location: %s', $url));     printf('<a href="%s">Moved</a>.', htmlspecialchars($url));     exit(); } // read the textfile $text = file_get_contents($file); ?> <!-- HTML form --> <form action="" method="post"> <textarea row

Python pxssh failed on login. could not set shell prompt

Python pxssh failed on login. could not set shell prompt  probably pxssh cannot find right prompt so it is better to setup original prompt s.prompt() and don`t forget to setup auto_prompt_reset = False from pexpect import pxssh import getpass try : s = pxssh . pxssh ( timeout = 60 ) s . force_password = True hostname = raw_imput ( 'hostname: ' ) username = raw_input ( 'password: ' ) password = getpass . getpass ( 'password: ' ) s . PROMPT = 'SSH> ' #here is your original prompt s . login ( hostname , username , password , auto_prompt_reset = False ) s . prompt () s . sendline ( 'show version' ) #your command is here s . prompt () data = s . before print data s . logout () except pxssh . ExceptionPxssh , e : print "pxssh failed on login." print str ( e )

XRDP crashes on Centos 7

XRDP crashes on Centos 7   Viewing /var/log/messasges showed these messages: Dec 23 17:57:16 localhost systemd: Failed at step EXEC spawning /usr/sbin/xrdp-sesman: Permission denied Dec 23 17:57:16 localhost systemd: Failed at step EXEC spawning /usr/sbin/xrdp: Permission denied Dec 23 17:57:16 localhost systemd: xrdp-sesman.service: main process exited, code=exited, status=203/EXEC Dec 23 17:57:16 localhost systemd: Unit xrdp-sesman.service entered failed state. Dec 23 17:57:16 localhost systemd: xrdp-sesman.service failed. Dec 23 17:57:16 localhost systemd: xrdp.service: main process exited, code=exited, status=203/EXEC Dec 23 17:57:16 localhost systemd: Unit xrdp.service entered failed state. Dec 23 17:57:16 localhost systemd: xrdp.service failed.   there is broken selinux context, to fix it use these commands: chcon --type=bin_t /usr/sbin/xrdp chcon --type=bin_t /usr/sbin/xrdp-sesman systemctl reenable xrdp.service systemctl start xrdp.service  

Install GoDaddy SSL Certificate on Cisco ASA with openssl

Image
Install GoDaddy SSL Certificate on Cisco ASA  1) Download the gd_intermediate.crt certificate https://certs.godaddy.com/anonymous/repository.pki GoDaddy Secure Server Certificate (Intermediate Certificate) gd_intermediate.crt (pem) 09 ED 6E 99 1F C3 27 3D 8F EA 31 7D 33 9C 02 04 18 61 97 35 49 CF A6 E1 55 8F 41 1F 11 21 1A A3 2) ASDM: Configuration, Device Management, Certificate Management, CA Certificates Click Add & Select the file “gd_intermediate.crt” that you downloaded and then click Add Certificate  3) Create PKCS12 format file openssl pkcs12 -export -in your-domain.com-from-GD.cer -inkey privateKey.key -out asa-your-domain-certificate.pfx -certfile gdig2-CACert-bundle-from-GD.cer   Enter Export Password: (put pfx password) Verifying - Enter Export Password: (put pfx password) 4) ASDM: Configuration, Device Management, Certificate Management, Identity Certificates Click Browse and select your PFX file that you saved in step 3, type the pfx

Increase limits - percona 5.7, centos 7.2

Edit /etc/security/limits.conf and add the following lines mysql soft nofile 65535  mysql hard nofile 65535 Edit /usr/lib/systemd/system/mysqld.service and add LimitNOFILE = infinity  LimitMEMLOCK = infinity Then run systemctl daemon-reload and systemctl restart mysql.service .

Connect to current session on Raspberry pi using xrdp and vnc

Connect to current session on Raspberry pi using xrdp and vnc I assume that Raspberry Pi is login into desktop and user Pi is the owner of it. 1. install xrdp and x11vnc apt-get install xrdp x11vnc   2.Change default setting for xrdp so will always connect to current session edit /etc/xrdp/xrdp.ini [xrdp1] name=Active local login lib=libvnc.so username= password=ask ip=127.0.0.1 port=5900 3. run first time x11vnc as user Pi to setup password   4. depends on Raspberry version    - add this line at the end of /etc/rc.local but before exit 0     ... su - pi -c '/usr/bin/x11vnc -auth /home/pi/.Xauthority -display :0 -usepw -listen 127.0.0.1 -noxdamage -ncache 10 -ncache_cr -viewonly -forever -bg' exit 0 - or if this does not work add at the end of line of /etc/xdg/lxsession/LXDE-pi/autostart @ /usr/bin/x11vnc -auth /home/pi/.Xauthority -display :0 -usepw -listen 127.0.0.1 -noxdamage -ncache 10 -ncache_cr -viewonly -forever -bg   reboot raspber

Grep only IP addresses

How to grep to display only IP addresses ? grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'