Posts

Showing posts with the label UNIX

Redis user permissions (ACL) and python connection

 Recently, I was working on setting up a redis cluster along with separate users for readwrite and readonly. I setup the readonly user using the below privileges (ACLs):   user redisreadonly on >mySuperSecretPassword ~* resetchannels -@all +@read +ping +asking   Once this is setup, I wrote a simple program in python to connect to the redis cluster using the readonly credentials and print the number of keys.   #!/usr/bin/env python3 """ pip3 install redis """ from redis.cluster import RedisCluster, ClusterNode # ─────── Cluster connection ─────── startup_nodes = [ ClusterNode("redis_host_1", 6379), ClusterNode("redis_host_2", 6379), ClusterNode("redis_host_3", 6379) ] rc = RedisCluster(startup_nodes=startup_nodes,decode_responses=True,username='redisreadonly',password='mySuperSecretPassw...

Print UNIX pipe character ("|") in Blogger

In order to get the UNIX pipe character ("|") printed in blogger, do the following: Always use the "Edit Html" tab for posts containing the pipe character and NOT the Compose tab. The ASCII value for the pipe character is "& # 124 ;" (I am delibrately using whitespace in betwen the ASCII value. Please remove them before using). Thanks for Greg Houston's blog and this thread for pointing me in the right direction.

Find the number of CPUs and RAM size in UNIX

I have tried to collate commands to find the number of CPUs and total physical memory (RAM) size in all common flavours of UNIX in one blog entry. This certainly is not an exhaustive list and will be modified as and when I find new commands. You are also more than welcome to add to this list. Number of CPUs Sun SPARC Solaris 1. prtconf | grep cpu | wc -l 2. psrinfo | wc -l 3. psrinfo -v | grep "Status of" | wc -l 4. psrinfo -vp 5. prtdiag | grep "on-line" | wc -l 6. mpstat | grep -vi cpu | wc -l Linux 1. grep "processor"/proc/cpuinfo | wc -l HP-UX 1. ioscan -kfnC processor | grep "processor" | wc -l 2. sar -M 1 | awk 'END {print NR-5}' 3. sar -Mu 1 1 | awk 'END {print NR-5}' 4. ioscan -kf | grep -c processor 5. cat /var/adm/syslog/syslog.log | grep processor | grep "vmunix" | wc -l AIX 1. lscfg -vp | grep proc | wc -l 2. lparstat -i | grep "Online Virtual CPUs" | cut -d ':' -f2 ...

Flower brackets {} and variables in UNIX - A perfect match

When passing a variable in unix, the general convention is to use $variable . Although this does suffice in most cases but in some rare cases, it gives connotations totally different than what was originally intended, as shown in the below example. The requirement Copy all files ending with ver to ver_old. For example, suppose I have a file called formver, I would like to copy it to formver_old. The code below is the code that I wrote to achieve the above requirement. for i in `ls *ver` do cp -p $i $i_old done The pitfall A cursory glance at the code indicates that it should run smoothly like a river. But it doent' and herein lies the catch. Let's have a look at the error and figure out what exactly is wrong with the above code. __________________________________________________________________ $ for i in `ls *ver` > do > cp -p $i $i_old > done cp: Insufficient arguments (1) Usage: cp [-f] [-i] [-p] [-@] f1 f2 cp [-f] [-i] [-p] [-@] f1 ... fn d1 cp -r-R [-H-L-P] [-f] [...

Find OS Kernel Bit in UNIX - Ready reckoner

Listed below is the ready reckoner for finding out the kernel bit information for Linux, Solaris, HP-UX and IBM AIX, which are the most commonly used OS for Oracle Apps. Linux getconf LONG_BIT or uname -m (works for x86-64 bit servers. Not tested it in 32 bit servers) eg: $ getconf LONG_BIT 64 $ uname -m x86_64 $ Sun SPARC Solaris isainfo -kv eg: $ isainfo -kv 64-bit sparcv9 kernel modules $ HP-UX getconf KERNEL_BITS eg: $ getconf KERNEL_BITS 64 $ IBM AIX bootinfo -K Not tested as I currently do not have any AIX servers to test on! Note 1 : To find whether a given executable is 32-bit or 64-bit, use the command file <executable_name> eg: $ file oracle oracle: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped $ file tnslsnr tnslsnr: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped $ file sqlplus sqlplus: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped Note 2 : You can install a 32-bit executab...

Shell script to monitor processes

Many a time, one is faced with a situation where one needs to monitor a process to its completion. For example, if one is performing a clone, one has to copy the source files to the target or if one is performing a backup of any instance, the cp or tar commands that one has fired has to be monitored to its completion. I generally use a customised script (as below) during those situations to monitor the processes. while true do ps -fu <owner_of_the_process> grep <cp or rman or process_id> wc -l printf "\n\nPress Ctrl+C to exit this loop.......\n\n" sleep <the_number_of_seconds_this_process_should_sleep> done

Find the UNIX Process ID given a port number

One of my colleagues had started the MWA server (telnet server) and it was running on port number 9198. However, when I queried the processes (ps -ef | grep mwa), I could not find the process which had kick started the MWA server. This had me thinking and I resolved to find the process ID. However, the utility lsof was not installed on the OS (Sun Sparc Solaris 5.10) . When I probed further (googled! actually), I found a script on onlineappsdba , which I found helpful. I had to modify that script suitably to exclude processes not owned by the current user. I also referred another blog , to complete my script. ______________________________________________________ # # Make sure the logfile directory exists # if [ ! -d ${HOME}/bkp/log ]; then mkdir -p ${HOME}/bkp/log fi; if [ $# -ne 1 ]; then echo "To run the program, please provide the port number as the arguement" printf "\n\t ${usage} \n\n" exit 1; fi port_num="$1" echo printf "\n Finding the...

Popular posts from this blog

EXCEPTION_ACCESS_VIOLATION in Jinitiator and IE crashes

Version of mod_security with EBS 11.5.10.2

Read a file and extract specific lines using Native Ansible Modules