Skip to content

Instantly share code, notes, and snippets.

View rajujith's full-sized avatar

Jithin Raju rajujith

View GitHub Profile
@rajujith
rajujith / duplicate_usage_events.txt
Created June 30, 2023 06:54
CloudStack: Mysql query to find duplicate usage events
select vm_instance_id,usage_type,start_date from usage_vm_instance uvi inner join ( select type,created,resource_id,count(*) as count from usage_event where processed=0 and type in ('VM.CREATE','VM.START','VM.STOP','VM.DESTROY') group by resource_id,type,created having count > 1) ue on uvi.vm_instance_id=ue.resource_id and uvi.start_date=ue.created;
@rajujith
rajujith / gist:1fd07fb6977d975c37c5bdd073e87b6f
Last active October 15, 2025 05:18
CloudStack Mysql queries
Find Networks without DHCP service:
===================================
select n.id,n.name,n.network_offering_id from networks n inner join (select no.id,ns1.offering_id from network_offerings no left join (select ns.network_offering_id as offering_id from ntwk_offering_service_map ns where ns.service='dhcp' and ns.provider in ('VpcVirtualRoutergroup','VirtualRouter','VpcVirtualRouter')) as ns1 on no.id=ns1.offering_id where no.removed is null and no.traffic_type='guest' and ns1.offering_id is null) as nd on n.network_offering_id=nd.id and n.removed is null;
Networks not having vms
========================
select n.id,n.name,n.removed from networks n left join vm_network_map v on v.network_id=n.id where v.network_id is null and n.removed is null and n.name is not null;
Find primary storage utilization
@rajujith
rajujith / Alpine-linux-router-setup.txt
Last active October 11, 2023 11:56
Alpine Linux router configuration
echo "net.ipv4.ip_forward=1" | tee -a /etc/sysctl.conf
sysctl -p
apk add iptables
rc-update add iptables
iptables -A FORWARD -i eth2 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/etc/init.d/iptables save
apk add dhcp
@rajujith
rajujith / Ubuntu Netplan with bond_VLAN
Created September 10, 2024 07:05
Ubuntu netplan with bonding and VLAN
---
network:
version: 2
ethernets:
eth0: {}
eth1: {}
eth2: {}
eth3: {}
bonds:
bond0:
@rajujith
rajujith / enable GPU passthrough on cloudstack KVM with extraconfig
Last active September 24, 2024 05:48
enable GPU passthrough on cloudstack KVM with extraconfig
On global configuration set enable.additional.vm.configuration =true
set paramaters name: allow.additional.vm.configuration.list.kvm
value: devices,hostdev,driver,source,address,alias
update instance with the extraconfig:
sample XML:
<devices>
<hostdev mode='subsystem' type='pci' managed='yes'>
@rajujith
rajujith / decrypt-cloudstack
Created November 6, 2024 06:56
Decrypt cloudstack secret values
#For ACS 4.18 and above
java -classpath /usr/share/cloudstack-common/lib/cloudstack-utils.jar com.cloud.utils.crypt.EncryptionCLI -d -i "$(grep -oP 'db.cloud.encrypt.secret=ENC\(\K[^\)]+(?=\))' /etc/cloudstack/management/db.properties)" -p "$(cat /etc/cloudstack/management/key)"
older versions:
===================
Grab the encrypted password from /etc/cloudstack/management/db.properties
@rajujith
rajujith / cloudstack-trace-logs
Created November 6, 2024 08:07
cloudstack trace logging
To enable TRACE level logging for CloudStack, we need to perform the following in all the management servers or the management server of interest.
1) Open the file /etc/cloudstack/management/log4j-cloud.xml
Find the logging level for 'com.cloud' for example.
<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->
<category name="com.cloud">
<priority value="DEBUG"/>