Pattern Matching
|
Result
|
|
$a =~ /pat/
|
match
|
True if $a contains
pattern
|
$a =~ s/p/r/
|
substitution
|
Replace contents of p
with r in $a
|
$a =~ tr/a-z/A-Z/
|
translation
|
Translate to
corresponding characters
|
Logical Operators
|
Result
|
|
$a && $b
|
And
|
True if $a is true and
$b is true
|
$a || $b
|
Or
|
$a if $a is true,
otherwise $b
|
! $a
|
Not
|
True if $a is not true
|
Arithmetic Operators
|
Result
|
|
$a + $b
|
Add
|
Sum of $a and $b
|
$a - $b
|
Subtract
|
Difference of $a and
$b
|
$a * $b
|
Multiply
|
Product of $a times $b
|
$a / $b
|
Divide
|
Quotient of $a divided
by $b
|
$a % $b
|
Modulus
|
Remainder of $a
divided by $b
|
$a ** $b
|
Exponentiate
|
$a to the power $b
|
++$a,$a++
|
Autoincrement
|
Add 1 to $a
|
--$a,$a--
|
Autodecrement
|
Subtract 1 from $a
|
rand($a)
|
Random
|
A random number in
range 0 .. $a
|
String Operators
|
Result
|
|
$a . $b
|
Concatenation
|
Values of $a and $b as
one long string
|
$a x $b
|
Repeat
|
Value of $a strung
together $b times
|
substr($a,$o,$l)
|
Substring
|
Substring at offset $o
of length $l
|
index($a,$b)
|
Index
|
Offset of string $b in
string $a
|
Assignment Operators
|
Result
|
|
$a = $b
|
Assign
|
$a gets the value of
$b
|
$a += $b
|
Add to
|
Increase $a by $b
|
$a -= $b
|
Subtract from
|
Decrease $a by $b
|
$a .= $b
|
Append
|
Append string $b to $a
|
File Test Operators
|
Result
|
|
-r $a
|
Readable
|
File name in $a is
readable by effective uid
|
-w $a
|
Writable
|
Writable by effective
uid
|
-x $a
|
Executable
|
Executable by
effective uid
|
-o $a
|
Owned
|
Owned by effective uid
|
-R $a
|
Readable
|
Readable by real uid
|
-W $a
|
Writable
|
Writable by real uid
|
-X $a
|
Executable
|
Executable by real uid
|
-O $a
|
Owned
|
Owned by real uid
|
-e $a
|
Exists
|
File exists
|
-z $a
|
Non-zero size
|
File has non-zero size
(returns size in bytes)
|
-s $a
|
Zero size
|
File has zero size
|
-f $a
|
Regular file
|
File is a regular file
|
-d $a
|
Directory
|
File is a directory
|
-l $a
|
Symbolic link
|
File is a symbolic
link
|
-p $a
|
Named pipe
|
File is a named pipe
(FIFO)
|
-S $a
|
Socket
|
File is a socket
|
-b $a
|
Block
|
File is a block
special file
|
-c $a
|
Character
|
File is a character
special file
|
-u $a
|
UID
|
File has setuid bit
set
|
-g $a
|
GID
|
File has setgid bit
set
|
-k $a
|
Sticky bit
|
File has sticky bit
set
|
-T $a
|
Text file
|
File is a text file
|
-B $a
|
Binary
|
File is a binary file
(opposite of -T)
|
-M $a
|
Modify
|
Age of file (at
startup) in days since modification
|
-A $a
|
Last Access
|
Age of file (at
startup) in days since last access
|
-C $a
|
Inode change
|
Age of file (at
startup) in days since inode change
|
Total Hit Counter
Thursday, March 6, 2014
Perl Operators
Friday, February 28, 2014
Maximum CPU usage in windows
Poweshell Script to get list of top10 processes which uses maximum cpu in windows
;####
;Description: Poweshell Script to get list of top10 processes which uses maximum cpu in windows
;Created by VCP Mutthukrishna- EFFONE Technologies
;Create date : 28-02-2014
;################################################################################
$RunningProcesses=Get-Process | Sort-Object CPU -Descending
$TotalProcess=10
$ProcessCounter=1
write-host OK". " -nonewline;
Function max_cpu_usage_procs
{
foreach ($objItm in $RunningProcesses) {
if ($ProcessCounter -gt $TotalProcess)
{
break
}
Write-Host $objItm.ProcessName,"=" $objItm.CPU"; " -nonewline
$ProcessCounter = $ProcessCounter + 1
}
}
$OUTPUT=max_cpu_usage_procs
write-host $OUTPUT "|" -nonewline;
max_cpu_usage_procs
Friday, January 31, 2014
Exception processing request
Your problem is the keys should NOT be with underscores (that's the old format)....
A good way to "solve this" is to runt he following command:
nscp settings --generate settings --add-defaults
THat will add all "normal keys" to your settings file correctly with descriptions...
You can (if you do):
nscp settings --help
Get some more details. There are options for generating all keys from all modeuls (default is only modules you have configured) and some other usefull things...
Thursday, January 23, 2014
check_oracle_health
check_oracle_health
Monitoring Oracle Database
To Create monitoring of Oracle database Follow below steps.Step 1: To Download Below Rpms Click Here.....
oracle-instantclient12.1-basic-12.1.0.1.0-1.x86_64.rpm
oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.x86_64.rpm
oracle-instantclient12.1-devel-12.1.0.1.0-1.x86_64.rpm
oracle-instantclient12.1-jdbc-12.1.0.1.0-1.x86_64.rpm
Step 2: After Downloading rpms Install them on Nagios Server.
Fist install below pacages: libdbi-drivers and libdbi perl-DBI libaio
[root@nagios_master ~]# yum install libdbi-drivers libdbi perl-DBI libaio
Now install oracle packages.
[root@nagios_master ~]# rpm -ivh oracle-instantclient12.1-devel-12.1.0.1.0-1.x86_64.rpm oracle-instantclient12.1-jdbc-12.1.0.1.0-1.x86_64.rpm oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.x86_64.rpm oracle-instantclient12.1-basic-12.1.0.1.0-1.x86_64.rpm
Now set ORACLE HOME
[root@nagios_master ~]# echo 'export ORACLE_HOME=/usr/lib/oracle/12.1/client64/' /etc/profile
[root@nagios_master ~]# echo 'export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib/' >> /etc/profile
[root@nagios_master ~]# mkdir -p /usr/lib/oracle/12.1/client64/lib/network/admin/ && echo 'names.directory_path = (TNSNAMES,EZCONNECT)' > /usr/lib/oracle/12.1/client64/lib/network/admin/sqlnet.ora
[root@nagios_master ~]# chmod 777 /tmp/check_oracle_health
Now execute cpan command prompt and install DBD-Oracle
[root@nagios_master ~]# cpan
cpan[1]> install DBD::Oracle
Step 3: Now download Check_oracle_health plugin from below link:
http://labs.consol.de/download/shinken-nagios-plugins/check_oracle_health-1.7.8.1.tar.gz
[root@nagios_master ~]# tar -xvf check_oracle_health-1.7.8.1.tar.gz
[root@nagios_master ~]# cd check_oracle_health-1.7.8.1
[root@nagios_master ~]# ./configure --with-statefiles-dir=/tmp/ --with-nagios-user=nagios --with-nagios-group=nagios --with-mymodules-dir=/usr/local/nagios/libexec/plugins/ --with-mymodules-dyn-dir=/usr/local/nagios/libexec/plugins/
[root@nagios_master ~]# make && make install
Then, create a dedicated user for monitoring, connect to your Oracle database and enter the following lines:
CREATE USER nagios IDENTIFIED BY nagios ;
GRANT CREATE SESSION TO nagios;GRANT SELECT any dictionary TO nagios;GRANT SELECT ON V_$SYSSTAT TO nagios;GRANT SELECT ON V_$INSTANCE TO nagios;GRANT SELECT ON V_$LOG TO nagios;GRANT SELECT ON SYS.DBA_DATA_FILES TO nagios;GRANT SELECT ON SYS.DBA_FREE_SPACE TO nagios;
[root@nagios_master ~]# /usr/local/nagios/libexec/plugins/check_oracle_health --connect=xxx.xxx.xxx.xxx/ORCL --username=nagios --password=nagios --tablespace=SUPERVISION --mode tablespace-usage
CRITICAL - tbs SYSTEM usage is 90%
Thursday, January 16, 2014
Syslog-ng Configuration to Send logs to Syslog server
Client IP:192.168.1.65
ServerIP:192.168.1.64
Client side add following lines into /etc/syslog-ng/syslog-ng.conf
##########################
source s_local { internal(); unix-stream("/dev/log"); file("/proc/kmsg" program_override("kernel: ")); };
source s_msg { file("/var/log/messages.myhost"); };
destination d_loghost {tcp("192.168.1.64" port(514));};
log { source(s_local); source(s_msg); destination(d_loghost); };
options {
flush_lines (0);
log_fifo_size (2048);
create_dirs (yes);
group (shankar);
dir_group (shankar);
perm (0640);
dir_perm (0750);
};
source s_remote { tcp(); };
destination d_clients { file("/var/log/HOSTS/$HOST/shankar.txt"); };
log { source(s_remote); destination(d_clients); };
# CREATES TABLE IF NOT IN MYSQL
destination d_sql {
sql(type(mysql)
host("localhost") username("root") password("") port("3306")
database("syslog")
table("messages_${HOST}_${R_YEAR}${R_MONTH}${R_DAY}")
columns("datetime", "host", "program", "pid", "message")
values("$R_DATE", "$HOST", "$PROGRAM", "$PID", "$MSGONLY")
indexes("datetime", "host", "program", "pid", "message"));
};
# TO SEND LOGS IN MYSQL
log { source(s_remote); destination(d_sql); };
ServerIP:192.168.1.64
Client side add following lines into /etc/syslog-ng/syslog-ng.conf
##########################
source s_local { internal(); unix-stream("/dev/log"); file("/proc/kmsg" program_override("kernel: ")); };
source s_msg { file("/var/log/messages.myhost"); };
destination d_loghost {tcp("192.168.1.64" port(514));};
log { source(s_local); source(s_msg); destination(d_loghost); };
###################################
Server side add following lines
To send logs to mysql need following packages
libdbi0, libdbi0-dev, libdbd-mysql
To send logs to mysql need following packages
libdbi0, libdbi0-dev, libdbd-mysql
##################################
options {
flush_lines (0);
log_fifo_size (2048);
create_dirs (yes);
group (shankar);
dir_group (shankar);
perm (0640);
dir_perm (0750);
};
source s_remote { tcp(); };
destination d_clients { file("/var/log/HOSTS/$HOST/shankar.txt"); };
log { source(s_remote); destination(d_clients); };
# CREATES TABLE IF NOT IN MYSQL
destination d_sql {
sql(type(mysql)
host("localhost") username("root") password("") port("3306")
database("syslog")
table("messages_${HOST}_${R_YEAR}${R_MONTH}${R_DAY}")
columns("datetime", "host", "program", "pid", "message")
values("$R_DATE", "$HOST", "$PROGRAM", "$PID", "$MSGONLY")
indexes("datetime", "host", "program", "pid", "message"));
};
# TO SEND LOGS IN MYSQL
log { source(s_remote); destination(d_sql); };
###################################
Subscribe to:
Posts (Atom)