Reading Azure Sessions from AZ CLI - azure-cli

I am using AZ CLI to try to see how many sessions my user account has open. I figured it would be a subcommand under az account but I can't find it. How can I see all active sessions?

Reading Azure Sessions from AZ CLI:
The following methods can be used to read user login session information as well as how many sessions the user has.
You can use --query user under az account Cli command to get user sessions as shown:
$accounts_info = az account show --query user.name --output table
$accounts_info
Output:
If a session/user count is required, the count operator should be used for the final output.
$accounts_info.count
To get complete log information of session activities, Use below command.
Get-AzLog
You can also obtain sessions using az account --query session.
Use query_session as mentioned here:
az account show --query session.name

Related

Zabbix get the result of running a command on the ESXi server

On the ESXi server (I connect via SSH), I execute the command to view the SMART disk:
esxcli storage core device smart get -d=t10.ATA_INTEL_SSDSC2BB080G4__PHSL4
How can I pass the received data to Zabbix?
I'm trying to create an Item with type "script". I create this Item in a template. The template already connects to ESXi using macros, Zabbix receives data. But in the script field of the Item, you simply cannot insert this command, you just need to write the script.
In Zabbix a Script is a command you can execute using Host the context menĂ¹, or a command you can execute as an Action, when a Problem is triggered.
An item to perform a command via SSH, should use the "SSH agent" item type.
You cannot perform an esxcli command through the vSphere HTTPS SDK with Zabbix.
See
https://www.zabbix.com/documentation/6.0/en/manual/web_interface/frontend_sections/administration/scripts
https://www.zabbix.com/documentation/6.0/en/manual/config/items/itemtypes/ssh_checks
Example:

Configure Azure MySQL Database firewall

I created an Azure MySQL Database for a school project, but i have issues with the firewall. Indeed, if i want my friends to connect to the database, i have to add manually their ip address to the firewall.
But the real problem is that i'm not sure that my teacher will accept to share his ip address with me, so he'll maybe not be able to evaluate my work.
So i have tried to disable the firewall (I don't need so much security it's just a school project, and the database will be removed after the evaluation), but i have only found solutions for Azure SQL Database that use settings that don't exist (or no longer exist) for Azure MySQL Database. I have also found this solution using the azure CLI:
https://learn.microsoft.com/en-us/azure/mysql/howto-manage-firewall-using-cli#:~:text=message%20text%20instead.-,Delete%20a%20firewall%20rule%20on%20Azure%20Database%20for%20MySQL%20Server,of%20the%20existing%20firewall%20rule
but the commands don't find my server, and if i execute this command:
az mysql server list --resource-group myresourcegroup
my resource group is found, but it returns an empty list, despite my server really appears in Azure GUI in this resource group
Can you help me to disable this firewall please.
The firewall rules I see in my database instance allow me to create a 0.0.0.0-255.255.255.255 IP range to allow all the hosts.
Obviously, this is not at all secure, but should 'disable' the firewall.
If you need to do it in CLI then the command would be:
az mysql server firewall-rule create --resource-group <rg-name> --server-name <server-name> --name DisableFirewall --start-ip-address 0.0.0.0 --end-ip-address 255.255.255.255
Maybe the teacher doesn't need to actually connect to the database? However, if he has access to the subscription and resource group then he will add his IP for the time he will review your solution if needed.

Plesk CLI database --create: This object can be created only in a subscription

I'm using Plesk on a Linux root-server and want to write a simple deployment shell script.
To do that, I want to drop the database, create it again, and import a sql dump file.
I'm trying to create a database using:
plesk bin database --create myDbName -domain myDomain -type mysql -server localhost
But this gives me the following error:
This object can be created only in a subscription.
I was unable to find anything about this issue in the Plesk docs. How can I select the description that shall be used?
Thanks & regards
Most likely you specified addition domain on the subscription as myDomain.
According to Plesk business logic, databases are associated with the webspace (or the subscription), not with the separate domains on the same subscription.
Basically, you should specify the name of the default domain for the subscription, which is the same as subscription name itself.
You can get the list of subscription names using plesk bin subscription -l. Then use the required name to create a database. For example:
# plesk bin subscription -l
domain.ltd
...
# plesk bin database --create myDbName -domain domain.ltd -type mysql -server localhost

How to fetch instances of instance groups for a managed instance group with multi-zone configuration

I recently started using managed instance group with multi zone configuration. When i use GCE api to fetch instances for this instance groups zone is a required parameter. For a managed instance group with instances in multiple zone instance group does not belong to one zone. how do i fetch instances in this case?
What API or gcloud command are you using to list the instances? I guess you are using the instanceGroups.listInstances API, but for regional instance group, you need to use regionInstanceGroupManagers.listManagedInstances, or the corresponding gcloud command:
$ gcloud beta compute instance-groups managed list-instances instance-group-1 --region us-central1
NAME ZONE STATUS ACTION LAST_ERROR
instance-group-1-mk4j us-central1-b RUNNING NONE
instance-group-1-xnyk us-central1-c RUNNING NONE
instance-group-1-g23r us-central1-f RUNNING NONE
Note that this feature is still in beta.

ejabberdctl - how to remove user from room

I use mod_rest module for ejabberd. And i need to add and remove users from rooms from the command line.
Please, help me. How to do it?
You do not need mod_rest for that. Lastest ejabberd release support mod_http_api and can expose all ejabberd commands as API.
There is no command to kick a user from a MUC room. However, the command you should use is likely the one to change affiliation for the user.
If you set affiliation to outcast, the user will be kicked out of the room and prevented to join again.
For example, from command-line (ejabberdctl), it would be:
ejabberdctl set_room_affiliation room conference.localhost user123#localhost outcast
Similar command can be used from mod_http_admin.
Another option is also to use XMPP and let an admin account set the proper affiliation from a client or a bot.