<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: need a scrript in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306271#M62706</link>
    <description>for 4) I have wrote the following script,  although the script works quite fine, but need suggestions/comments/help to make the script better&lt;BR /&gt;&lt;BR /&gt;the only problem(I noticed) with this script is that I have to configure all the ntp clients for "password less ssh login" on the ntp server(ssh server)&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;&lt;BR /&gt;# timezone of the local network&lt;BR /&gt;export zone=UZT&lt;BR /&gt;&lt;BR /&gt;export script=ntp_script@xyz.local&lt;BR /&gt;&lt;BR /&gt;# sys admin email address&lt;BR /&gt;export sysadmin=abc@xyz.local&lt;BR /&gt;&lt;BR /&gt;# ldate, lmonth, lyear, lhour, lminute, lzone are client's date, month, year etc&lt;BR /&gt;export ldate=$(date +%d)&lt;BR /&gt;export lmonth=$(date +%m)&lt;BR /&gt;export lyear=$(date +%Y)&lt;BR /&gt;export lhour=$(date +%k)&lt;BR /&gt;export lminute=$(date +%M)&lt;BR /&gt;export lzone=$(date +%Z)&lt;BR /&gt;&lt;BR /&gt;# sdate, smonth, syear, shour, sminute, szone are the NTP Server's date, month, year etc&lt;BR /&gt;# ntp server ip = 192.168.0.1&lt;BR /&gt;export sdate=$(ssh 192.168.0.1 "date +%d")&lt;BR /&gt;export smonth=$(ssh 192.168.0.1 "date +%m")&lt;BR /&gt;export syear=$(ssh 192.168.0.1 "date +%Y")&lt;BR /&gt;export shour=$(ssh 192.168.0.1 "date +%k")&lt;BR /&gt;export sminute=$(ssh 192.168.0.1 "date +%M")&lt;BR /&gt;export szone=$(ssh 192.168.0.1 "date +%Z")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if [ $ldate -eq $sdate -a $lmonth -eq $smonth -a $lyear -eq $syear -a $lzone = $szone ]; then&lt;BR /&gt;      echo "date, month, year and timezone are OK"&lt;BR /&gt;      exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $lzone != $szone -a $szone = $zone ]; then&lt;BR /&gt;      cp /etc/localtime /tmp&lt;BR /&gt;      rm -f /etc/localtime&lt;BR /&gt;      ln -s /usr/share/zoneinfo/Asia/Tashkent /etc/localtime&lt;BR /&gt;      /etc/init.d/ntp stop; sleep 3;&lt;BR /&gt;      ntpdate 192.168.0.1 &amp;amp;&amp;amp; ntpdate 192.168.0.1 &amp;amp;&amp;amp; ntpdate 192.168.0.1&lt;BR /&gt;      /etc/init.d/ntp start;&lt;BR /&gt;#     inform the admin via email&lt;BR /&gt;      echo "client timezone was not right, issue resolved" |mail -s "NTP issue fixed" -r $script $sysadmin &amp;lt;~&lt;BR /&gt;      exit&lt;BR /&gt;&lt;BR /&gt;   else if [ $szone != $zone ]; then&lt;BR /&gt;      echo "NTP Server timezone is not correct" |mail -s "NTP Server Timezone wrong" -r $script $sysadmin &amp;lt;~     &lt;BR /&gt;      exit&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $ldate -eq $sdate -a $lmonth -eq $smonth -a $lyear -eq $syear ]; then exit&lt;BR /&gt;   else &lt;BR /&gt;      /etc/init.d/ntp stop; sleep 3;&lt;BR /&gt;      ntpate 192.168.0.1 &amp;amp;&amp;amp; ntpdate 192.168.0.1 &amp;amp;&amp;amp; ntpdate 192.168.0.1&lt;BR /&gt;      /etc/init.d/ntp start;&lt;BR /&gt;      echo "client date/time was not right, issue resolved" |mail -s "NTP issue fixed" -r $script $sysadmin &amp;lt;~&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Regards</description>
    <pubDate>Wed, 19 Nov 2008 14:01:18 GMT</pubDate>
    <dc:creator>Maaz</dc:creator>
    <dc:date>2008-11-19T14:01:18Z</dc:date>
    <item>
      <title>need a scrript</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306267#M62702</link>
      <description>please help me write a script that can &lt;BR /&gt;&lt;BR /&gt;1, add the "used" and "cached" values(from the output of 'free'), and then email the value to admin@mynetworks.local&lt;BR /&gt;&lt;BR /&gt;2, System Reboot instances should be reported(via email) to the sys admin, each system should be configured such that on startup it sends a notification to the System admin with following minimum details&lt;BR /&gt;a, Server Name and IP&lt;BR /&gt;b, Startup Date and Time&lt;BR /&gt;&lt;BR /&gt;3, Through an automated script generate list of users files(/home/*) which fall under unauthorized or suspicious catagory. This includes but not limited to AVI, MP3, JPEG, TIF. All users found with such files should be notified(via email), also a notification should also be sent to the system admin and HR.&lt;BR /&gt;&lt;BR /&gt;please help me meet the above requirements of our Auditors.</description>
      <pubDate>Fri, 14 Nov 2008 10:32:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306267#M62702</guid>
      <dc:creator>Maaz</dc:creator>
      <dc:date>2008-11-14T10:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: need a scrript</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306268#M62703</link>
      <description>and last&lt;BR /&gt;4, check whether the time synchronization is correct with the NTP Server, if time difference is more then 1 minute an email is sent to sysadmin with details.&lt;BR /&gt;&lt;BR /&gt;Thanks in anticipation&lt;BR /&gt;Regards&lt;BR /&gt;Maaz</description>
      <pubDate>Fri, 14 Nov 2008 10:40:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306268#M62703</guid>
      <dc:creator>Maaz</dc:creator>
      <dc:date>2008-11-14T10:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: need a scrript</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306269#M62704</link>
      <description>For 1)&lt;BR /&gt;&lt;BR /&gt;free -m | grep Mem | awk 'TOT=$3+$6 { print TOT }' | mail -s "Memory report" admin@mynetworks.local&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Nov 2008 13:47:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306269#M62704</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2008-11-14T13:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: need a scrript</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306270#M62705</link>
      <description>For 2)&lt;BR /&gt;&lt;BR /&gt;Create a script like this:&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;DEVICE=eth0&lt;BR /&gt;HOSTNAME=$(hostname)&lt;BR /&gt;IP=$(ifconfig eth0 | grep "inet addr"  | awk '{print $2}' | sed 's/addr://')&lt;BR /&gt;DATE=$(date)&lt;BR /&gt;&lt;BR /&gt;echo "$HOSTNAME ($IP) booted at $DATE" | mail -s "$HOSTANME boot" admin@mynetworks.local&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And add to /etc/rc.local.</description>
      <pubDate>Fri, 14 Nov 2008 13:54:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306270#M62705</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2008-11-14T13:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: need a scrript</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306271#M62706</link>
      <description>for 4) I have wrote the following script,  although the script works quite fine, but need suggestions/comments/help to make the script better&lt;BR /&gt;&lt;BR /&gt;the only problem(I noticed) with this script is that I have to configure all the ntp clients for "password less ssh login" on the ntp server(ssh server)&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;&lt;BR /&gt;# timezone of the local network&lt;BR /&gt;export zone=UZT&lt;BR /&gt;&lt;BR /&gt;export script=ntp_script@xyz.local&lt;BR /&gt;&lt;BR /&gt;# sys admin email address&lt;BR /&gt;export sysadmin=abc@xyz.local&lt;BR /&gt;&lt;BR /&gt;# ldate, lmonth, lyear, lhour, lminute, lzone are client's date, month, year etc&lt;BR /&gt;export ldate=$(date +%d)&lt;BR /&gt;export lmonth=$(date +%m)&lt;BR /&gt;export lyear=$(date +%Y)&lt;BR /&gt;export lhour=$(date +%k)&lt;BR /&gt;export lminute=$(date +%M)&lt;BR /&gt;export lzone=$(date +%Z)&lt;BR /&gt;&lt;BR /&gt;# sdate, smonth, syear, shour, sminute, szone are the NTP Server's date, month, year etc&lt;BR /&gt;# ntp server ip = 192.168.0.1&lt;BR /&gt;export sdate=$(ssh 192.168.0.1 "date +%d")&lt;BR /&gt;export smonth=$(ssh 192.168.0.1 "date +%m")&lt;BR /&gt;export syear=$(ssh 192.168.0.1 "date +%Y")&lt;BR /&gt;export shour=$(ssh 192.168.0.1 "date +%k")&lt;BR /&gt;export sminute=$(ssh 192.168.0.1 "date +%M")&lt;BR /&gt;export szone=$(ssh 192.168.0.1 "date +%Z")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if [ $ldate -eq $sdate -a $lmonth -eq $smonth -a $lyear -eq $syear -a $lzone = $szone ]; then&lt;BR /&gt;      echo "date, month, year and timezone are OK"&lt;BR /&gt;      exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $lzone != $szone -a $szone = $zone ]; then&lt;BR /&gt;      cp /etc/localtime /tmp&lt;BR /&gt;      rm -f /etc/localtime&lt;BR /&gt;      ln -s /usr/share/zoneinfo/Asia/Tashkent /etc/localtime&lt;BR /&gt;      /etc/init.d/ntp stop; sleep 3;&lt;BR /&gt;      ntpdate 192.168.0.1 &amp;amp;&amp;amp; ntpdate 192.168.0.1 &amp;amp;&amp;amp; ntpdate 192.168.0.1&lt;BR /&gt;      /etc/init.d/ntp start;&lt;BR /&gt;#     inform the admin via email&lt;BR /&gt;      echo "client timezone was not right, issue resolved" |mail -s "NTP issue fixed" -r $script $sysadmin &amp;lt;~&lt;BR /&gt;      exit&lt;BR /&gt;&lt;BR /&gt;   else if [ $szone != $zone ]; then&lt;BR /&gt;      echo "NTP Server timezone is not correct" |mail -s "NTP Server Timezone wrong" -r $script $sysadmin &amp;lt;~     &lt;BR /&gt;      exit&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $ldate -eq $sdate -a $lmonth -eq $smonth -a $lyear -eq $syear ]; then exit&lt;BR /&gt;   else &lt;BR /&gt;      /etc/init.d/ntp stop; sleep 3;&lt;BR /&gt;      ntpate 192.168.0.1 &amp;amp;&amp;amp; ntpdate 192.168.0.1 &amp;amp;&amp;amp; ntpdate 192.168.0.1&lt;BR /&gt;      /etc/init.d/ntp start;&lt;BR /&gt;      echo "client date/time was not right, issue resolved" |mail -s "NTP issue fixed" -r $script $sysadmin &amp;lt;~&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Wed, 19 Nov 2008 14:01:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306271#M62706</guid>
      <dc:creator>Maaz</dc:creator>
      <dc:date>2008-11-19T14:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: need a scrript</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306272#M62707</link>
      <description>Your script check more than just the time difference, that is OK. But I'm not sure if you should check the timezone also. Timezone can be different but still work correctly, depending of your location.&lt;BR /&gt;&lt;BR /&gt;See also this script:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.mattiaswikstrom.net/linux/20061102-time-offset-check-script.html" target="_blank"&gt;http://www.mattiaswikstrom.net/linux/20061102-time-offset-check-script.html&lt;/A&gt;</description>
      <pubDate>Wed, 19 Nov 2008 14:09:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306272#M62707</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2008-11-19T14:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: need a scrript</title>
      <link>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306273#M62708</link>
      <description>Thanks for the quick help&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Timezone can be different but still work correctly, depending of your location.&lt;BR /&gt;Yes, I did this because both(client/Server) belongs to the same timezone, anyway I think timezone checking should be omitted.&lt;BR /&gt;&lt;BR /&gt;and for the url, its simply great, I think I exactly need such a script that can do quite efficiently/perfectly.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Maaz</description>
      <pubDate>Wed, 19 Nov 2008 14:32:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/need-a-scrript/m-p/4306273#M62708</guid>
      <dc:creator>Maaz</dc:creator>
      <dc:date>2008-11-19T14:32:14Z</dc:date>
    </item>
  </channel>
</rss>

