Implement support for notification types

- add new flag "-t" for notification types to matrix-host-notification
  and matrix-service-notification
- implement value validation for HostState and ServiceState
This commit is contained in:
Jan Dittberner 2024-09-26 17:18:32 +02:00
parent 902d4cb310
commit 1aeacd0d1b
6 changed files with 81 additions and 10 deletions

View file

@ -13,6 +13,8 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// The main package for matrix-service-notification
package main
import (
@ -45,11 +47,12 @@ func parseFlags() *icinga2.ServiceParameters {
flag.StringVar(&parameters.LongDateTime, "d", "", "long date time ($icinga.long_date_time$)")
flag.StringVar(&parameters.Hostname, "l", "", "hostname ($host.name$)")
flag.StringVar(&parameters.HostDisplayName, "n", "", "host display name ($host.display_name$)")
flag.Var(&parameters.NotificationType, "t", "notification type ($notification_type$)")
flag.StringVar(&parameters.ServiceName, "e", "", "service name ($service.name$)")
flag.StringVar(&parameters.ServiceDisplayName, "u", "", "service display name ($service.display_name$)")
flag.StringVar(&parameters.ServiceOutput, "o", "", "service output ($service.output$)")
flag.StringVar(&parameters.ServiceState, "s", "", "service state ($service.state$)")
flag.Var(&parameters.ServiceState, "s", "service state ($service.state$)")
flag.StringVar(&parameters.MatrixRoom, "m", "", "matrix room ($notification_matrix_room$)")
flag.Var(&parameters.MatrixServer, "x", "matrix server ($notification_matrix_server$)")