Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Self-made python script to monitor EMC VNXe 3200 storage hard disk

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Self-made python script to monitor EMC VNXe 3200 storage hard disk

[root@localhost libexec] # vi vnxe.py

#! / usr/bin/env python

Import commands

Import os

# 0 ok; 1 warning; 2 critical; 3 unknown

Os.chdir ("/ usr/local/nagios/libexec/")

(status, output) = commands.getstatusoutput ("uemcli-d 10.10.1.11-u admin-p Password / env/ps show | grep 'Health state' | awk' {print $4}'| wc-l")

If int (output) = = 2:

Print "VNXe 3200 harddisk ok"

Else:

Print "VNXe 3200 harddisk fail"

Test run results

[root@localhost libexec] #. / vnxe.py

VNXe 3200 harddisk ok

Add commands to commands.cfg first.

[root@localhost libexec] # vi / usr/local/nagios/etc/objects/commands.cfg

Define command {

Command_name vnxe

Command_line $USER1 $/ vnxe.py

}

Add the following to nagios.cfg

[root@localhost libexec] # vi / usr/local/nagios/etc/nagios.cfg

Cfg_file=/usr/local/nagios/etc/objects/VNXe.cfg

Define hosts and services: create a new VNXe.cfg in / usr/local/nagios/etc/objects

[root@localhost libexec] # vi / usr/local/nagios/etc/objects/VNXe.cfg

Define host {

Use EMC VNXe 3200

Host_name EMC VNXe 3200

Alias EMC VNXe 3200

Address 10.10.1.11

}

Define service {

Use generic-service

Host_name EMC VNXe 3200

Service_description EMC VNXe 3200

Check_command vnxe

Notifications_enabled 1

}

Then you must add the following to the templates.cfg

[root@localhost libexec] # vi / usr/local/nagios/etc/objects/templates.cfg

Define host {

Name EMC VNXe 3200; The name of this host template

Use generic-host; This template inherits other values from the generic-host template

Check_period 24x7; By default, EMC VNXe 3200 hosts are checked round the clock

Check_interval 5; Actively check the host every 10 minutes

Retry_interval 1; Schedule host check retries at 10 minute intervals

Max_check_attempts 10; Check each EMC VNXe 3200 host 10 times (max)

Check_command check-host-alive; Default command to check EMC VNXe 3200 hosts

Notification_period workhours; EMC VNXe 3200 admins hate to be woken up, so we only notify during the day

; Note that the notification_period variable is being overridden from

; the value that is inherited from the generic-host template!

Notification_interval 120; Resend notifications every 2 hours

Notification_options djingheng r; Only send notifications for specific host states

Contact_groups admins; Notifications get sent to the admins by default

Register 0; DONT REGISTER THIS DEFINITION-ITS NOT A REAL HOST, JUST A TEMPLATE!

}

After putting in the Nagios test, the result went wrong and the problem was never found (without any error message). The reason is that the command_line $USER1 $/ vnxe.py in Nagios runs the script vnxe.py under the nagios account and does not get the correct python script result (we ran it with root earlier, so we can get the correct result). The following solves the problem.

[root@localhost libexec] # visudo

Nagios ALL= (ALL) NOPASSWD:/usr/local/nagios/libexec/vnxe.py

# Defaults requiretty

Modify the command in commands.cfg.

[root@localhost libexec] # vi / usr/local/nagios/etc/objects/commands.cfg

Define command {

Command_name vnxe

Command_line sudo $USER1 $/ vnxe.py

Restart Nagios takes effect

[root@localhost libexec] # systemctl restart nagios.service

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report