Skip to content

Instantly share code, notes, and snippets.

View redsfyre's full-sized avatar
:shipit:
There is nothing here -> /dev/null

Yasin İsa YILDIRIM redsfyre

:shipit:
There is nothing here -> /dev/null
View GitHub Profile
@redsfyre
redsfyre / list-table-indexes-on-oracledb.sql
Last active October 3, 2022 07:36
Oracle DB list table indexes and their columns for specific table
select index_name, column_name from user_ind_columns where table_name='&tablename';
-- Enter table name after running this query
-- dba_ind_columns : This is to used if login with user having DBA role
-- all_ind_columns : This is to used if login with user having normal role
-- user_ind_columns : This is to used if login with user having normal role
-- OK nvm, this one is better;
set pagesize 50000 verify off echo off
@redsfyre
redsfyre / oracle-useful-queries.sql
Last active September 4, 2024 11:10
Oracle db useful queries
-- Gets tables with their auto generated sequences
select table_name,data_default from user_tab_cols where identity_column='YES';
-- Gets table and its ID column details, like sequence name if its auto generated sequence
COLUMN table_name FORMAT A50
COLUMN column_name FORMAT A15
COLUMN sequence_name format A15
COLUMN generation_type FORMAT A10
COLUMN identity_options FORMAT A75
@redsfyre
redsfyre / custom-opsgenieintegration
Last active March 16, 2025 14:16
An example script for Wazuh - Opsgenie integrations. You need to edit the issue_data variable within the generate_msg function. For example, you should write the name of the team you created on opsgenie in the responder field. Find "XXXX Team" in the code below. Below code tested on Wazuh 4.3.7
#!/bin/bash
# Copyright (C) 2015, Wazuh Inc.
# Created by Wazuh, Inc. <[email protected]>.
# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2
WPYTHON_BIN="framework/python/bin/python3"
SCRIPT_PATH_NAME="$0"
DIR_NAME="$(cd $(dirname ${SCRIPT_PATH_NAME}); pwd -P)"
@redsfyre
redsfyre / postgresql_index_stats.sql
Created September 15, 2022 10:47
Postgresql get index scan, index size stats
SELECT
pt.tablename AS TableName
,t.indexname AS IndexName
,to_char(pc.reltuples, '999,999,999,999') AS TotalRows
,pg_size_pretty(pg_relation_size(quote_ident(pt.tablename)::text)) AS TableSize
,pg_size_pretty(pg_relation_size(quote_ident(t.indexrelname)::text)) AS IndexSize
,to_char(t.idx_scan, '999,999,999,999') AS TotalNumberOfScan
,to_char(t.idx_tup_read, '999,999,999,999') AS TotalTupleRead
,to_char(t.idx_tup_fetch, '999,999,999,999') AS TotalTupleFetched
FROM pg_tables AS pt
@redsfyre
redsfyre / pg_show_active_locks.sql
Created March 20, 2024 19:29
Postgresql locks view
CREATE OR REPLACE VIEW public.active_locks AS
SELECT t.schemaname,
t.relname,
l.locktype,
l.page,
l.virtualtransaction,
l.pid,
l.mode,
l.granted
FROM pg_locks l
@redsfyre
redsfyre / queries.sql
Last active April 22, 2024 06:14
Postgresql troubleshooting shortcuts
-- Get long queries
SELECT
pid,
now() - pg_stat_activity.query_start AS duration,
state,
datname,
query
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 seconds' and state != 'idle' order by duration desc;