SAP Sybase Service monitoring for  Database Space & Log Space

 

Step 1:-

 usermod -G sapsys zabbix

 

Step 2:-

#  vi /usr/local/bin/zabbix-mon.sh

isql -Usapsa -SMHS -w1234 -X -Ppassword -i /usr/local/bin/dbussagedetails.sql > /tmp/.databasedetailsforzabbix                                ## Relace DBname(MHS), username and passowrd

 

Step 3:-

#  chmod 755 /usr/local/bin/zabbix-mon.sh

 

 

Step 4:-

# vi /usr/local/bin/dbussagedetails.sql       [ Copy below script in the “/usr/local/bin/dbussagedetails.sql ” file  ]

set nocount on

go

set proc_return_status off

go

SELECT "Database Name" = CONVERT(char(20), db_name(D.dbid)),"Data Full%" = STR(100 * (1 - 1.0 * SUM(CASE WHEN U.segmap != 4

THEN curunreservedpgs(U.dbid, U.lstart, U.unreservedpgs) END)/SUM(CASE WHEN U.segmap != 4 THEN U.size END)),9,1),

"Log Full%" = STR(100 * (1 - 1.0 * lct_admin("logsegment_freepages",D.dbid) /

SUM(CASE WHEN U.segmap = 4 THEN U.size END)),8,1) FROM master..sysdatabases D, master..sysusages U

WHERE U.dbid = D.dbid GROUP BY D.dbid

ORDER BY db_name(D.dbid)

go

 

 

Step 5:- Create Cron job to update DB files

# crontab -e

*/5 * * * * su - sybmhs -c /usr/local/bin/zabbix-mon.sh                                                               ## Replace sybmhs with Sybase system account.

 

 

Step 6:- Test and check files creation : /tmp/.databasedetailsforzabbix

/usr/local/bin/zabbix-mon.sh

cat /tmp/.databasedetailsforzabbix

 

Step 7:-  create below files:

 

# vi /opt/zabbix/dbfull.sh

cat /tmp/.databasedetailsforzabbix | grep MHS | awk '{ print $2 }'                                                         ### replace MHS With DB name

 

# vi /opt/zabbix/dblogfull.sh

cat /tmp/.databasedetailsforzabbix | grep MHS | awk '{ print $3 }'                                                         ### Replace MHS witg DB name

 

# chmod 755 /opt/zabbix/dbfull.sh /opt/zabbix/dblogfull.sh

 

Step 8:-

add below lines /opt/zabbix/etc/zabbix_agentd.conf file:

 

UserParameter=DatabaseDBFull,/opt/zabbix/dbfull.sh

UserParameter=DatabaseLogFull,/opt/zabbix/dblogfull.sh

 

Step 9:- Restart zabbix agent

 

Apply Templete:              Template Sybase DBSize Monitoring

 

Create Macro: {$DBNAME}                          ### enter database name

 

 

 

PLEASE WRITE A FEEDBACK OR SUGGESTIONS TO BELOW EMAIL ID’S.

prashantkumar.chawan@gmail.com

info@mytara.co.in