Skip to content

Linux script to find last quarter

##find_last_quarter.sh
currentmonth=`date +’%m’`
##echo $currentmonth
currentyear=`date +’%Y’`
lastyear=`expr $currentyear – 1`

##echo $currentyear
##echo $lastyear

if [ $currentmonth = 01 ]; then
echo “Last Quarter was Q4 $lastyear”
elif [ $currentmonth = 02 ]; then
echo “Last Quarter was Q4 $lastyear”
elif [ $currentmonth = 03 ]; then
echo “Last Quarter was Q4 $lastyear”
elif [ $currentmonth = 04 ]; then
echo “Last Quarter was Q1 $currentyear”
elif [ $currentmonth = 05 ]; then
echo “Last Quarter was Q1 $currentyear”
elif [ $currentmonth = 06 ]; then
echo “Last Quarter was Q1 $currentyear”
elif [ $currentmonth = 07 ]; then
echo “Last Quarter was Q2 $currentyear”
elif [ $currentmonth = 08 ]; then
echo “Last Quarter was Q2 $currentyear”
elif [ $currentmonth = 09 ]; then
echo “Last Quarter was Q2 $currentyear”
elif [ $currentmonth = 10 ]; then
echo “Last Quarter was Q3 $currentyear”
elif [ $currentmonth = 11 ]; then
echo “Last Quarter was Q3 $currentyear”
elif [ $currentmonth = 12 ]; then
echo “Last Quarter was Q3 $currentyear”
else
echo “Error: check your script”
fi;

How to find Netezza model type?

To find if Netezza system is a Mustang box, TwinFin or Striper by connecting to the server using putty:

1) Run Netezza provided support script nz_get_model

eg. Below was run on Mustang 10100 model
/export/home/nz->nz_get_model
10100SL

eg. Below was run on TwinFin 12 (newer model)
/nz/support/bin->nz_get_model
IBM PureData System for Analytics N1001-010

eg. Below was run on TwinFin 48 (old model)
/export/home/nz->nz_get_model
IBM Netezza 1000-48

eg. Below was run on Striper (1 rack)
/export/home/nz->nz_get_model
IBM PureData System for Analytics N2001-010

2) If you are on version 5 or above then you can find the system family and details by running below sql query

eg. Below query was run on TwinFin 48. NPS_MODEL = P400X_A means 4 rack i.e. TF-48
/export/home/nz->nzsql -c “select * from _t_environ where name like ‘NPS%’;”
NAME | VAL
————–+———
NPS_PLATFORM | xs
NPS_MODEL | P400X_A
NPS_FAMILY | PSeries

eg. Below query was run on TwinFin 12
/export/home/nz->nzsql -c “select * from _t_environ where name like ‘NPS%’;’
NAME | VAL
————–+———
NPS_PLATFORM | xs
NPS_MODEL | P100_A
NPS_FAMILY | PSeries

eg. Below query was run on TwinFin 120
/export/home/nz->nzsql -c “select * from _t_environ where name like ‘NPS%’;”
NAME | VAL
————–+————
NPS_PLATFORM | xs
NPS_MODEL | P1000X_A_E
NPS_FAMILY | PSeries

NOTE: NPS_MODEL = P* means TwinFin machine and NPZ_MODEL = Q* means Striper series. For 10 rack Striper NPS_Model will be Q1000*

Also, under NPS_FAMILY, PSeries means TwinFin and QSeries means Striper.

What authentication is my Netezza server using?

To check the type of authentication being used by Netezza database server, just run below query in system database. Output of AUTH_VALUE column will be either LOCAL or LDAP.

select * from _v_authentication

AUTH_OPTION AUTH_VALUE
=========== ==========
AUTHENTICATION METHOD LDAP

OR

select * from _v_authentication_settings where AUTH_OPTION = ‘AUTHENTICATION METHOD’;

AUTH_OPTION AUTH_VALUE
=========== ==========
AUTHENTICATION METHOD LDAP

And to check the complete authentication setting for LDAP/LOCAL, just run below query in system database:

select * from _v_authentication_settings

OR

SYSTEM(ADMIN)=> show authentication;
AUTH_OPTION | AUTH_VALUE
———————–+————
AUTHENTICATION METHOD | LDAP

Can also run below for more details:
SYSTEM(ADMIN)=> show authentication all;
AUTH_OPTION | AUTH_VALUE
————————+—————————————————————————
AUTHENTICATION METHOD | LDAP
AUTHMTHD LDAP ATTRNAME | sAMAccountName
AUTHMTHD LDAP BASE | dc=corp,dc=****,dc=com
AUTHMTHD LDAP BINDDN | ****************
AUTHMTHD LDAP PORT | 389
AUTHMTHD LDAP SCOPE | sub
AUTHMTHD LDAP SERVER | *.com
AUTHMTHD LDAP SSL | off
AUTHMTHD LDAP VERSION | 3

Sequence – Issue with Netezza restart?

In Netezza, sequence can be declared as 8-, 16-, 32-, or 64-bit integers and the cache size is a function of the number of distinct values in one complete cycle of the sequence (so it depends on the declared minvalue, maxvalue, and increment of the sequence).

Netezza caches sequence numbers at each SPU and whenever Netezza state changes from online (i.e. changed from Online to anyother state) all the cached sequesnces were lost and next time when Netezza comes online, it will cache from the next available non-cached value. Same issue will be faced when any SPU goes offline. In this scenario only the cached values in that SPU is lost.

If you are using 64 bit integer then approx cached value per data slice (and not per SPU) is 100K and if you are on TF120 which has 920 data slices, which mean around 9200K values are cached each time. And if your system have too many restarts than you may run out of sequence numbers/hit max value very fast.

How to manage/avoid losing sequence numbers?

To avoid losing too many sequence number you can setup a process (to run when Netezza comes online) to alter sequence number to start from current max value used in a table.
Just pull the max value from table which is using the sequence and then alter your sequence to start at that value.

select max(Sequence_Num) from TableName;
alter sequence Sequence_Name restart with <Sequence_Num + 1>;

 

Systeminfo – error resolution

Issue:-
You may get below error when you try to run systeminfo command in Windows Server 2003.

C:\Documents and Settings\user>systeminfo
Loading Operating System Information …ERROR: Server buffers are full and data cannot be accepted

Cause:-
This error is encountered because of some issues with Windows Management Instrumentation (WMI)

Resolution:-
1) Go to Start -> Run -> type services.msc to go to Windows services
2) Navigate to Windows Management Instrumentation (WMI) service
3) Restart Windows Management Service
4) Try to run systeminfo again. It will run fine.