Monday, June 29, 2015

Splunk useful commands

put cluster in maintenance mode

$SPLUNK_HOME/bin/splunk enable maintenance-mode

rolling restart


splunk rolling-restart cluster-peers


Daily License volume by host

index=_internal source=*license_usage.log type=Usage 
 | stats sum(b) as bytes by h 
 | eval MB = round(bytes/1024/1024,1)
 | fields h MB
 | rename h as host


Friday, May 29, 2015

Command to recursively delete files older than N days

this command will delete all files inside c:\Folder and subfolders which are older than <Number of Days>

forfiles -p "C:\Folder" -s -m *.* /D -<Number of Days> /C "cmd /c del @path"

Wednesday, April 22, 2015

List of Splunk universal forwarders with client OS & version

index=_internal source=*metrics.log group=tcpin_connections | eval sourceHost=if(isnull(hostname), sourceHost,hostname) | dedup sourceHost | table sourceHost sourceIP os version | sort version

Friday, March 27, 2015

Linux Commands

List all Linux users

cut -d: -f1 /etc/passwd

set password never to expire

chage -I -1 -m 0 -M 99999 -E -1 username

Thursday, September 25, 2014

Linux Check last password change, expire date & other info

$chage -l root

Output

Last password change                                    : Sep 25, 2014
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999

Number of days of warning before password expires       : 7

 Other options

  -d, --lastday LAST_DAY        set last password change to LAST_DAY
  -E, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -h, --help                    display this help message and exit
  -I, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -l, --list                    show account aging information
  -m, --mindays MIN_DAYS        set minimum number of days before password
                                change to MIN_DAYS
  -M, --maxdays MAX_DAYS        set maximim number of days before password
                                change to MAX_DAYS
  -W, --warndays WARN_DAYS      set expiration warning days to WARN_DAYS


Monday, July 14, 2014

Remote connection to Oracle database using SQL*Plus

sqlplus "uname/pwd@ (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host.network.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.network.com) ) )"

Friday, July 11, 2014

Script to recreate all tablespaces

select 'create tablespace ' || df.tablespace_name || chr(10)
 || ' datafile ''' || df.file_name || ''' size ' || df.bytes
 || decode(autoextensible,'N',null, chr(10) || ' autoextend on maxsize '
 || maxbytes)
 || chr(10)
 || 'default storage ( initial ' || initial_extent
 || decode (next_extent, null, null, ' next ' || next_extent )
 || ' minextents ' || min_extents
 || ' maxextents ' ||  decode(max_extents,'2147483645','unlimited',max_extents)
 || ') ;'
 from dba_data_files df, dba_tablespaces t
 where df.tablespace_name=t.tablespace_name