Saltstack action on state change - windows

I have a following config for saltstack to apply a change on Windows machine:
---
HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR:
reg.present:
- name:
- vname: "Start"
- vtype: "REG_DWORD"
- vdata: 4
Is there any possibility to tell saltstack to flip the value back to 4 when someone changes it manually to different value?

Saltstack beacons & reactors are designed for this.
You can configure a beacon on the minion, when the value changes, it will send an event to the master; on the master side, you need to create a reactor to catch this event, and apply your salt state.
However, there are currently no such beacon for windows registry, you might have to write your own.

Related

Prometheus New Registry enable HTTP Metrics

I am using:
var registry = prometheus.NewRegistry()
I know I can do for some goroutine (etc.) related metrics:
registry.MustRegistry(collectors.NewGoCollector());
But, I cannot see http metrics which I see when using default registry, like:
promhttp_metric_handler_requests_total{code="200"} 1
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
How to bring these metrics?
Also, I cannot see http_requests_total irrespective of the registry I use. Is there a way to automatically expose it (instead of defining it)?
You also need to register your custom defined metric like http_requests_total (in this case).
This should solve your problem :
`registry.MustRegistry(promHttpRequestTotal)
Here promHttpRequestTotal is the variable in which your metric http_requests_total is defined.

Trigger indefinite notification on Windows 10

I'm trying to trigger a notification which has no expiry but must be closed by pressing the top-right X close button. Is this possible?
I've been able to trigger a timed notification which also closes when anywhere else is clicked. With this answer.
[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[reflection.assembly]::loadwithpartialname("System.Drawing")
$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Information
$notify.visible = $true
$notify.showballoontip(10,"New Chat!","You have received New Chat!",[system.windows.forms.tooltipicon]::None)
Per Microsofts NotifyIcon.ShowBalloonTip Method documentation, the actual timeout property is set by the current system settings.
Minimum and maximum timeout values are enforced by the operating system and are typically 10 and 30 seconds, respectively, however this can vary depending on the operating system. Timeout values that are too large or too small are adjusted to the appropriate minimum or maximum value. In addition, if the user does not appear to be using the computer (no keyboard or mouse events are occurring) then the system does not count this time towards the timeout.
According to a couple of more google searches, you can set the time for your profile through the Registry ( Regedit - HKEY_CURRENT_USER\Control Panel\Accessibility: MessageDuration - didn't work for me).
Through group policy, or using theSystemParametersInfo API which is out of my league to explain any further. Only reference I can find was configuring the Accessibility/System Parameter: SPI_SETMESSAGEDURATION.
Its C++ though and only other article I could find was this one:SystemParametersInfoA function.
Seems possible but, it will definitely be a hassle to get it working.

How to detect sender and destination of a notification in dbus-monitor?

My goal is to filter notifications coming from different applications (mainly from different browser window).
I found that with the help of the dbus-monitor I can write a small script that could filter the notification messages that I am interested in.
The filter script is working well, but I have a small problem:
I am starting with the
dbus-monitor "interface='org.freedesktop.Notifications', destination=':1.40'"
command. I have to added the "destination=':1.40'" because on Ubuntu 20.04 I always got twice the same notification.
The following output of
dbus-monitor --profile "interface='org.freedesktop.Notifications'"
demonstrate the reason:
type timestamp serial sender destination path interface member
# in_reply_to
mc 1612194356.476927 7 :1.227 :1.56 /org/freedesktop/Notifications org.freedesktop.Notifications Notify
mc 1612194356.483161 188 :1.56 :1.40 /org/freedesktop/Notifications org.freedesktop.Notifications Notify
As you can see the sender :1.277 sends to :1.56 first than this will be the sender to :1.40 destination. (Simply notify-send hello test message was sent)
My script is working on that way, but every time system boot up, I have to check the destination number and modify my script accordingly to get worked.
I have two questions:
how to discover the destination string automatically? (:1.40 in the above example)
how to prevent system sending the same message twice? (If this question would be answered, than the question under point 1. became pointless.)

ZK: Force server to send updated value to peer widget

I have a current setup where client updates a combobox value at client only (not updating the component at server).The server updates both widget and component when setValue() is done.
However it does not when the existing value is the same as the one being set.
Consider the following:-
1.client-setValue('1') - values{client:'1',server:""}
2.server-setValue("2") - values{client:'2',server:"2"}
3.client-setValue('') - values{client:'',server:"2"}
4.server-setValue('2') - values{client:'',server:"2"}--server does not update client as the value at server is the same as the one being set.
**Forcefully updating client:-**
1.client-setValue('1') - values{client:'1',server:""}
2.server-setValue("2") and forcefully updateclient - values{client:'2',server:"2"}
3.client-setValue('') - values{client:'',server:"2"}
4.server-setValue('2') and forcefully update client- values{client:'2',server:"2"}
Is this anyhow possible, other than setting one garbage/irrelevant value before setting the actual value ,which would possibly have the garbage value as the latest value and will update the client.
EDIT:
ZK Fiddle link

Have the clock in a Zabbix screen show host time

In Zabbix 3.2, I am setting up a screen for a new server, and want to configure a clock that shows the local time from the monitored host.
This is how I configured the screen element:
I have checked in Latest Data that the Host localtime is being received (it is).
However, when I save this screen configuration, the display just says, "No data":
How do you display the time on the monitored host?
In order for this screen element to work, you have to use system.localtime[local] item (which returns a string in a certain format, see item documentation) instead of the default system.localtime (which returns an integer timestamp).
The system.localtime[local] item returns a string like the following:
2016-12-07,09:36:59.688,+02:00
It allows the frontend to nicely display the time zone:

Resources