Update 44 files
- /Daily_Backup_review/database_s3_check.ps1 - /Daily_Backup_review/Get-StorageContainerContent.ps1 - /Daily_Backup_review/Global_Checks.ps1 - /Daily_Backup_review/list_table_within_databases.ps1 - /Daily_Backup_review/Start-AzureSQLExport.ps1 - /Daily_Backup_review/Start-BackupCheckBpScus.ps1 - /Daily_Backup_review/Start-BackupCheckBpWeu.ps1 - /Daily_Backup_review/Start-BackupCheckRoserAttachments.ps1 - /Daily_Backup_review/Start-BackupCheckRoserCloud.ps1 - /Daily_Backup_review/Start-BackupCheckTotal.ps1 - /Daily_Backup_review/Start-DatabaseExport.ps1 - /Daily_Backup_review/Start-PointInTimeRestore.ps1 - /Daily_Backup_review/list_databases_within_instances.py - /Daily_Citrix_VDA_and_Server_Utilization_review/Cloudwatch_review/cloudwatch_alarm_ap-southeast-2.json - /Daily_Citrix_VDA_and_Server_Utilization_review/Cloudwatch_review/Cloudwatch_review.ps1 - /Ansible/audit-netscaler-exp.yaml - /Ansible/concurrent-user.yaml - /Ansible/do-something.yaml - /Ansible/hello-world.yaml - /Ansible/p6-log-cleanup.yaml - /Ansible/Roser_DB_backup_one_off.yaml - /Ansible/test-sql.yaml - /Ansible/test-sql-double-creds.yaml - /RoserUsefull/access_bulk_servers.ps1 - /RoserUsefull/access_bulk_servers_cezar.ps1 - /RoserUsefull/Bulk_copy_files.ps1 - /RoserUsefull/Besfort_data.ps1 - /RoserUsefull/check_permissions_bulk_servers.ps1 - /RoserUsefull/Check-p6interface-checksum.ps1 - /RoserUsefull/compare_files.ps1 - /RoserUsefull/connections_parser.ps1 - /RoserUsefull/drop_rds_registry_key.ps1 - /RoserUsefull/EmergencyAccessRemote.ps1 - /RoserUsefull/Keycloak_TestConnection.ps1 - /RoserUsefull/Kickoff_disconnected_users.ps1 - /RoserUsefull/launch_jira.ps1 - /RoserUsefull/launch_jira_gui.ps1 - /RoserUsefull/ownership_taker_anonymized.ps1 - /RoserUsefull/purge_files.ps1 - /RoserUsefull/remove_local_profiles_PowerShell.PS1 - /RoserUsefull/retrieve_attachements.ps1 - /RoserUsefull/Send_patch_multiple_servers.ps1 - /RoserUsefull/Test-RSAAPI-BP.ps1 - /RoserUsefull/Linux_identify_big_files.sh
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
- hosts: all
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: display time
|
||||
ansible.builtin.shell: echo {{ '%Y%m%d' | strftime }}
|
||||
register: today_date
|
||||
|
||||
- name: Set variables current date
|
||||
set_fact:
|
||||
current_date: "{{ today_date.stdout}}"
|
||||
|
||||
- name: Set variables Db name with the date
|
||||
set_fact:
|
||||
DbNameWithDate: "{{DBname+current_date}}"
|
||||
|
||||
- name: Set variables ARN
|
||||
set_fact:
|
||||
Arn_generated: "{{'arn:aws:s3:::'+S3Bucket+'/'+DBInstancename+'/'+current_date+'/'+DbNameWithDate+additional_comment+'.bak'}}"
|
||||
|
||||
- name: perform the query
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
script: |
|
||||
USE [MASTER]
|
||||
DECLARE @arn varchar(MAX) = '{{Arn_generated}}'
|
||||
exec msdb.dbo.rds_backup_database @source_db_name='{{DBname}}', @s3_arn_to_backup_to=@arn ,@overwrite_s3_backup_file=1;
|
||||
register: db_output
|
||||
|
||||
- name: Set task ID
|
||||
set_fact:
|
||||
Task_ID: "{{db_output.query_results[0][0][0][0]}}"
|
||||
#testing
|
||||
#Task_ID: "9124"
|
||||
|
||||
|
||||
- name: Display task ID
|
||||
debug: var=Task_ID
|
||||
|
||||
- name: Check the status of the backup
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
script: |
|
||||
USE [MASTER]
|
||||
exec msdb.dbo.rds_task_status @task_id='{{Task_ID}}'
|
||||
register: db_backup_output
|
||||
until: "'SUCCESS' in db_backup_output.query_results[0][0][0][5] or 'ERROR' in db_backup_output.query_results[0][0][0][5]"
|
||||
retries: 10
|
||||
delay: 60
|
||||
failed_when: "'ERROR' in db_backup_output.query_results[0][0][0][5]"
|
||||
|
||||
|
||||
- name: Display Status of the task
|
||||
debug: var=db_backup_output.query_results[0][0][0][5]
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- hosts: all
|
||||
gather_facts: no
|
||||
vars:
|
||||
ansible_remote_tmp: /tmp
|
||||
ssh_executable: shell
|
||||
tasks:
|
||||
- name: Enter shell
|
||||
shell: ls
|
||||
|
||||
- name: Execute aws-cost script
|
||||
shell: cat /nsconfig/license/FID_449a0c5a_a0c5_4bdb_98e1_200eff40afc7.lic | grep -oE '\.*[0-9]+\-(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\-[0-9][0-9][0-9][0-9]'
|
||||
@@ -0,0 +1,56 @@
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Concurrent User
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
db: "{{ db_name }}"
|
||||
script: |
|
||||
use {{ db_name }}
|
||||
DECLARE @start Datetime = '{{ begin_date }}';
|
||||
DECLARE @end Datetime = '{{ end_date }}';
|
||||
WITH RankedDays AS (
|
||||
SELECT
|
||||
login_day,
|
||||
column_{{ month }}{{ year }}_concurrent_user_count,
|
||||
ROW_NUMBER() OVER (PARTITION BY MONTH(login_day) ORDER BY column_{{ month }}{{ year }}_concurrent_user_count DESC) AS rn
|
||||
FROM
|
||||
(
|
||||
select login_day, max(column_{{ month }}{{ year }}_concurrent_user_count) column_{{ month }}{{ year }}_concurrent_user_count from (
|
||||
SELECT
|
||||
DISTINCT CAST(ul_main.logindate AS DATE) AS login_day,
|
||||
( SELECT
|
||||
COUNT(DISTINCT CHECKSUM(ul_sub.fk_userid, ul_sub.createcomputer))
|
||||
FROM
|
||||
tblUserLogin ul_sub
|
||||
INNER JOIN tblApplication a ON a.pk_applicationid = ul_sub.fk_applicationid
|
||||
WHERE
|
||||
a.enumvalue IN (2, 3, 4, 5, 7, 11, 13, 15, 6, 9, 18, 10) --no rosercatalog!
|
||||
AND ul_sub.logindate <= ul_main.logindate
|
||||
AND (
|
||||
CASE
|
||||
WHEN lastheartbeat < logoutdate
|
||||
THEN lastheartbeat
|
||||
ELSE logoutdate
|
||||
END
|
||||
) >= ul_main.logindate
|
||||
) AS column_{{ month }}{{ year }}_concurrent_user_count
|
||||
FROM
|
||||
tblUserLogin ul_main
|
||||
WHERE
|
||||
ul_main.logindate >= @start
|
||||
AND ul_main.logindate < @end
|
||||
) max_of_each_month group by login_day ) sub_query
|
||||
WHERE login_day LIKE '{{ year }}%'
|
||||
)
|
||||
SELECT
|
||||
login_day,
|
||||
column_{{ month }}{{ year }}_concurrent_user_count
|
||||
FROM
|
||||
RankedDays
|
||||
WHERE
|
||||
rn <= 1
|
||||
ORDER BY
|
||||
MONTH(login_day),
|
||||
column_{{ month }}{{ year }}_concurrent_user_count DESC;
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- hosts: all
|
||||
gather_facts: no
|
||||
vars:
|
||||
ansible_remote_tmp: /tmp
|
||||
ssh_executable: shell
|
||||
tasks:
|
||||
- name: Enter shell
|
||||
shell: ls
|
||||
|
||||
- name: Execute aws-cost script
|
||||
shell: cat /nsconfig/license/FID_449a0c5a_a0c5_4bdb_98e1_200eff40afc7.lic | grep -oE '\.*[0-9]+\-(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\-[0-9][0-9][0-9][0-9]'
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- hosts: VDA-R7Y95
|
||||
tasks:
|
||||
- name: Run basic PowerShell script
|
||||
ansible.windows.win_powershell:
|
||||
script: |
|
||||
echo "Hello World"
|
||||
write-output "Hiya, AWx" | Out-File c:\temp\my-first-awx.txt
|
||||
@@ -0,0 +1,33 @@
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Cleanup P6 logs
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
db: "{{ db_name }}"
|
||||
script: |
|
||||
use {{ db_name }}
|
||||
IF EXISTS (select p.pk_p6sessionid, p.createdate, p.modifydate, h.modifydate, getdate() from rsy.tblP6Session p join rsy.tblP6SessionHeartbeat h on p.pk_p6sessionid = h.fk_p6sessionid where p.createdate > DATEADD(HOUR, -6, GETDATE()) and h.modifydate > DATEADD(HOUR, -2, GETDATE()))
|
||||
BEGIN
|
||||
SELECT 'Possible active Sessions';
|
||||
select p.pk_p6sessionid, p.createdate, p.modifydate, h.modifydate, getdate() from rsy.tblP6Session p
|
||||
join rsy.tblP6SessionHeartbeat h on p.pk_p6sessionid = h.fk_p6sessionid
|
||||
where p.createdate > DATEADD(HOUR, -6, GETDATE()) and h.modifydate > DATEADD(HOUR, -2, GETDATE())
|
||||
END ELSE
|
||||
BEGIN
|
||||
SELECT 'do cleanup'
|
||||
BEGIN TRAN
|
||||
SELECT TOP (1) 1 FROM [rsy].[tblP6Session] WITH (TABLOCKX);
|
||||
truncate table [rsy].[tblP6SessionHeartbeat];
|
||||
truncate table [rsy].[tblP6SessionLog];
|
||||
truncate table [rsy].[tblP6SessionMilestone];
|
||||
truncate table [rsy].[tblP6SessionPlancard];
|
||||
truncate table [rsy].[tblP6SessionRelation];
|
||||
alter table [rsy].[tblP6Session] disable trigger all;
|
||||
delete from [rsy].[tblP6Session];
|
||||
alter table [rsy].[tblP6Session] enable trigger all;
|
||||
COMMIT TRAN;
|
||||
END
|
||||
register: db_output
|
||||
- debug: var=db_output
|
||||
@@ -0,0 +1,12 @@
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Test Connectivity
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
script: |
|
||||
USE {{ db_name }}
|
||||
SELECT * FROM dbo.tblsetting;
|
||||
register: db_output
|
||||
- debug: var=db_output
|
||||
@@ -0,0 +1,13 @@
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Test Connectivity
|
||||
community.general.mssql_script:
|
||||
login_user: "{{ database_admin_user }}"
|
||||
login_password: "{{ database_admin_password }}"
|
||||
login_host: "{{ database_host }}"
|
||||
db: "{{ db_name }}"
|
||||
script: |
|
||||
USE {{ db_name }}
|
||||
SELECT * FROM dbo.tblsetting;
|
||||
register: db_output
|
||||
- debug: var=db_output
|
||||
Reference in New Issue
Block a user